Fixed change fragment crash on Android 4.x

This commit is contained in:
PeratX 2017-04-26 22:09:22 +08:00
parent 0907fe2d5b
commit e7f5c46529

View File

@ -2,7 +2,6 @@ package org.itxtech.daedalus.fragment;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.net.VpnService;
import android.os.Bundle;
@ -56,20 +55,12 @@ public class MainFragment extends Fragment {
});
updateUserInterface();
mHandler = (new MainFragmentHandler()).setFragment(this);
MainActivity.getInstance().setMainFragmentHandler(mHandler);
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof MainActivity) {
mHandler = (new MainFragmentHandler()).setFragment(this);
((MainActivity) context).setMainFragmentHandler(mHandler);
}
}
@Override
public void onDetach() {
super.onDetach();