Use Intent rather than global variable

This commit is contained in:
topjohnwu 2019-02-02 04:22:25 -05:00
parent 6bbe0f07d4
commit 9fbe5895b7
4 changed files with 3 additions and 4 deletions

View File

@ -20,7 +20,6 @@ import java.util.concurrent.ThreadPoolExecutor;
public class App extends ContainerApp {
public static App self;
public boolean init = false;
public static ThreadPoolExecutor THREAD_POOL;
// Global resources

View File

@ -84,6 +84,7 @@ public class Const {
public static final String LINK_KEY = "Link";
public static final String IF_NONE_MATCH = "If-None-Match";
// intents
public static final String FROM_SPLASH = "splash";
public static final String OPEN_SECTION = "section";
public static final String INTENT_SET_NAME = "filename";
public static final String INTENT_SET_LINK = "link";

View File

@ -50,7 +50,7 @@ public class MainActivity extends BaseActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
if (!app.init) {
if (!getIntent().getBooleanExtra(Const.Key.FROM_SPLASH, false)) {
startActivity(new Intent(this, ClassMap.get(SplashActivity.class)));
finish();
}

View File

@ -58,10 +58,9 @@ public class SplashActivity extends BaseActivity {
new UpdateRepos().exec();
}
app.init = true;
Intent intent = new Intent(this, ClassMap.get(MainActivity.class));
intent.putExtra(Const.Key.OPEN_SECTION, getIntent().getStringExtra(Const.Key.OPEN_SECTION));
intent.putExtra(Const.Key.FROM_SPLASH, true);
intent.putExtra(BaseActivity.INTENT_PERM, getIntent().getStringExtra(BaseActivity.INTENT_PERM));
startActivity(intent);
finish();