mirror of https://github.com/M66B/FairEmail.git
Fixed log auto scroll
This commit is contained in:
parent
1837cf9dea
commit
feab958d41
|
@ -106,7 +106,8 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
|
||||
public void set(@NonNull List<EntityLog> logs,
|
||||
Long account, Long folder, Long message,
|
||||
@NonNull List<EntityLog.Type> types) {
|
||||
@NonNull List<EntityLog.Type> types,
|
||||
Runnable callback) {
|
||||
Log.i("Set logs=" + logs.size());
|
||||
|
||||
this.all = logs;
|
||||
|
@ -162,6 +163,8 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
|
||||
try {
|
||||
diff.dispatchUpdatesTo(AdapterLog.this);
|
||||
if (callback != null)
|
||||
callback.run();
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
|
@ -175,7 +178,7 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
}
|
||||
|
||||
public void setTypes(@NonNull List<EntityLog.Type> types) {
|
||||
set(all, account, folder, message, types);
|
||||
set(all, account, folder, message, types, null);
|
||||
}
|
||||
|
||||
private static class DiffCallback extends DiffUtil.Callback {
|
||||
|
|
|
@ -125,9 +125,13 @@ public class FragmentLogs extends FragmentBase {
|
|||
if (logs == null)
|
||||
logs = new ArrayList<>();
|
||||
|
||||
adapter.set(logs, account, folder, message, getTypes());
|
||||
adapter.set(logs, account, folder, message, getTypes(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (autoScroll)
|
||||
rvLog.scrollToPosition(0);
|
||||
}
|
||||
});
|
||||
|
||||
pbWait.setVisibility(View.GONE);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
|
@ -173,7 +177,7 @@ public class FragmentLogs extends FragmentBase {
|
|||
} else if (itemId == R.id.menu_auto_scroll) {
|
||||
boolean enabled = !item.isChecked();
|
||||
item.setChecked(enabled);
|
||||
onMenuAutoScoll(enabled);
|
||||
onMenuAutoScroll(enabled);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_show) {
|
||||
onMenuShow();
|
||||
|
@ -189,7 +193,7 @@ public class FragmentLogs extends FragmentBase {
|
|||
prefs.edit().putBoolean("main_log", enabled).apply();
|
||||
}
|
||||
|
||||
private void onMenuAutoScoll(boolean enabled) {
|
||||
private void onMenuAutoScroll(boolean enabled) {
|
||||
autoScroll = enabled;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue