Fix a crash when app takes long to load
This commit is contained in:
parent
3c7129f47a
commit
30f21c035d
|
@ -322,7 +322,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
binding.compose.setOnClickListener(v -> startActivity(new Intent(this, ComposeActivity.class)));
|
binding.compose.setOnClickListener(v -> startActivity(new Intent(this, ComposeActivity.class)));
|
||||||
headerMenuOpen = false;
|
headerMenuOpen = false;
|
||||||
|
|
||||||
|
PushHelper.startStreaming(BaseMainActivity.this);
|
||||||
|
|
||||||
// Passing each menu ID as a set of Ids because each
|
// Passing each menu ID as a set of Ids because each
|
||||||
// menu should be considered as top level destinations.
|
// menu should be considered as top level destinations.
|
||||||
|
@ -564,21 +564,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
//Update account details
|
//Update account details
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
currentAccount = new Account(BaseMainActivity.this).getConnectedAccount();
|
if (currentToken == null) {
|
||||||
//Delete cache older than 7 days
|
currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
||||||
new StatusCache(BaseMainActivity.this).deleteForAllAccountAfter7Days();
|
|
||||||
MutedAccounts mutedAccounts = new MutedAccounts(BaseMainActivity.this).getMutedAccount(currentAccount);
|
|
||||||
if (mutedAccounts != null && mutedAccounts.accounts != null) {
|
|
||||||
filteredAccounts = mutedAccounts.accounts;
|
|
||||||
}
|
}
|
||||||
|
currentAccount = new Account(BaseMainActivity.this).getConnectedAccount();
|
||||||
} catch (DBException e) {
|
} catch (DBException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
if (currentToken == null) {
|
|
||||||
currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
|
||||||
}
|
|
||||||
if (currentAccount == null) {
|
if (currentAccount == null) {
|
||||||
//It is not, the user is redirected to the login page
|
//It is not, the user is redirected to the login page
|
||||||
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
Intent myIntent = new Intent(BaseMainActivity.this, LoginActivity.class);
|
||||||
|
@ -747,7 +741,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
PushHelper.startStreaming(BaseMainActivity.this);
|
|
||||||
|
|
||||||
binding.toolbarSearch.setOnSearchClickListener(v -> binding.tabLayout.setVisibility(View.VISIBLE));
|
binding.toolbarSearch.setOnSearchClickListener(v -> binding.tabLayout.setVisibility(View.VISIBLE));
|
||||||
//For receiving data from other activities
|
//For receiving data from other activities
|
||||||
|
@ -764,6 +758,20 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
//Fetch some db values to initialize data
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
MutedAccounts mutedAccounts = new MutedAccounts(BaseMainActivity.this).getMutedAccount(currentAccount);
|
||||||
|
if (mutedAccounts != null && mutedAccounts.accounts != null) {
|
||||||
|
filteredAccounts = mutedAccounts.accounts;
|
||||||
|
}
|
||||||
|
//Delete cache older than 7 days
|
||||||
|
new StatusCache(BaseMainActivity.this).deleteForAllAccountAfter7Days();
|
||||||
|
} catch (DBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
//Fetch recent used accounts
|
//Fetch recent used accounts
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue