整理NormalFragment相关代码
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
@ -24,6 +23,7 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -38,6 +38,26 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
protected String mEntrance;
|
||||
private boolean mIsPause;
|
||||
|
||||
protected final Handler mBaseHandler = new BaseHandler(this);
|
||||
|
||||
protected static class BaseHandler extends Handler {
|
||||
private final WeakReference<BaseActivity> mActivityWeakReference;
|
||||
|
||||
BaseHandler(BaseActivity activity) {
|
||||
mActivityWeakReference = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
mActivityWeakReference.get().handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleMessage(Message msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -52,6 +72,7 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
mBaseHandler.removeCallbacksAndMessages(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@ -121,7 +142,7 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
, null, new DialogUtils.CancelListener() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
startActivity(LoginActivity.getIntent(BaseActivity.this));
|
||||
startActivity(LoginActivity.getIntent(BaseActivity.this));
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
|
||||
Reference in New Issue
Block a user