Added message property changed debugging

pull/175/head
M66B 5 years ago
parent ba36ed09d5
commit e62964ccd2

@ -4395,138 +4395,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
debug = prefs.getBoolean("debug", false); debug = prefs.getBoolean("debug", false);
AsyncDifferConfig<TupleMessageEx> config = new AsyncDifferConfig.Builder<>(DIFF_CALLBACK) DiffUtil.ItemCallback<TupleMessageEx> callback = new DiffUtil.ItemCallback<TupleMessageEx>() {
.setBackgroundThreadExecutor(executor)
.build();
this.differ = new AsyncPagedListDiffer<>(new AdapterListUpdateCallback(this), config);
this.differ.addPagedListListener(new AsyncPagedListDiffer.PagedListListener<TupleMessageEx>() {
@Override
public void onCurrentListChanged(@Nullable PagedList<TupleMessageEx> previousList, @Nullable PagedList<TupleMessageEx> currentList) {
if (gotoTop) {
gotoTop = false;
properties.scrollTo(0);
}
}
});
try {
// https://issuetracker.google.com/issues/135628748
Handler handler = new Handler(Looper.getMainLooper());
Field mMainThreadExecutor = this.differ.getClass().getDeclaredField("mMainThreadExecutor");
mMainThreadExecutor.setAccessible(true);
mMainThreadExecutor.set(this.differ, new Executor() {
@Override
public void execute(final Runnable command) {
handler.post(new Runnable() {
@Override
public void run() {
try {
command.run();
} catch (Throwable ex) {
Log.e(ex);
}
}
});
}
});
} catch (Throwable ex) {
Log.e(ex);
}
owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
Log.d(AdapterMessage.this + " parent destroyed");
AdapterMessage.this.parentFragment = null;
}
});
}
void gotoTop() {
properties.scrollTo(0);
this.gotoTop = true;
}
void submitList(PagedList<TupleMessageEx> list) {
keyPosition.clear();
if (keywords_header)
for (int i = 0; i < list.size(); i++) {
TupleMessageEx message = list.get(i);
if (message != null)
message.resolveKeywordColors(context);
}
differ.submitList(list);
}
PagedList<TupleMessageEx> getCurrentList() {
return differ.getCurrentList();
}
void setCompact(boolean compact) {
if (this.compact != compact) {
this.compact = compact;
notifyDataSetChanged();
}
}
void setZoom(int zoom) {
if (this.zoom != zoom) {
this.zoom = zoom;
textSize = Helper.getTextSize(context, zoom);
notifyDataSetChanged();
}
}
int getZoom() {
return this.zoom;
}
void setSort(String sort) {
if (!sort.equals(this.sort)) {
this.sort = sort;
notifyDataSetChanged();
// Needed to redraw item decorators / add/remove size
}
}
String getSort() {
return this.sort;
}
void setAscending(boolean ascending) {
this.ascending = ascending;
}
void setFilterDuplicates(boolean filter_duplicates) {
if (this.filter_duplicates != filter_duplicates) {
this.filter_duplicates = filter_duplicates;
notifyDataSetChanged();
}
}
void checkInternet() {
ConnectionHelper.NetworkState state = ConnectionHelper.getNetworkState(context);
if (this.suitable != state.isSuitable() || this.unmetered != state.isUnmetered()) {
this.suitable = state.isSuitable();
this.unmetered = state.isUnmetered();
notifyDataSetChanged();
}
}
void setAnswerCount(int answers) {
this.answers = answers;
Log.i("Answer count=" + answers);
}
@Override
public int getItemCount() {
return differ.getItemCount();
}
private static final DiffUtil.ItemCallback<TupleMessageEx> DIFF_CALLBACK =
new DiffUtil.ItemCallback<TupleMessageEx>() {
@Override @Override
public boolean areItemsTheSame( public boolean areItemsTheSame(
@NonNull TupleMessageEx prev, @NonNull TupleMessageEx next) { @NonNull TupleMessageEx prev, @NonNull TupleMessageEx next) {
@ -4544,289 +4413,434 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (!Objects.equals(prev.identity, next.identity)) { if (!Objects.equals(prev.identity, next.identity)) {
// via // via
same = false; same = false;
Log.i("Entity changed id=" + next.id); log("Entity changed", next.id);
} }
// extra // extra
if (!Objects.equals(prev.uid, next.uid)) { if (!Objects.equals(prev.uid, next.uid)) {
same = false; same = false;
Log.i("uid changed id=" + next.id); log("uid changed", next.id);
} }
if (!Objects.equals(prev.msgid, next.msgid)) { if (!Objects.equals(prev.msgid, next.msgid)) {
// debug info // debug info
same = false; same = false;
Log.i("msgid changed id=" + next.id); log("msgid changed", next.id);
} }
// references // references
// deliveredto // deliveredto
// inreplyto // inreplyto
if (!Objects.equals(prev.thread, next.thread)) { if (!Objects.equals(prev.thread, next.thread)) {
same = false; same = false;
Log.i("thread changed id=" + next.id); log("thread changed", next.id);
} }
if (!Objects.equals(prev.ui_priority, next.ui_priority)) { if (!Objects.equals(prev.ui_priority, next.ui_priority)) {
same = false; same = false;
Log.i("ui_priority changed id=" + next.id); log("ui_priority changed", next.id);
} }
if (!Objects.equals(prev.ui_importance, next.ui_importance)) { if (!Objects.equals(prev.ui_importance, next.ui_importance)) {
same = false; same = false;
Log.i("ui_importance changed id=" + next.id); log("ui_importance changed", next.id);
} }
if (!Objects.equals(prev.receipt_request, next.receipt_request)) { if (!Objects.equals(prev.receipt_request, next.receipt_request)) {
same = false; same = false;
Log.i("receipt_request changed id=" + next.id); log("receipt_request changed", next.id);
} }
if (!MessageHelper.equal(prev.receipt_to, next.receipt_to)) { if (!MessageHelper.equal(prev.receipt_to, next.receipt_to)) {
same = false; same = false;
Log.i("receipt_to changed id=" + next.id); log("receipt_to changed", next.id);
} }
if (!Objects.equals(prev.dkim, next.dkim)) { if (!Objects.equals(prev.dkim, next.dkim)) {
same = false; same = false;
Log.i("dkim changed id=" + next.id); log("dkim changed", next.id);
} }
if (!Objects.equals(prev.spf, next.spf)) { if (!Objects.equals(prev.spf, next.spf)) {
same = false; same = false;
Log.i("spf changed id=" + next.id); log("spf changed", next.id);
} }
if (!Objects.equals(prev.dmarc, next.dmarc)) { if (!Objects.equals(prev.dmarc, next.dmarc)) {
same = false; same = false;
Log.i("dmarc changed id=" + next.id); log("dmarc changed", next.id);
} }
if (!Objects.equals(prev.mx, next.mx)) { if (!Objects.equals(prev.mx, next.mx)) {
same = false; same = false;
Log.i("mx changed id=" + next.id); log("mx changed", next.id);
} }
if (!Objects.equals(prev.avatar, next.avatar)) { if (!Objects.equals(prev.avatar, next.avatar)) {
same = false; same = false;
Log.i("avatar changed id=" + next.id); log("avatar changed", next.id);
} }
if (!Objects.equals(prev.sender, next.sender)) { if (!Objects.equals(prev.sender, next.sender)) {
same = false; same = false;
Log.i("sender changed id=" + next.id); log("sender changed", next.id);
} }
if (!MessageHelper.equal(prev.from, next.from)) { if (!MessageHelper.equal(prev.from, next.from)) {
same = false; same = false;
Log.i("from changed id=" + next.id); log("from changed", next.id);
} }
if (!MessageHelper.equal(prev.to, next.to)) { if (!MessageHelper.equal(prev.to, next.to)) {
same = false; same = false;
Log.i("to changed id=" + next.id); log("to changed", next.id);
} }
if (!MessageHelper.equal(prev.cc, next.cc)) { if (!MessageHelper.equal(prev.cc, next.cc)) {
same = false; same = false;
Log.i("cc changed id=" + next.id); log("cc changed", next.id);
} }
if (!MessageHelper.equal(prev.bcc, next.bcc)) { if (!MessageHelper.equal(prev.bcc, next.bcc)) {
same = false; same = false;
Log.i("bcc changed id=" + next.id); log("bcc changed", next.id);
} }
if (!MessageHelper.equal(prev.reply, next.reply)) { if (!MessageHelper.equal(prev.reply, next.reply)) {
same = false; same = false;
Log.i("reply changed id=" + next.id); log("reply changed", next.id);
} }
if (!MessageHelper.equal(prev.list_post, next.list_post)) { if (!MessageHelper.equal(prev.list_post, next.list_post)) {
same = false; same = false;
Log.i("list_post changed id=" + next.id); log("list_post changed", next.id);
} }
if (!Objects.equals(prev.headers, next.headers)) { if (!Objects.equals(prev.headers, next.headers)) {
same = false; same = false;
Log.i("headers changed id=" + next.id); log("headers changed", next.id);
} }
if (!Objects.equals(prev.raw, next.raw)) { if (!Objects.equals(prev.raw, next.raw)) {
same = false; same = false;
Log.i("raw changed id=" + next.id); log("raw changed", next.id);
} }
if (!Objects.equals(prev.subject, next.subject)) { if (!Objects.equals(prev.subject, next.subject)) {
same = false; same = false;
Log.i("subject changed id=" + next.id); log("subject changed", next.id);
} }
if (!Objects.equals(prev.size, next.size)) { if (!Objects.equals(prev.size, next.size)) {
same = false; same = false;
Log.i("size changed id=" + next.id); log("size changed", next.id);
} }
if (!Objects.equals(prev.total, next.total)) { if (!Objects.equals(prev.total, next.total)) {
same = false; same = false;
Log.i("total changed id=" + next.id); log("total changed", next.id);
} }
if (!Objects.equals(prev.attachments, next.attachments)) { if (!Objects.equals(prev.attachments, next.attachments)) {
same = false; same = false;
Log.i("attachments changed id=" + next.id); log("attachments changed", next.id);
} }
if (!prev.content.equals(next.content)) { if (!prev.content.equals(next.content)) {
same = false; same = false;
Log.i("content changed id=" + next.id); log("content changed", next.id);
} }
if (!Objects.equals(prev.plain_only, next.plain_only)) { if (!Objects.equals(prev.plain_only, next.plain_only)) {
same = false; same = false;
Log.i("plain_only changed id=" + next.id); log("plain_only changed", next.id);
} }
if (!Objects.equals(prev.encrypt, next.encrypt)) { if (!Objects.equals(prev.encrypt, next.encrypt)) {
same = false; same = false;
Log.i("encrypt changed id=" + next.id); log("encrypt changed", next.id);
} }
if (!Objects.equals(prev.preview, next.preview)) { if (!Objects.equals(prev.preview, next.preview)) {
same = false; same = false;
Log.i("preview changed id=" + next.id); log("preview changed", next.id);
} }
if (!Objects.equals(prev.sent, next.sent)) { if (!Objects.equals(prev.sent, next.sent)) {
same = false; same = false;
Log.i("sent changed id=" + next.id); log("sent changed", next.id);
} }
if (!prev.received.equals(next.received)) { if (!prev.received.equals(next.received)) {
same = false; same = false;
Log.i("received changed id=" + next.id); log("received changed", next.id);
} }
if (!prev.stored.equals(next.stored)) { if (!prev.stored.equals(next.stored)) {
// updated after decryption // updated after decryption
same = false; same = false;
Log.i("stored changed id=" + next.id); log("stored changed", next.id);
} }
// seen // seen
// answered // answered
// flagged // flagged
if (debug && !Objects.equals(prev.flags, next.flags)) { if (debug && !Objects.equals(prev.flags, next.flags)) {
same = false; same = false;
Log.i("flags changed id=" + next.id); log("flags changed", next.id);
} }
if (!Helper.equal(prev.keywords, next.keywords)) { if (!Helper.equal(prev.keywords, next.keywords)) {
same = false; same = false;
Log.i("keywords changed id=" + next.id); log("keywords changed", next.id);
} }
// notifying // notifying
// fts // fts
if (!prev.ui_seen.equals(next.ui_seen)) { if (!prev.ui_seen.equals(next.ui_seen)) {
same = false; same = false;
Log.i("ui_seen changed id=" + next.id); log("ui_seen changed " + prev.ui_seen + "/" + next.ui_seen, next.id);
} }
if (!prev.ui_answered.equals(next.ui_answered)) { if (!prev.ui_answered.equals(next.ui_answered)) {
same = false; same = false;
Log.i("ui_answer changed id=" + next.id); log("ui_answer changed", next.id);
} }
if (!prev.ui_flagged.equals(next.ui_flagged)) { if (!prev.ui_flagged.equals(next.ui_flagged)) {
same = false; same = false;
Log.i("ui_flagged changed id=" + next.id); log("ui_flagged changed", next.id);
} }
if (!prev.ui_hide.equals(next.ui_hide)) { if (!prev.ui_hide.equals(next.ui_hide)) {
same = false; same = false;
Log.i("ui_hide changed id=" + next.id); log("ui_hide changed", next.id);
} }
if (!prev.ui_found.equals(next.ui_found)) { if (!prev.ui_found.equals(next.ui_found)) {
same = false; same = false;
Log.i("ui_found changed id=" + next.id); log("ui_found changed", next.id);
} }
// ui_ignored // ui_ignored
if (!prev.ui_browsed.equals(next.ui_browsed)) { if (!prev.ui_browsed.equals(next.ui_browsed)) {
same = false; same = false;
Log.i("ui_browsed changed id=" + next.id); log("ui_browsed changed", next.id);
} }
if (!Objects.equals(prev.ui_busy, next.ui_busy)) { if (!Objects.equals(prev.ui_busy, next.ui_busy)) {
same = false; same = false;
Log.i("ui_busy changed id=" + next.id); log("ui_busy changed " + prev.ui_busy + "/" + next.ui_busy, next.id);
} }
if (!Objects.equals(prev.ui_snoozed, next.ui_snoozed)) { if (!Objects.equals(prev.ui_snoozed, next.ui_snoozed)) {
same = false; same = false;
Log.i("ui_snoozed changed id=" + next.id); log("ui_snoozed changed", next.id);
} }
if (!Objects.equals(prev.color, next.color)) { if (!Objects.equals(prev.color, next.color)) {
same = false; same = false;
Log.i("color changed id=" + next.id); log("color changed", next.id);
} }
// revision // revision
// revisions // revisions
if (!Objects.equals(prev.warning, next.warning)) { if (!Objects.equals(prev.warning, next.warning)) {
same = false; same = false;
Log.i("warning changed id=" + next.id); log("warning changed", next.id);
} }
if (!Objects.equals(prev.error, next.error)) { if (!Objects.equals(prev.error, next.error)) {
same = false; same = false;
Log.i("error changed id=" + next.id); log("error changed", next.id);
} }
// last_attempt // last_attempt
// accountPop // accountPop
if (!Objects.equals(prev.accountName, next.accountName)) { if (!Objects.equals(prev.accountName, next.accountName)) {
same = false; same = false;
Log.i("accountName changed id=" + next.id); log("accountName changed", next.id);
} }
if (!Objects.equals(prev.accountColor, next.accountColor)) { if (!Objects.equals(prev.accountColor, next.accountColor)) {
same = false; same = false;
Log.i("accountColor changed id=" + next.id); log("accountColor changed", next.id);
} }
// accountNotify // accountNotify
// accountAutoSeen // accountAutoSeen
if (!prev.folderName.equals(next.folderName)) { if (!prev.folderName.equals(next.folderName)) {
same = false; same = false;
Log.i("folderName changed id=" + next.id); log("folderName changed", next.id);
} }
if (!Objects.equals(prev.folderDisplay, next.folderDisplay)) { if (!Objects.equals(prev.folderDisplay, next.folderDisplay)) {
same = false; same = false;
Log.i("folderDisplay changed id=" + next.id); log("folderDisplay changed", next.id);
} }
if (!prev.folderType.equals(next.folderType)) { if (!prev.folderType.equals(next.folderType)) {
same = false; same = false;
Log.i("folderType changed id=" + next.id); log("folderType changed", next.id);
} }
if (prev.folderReadOnly != next.folderReadOnly) { if (prev.folderReadOnly != next.folderReadOnly) {
same = false; same = false;
Log.i("folderReadOnly changed id=" + next.id); log("folderReadOnly changed", next.id);
} }
if (!Objects.equals(prev.identityName, next.identityName)) { if (!Objects.equals(prev.identityName, next.identityName)) {
same = false; same = false;
Log.i("identityName changed id=" + next.id); log("identityName changed", next.id);
} }
if (!Objects.equals(prev.identityEmail, next.identityEmail)) { if (!Objects.equals(prev.identityEmail, next.identityEmail)) {
same = false; same = false;
Log.i("identityEmail changed id=" + next.id); log("identityEmail changed", next.id);
} }
if (!Objects.equals(prev.identitySynchronize, next.identitySynchronize)) { if (!Objects.equals(prev.identitySynchronize, next.identitySynchronize)) {
same = false; same = false;
Log.i("identitySynchronize changed id=" + next.id); log("identitySynchronize changed", next.id);
} }
// senders // senders
if (prev.count != next.count) { if (prev.count != next.count) {
same = false; same = false;
Log.i("count changed id=" + next.id); log("count changed " + prev.count + "/" + next.count, next.id);
} }
if (prev.unseen != next.unseen) { if (prev.unseen != next.unseen) {
same = false; same = false;
Log.i("unseen changed id=" + next.id); log("unseen changed " + prev.unseen + "/" + next.unseen, next.id);
} }
if (prev.unflagged != next.unflagged) { if (prev.unflagged != next.unflagged) {
same = false; same = false;
Log.i("unflagged changed id=" + next.id); log("unflagged changed", next.id);
} }
if (prev.drafts != next.drafts) { if (prev.drafts != next.drafts) {
same = false; same = false;
Log.i("drafts changed id=" + next.id); log("drafts changed", next.id);
} }
if (prev.signed != next.signed) { if (prev.signed != next.signed) {
same = false; same = false;
Log.i("signed changed id=" + next.id); log("signed changed", next.id);
} }
if (prev.encrypted != next.encrypted) { if (prev.encrypted != next.encrypted) {
same = false; same = false;
Log.i("encrypted changed id=" + next.id); log("encrypted changed", next.id);
} }
if (prev.visible != next.visible) { if (prev.visible != next.visible) {
same = false; same = false;
Log.i("visible changed id=" + next.id); log("visible changed " + prev.visible + "/" + next.visible, next.id);
} }
if (!Objects.equals(prev.totalSize, next.totalSize)) { if (!Objects.equals(prev.totalSize, next.totalSize)) {
same = false; same = false;
Log.i("totalSize changed id=" + next.id); log("totalSize changed", next.id);
} }
if (prev.duplicate != next.duplicate) { if (prev.duplicate != next.duplicate) {
same = false; same = false;
Log.i("duplicate changed id=" + next.id); log("duplicate changed", next.id);
} }
if (!Arrays.equals(prev.keyword_colors, next.keyword_colors)) { if (!Arrays.equals(prev.keyword_colors, next.keyword_colors)) {
same = false; same = false;
Log.i("keyword colors changed id=" + next.id); log("keyword colors changed", next.id);
} }
return same; return same;
} }
private void log(String msg, long id) {
Log.i(msg + " id=" + id);
if (debug)
parentFragment.getView().post(new Runnable() {
@Override
public void run() {
if (properties.getValue("expanded", id)) {
Context context = parentFragment.getContext();
if (context != null)
ToastEx.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
}
});
}
}; };
AsyncDifferConfig<TupleMessageEx> config = new AsyncDifferConfig.Builder<>(callback)
.setBackgroundThreadExecutor(executor)
.build();
this.differ = new AsyncPagedListDiffer<>(new AdapterListUpdateCallback(this), config);
this.differ.addPagedListListener(new AsyncPagedListDiffer.PagedListListener<TupleMessageEx>() {
@Override
public void onCurrentListChanged(@Nullable PagedList<TupleMessageEx> previousList, @Nullable PagedList<TupleMessageEx> currentList) {
if (gotoTop) {
gotoTop = false;
properties.scrollTo(0);
}
}
});
try {
// https://issuetracker.google.com/issues/135628748
Handler handler = new Handler(Looper.getMainLooper());
Field mMainThreadExecutor = this.differ.getClass().getDeclaredField("mMainThreadExecutor");
mMainThreadExecutor.setAccessible(true);
mMainThreadExecutor.set(this.differ, new Executor() {
@Override
public void execute(final Runnable command) {
handler.post(new Runnable() {
@Override
public void run() {
try {
command.run();
} catch (Throwable ex) {
Log.e(ex);
}
}
});
}
});
} catch (Throwable ex) {
Log.e(ex);
}
owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
Log.d(AdapterMessage.this + " parent destroyed");
AdapterMessage.this.parentFragment = null;
}
});
}
void gotoTop() {
properties.scrollTo(0);
this.gotoTop = true;
}
void submitList(PagedList<TupleMessageEx> list) {
keyPosition.clear();
if (keywords_header)
for (int i = 0; i < list.size(); i++) {
TupleMessageEx message = list.get(i);
if (message != null)
message.resolveKeywordColors(context);
}
differ.submitList(list);
}
PagedList<TupleMessageEx> getCurrentList() {
return differ.getCurrentList();
}
void setCompact(boolean compact) {
if (this.compact != compact) {
this.compact = compact;
notifyDataSetChanged();
}
}
void setZoom(int zoom) {
if (this.zoom != zoom) {
this.zoom = zoom;
textSize = Helper.getTextSize(context, zoom);
notifyDataSetChanged();
}
}
int getZoom() {
return this.zoom;
}
void setSort(String sort) {
if (!sort.equals(this.sort)) {
this.sort = sort;
notifyDataSetChanged();
// Needed to redraw item decorators / add/remove size
}
}
String getSort() {
return this.sort;
}
void setAscending(boolean ascending) {
this.ascending = ascending;
}
void setFilterDuplicates(boolean filter_duplicates) {
if (this.filter_duplicates != filter_duplicates) {
this.filter_duplicates = filter_duplicates;
notifyDataSetChanged();
}
}
void checkInternet() {
ConnectionHelper.NetworkState state = ConnectionHelper.getNetworkState(context);
if (this.suitable != state.isSuitable() || this.unmetered != state.isUnmetered()) {
this.suitable = state.isSuitable();
this.unmetered = state.isUnmetered();
notifyDataSetChanged();
}
}
void setAnswerCount(int answers) {
this.answers = answers;
Log.i("Answer count=" + answers);
}
@Override
public int getItemCount() {
return differ.getItemCount();
}
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
TupleMessageEx message = differ.getItem(position); TupleMessageEx message = differ.getItem(position);

Loading…
Cancel
Save