mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2026-02-04 17:05:43 +00:00
Move 'Untagged' chip to end and center selected tag in subscription view (#8141)
This commit is contained in:
@ -416,6 +416,25 @@ public class SubscriptionFragment extends Fragment
|
||||
}
|
||||
}
|
||||
tagsRecycler.setVisibility(shouldShowTags ? View.VISIBLE : View.GONE);
|
||||
// Scroll to center the selected tag
|
||||
tagsRecycler.post(() -> {
|
||||
int selectedPosition = tagAdapter.getSelectedTagPosition();
|
||||
if (selectedPosition < 0) {
|
||||
return;
|
||||
}
|
||||
LinearLayoutManager layoutManager =
|
||||
(LinearLayoutManager) tagsRecycler.getLayoutManager();
|
||||
// Calculate offset to center the selected chip
|
||||
View selectedView = layoutManager.findViewByPosition(selectedPosition);
|
||||
if (selectedView != null) {
|
||||
int recyclerWidth = tagsRecycler.getWidth();
|
||||
int chipWidth = selectedView.getWidth();
|
||||
int offset = (recyclerWidth - chipWidth) / 2;
|
||||
layoutManager.scrollToPositionWithOffset(selectedPosition, offset);
|
||||
} else {
|
||||
tagsRecycler.scrollToPosition(selectedPosition);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, error -> {
|
||||
Log.e(TAG, Log.getStackTraceString(error));
|
||||
|
||||
@ -45,6 +45,18 @@ public class SubscriptionTagAdapter extends RecyclerView.Adapter<SubscriptionTag
|
||||
return selectedTag;
|
||||
}
|
||||
|
||||
public int getSelectedTagPosition() {
|
||||
if (selectedTag == null) {
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
if (tags.get(i).getTitle().equals(selectedTag)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public TagViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
Reference in New Issue
Block a user