Added message property changed debugging

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

@ -4395,138 +4395,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
debug = prefs.getBoolean("debug", false);
AsyncDifferConfig<TupleMessageEx> config = new AsyncDifferConfig.Builder<>(DIFF_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();
}
private static final DiffUtil.ItemCallback<TupleMessageEx> DIFF_CALLBACK =
new DiffUtil.ItemCallback<TupleMessageEx>() {
DiffUtil.ItemCallback<TupleMessageEx> callback = new DiffUtil.ItemCallback<TupleMessageEx>() {
@Override
public boolean areItemsTheSame(
@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)) {
// via
same = false;
Log.i("Entity changed id=" + next.id);
log("Entity changed", next.id);
}
// extra
if (!Objects.equals(prev.uid, next.uid)) {
same = false;
Log.i("uid changed id=" + next.id);
log("uid changed", next.id);
}
if (!Objects.equals(prev.msgid, next.msgid)) {
// debug info
same = false;
Log.i("msgid changed id=" + next.id);
log("msgid changed", next.id);
}
// references
// deliveredto
// inreplyto
if (!Objects.equals(prev.thread, next.thread)) {
same = false;
Log.i("thread changed id=" + next.id);
log("thread changed", next.id);
}
if (!Objects.equals(prev.ui_priority, next.ui_priority)) {
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)) {
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)) {
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)) {
same = false;
Log.i("receipt_to changed id=" + next.id);
log("receipt_to changed", next.id);
}
if (!Objects.equals(prev.dkim, next.dkim)) {
same = false;
Log.i("dkim changed id=" + next.id);
log("dkim changed", next.id);
}
if (!Objects.equals(prev.spf, next.spf)) {
same = false;
Log.i("spf changed id=" + next.id);
log("spf changed", next.id);
}
if (!Objects.equals(prev.dmarc, next.dmarc)) {
same = false;
Log.i("dmarc changed id=" + next.id);
log("dmarc changed", next.id);
}
if (!Objects.equals(prev.mx, next.mx)) {
same = false;
Log.i("mx changed id=" + next.id);
log("mx changed", next.id);
}
if (!Objects.equals(prev.avatar, next.avatar)) {
same = false;
Log.i("avatar changed id=" + next.id);
log("avatar changed", next.id);
}
if (!Objects.equals(prev.sender, next.sender)) {
same = false;
Log.i("sender changed id=" + next.id);
log("sender changed", next.id);
}
if (!MessageHelper.equal(prev.from, next.from)) {
same = false;
Log.i("from changed id=" + next.id);
log("from changed", next.id);
}
if (!MessageHelper.equal(prev.to, next.to)) {
same = false;
Log.i("to changed id=" + next.id);
log("to changed", next.id);
}
if (!MessageHelper.equal(prev.cc, next.cc)) {
same = false;
Log.i("cc changed id=" + next.id);
log("cc changed", next.id);
}
if (!MessageHelper.equal(prev.bcc, next.bcc)) {
same = false;
Log.i("bcc changed id=" + next.id);
log("bcc changed", next.id);
}
if (!MessageHelper.equal(prev.reply, next.reply)) {
same = false;
Log.i("reply changed id=" + next.id);
log("reply changed", next.id);
}
if (!MessageHelper.equal(prev.list_post, next.list_post)) {
same = false;
Log.i("list_post changed id=" + next.id);
log("list_post changed", next.id);
}
if (!Objects.equals(prev.headers, next.headers)) {
same = false;
Log.i("headers changed id=" + next.id);
log("headers changed", next.id);
}
if (!Objects.equals(prev.raw, next.raw)) {
same = false;
Log.i("raw changed id=" + next.id);
log("raw changed", next.id);
}
if (!Objects.equals(prev.subject, next.subject)) {
same = false;
Log.i("subject changed id=" + next.id);
log("subject changed", next.id);
}
if (!Objects.equals(prev.size, next.size)) {
same = false;
Log.i("size changed id=" + next.id);
log("size changed", next.id);
}
if (!Objects.equals(prev.total, next.total)) {
same = false;
Log.i("total changed id=" + next.id);
log("total changed", next.id);
}
if (!Objects.equals(prev.attachments, next.attachments)) {
same = false;
Log.i("attachments changed id=" + next.id);
log("attachments changed", next.id);
}
if (!prev.content.equals(next.content)) {
same = false;
Log.i("content changed id=" + next.id);
log("content changed", next.id);
}
if (!Objects.equals(prev.plain_only, next.plain_only)) {
same = false;
Log.i("plain_only changed id=" + next.id);
log("plain_only changed", next.id);
}
if (!Objects.equals(prev.encrypt, next.encrypt)) {
same = false;
Log.i("encrypt changed id=" + next.id);
log("encrypt changed", next.id);
}
if (!Objects.equals(prev.preview, next.preview)) {
same = false;
Log.i("preview changed id=" + next.id);
log("preview changed", next.id);
}
if (!Objects.equals(prev.sent, next.sent)) {
same = false;
Log.i("sent changed id=" + next.id);
log("sent changed", next.id);
}
if (!prev.received.equals(next.received)) {
same = false;
Log.i("received changed id=" + next.id);
log("received changed", next.id);
}
if (!prev.stored.equals(next.stored)) {
// updated after decryption
same = false;
Log.i("stored changed id=" + next.id);
log("stored changed", next.id);
}
// seen
// answered
// flagged
if (debug && !Objects.equals(prev.flags, next.flags)) {
same = false;
Log.i("flags changed id=" + next.id);
log("flags changed", next.id);
}
if (!Helper.equal(prev.keywords, next.keywords)) {
same = false;
Log.i("keywords changed id=" + next.id);
log("keywords changed", next.id);
}
// notifying
// fts
if (!prev.ui_seen.equals(next.ui_seen)) {
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)) {
same = false;
Log.i("ui_answer changed id=" + next.id);
log("ui_answer changed", next.id);
}
if (!prev.ui_flagged.equals(next.ui_flagged)) {
same = false;
Log.i("ui_flagged changed id=" + next.id);
log("ui_flagged changed", next.id);
}
if (!prev.ui_hide.equals(next.ui_hide)) {
same = false;
Log.i("ui_hide changed id=" + next.id);
log("ui_hide changed", next.id);
}
if (!prev.ui_found.equals(next.ui_found)) {
same = false;
Log.i("ui_found changed id=" + next.id);
log("ui_found changed", next.id);
}
// ui_ignored
if (!prev.ui_browsed.equals(next.ui_browsed)) {
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)) {
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)) {
same = false;
Log.i("ui_snoozed changed id=" + next.id);
log("ui_snoozed changed", next.id);
}
if (!Objects.equals(prev.color, next.color)) {
same = false;
Log.i("color changed id=" + next.id);
log("color changed", next.id);
}
// revision
// revisions
if (!Objects.equals(prev.warning, next.warning)) {
same = false;
Log.i("warning changed id=" + next.id);
log("warning changed", next.id);
}
if (!Objects.equals(prev.error, next.error)) {
same = false;
Log.i("error changed id=" + next.id);
log("error changed", next.id);
}
// last_attempt
// accountPop
if (!Objects.equals(prev.accountName, next.accountName)) {
same = false;
Log.i("accountName changed id=" + next.id);
log("accountName changed", next.id);
}
if (!Objects.equals(prev.accountColor, next.accountColor)) {
same = false;
Log.i("accountColor changed id=" + next.id);
log("accountColor changed", next.id);
}
// accountNotify
// accountAutoSeen
if (!prev.folderName.equals(next.folderName)) {
same = false;
Log.i("folderName changed id=" + next.id);
log("folderName changed", next.id);
}
if (!Objects.equals(prev.folderDisplay, next.folderDisplay)) {
same = false;
Log.i("folderDisplay changed id=" + next.id);
log("folderDisplay changed", next.id);
}
if (!prev.folderType.equals(next.folderType)) {
same = false;
Log.i("folderType changed id=" + next.id);
log("folderType changed", next.id);
}
if (prev.folderReadOnly != next.folderReadOnly) {
same = false;
Log.i("folderReadOnly changed id=" + next.id);
log("folderReadOnly changed", next.id);
}
if (!Objects.equals(prev.identityName, next.identityName)) {
same = false;
Log.i("identityName changed id=" + next.id);
log("identityName changed", next.id);
}
if (!Objects.equals(prev.identityEmail, next.identityEmail)) {
same = false;
Log.i("identityEmail changed id=" + next.id);
log("identityEmail changed", next.id);
}
if (!Objects.equals(prev.identitySynchronize, next.identitySynchronize)) {
same = false;
Log.i("identitySynchronize changed id=" + next.id);
log("identitySynchronize changed", next.id);
}
// senders
if (prev.count != next.count) {
same = false;
Log.i("count changed id=" + next.id);
log("count changed " + prev.count + "/" + next.count, next.id);
}
if (prev.unseen != next.unseen) {
same = false;
Log.i("unseen changed id=" + next.id);
log("unseen changed " + prev.unseen + "/" + next.unseen, next.id);
}
if (prev.unflagged != next.unflagged) {
same = false;
Log.i("unflagged changed id=" + next.id);
log("unflagged changed", next.id);
}
if (prev.drafts != next.drafts) {
same = false;
Log.i("drafts changed id=" + next.id);
log("drafts changed", next.id);
}
if (prev.signed != next.signed) {
same = false;
Log.i("signed changed id=" + next.id);
log("signed changed", next.id);
}
if (prev.encrypted != next.encrypted) {
same = false;
Log.i("encrypted changed id=" + next.id);
log("encrypted changed", next.id);
}
if (prev.visible != next.visible) {
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)) {
same = false;
Log.i("totalSize changed id=" + next.id);
log("totalSize changed", next.id);
}
if (prev.duplicate != next.duplicate) {
same = false;
Log.i("duplicate changed id=" + next.id);
log("duplicate changed", next.id);
}
if (!Arrays.equals(prev.keyword_colors, next.keyword_colors)) {
same = false;
Log.i("keyword colors changed id=" + next.id);
log("keyword colors changed", next.id);
}
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
public int getItemViewType(int position) {
TupleMessageEx message = differ.getItem(position);

Loading…
Cancel
Save