Skip to content

Commit

Permalink
Redo logic for segment labels
Browse files Browse the repository at this point in the history
Fixes appending an extra set of segment labels to the json layout which forced all segments to use the first text defined and not per cell. Went unnoticed because we have only had 1 segment widget before
  • Loading branch information
deadman96385 committed Feb 21, 2024
1 parent 1976c05 commit aa58621
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class MultiviewTypeAdapter extends RecyclerView.Adapter<RecyclerView.View
ItemTouchHelperAdapter {

public List<Cell> mCell;
List<String> segmentLabels = new ArrayList<>();
List<String> entryLabels = new ArrayList<>();

public static class YesNoTypeViewHolder extends RecyclerView.ViewHolder {
Expand Down Expand Up @@ -303,18 +302,16 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int
((SegmentTypeViewHolder) holder).six
};

//Maybe need -1
for (int i = 0; i < segmentCount; i++) {
segmentLabels.add(object.getSegmentLabels().get(i));
}

for (int i = 0; i < segmentLabels.size() & segmentCount > i; i++) {
segmentedButtons[i].setText(segmentLabels.get(i));
int visibleSegmentCount = Math.min(object.getSegmentLabels().size(), segmentCount);

for (int i = 0; i < visibleSegmentCount; i++) {
segmentedButtons[i].setText(object.getSegmentLabels().get(i));
segmentedButtons[i].setVisibility(View.VISIBLE);
}

for (int i = 0; i < segmentedButtons.length; i++) {
segmentedButtons[i].setVisibility(i < segmentCount ? View.VISIBLE :
View.GONE);
for (int i = visibleSegmentCount; i < segmentedButtons.length; i++) {
segmentedButtons[i].setVisibility(View.GONE);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Expand Down

0 comments on commit aa58621

Please sign in to comment.