Skip to content

Commit 2da3398

Browse files
committed
fix Channels section card title scroll speed
1 parent 34bf27c commit 2da3398

File tree

4 files changed

+32
-31
lines changed

4 files changed

+32
-31
lines changed

smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/presenter/ChannelCardPresenter.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.liskovsoft.smartyoutubetv2.tv.presenter;
22

3+
import android.annotation.SuppressLint;
34
import android.content.Context;
45
import android.graphics.drawable.Drawable;
56
import android.util.Pair;
@@ -51,13 +52,19 @@ public ViewHolder onCreateViewHolder(ViewGroup parent) {
5152

5253
updateDimensions(context);
5354

55+
@SuppressLint("InflateParams")
5456
View container = LayoutInflater.from(context).inflate(R.layout.channel_card, null);
5557
container.setBackgroundColor(mDefaultBackgroundColor);
5658

5759
TextView textView = container.findViewById(R.id.channel_title);
5860
textView.setBackgroundColor(mDefaultBackgroundColor);
5961
textView.setTextColor(mDefaultTextColor);
6062

63+
boolean autoScrollEnabled = isCardTextAutoScrollEnabled(context);
64+
if (autoScrollEnabled) {
65+
ViewUtil.setTextScrollSpeed(textView, getCardTextScrollSpeed(context));
66+
}
67+
6168
container.setOnFocusChangeListener((v, hasFocus) -> {
6269
int backgroundColor = hasFocus ? mSelectedBackgroundColor :
6370
textView.getTag(R.id.channel_new_content) != null ? mNewContentBackgroundColor : mDefaultBackgroundColor;
@@ -66,6 +73,10 @@ public ViewHolder onCreateViewHolder(ViewGroup parent) {
6673
textView.setBackgroundColor(backgroundColor);
6774
textView.setTextColor(textColor);
6875

76+
if (!autoScrollEnabled) {
77+
return;
78+
}
79+
6980
if (hasFocus) {
7081
ViewUtil.enableMarquee(textView);
7182
} else {
@@ -126,6 +137,14 @@ protected Pair<Integer, Integer> getCardDimensPx(Context context) {
126137
true);
127138
}
128139

140+
protected boolean isCardTextAutoScrollEnabled(Context context) {
141+
return MainUIData.instance(context).isCardTextAutoScrollEnabled();
142+
}
143+
144+
protected float getCardTextScrollSpeed(Context context) {
145+
return MainUIData.instance(context).getCardTextScrollSpeed();
146+
}
147+
129148
private final RequestListener<Drawable> mErrorListener = new RequestListener<Drawable>() {
130149
@Override
131150
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {

smarttubetv/src/main/java/com/liskovsoft/smartyoutubetv2/tv/presenter/SettingsCardPresenter.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.liskovsoft.smartyoutubetv2.tv.presenter;
22

3+
import android.annotation.SuppressLint;
34
import android.content.Context;
45
import android.view.LayoutInflater;
56
import android.view.View;
@@ -33,13 +34,16 @@ public ViewHolder onCreateViewHolder(ViewGroup parent) {
3334
mSelectedTextColor =
3435
ContextCompat.getColor(context, R.color.card_selected_text_grey);
3536

37+
@SuppressLint("InflateParams")
3638
View container = LayoutInflater.from(context).inflate(R.layout.settings_card, null);
3739
container.setBackgroundColor(mDefaultBackgroundColor);
3840

3941
TextView textView = container.findViewById(R.id.settings_title);
4042
textView.setBackgroundColor(mDefaultBackgroundColor);
4143
textView.setTextColor(mDefaultTextColor);
4244

45+
ViewUtil.setTextScrollSpeed(textView, getCardTextScrollSpeed(context));
46+
4347
container.setOnFocusChangeListener((v, hasFocus) -> {
4448
int backgroundColor = hasFocus ? mSelectedBackgroundColor : mDefaultBackgroundColor;
4549
int textColor = hasFocus ? mSelectedTextColor : mDefaultTextColor;
@@ -49,7 +53,6 @@ public ViewHolder onCreateViewHolder(ViewGroup parent) {
4953

5054
if (hasFocus) {
5155
ViewUtil.enableMarquee(textView);
52-
ViewUtil.setTextScrollSpeed(textView, MainUIData.instance(context).getCardTextScrollSpeed());
5356
} else {
5457
ViewUtil.disableMarquee(textView);
5558
}
@@ -77,4 +80,12 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item) {
7780
@Override
7881
public void onUnbindViewHolder(ViewHolder viewHolder) {
7982
}
83+
84+
protected boolean isCardTextAutoScrollEnabled(Context context) {
85+
return MainUIData.instance(context).isCardTextAutoScrollEnabled();
86+
}
87+
88+
protected float getCardTextScrollSpeed(Context context) {
89+
return MainUIData.instance(context).getCardTextScrollSpeed();
90+
}
8091
}

smarttubetv/src/main/res/layout/channel_card.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
android:layout_gravity="start"
2121
android:visibility="invisible"
2222
tools:ignore="ContentDescription"/>
23-
<TextView
23+
<com.liskovsoft.smartyoutubetv2.tv.ui.widgets.marqueetextviewcompat.MarqueeTextViewCompat
2424
android:id="@+id/channel_title"
2525
android:singleLine="true"
2626
android:ellipsize="end"

smarttubetv/src/main/res/layout/channel_card_old.xml

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)