Fix a number of issues related to updating the group chip after changes

pull/760/head
Alexander Bakker 4 years ago
parent d152d13580
commit 51eade900c

@ -793,6 +793,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
if (entry.getGroup() != null) {
if (!_vault.getGroups().contains(entry.getGroup())) {
_entryListView.setGroups(_vault.getGroups());
break;
}
}
}

@ -6,9 +6,9 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory;
import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.helpers.ItemTouchHelperAdapter;
@ -232,20 +232,14 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
}
}
public void setGroupFilter(List<String> groups, boolean apply) {
if (groups == null) {
groups = new ArrayList<>();
}
public void setGroupFilter(@NonNull List<String> groups) {
if (_groupFilter.equals(groups)) {
return;
}
_groupFilter = groups;
if (apply) {
updateShownEntries();
checkPeriodUniformity();
}
updateShownEntries();
checkPeriodUniformity();
}
public void setSortCategory(SortCategory category, boolean apply) {

@ -144,12 +144,14 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
super.onDestroyView();
}
public void setGroupFilter(List<String> groups, boolean apply) {
public void setGroupFilter(List<String> groups, boolean animate) {
_groupFilter = groups;
_adapter.setGroupFilter(groups, apply);
_adapter.setGroupFilter(groups);
_touchCallback.setIsLongPressDragEnabled(_adapter.isDragAndDropAllowed());
updateEmptyState();
updateGroupChip();
if (apply) {
if (animate) {
runEntriesAnimation();
}
}
@ -375,7 +377,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
Button clearButton = view.findViewById(R.id.btnClear);
clearButton.setOnClickListener(v -> {
chipGroup.clearCheck();
setGroupFilter(null, true);
setGroupFilter(Collections.emptyList(), true);
dialog.dismiss();
});
@ -396,12 +398,6 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
.map(i -> ((Chip) view.findViewById(i)).getText().toString())
.collect(Collectors.toList());
setGroupFilter(groupFilter, true);
if (groupFilter.isEmpty()) {
_groupChip.setText(R.string.groups);
} else {
_groupChip.setText(String.format("%s (%d)", getString(R.string.groups), groupFilter.size()));
}
});
chipGroup.addView(chip);
@ -411,6 +407,14 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
});
}
private void updateGroupChip() {
if (_groupFilter.isEmpty()) {
_groupChip.setText(R.string.groups);
} else {
_groupChip.setText(String.format("%s (%d)", getString(R.string.groups), _groupFilter.size()));
}
}
private void setShowProgress(boolean showProgress) {
_showProgress = showProgress;
updateDividerDecoration();

Loading…
Cancel
Save