forked from upstream-mirrors/quik
Fixed crashlytics #975
This commit is contained in:
@@ -53,6 +53,9 @@ import java.util.Locale;
|
||||
public class QKSMSAppBase extends MultiDexApplication {
|
||||
public static final String LOG_TAG = "Mms";
|
||||
|
||||
public static final int LOADER_CONVERSATIONS = 0;
|
||||
public static final int LOADER_MESSAGES = 1;
|
||||
|
||||
private SearchRecentSuggestions mRecentSuggestions;
|
||||
private TelephonyManager mTelephonyManager;
|
||||
private String mCountryIso;
|
||||
|
||||
+27
-17
@@ -21,6 +21,7 @@ import android.widget.ImageView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
@@ -265,7 +266,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
}
|
||||
|
||||
private void initLoaderManager() {
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
getLoaderManager().restartLoader(QKSMSApp.LOADER_CONVERSATIONS, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,27 +290,36 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new CursorLoader(mContext, SmsHelper.CONVERSATIONS_CONTENT_PROVIDER, Conversation.ALL_THREADS_PROJECTION,
|
||||
BlockedConversationHelper.getCursorSelection(mPrefs, mShowBlocked),
|
||||
BlockedConversationHelper.getBlockedConversationArray(mPrefs), "date DESC");
|
||||
}
|
||||
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
if (mAdapter != null) {
|
||||
// Swap the new cursor in. (The framework will take care of closing the, old cursor once we return.)
|
||||
mAdapter.changeCursor(data);
|
||||
if (mPosition != 0) {
|
||||
mRecyclerView.scrollToPosition(Math.min(mPosition, data.getCount() - 1));
|
||||
mPosition = 0;
|
||||
}
|
||||
if (id == QKSMSApp.LOADER_CONVERSATIONS) {
|
||||
return new CursorLoader(mContext, SmsHelper.CONVERSATIONS_CONTENT_PROVIDER, Conversation.ALL_THREADS_PROJECTION,
|
||||
BlockedConversationHelper.getCursorSelection(mPrefs, mShowBlocked),
|
||||
BlockedConversationHelper.getBlockedConversationArray(mPrefs), "date DESC");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
mEmptyState.setVisibility(data != null && data.getCount() > 0 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
if (loader.getId() == QKSMSApp.LOADER_CONVERSATIONS) {
|
||||
if (mAdapter != null) {
|
||||
// Swap the new cursor in. (The framework will take care of closing the, old cursor once we return.)
|
||||
mAdapter.changeCursor(data);
|
||||
if (mPosition != 0) {
|
||||
mRecyclerView.scrollToPosition(Math.min(mPosition, data.getCount() - 1));
|
||||
mPosition = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mEmptyState.setVisibility(data != null && data.getCount() > 0 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
if (mAdapter != null) {
|
||||
if (mAdapter != null && loader.getId() == QKSMSApp.LOADER_CONVERSATIONS) {
|
||||
mAdapter.changeCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static android.R.attr.data;
|
||||
|
||||
public class MessageListFragment extends QKFragment implements ActivityLauncher, SensorEventListener,
|
||||
LoaderManager.LoaderCallbacks<Cursor>, RecyclerCursorAdapter.MultiSelectListener, SwipeBackLayout.ScrollChangedListener,
|
||||
RecyclerCursorAdapter.ItemClickListener<MessageItem> {
|
||||
@@ -572,7 +574,7 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
||||
}
|
||||
|
||||
private void initLoaderManager() {
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getLoaderManager().initLoader(QKSMSApp.LOADER_MESSAGES, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -619,21 +621,28 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
||||
// Ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new CursorLoader(mContext,
|
||||
Uri.withAppendedPath(Message.MMS_SMS_CONTENT_PROVIDER, String.valueOf(mThreadId)),
|
||||
MessageColumns.PROJECTION, null, null, "normalized_date ASC");
|
||||
if (id == QKSMSApp.LOADER_MESSAGES) {
|
||||
return new CursorLoader(mContext,
|
||||
Uri.withAppendedPath(Message.MMS_SMS_CONTENT_PROVIDER, String.valueOf(mThreadId)),
|
||||
MessageColumns.PROJECTION, null, null, "normalized_date ASC");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
if (mAdapter != null) {
|
||||
if (mAdapter != null && loader.getId() == QKSMSApp.LOADER_MESSAGES) {
|
||||
// Swap the new cursor in. (The framework will take care of closing the, old cursor once we return.)
|
||||
mAdapter.changeCursor(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
if (mAdapter != null) {
|
||||
if (mAdapter != null && loader.getId() == QKSMSApp.LOADER_MESSAGES) {
|
||||
mAdapter.changeCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user