mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 19:38:34 +00:00
Add better Loader performance logs.
This commit is contained in:
parent
b0a6bb79f6
commit
c1e6b6b086
@ -364,8 +364,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle state, boolean ready) {
|
protected void onCreate(Bundle state, boolean ready) {
|
||||||
Log.i(TAG, "onCreate()");
|
|
||||||
|
|
||||||
RecipientId recipientId = getIntent().getParcelableExtra(RECIPIENT_EXTRA);
|
RecipientId recipientId = getIntent().getParcelableExtra(RECIPIENT_EXTRA);
|
||||||
|
|
||||||
if (recipientId == null) {
|
if (recipientId == null) {
|
||||||
|
@ -146,7 +146,6 @@ public class ConversationFragment extends Fragment
|
|||||||
private int previousOffset;
|
private int previousOffset;
|
||||||
private int activeOffset;
|
private int activeOffset;
|
||||||
private boolean firstLoad;
|
private boolean firstLoad;
|
||||||
private long loaderStartTime;
|
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private RecyclerView list;
|
private RecyclerView list;
|
||||||
@ -654,7 +653,6 @@ public class ConversationFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public @NonNull Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public @NonNull Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
Log.i(TAG, "onCreateLoader");
|
Log.i(TAG, "onCreateLoader");
|
||||||
loaderStartTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
int limit = args.getInt(KEY_LIMIT, PARTIAL_CONVERSATION_LIMIT);
|
int limit = args.getInt(KEY_LIMIT, PARTIAL_CONVERSATION_LIMIT);
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -668,9 +666,7 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(@NonNull Loader<Cursor> cursorLoader, Cursor cursor) {
|
public void onLoadFinished(@NonNull Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||||
long loadTime = System.currentTimeMillis() - loaderStartTime;
|
|
||||||
int count = cursor.getCount();
|
int count = cursor.getCount();
|
||||||
Log.i(TAG, "onLoadFinished - took " + loadTime + " ms to load a cursor of size " + count);
|
|
||||||
ConversationLoader loader = (ConversationLoader)cursorLoader;
|
ConversationLoader loader = (ConversationLoader)cursorLoader;
|
||||||
|
|
||||||
ConversationAdapter adapter = getListAdapter();
|
ConversationAdapter adapter = getListAdapter();
|
||||||
|
@ -5,6 +5,8 @@ import android.content.Context;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import androidx.loader.content.AsyncTaskLoader;
|
import androidx.loader.content.AsyncTaskLoader;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Loader similar to CursorLoader that doesn't require queries to go through the ContentResolver
|
* A Loader similar to CursorLoader that doesn't require queries to go through the ContentResolver
|
||||||
* to get the benefits of reloading when content has changed.
|
* to get the benefits of reloading when content has changed.
|
||||||
@ -71,11 +73,15 @@ public abstract class AbstractCursorLoader extends AsyncTaskLoader<Cursor> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor loadInBackground() {
|
public Cursor loadInBackground() {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
Cursor newCursor = getCursor();
|
Cursor newCursor = getCursor();
|
||||||
if (newCursor != null) {
|
if (newCursor != null) {
|
||||||
newCursor.getCount();
|
newCursor.getCount();
|
||||||
newCursor.registerContentObserver(observer);
|
newCursor.registerContentObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.d(TAG, "[" + getClass().getSimpleName() + "] Cursor load time: " + (System.currentTimeMillis() - startTime) + " ms");
|
||||||
return newCursor;
|
return newCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user