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