package jp.gr.procon.proconapp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;

import jp.gr.procon.proconapp.R;
import jp.gr.procon.proconapp.util.AppSharedPreference;

public class SplashActivity extends AppCompatActivity {
    private static final int DELAY_TIME = 2000;

    private Handler mHandler;
    private Runnable mRunnable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (mHandler == null) {
            mHandler = new Handler();
        }
        boolean isFirstLaunch = TextUtils.isEmpty(AppSharedPreference.getString(this, AppSharedPreference.PREFERENCE_IS_FIRST_LAUNCH));
        mRunnable = isFirstLaunch ? new FirstLaunchRunnable() : new HomeLaunchRunnable();
        mHandler.postDelayed(mRunnable, DELAY_TIME);
    }

    @Override
    protected void onPause() {
        mHandler.removeCallbacks(mRunnable);
        super.onPause();
    }

    private class HomeLaunchRunnable implements Runnable {
        @Override
        public void run() {
            Intent intent = MainActivity.createIntent(getBaseContext());
            startActivity(intent);
            overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
            finish();
        }
    }

    private class FirstLaunchRunnable implements Runnable {

        @Override
        public void run() {
            Intent intent = EnterActivity.createIntent(getBaseContext());
            startActivity(intent);
            overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
            finish();
        }
    }

}

@@ -625,16 +625,256 @@
 splash);
+%0A%0A        // %E5%89%8D%E5%9B%9E%E7%99%BB%E9%8C%B2%E3%81%97%E3%81%9FGCM%E3%81%AEregister id%E3%81%AE%E6%83%85%E5%A0%B1%E3%82%92%E5%89%8A%E9%99%A4%0A        // %E6%9C%AC%E6%9D%A5%E3%81%AA%E3%82%89%E8%B5%B7%E5%8B%95%E6%99%82%E3%81%AB%E5%89%8D%E5%9B%9E%E3%81%A8%E3%81%AE%E5%B7%AE%E5%88%86%E3%82%92%E8%A6%8B%E3%81%A6%E7%95%B0%E3%81%AA%E3%81%A3%E3%81%9F%E5%A0%B4%E5%90%88%E3%81%A0%E3%81%91API%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E3%81%B8%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B%E6%96%B9%E3%81%8C%E8%89%AF%E3%81%84%0A        // %E4%BB%8A%E5%9B%9E%E3%81%AF%E3%81%A8%E3%82%8A%E3%81%82%E3%81%88%E3%81%9A%E8%B5%B7%E5%8B%95%E3%81%94%E3%81%A8%E3%81%ABAPI%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E3%81%B8%E6%8A%95%E3%81%92%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E3%83%AA%E3%82%BB%E3%83%83%E3%83%88%0A        AppSharedPreference.putString(this, AppSharedPreference.PREFERENCE_GCM_REGISTER_ID, null);
 %0A    %7D%0A%0A

reset saved register id in app when application lanunched