/*
 * Copyright (c) 2015. Ncomz. All Rights Reserved
 */

package com.ntels.kneet.v3.view;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.ntels.kneet.v3.common.Constants;
import com.ntels.kneet.v3.common.util.Util;

public class AppStart extends Activity {

    /*공통*/
    private Activity act;
    private Util   util  = new Util();
    private String sType = "";

    /**
     * <PRE>
     * 1. MethodName: onRestoreInstanceState
     * 2. ClassName :
     * 3. Comment   : onRestoreInstanceState
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override protected void onRestoreInstanceState(Bundle savedInstanceState) {

        super.onRestoreInstanceState(savedInstanceState);
    }

    /**
     * <PRE>
     * 1. MethodName: onSaveInstanceState
     * 2. ClassName :
     * 3. Comment   : onSaveInstanceState
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override protected void onSaveInstanceState(Bundle outState) {

        super.onSaveInstanceState(outState);
    }

    /**
     * <PRE>
     * 1. MethodName: onNewIntent
     * 2. ClassName :
     * 3. Comment   : onNewIntent
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override protected void onNewIntent(Intent saveIntent) {

        super.onNewIntent(saveIntent);
        if ( getIntent() != null ) {
            Uri uri = getIntent().getData();
            if ( uri != null ) {
                sType = util.null2string(uri.getQueryParameter("type"));
                Intent intent = new Intent(act, Intro.class);
                if ( !sType.equals("") ) {
                    intent.putExtra(Constants.EXTRA_PUSH_TYPE_CODE, sType);
                } else {
                    intent.putExtra(Constants.EXTRA_PUSH_TYPE_CODE, "");
                }
                intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
                util.callActivityNoAnim(act, intent);
            }
        }
        onBackPressed();
    }

    /**
     * <PRE>
     * 1. MethodName: onCreate
     * 2. ClassName :
     * 3. Comment   : onCreate
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        act = AppStart.this;

        if ( getIntent() != null ) {
            Uri uri = getIntent().getData();
            if ( uri != null ) {
                sType = util.null2string(uri.getQueryParameter("type"));
                Intent intent = new Intent(act, Intro.class);
                if ( !sType.equals("") ) {
                    intent.putExtra(Constants.EXTRA_PUSH_TYPE_CODE, sType);
                } else {
                    intent.putExtra(Constants.EXTRA_PUSH_TYPE_CODE, "");
                }
                intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
                util.callActivityNoAnim(act, intent);
            }
        }

        onBackPressed();
    }
}
