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