(@NonNull List<EntityLog> logs,
Long account, Long folder, Long message,
@NonNull List<EntityLog.Type> types,
Runnable callback)
| 101 | } |
| 102 | |
| 103 | public void set(@NonNull List<EntityLog> logs, |
| 104 | Long account, Long folder, Long message, |
| 105 | @NonNull List<EntityLog.Type> types, |
| 106 | Runnable callback) { |
| 107 | Log.i("Set logs=" + logs.size()); |
| 108 | |
| 109 | this.all = logs; |
| 110 | this.account = account; |
| 111 | this.folder = folder; |
| 112 | this.message = message; |
| 113 | this.types = types; |
| 114 | |
| 115 | new SimpleTask<List<EntityLog>>() { |
| 116 | @Override |
| 117 | protected List<EntityLog> onExecute(Context context, Bundle args) throws Throwable { |
| 118 | List<EntityLog> items = new ArrayList<>(); |
| 119 | for (EntityLog log : logs) |
| 120 | if (account == null && folder == null && message == null) { |
| 121 | if (types.contains(log.type)) |
| 122 | items.add(log); |
| 123 | } else { |
| 124 | if ((account == null || account.equals(log.account)) && |
| 125 | (folder == null || folder.equals(log.folder)) && |
| 126 | (message == null || message.equals(log.message))) |
| 127 | items.add(log); |
| 128 | } |
| 129 | return items; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | protected void onExecuted(Bundle args, List<EntityLog> items) { |
| 134 | DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(selected, items), false); |
| 135 | |
| 136 | selected = items; |
| 137 | |
| 138 | diff.dispatchUpdatesTo(new ListUpdateCallback() { |
| 139 | @Override |
| 140 | public void onInserted(int position, int count) { |
| 141 | Log.d("Inserted @" + position + " #" + count); |
| 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public void onRemoved(int position, int count) { |
| 146 | Log.d("Removed @" + position + " #" + count); |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public void onMoved(int fromPosition, int toPosition) { |
| 151 | Log.d("Moved " + fromPosition + ">" + toPosition); |
| 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public void onChanged(int position, int count, Object payload) { |
| 156 | Log.d("Changed @" + position + " #" + count); |
| 157 | } |
| 158 | }); |
| 159 | |
| 160 | try { |
no test coverage detected