Fixed setMainFragmentHandler on null on Android 6.x
This commit is contained in:
parent
1f4957a476
commit
6edc62d715
@ -65,12 +65,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
private DnsServersFragment mDnsServers;
|
||||
private int currentFragment = FRAGMENT_NONE;
|
||||
|
||||
private MainFragment.MainFragmentHandler mHandler = null;
|
||||
|
||||
public void setMainFragmentHandler(MainFragment.MainFragmentHandler mHandler) {
|
||||
this.mHandler = mHandler;
|
||||
}
|
||||
|
||||
public static MainActivity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@ -291,8 +285,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
Daedalus.getInstance().deactivateService();
|
||||
} else if (launchAction == LAUNCH_ACTION_AFTER_DEACTIVATE) {
|
||||
Daedalus.updateShortcut(this.getApplicationContext());
|
||||
if (currentFragment == FRAGMENT_MAIN && mHandler != null) {
|
||||
mHandler.obtainMessage(MainFragment.MainFragmentHandler.MSG_REFRESH).sendToTarget();
|
||||
if (currentFragment == FRAGMENT_MAIN && MainFragment.mHandler != null) {
|
||||
MainFragment.mHandler.obtainMessage(MainFragment.MainFragmentHandler.MSG_REFRESH).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import org.itxtech.daedalus.Daedalus;
|
||||
import org.itxtech.daedalus.R;
|
||||
import org.itxtech.daedalus.activity.MainActivity;
|
||||
import org.itxtech.daedalus.service.DaedalusVpnService;
|
||||
import org.itxtech.daedalus.util.DnsServerHelper;
|
||||
|
||||
@ -34,14 +33,13 @@ import org.itxtech.daedalus.util.DnsServerHelper;
|
||||
public class MainFragment extends Fragment {
|
||||
|
||||
private View view = null;
|
||||
private MainFragmentHandler mHandler = null;
|
||||
public static MainFragmentHandler mHandler = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mHandler = (new MainFragmentHandler()).setFragment(this);
|
||||
MainActivity.getInstance().setMainFragmentHandler(mHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,7 +66,7 @@ public class MainFragment extends Fragment {
|
||||
super.onDetach();
|
||||
|
||||
mHandler.shutdown();
|
||||
MainActivity.getInstance().setMainFragmentHandler(null);
|
||||
mHandler = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,7 +152,8 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
stopSelf();
|
||||
|
||||
if (shouldRefresh && MainActivity.getInstance() != null && Daedalus.getInstance().isAppOnForeground()) {
|
||||
MainActivity.getInstance().startActivity(new Intent(getApplicationContext(), MainActivity.class).putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_AFTER_DEACTIVATE));
|
||||
MainActivity.getInstance().startActivity(new Intent(getApplicationContext(), MainActivity.class)
|
||||
.putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_AFTER_DEACTIVATE));
|
||||
} else if (shouldRefresh) {
|
||||
Daedalus.updateShortcut(getApplicationContext());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user