null exeption fix

This commit is contained in:
androiddevkotlin 2021-01-24 23:36:55 +02:00
parent 5e68d14273
commit 3c6b065f50
4 changed files with 47 additions and 29 deletions

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/list_item_divider"/>
<net.osmand.plus.views.controls.PagerSlidingTabStrip
android:id="@+id/sliding_tabs"

View file

@ -513,13 +513,13 @@ public class UiUtilities {
GradientDrawable background = new GradientDrawable();
background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
GradientDrawable startButtonSharpCorner = new GradientDrawable();
startButtonSharpCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
GradientDrawable startButtonRoundedCorner = new GradientDrawable();
startButtonRoundedCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
GradientDrawable endButtonRoundedCorner = new GradientDrawable();
endButtonRoundedCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
GradientDrawable centerButtonSharpCorner = new GradientDrawable();
centerButtonSharpCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
setStartEndCenterRoundedCorner(roundedCorner, isLayoutRtl, startButtonSharpCorner, endButtonRoundedCorner, centerButtonSharpCorner);
setStartEndCenterRoundedCorner(roundedCorner, isLayoutRtl, startButtonRoundedCorner, endButtonRoundedCorner, centerButtonSharpCorner);
if (buttonType == CustomRadioButtonTypeGroup.START) {
if (isLayoutRtl) {
@ -527,33 +527,57 @@ public class UiUtilities {
} else {
background.setCornerRadii(new float[]{roundedCorner, roundedCorner, 0, 0, 0, 0, roundedCorner, roundedCorner});
}
endButtonContainer.setBackground(endButtonRoundedCorner);
endButtonText.setTextColor(activeColor);
centerButtonContainer.setBackground(centerButtonSharpCorner);
centerButtonText.setTextColor(activeColor);
endButtonText.setTextColor(activeColor);
startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor);
} else if (buttonType == CustomRadioButtonTypeGroup.CENTER){
endButtonContainer.setBackground(endButtonRoundedCorner);
endButtonText.setTextColor(activeColor);
startButtonContainer.setBackground(startButtonSharpCorner);
startButtonText.setTextColor(activeColor);
endButtonText.setTextColor(activeColor);
if (endButtonContainer != null && centerButtonContainer != null) {
endButtonContainer.setBackground(endButtonRoundedCorner);
endButtonText.setTextColor(activeColor);
centerButtonContainer.setBackground(centerButtonSharpCorner);
centerButtonText.setTextColor(activeColor);
startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor);
} else if (centerButtonContainer != null) {
centerButtonContainer.setBackground(endButtonRoundedCorner);
centerButtonText.setTextColor(activeColor);
startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor);
} else if (endButtonContainer != null) {
endButtonContainer.setBackground(endButtonRoundedCorner);
endButtonText.setTextColor(activeColor);
startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor);
} else if (endButtonContainer == null && centerButtonContainer == null) {
background.setCornerRadii(new float[]{roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner, roundedCorner});
startButtonContainer.setBackgroundDrawable(background);
startButtonText.setTextColor(textColor);
}
} else if (buttonType == CustomRadioButtonTypeGroup.CENTER) {
centerButtonContainer.setBackgroundDrawable(background);
centerButtonText.setTextColor(textColor);
startButtonContainer.setBackground(startButtonRoundedCorner);
startButtonText.setTextColor(activeColor);
if (endButtonContainer != null) {
endButtonContainer.setBackground(endButtonRoundedCorner);
endButtonText.setTextColor(activeColor);
} else {
endButtonRoundedCorner.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(inActiveColor, 0.5f));
centerButtonContainer.setBackgroundDrawable(endButtonRoundedCorner);
centerButtonText.setTextColor(textColor);
}
} else {
if (isLayoutRtl) {
background.setCornerRadii(new float[]{roundedCorner, roundedCorner, 0, 0, 0, 0, roundedCorner, roundedCorner});
} else {
background.setCornerRadii(new float[]{0, 0, roundedCorner, roundedCorner, roundedCorner, roundedCorner, 0, 0});
}
startButtonContainer.setBackground(startButtonRoundedCorner);
startButtonText.setTextColor(activeColor);
endButtonContainer.setBackgroundDrawable(background);
endButtonText.setTextColor(textColor);
startButtonContainer.setBackground(startButtonSharpCorner);
startButtonText.setTextColor(activeColor);
centerButtonContainer.setBackground(centerButtonSharpCorner);
centerButtonText.setTextColor(activeColor);
if (centerButtonContainer != null) {
centerButtonContainer.setBackground(centerButtonSharpCorner);
centerButtonText.setTextColor(activeColor);
}
}
}

View file

@ -644,7 +644,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
type = UiUtilities.CustomRadioButtonTypeGroup.END;
}
View parent = (View) tab.getParent();
UiUtilities.updateCustomRadioButtonsGroup(app,parent , false, type);
UiUtilities.updateCustomRadioButtonsGroup(app, parent, false, type);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) parent.getLayoutParams();
int contentPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);

View file

@ -73,13 +73,7 @@ public class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
PagerSlidingTabStrip tabLayout = row.findViewById(R.id.sliding_tabs);
tabLayout.setTabBackground(R.color.color_transparent);
tabLayout.setIndicatorColorResource(nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
tabLayout.setIndicatorBgColorResource(nightMode ? R.color.divider_color_dark : R.color.divider_color_light);
tabLayout.setIndicatorHeight(AndroidUtils.dpToPx(context, 1f));
if (!nightMode) {
tabLayout.setTextColor(tabLayout.getIndicatorColor());
tabLayout.setTabInactiveTextColor(ContextCompat.getColor(row.getContext(), R.color.text_color_secondary_light));
}
tabLayout.setIndicatorHeight(AndroidUtils.dpToPx(context, 0));
tabLayout.setTextSize(AndroidUtils.spToPx(context, 12f));
tabLayout.setShouldExpand(true);
WrapContentHeightViewPager pager = row.findViewById(R.id.pager);