package com.xiecc.seeWeather.modules.launch;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.xiecc.seeWeather.modules.main.ui.MainActivity;
import java.lang.ref.WeakReference;

/**
 * Created by hugo on 2015/10/25 0025.
 * 闪屏页
 * @see <a herf="http://www.androiddesignpatterns.com/2013/01/inner-class-handler-memory-leak.html">How to Leak a Context: Handlers & Inner Classes</a>
 */
public class FirstActivity extends Activity {
    private static final String TAG = FirstActivity.class.getSimpleName();
    private SwitchHandler mHandler = new SwitchHandler(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //activity切换的淡入淡出效果
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        super.onCreate(savedInstanceState);
        mHandler.sendEmptyMessageDelayed(1, 1000);

    }

    private static class SwitchHandler extends Handler {
        private WeakReference<FirstActivity> mWeakReference;

        SwitchHandler(FirstActivity activity) {
            mWeakReference = new WeakReference<FirstActivity>(activity);
        }

        @Override
        public void handleMessage(Message msg) {
            FirstActivity activity = mWeakReference.get();
            if (activity != null) {
                MainActivity.launch(activity);
                activity.finish();
            }
        }
    }
}
@@ -98,62 +98,8 @@
 le;%0A
-import android.os.Handler;%0Aimport android.os.Message;%0A
 impo
@@ -163,243 +163,129 @@
 ort 
-java.lang.ref.WeakReference;%0A%0A/**%0A * Created by hugo on 2015/10/25 0025.%0A * %E9%97%AA%E5%B1%8F%E9%A1%B5%0A * @see %3Ca herf=%22http://www.androiddesignpatt
+io.reactivex.Observable;%0Aimport io.reactivex.android.schedul
 er
-n
 s.
-com/2013/01/inner-class-handler-memory-leak.html%22%3EHow to Leak a Context: Handlers & Inner Classes%3C/a%3E%0A */
+AndroidSchedulers;%0Aimport java.util.concurrent.TimeUnit;%0A
 %0Apub
@@ -405,70 +405,8 @@
 e();
-%0A    private SwitchHandler mHandler = new SwitchHandler(this);
 %0A%0A  
@@ -478,36 +478,8 @@
 ) %7B%0A
-        //activity%E5%88%87%E6%8D%A2%E7%9A%84%E6%B7%A1%E5%85%A5%E6%B7%A1%E5%87%BA%E6%95%88%E6%9E%9C%0A
     
@@ -614,469 +614,159 @@
     
-mHandler.sendEmptyMessageDelayed(1, 1000);%0A%0A    %7D%0A%0A    private static class SwitchHandler extends Handler %7B%0A        private WeakReference%3CFirstActivity%3E mWeakReference;%0A%0A        SwitchHandler(FirstActivity activity) %7B%0A            mWeakReference = new WeakReference%3CFirstActivity%3E(activity);%0A        %7D%0A%0A        @Override%0A        public void handleMessage(Message msg) %7B%0A            FirstActivity activity = mWeakReference.get();%0A            if (activity != null)
+Observable.timer(1, TimeUnit.SECONDS) // thanks to XieEDeHeiShou%0A            .observeOn(AndroidSchedulers.mainThread())%0A            .subscribe(aLong -%3E
  %7B%0A 
@@ -800,24 +800,20 @@
 .launch(
-activity
+this
 );%0A     
@@ -827,17 +827,8 @@
     
-activity.
 fini
@@ -850,18 +850,10 @@
    %7D
-%0A        %7D
+);
 %0A   

optimize code