mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 22:08:22 +03:00
searchfilters: fixup 4th dialog to draw a separator line between FilterGroup without a label
This commit is contained in:
parent
161eb16906
commit
90e434663c
3 changed files with 38 additions and 3 deletions
|
@ -42,9 +42,17 @@ public abstract class BaseSearchFilterUiDialogGenerator extends BaseSearchFilter
|
||||||
return new BaseCreateSearchFilterUI.CreateSortFilterUI(this, context, logic);
|
return new BaseCreateSearchFilterUI.CreateSortFilterUI(this, context, logic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a View that acts as a separator between two other {@link View}-Elements.
|
||||||
|
*
|
||||||
|
* @param layoutParams this layout will be modified to have the height of 1 -> to have a
|
||||||
|
* the actual separator line.
|
||||||
|
* @return the created {@link SeparatorLineView}
|
||||||
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
protected View createSeparatorLine(@NonNull final ViewGroup.LayoutParams layoutParams) {
|
protected SeparatorLineView createSeparatorLine(
|
||||||
final View separatorLine = new View(context);
|
@NonNull final ViewGroup.LayoutParams layoutParams) {
|
||||||
|
final SeparatorLineView separatorLine = new SeparatorLineView(context);
|
||||||
separatorLine.setBackgroundColor(getSeparatorLineColorFromTheme());
|
separatorLine.setBackgroundColor(getSeparatorLineColorFromTheme());
|
||||||
layoutParams.height = 1; // always set the separator to the height of 1
|
layoutParams.height = 1; // always set the separator to the height of 1
|
||||||
separatorLine.setLayoutParams(layoutParams);
|
separatorLine.setLayoutParams(layoutParams);
|
||||||
|
@ -60,4 +68,17 @@ public abstract class BaseSearchFilterUiDialogGenerator extends BaseSearchFilter
|
||||||
title.setLayoutParams(layoutParams);
|
title.setLayoutParams(layoutParams);
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A special view to separate two other {@link View}s.
|
||||||
|
* <p>
|
||||||
|
* class only needed to distinct this special view from other View based views.
|
||||||
|
* (eg. instanceof)
|
||||||
|
*/
|
||||||
|
protected static final class SeparatorLineView extends View {
|
||||||
|
|
||||||
|
private SeparatorLineView(@NonNull final Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
package org.schabi.newpipe.fragments.list.search.filter;
|
package org.schabi.newpipe.fragments.list.search.filter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.GridLayout;
|
import android.widget.GridLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -37,6 +38,10 @@ public class SearchFilterChipDialogGenerator extends SearchFilterDialogGenerator
|
||||||
final TextView filterLabel = createFilterLabel(filterGroup, layoutParams);
|
final TextView filterLabel = createFilterLabel(filterGroup, layoutParams);
|
||||||
globalLayout.addView(filterLabel);
|
globalLayout.addView(filterLabel);
|
||||||
viewsWrapper.add(filterLabel);
|
viewsWrapper.add(filterLabel);
|
||||||
|
} else if (doWeNeedASeparatorView()) {
|
||||||
|
final SeparatorLineView separatorLineView = createSeparatorLine();
|
||||||
|
globalLayout.addView(separatorLineView);
|
||||||
|
viewsWrapper.add(separatorLineView);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ChipGroup chipGroup = new ChipGroup(context);
|
final ChipGroup chipGroup = new ChipGroup(context);
|
||||||
|
@ -55,6 +60,15 @@ public class SearchFilterChipDialogGenerator extends SearchFilterDialogGenerator
|
||||||
viewsWrapper.add(chipGroup);
|
viewsWrapper.add(chipGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean doWeNeedASeparatorView() {
|
||||||
|
// if 0 than there is nothing to separate
|
||||||
|
if (globalLayout.getChildCount() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final View lastView = globalLayout.getChildAt(globalLayout.getChildCount() - 1);
|
||||||
|
return !(lastView instanceof SeparatorLineView);
|
||||||
|
}
|
||||||
|
|
||||||
private ViewGroup.MarginLayoutParams setDefaultMarginInDp(
|
private ViewGroup.MarginLayoutParams setDefaultMarginInDp(
|
||||||
@NonNull final ViewGroup.MarginLayoutParams layoutParams,
|
@NonNull final ViewGroup.MarginLayoutParams layoutParams,
|
||||||
final int left, final int top, final int right, final int bottom) {
|
final int left, final int top, final int right, final int bottom) {
|
||||||
|
|
|
@ -239,7 +239,7 @@ public class SearchFilterDialogGenerator extends BaseSearchFilterUiDialogGenerat
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private View createSeparatorLine() {
|
protected SeparatorLineView createSeparatorLine() {
|
||||||
return createSeparatorLine(clipFreeRightColumnLayoutParams(true));
|
return createSeparatorLine(clipFreeRightColumnLayoutParams(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue