mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-20 22:09:12 +00:00
Fix a number of issues related to updating the group chip after changes
This commit is contained in:
parent
d152d13580
commit
51eade900c
3 changed files with 19 additions and 20 deletions
|
@ -793,6 +793,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
if (entry.getGroup() != null) {
|
if (entry.getGroup() != null) {
|
||||||
if (!_vault.getGroups().contains(entry.getGroup())) {
|
if (!_vault.getGroups().contains(entry.getGroup())) {
|
||||||
_entryListView.setGroups(_vault.getGroups());
|
_entryListView.setGroups(_vault.getGroups());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.beemdevelopment.aegis.R;
|
|
||||||
import com.beemdevelopment.aegis.SortCategory;
|
import com.beemdevelopment.aegis.SortCategory;
|
||||||
import com.beemdevelopment.aegis.ViewMode;
|
import com.beemdevelopment.aegis.ViewMode;
|
||||||
import com.beemdevelopment.aegis.helpers.ItemTouchHelperAdapter;
|
import com.beemdevelopment.aegis.helpers.ItemTouchHelperAdapter;
|
||||||
|
@ -232,21 +232,15 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupFilter(List<String> groups, boolean apply) {
|
public void setGroupFilter(@NonNull List<String> groups) {
|
||||||
if (groups == null) {
|
|
||||||
groups = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_groupFilter.equals(groups)) {
|
if (_groupFilter.equals(groups)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_groupFilter = groups;
|
_groupFilter = groups;
|
||||||
if (apply) {
|
|
||||||
updateShownEntries();
|
updateShownEntries();
|
||||||
checkPeriodUniformity();
|
checkPeriodUniformity();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSortCategory(SortCategory category, boolean apply) {
|
public void setSortCategory(SortCategory category, boolean apply) {
|
||||||
if (_sortCategory == category) {
|
if (_sortCategory == category) {
|
||||||
|
|
|
@ -144,12 +144,14 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupFilter(List<String> groups, boolean apply) {
|
public void setGroupFilter(List<String> groups, boolean animate) {
|
||||||
_groupFilter = groups;
|
_groupFilter = groups;
|
||||||
_adapter.setGroupFilter(groups, apply);
|
_adapter.setGroupFilter(groups);
|
||||||
_touchCallback.setIsLongPressDragEnabled(_adapter.isDragAndDropAllowed());
|
_touchCallback.setIsLongPressDragEnabled(_adapter.isDragAndDropAllowed());
|
||||||
|
updateEmptyState();
|
||||||
|
updateGroupChip();
|
||||||
|
|
||||||
if (apply) {
|
if (animate) {
|
||||||
runEntriesAnimation();
|
runEntriesAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,7 +377,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
Button clearButton = view.findViewById(R.id.btnClear);
|
Button clearButton = view.findViewById(R.id.btnClear);
|
||||||
clearButton.setOnClickListener(v -> {
|
clearButton.setOnClickListener(v -> {
|
||||||
chipGroup.clearCheck();
|
chipGroup.clearCheck();
|
||||||
setGroupFilter(null, true);
|
setGroupFilter(Collections.emptyList(), true);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -396,12 +398,6 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
|
||||||
.map(i -> ((Chip) view.findViewById(i)).getText().toString())
|
.map(i -> ((Chip) view.findViewById(i)).getText().toString())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
setGroupFilter(groupFilter, true);
|
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);
|
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) {
|
private void setShowProgress(boolean showProgress) {
|
||||||
_showProgress = showProgress;
|
_showProgress = showProgress;
|
||||||
updateDividerDecoration();
|
updateDividerDecoration();
|
||||||
|
|
Loading…
Add table
Reference in a new issue