Speed up starting
This commit is contained in:
parent
437854911c
commit
dcf48be57a
|
@ -394,7 +394,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
main_app_container = findViewById(R.id.main_app_container);
|
||||
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, BaseMainActivity.this).execute();
|
||||
|
||||
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||
TabLayout.Tab pTabsub = tabLayout.newTab();
|
||||
|
@ -752,7 +752,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
int position = 0;
|
||||
if (tabLayout != null)
|
||||
position = tabLayout.getSelectedTabPosition();
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, BaseMainActivity.this).execute();
|
||||
}
|
||||
};
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(hidde_menu, new IntentFilter(Helper.RECEIVE_HIDE_ITEM));
|
||||
|
@ -1478,12 +1478,12 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.REDRAW_MENU) {
|
||||
Helper.hideMenuItem(BaseMainActivity.this, navigationView.getMenu());
|
||||
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_TAG) {
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, -1, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, -1, BaseMainActivity.this).execute();
|
||||
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.REFRESH_TIMELINE) {
|
||||
int position = 0;
|
||||
if (tabLayout != null)
|
||||
position = tabLayout.getSelectedTabPosition();
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new SyncTimelinesAsyncTask(BaseMainActivity.this, position, BaseMainActivity.this).execute();
|
||||
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_REMOTE) {
|
||||
String url = extras.getString(Helper.SEARCH_URL);
|
||||
intent.replaceExtras(new Bundle());
|
||||
|
|
|
@ -142,7 +142,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
|
||||
if (!flag_loading) {
|
||||
flag_loading = true;
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, max_id, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, max_id, DisplayNotificationsFragment.this).execute();
|
||||
nextElementLoader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
|
@ -205,7 +205,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
if (notifications != null && notifications.size() > 0)
|
||||
sinceId = notifications.get(0).getId();
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveMissingNotificationsAsyncTask(context, type, sinceId, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveMissingNotificationsAsyncTask(context, type, sinceId, DisplayNotificationsFragment.this).execute();
|
||||
}
|
||||
});
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -231,13 +231,13 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
break;
|
||||
}
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, max_id, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, max_id, DisplayNotificationsFragment.this).execute();
|
||||
else
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (context != null)
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, max_id, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, max_id, DisplayNotificationsFragment.this).execute();
|
||||
}
|
||||
}, 500);
|
||||
return rootView;
|
||||
|
@ -381,7 +381,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
* @param sinceId String
|
||||
*/
|
||||
void retrieveMissingNotifications(String sinceId) {
|
||||
asyncTask = new RetrieveMissingNotificationsAsyncTask(context, type, sinceId, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveMissingNotificationsAsyncTask(context, type, sinceId, DisplayNotificationsFragment.this).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -415,7 +415,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
if (type == Type.ALL) {
|
||||
countNewNotifications = 0;
|
||||
}
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveNotificationsAsyncTask(context, type, true, null, null, DisplayNotificationsFragment.this).execute();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -361,9 +361,9 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
max_id = "0";
|
||||
peertubeAdapater.notifyItemRangeRemoved(0, size);
|
||||
if (search_peertube == null) { //Not a Peertube search
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, "0", DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, "0", DisplayStatusFragment.this).execute();
|
||||
} else {
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
if (type == RetrieveFeedsAsyncTask.Type.HOME && !firstTootsLoaded) {
|
||||
boolean remember_position_home = sharedpreferences.getBoolean(Helper.SET_REMEMBER_POSITION_HOME, true);
|
||||
if (remember_position_home)
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, null, false, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, null, false, DisplayStatusFragment.this).execute();
|
||||
firstTootsLoaded = true;
|
||||
}
|
||||
//Let's deal with statuses
|
||||
|
@ -739,13 +739,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
private void retrieveMissingToots(String sinceId) {
|
||||
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, null, false, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, null, false, DisplayStatusFragment.this).execute();
|
||||
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, remoteInstance, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, remoteInstance, sinceId, type, DisplayStatusFragment.this).execute();
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.TAG)
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, tag, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, tag, sinceId, type, DisplayStatusFragment.this).execute();
|
||||
else
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveMissingFeedsAsyncTask(context, sinceId, type, DisplayStatusFragment.this).execute();
|
||||
|
||||
}
|
||||
|
||||
|
@ -764,7 +764,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
if (statuses.size() > 0)
|
||||
initialBookMarkDate = statuses.get(0).getCreated_at();
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, null, false, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, null, false, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -963,7 +963,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
|
||||
public void fetchMore(String max_id) {
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, max_id, true, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAfterBookmarkAsyncTask(context, max_id, true, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1050,21 +1050,21 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
private void manageAsyncTask(boolean pagination) {
|
||||
//Message for an account
|
||||
if (type == RetrieveFeedsAsyncTask.Type.USER || type == RetrieveFeedsAsyncTask.Type.CHANNEL)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, showReply, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, showReply, DisplayStatusFragment.this).execute();
|
||||
//Tag timelines
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.SEARCH)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).execute();
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.TAG)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, timelineId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, timelineId, max_id, DisplayStatusFragment.this).execute();
|
||||
else if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
|
||||
//Remote instances
|
||||
if (search_peertube == null) { //Not a Peertube search
|
||||
if (remote_channel_name == null) { //Not a channel
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).execute();
|
||||
} else
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, remoteInstance, remote_channel_name, null, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, remoteInstance, remote_channel_name, null, DisplayStatusFragment.this).execute();
|
||||
} else
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).execute();
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE_FILTERED) {
|
||||
RetrieveFeedsParam retrieveFeedsParam = new RetrieveFeedsParam();
|
||||
retrieveFeedsParam.setAction(type);
|
||||
|
@ -1072,27 +1072,27 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
retrieveFeedsParam.setRemoteInstance(remoteInstance);
|
||||
retrieveFeedsParam.setMax_id(max_id);
|
||||
retrieveFeedsParam.setSocial(instanceType);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, retrieveFeedsParam, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, retrieveFeedsParam, DisplayStatusFragment.this).execute();
|
||||
} else if (type == RetrieveFeedsAsyncTask.Type.LIST) {
|
||||
new ManageListsAsyncTask(context, targetedId, max_id, null, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new ManageListsAsyncTask(context, targetedId, max_id, null, DisplayStatusFragment.this).execute();
|
||||
} else {
|
||||
if (!pagination) {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME) {
|
||||
if (context instanceof BaseMainActivity) {
|
||||
boolean remember_position_home = sharedpreferences.getBoolean(Helper.SET_REMEMBER_POSITION_HOME, true);
|
||||
if (remember_position_home)
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, initialBookMark, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, initialBookMark, DisplayStatusFragment.this).execute();
|
||||
else
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, null, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, null, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
} else { //Most classical search will be done by this call
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, null, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, null, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
} else {
|
||||
if (type == RetrieveFeedsAsyncTask.Type.HOME) {
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).execute();
|
||||
} else {//Most classical search will be done by this call for pagination
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1178,9 +1178,9 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
max_id = "0";
|
||||
peertubeAdapater.notifyItemRangeRemoved(0, size);
|
||||
if (search_peertube == null) { //Not a Peertube search
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, "0", DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, "0", DisplayStatusFragment.this).execute();
|
||||
} else {
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
asyncTask = new RetrievePeertubeSearchAsyncTask(context, remoteInstance, search_peertube, DisplayStatusFragment.this).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue