forked from upstream-mirrors/quik
Fix ConversationListFragment leak
This commit is contained in:
@@ -26,6 +26,7 @@ import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.data.Contact;
|
||||
import com.moez.QKSMS.ui.dialog.conversationdetails.ConversationDetailsDialog;
|
||||
import com.moez.QKSMS.enums.QKPreference;
|
||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||
@@ -282,6 +283,21 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
BlockedConversationHelper.FutureBlockedConversationObservable.getInstance().deleteObserver(this);
|
||||
|
||||
if (null == mRecyclerView) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
for (int i = 0; i < mRecyclerView.getChildCount(); i++) {
|
||||
View child = mRecyclerView.getChildAt(i);
|
||||
RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(child);
|
||||
if (holder instanceof ConversationListViewHolder) {
|
||||
Contact.removeListener((ConversationListViewHolder) holder);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
|
||||
+4
-7
@@ -85,13 +85,10 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
|
||||
final ConversationLegacy conversationLegacy = new ConversationLegacy(mContext, mData.getThreadId());
|
||||
|
||||
if (shouldUpdate) {
|
||||
((MainActivity) mContext).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mAvatarView.setImageDrawable(drawable);
|
||||
mAvatarView.setContactName(name);
|
||||
fromView.setText(formatMessage(mData, conversationLegacy));
|
||||
}
|
||||
mContext.runOnUiThread(() -> {
|
||||
mAvatarView.setImageDrawable(drawable);
|
||||
mAvatarView.setContactName(name);
|
||||
fromView.setText(formatMessage(mData, conversationLegacy));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user