mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
play around with messags list loading
This commit is contained in:
@@ -184,14 +184,7 @@ public class ConversationFragment extends Fragment
|
||||
initializeListAdapter();
|
||||
|
||||
if (threadId == -1) {
|
||||
getLoaderManager().restartLoader(0, Bundle.EMPTY, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadList() {
|
||||
LoaderManager loaderManager = getLoaderManager();
|
||||
if (loaderManager!=null) {
|
||||
getLoaderManager().restartLoader(0, Bundle.EMPTY, this);
|
||||
reloadList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +221,7 @@ public class ConversationFragment extends Fragment
|
||||
list.addItemDecoration(new StickyHeaderDecoration(adapter, false, false));
|
||||
|
||||
setLastSeen(lastSeen);
|
||||
getLoaderManager().restartLoader(0, Bundle.EMPTY, this);
|
||||
reloadList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,6 +449,24 @@ public class ConversationFragment extends Fragment
|
||||
*/
|
||||
}
|
||||
|
||||
public void reloadList() {
|
||||
// just for testing, here are two variants.
|
||||
final boolean loadSynchronous = true;
|
||||
if (loadSynchronous) {
|
||||
// this typically takes <1 ms ...
|
||||
loaderStartTime = System.currentTimeMillis();
|
||||
int[] msgs = DcHelper.getContext(getContext()).getChatMsgs((int)threadId, 0, 0);
|
||||
onLoadFinished(null, msgs);
|
||||
}
|
||||
else {
|
||||
// ... while this takes >100 ms
|
||||
LoaderManager loaderManager = getLoaderManager();
|
||||
if (loaderManager != null) {
|
||||
loaderManager.restartLoader(0, Bundle.EMPTY, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<int[]> onCreateLoader(int id, Bundle args) {
|
||||
Log.w(TAG, "onCreateLoader");
|
||||
|
||||
@@ -28,11 +28,7 @@ public class DcMsgListLoader extends AsyncLoader<int[]> {
|
||||
public @NonNull
|
||||
int[] loadInBackground() {
|
||||
try {
|
||||
long loaderStartTime = System.currentTimeMillis();
|
||||
int[] msgs = DcHelper.getContext(getContext()).getChatMsgs(chatId, listflags, marker1before);
|
||||
long loadTime = System.currentTimeMillis() - loaderStartTime;
|
||||
Log.i(TAG, "loadInBackground - took " + loadTime + " ms to load a message list of size " + msgs.length);
|
||||
return msgs;
|
||||
return DcHelper.getContext(getContext()).getChatMsgs(chatId, listflags, marker1before);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
|
||||
Reference in New Issue
Block a user