Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dba175a

Browse filesBrowse files
committed
chore: Making use of AndroidHelper functions in segmented bar module
1 parent 747753a commit dba175a
Copy full SHA for dba175a

File tree

Expand file treeCollapse file tree

2 files changed

+3
-13
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-13
lines changed

‎apps/automated/src/ui/segmented-bar/segmented-bar-tests-native.android.ts

Copy file name to clipboardExpand all lines: apps/automated/src/ui/segmented-bar/segmented-bar-tests-native.android.ts
+2-12Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as segmentedBarModule from '@nativescript/core/ui/segmented-bar';
22
import { Color } from '@nativescript/core';
3+
import { AndroidHelper } from '@nativescript/core/ui/core/view';
34

45
export function getNativeTabWidget(bar: segmentedBarModule.SegmentedBar): android.widget.TabWidget {
56
return (<android.widget.TabHost>bar.android).getTabWidget();
@@ -44,7 +45,7 @@ export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segment
4445
const item = bar.items[i];
4546
const textView = item?.nativeViewProtected;
4647

47-
const newDrawable = tryCloneDrawable(view.getBackground(), view.getResources());
48+
const newDrawable = AndroidHelper.getCopyOrDrawable(view.getBackground(), view.getResources());
4849
newDrawable.setColorFilter(new android.graphics.Paint(bar.selectedBackgroundColor.android).getColorFilter());
4950

5051
if (bar.selectedIndex == i) {
@@ -68,16 +69,5 @@ export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segment
6869
}
6970
}
7071

71-
function tryCloneDrawable(value: android.graphics.drawable.Drawable, resources: android.content.res.Resources): android.graphics.drawable.Drawable {
72-
if (value) {
73-
const constantState = value.getConstantState();
74-
if (constantState) {
75-
return constantState.newDrawable(resources);
76-
}
77-
}
78-
79-
return value;
80-
}
81-
8272
return isValid === 0;
8373
};

‎packages/core/ui/segmented-bar/index.android.ts

Copy file name to clipboardExpand all lines: packages/core/ui/segmented-bar/index.android.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
171171
const backgroundDrawable = viewGroup.getBackground();
172172
if (SDK_VERSION > 21 && backgroundDrawable) {
173173
const newDrawable = AndroidHelper.getCopyOrDrawable(backgroundDrawable, nativeView.getResources());
174-
newDrawable.setColorFilter(new android.graphics.Paint(color).getColorFilter());
174+
AndroidHelper.setDrawableColor(color, newDrawable);
175175
viewGroup.setBackground(newDrawable);
176176
} else {
177177
const stateDrawable = new android.graphics.drawable.StateListDrawable();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.