Refactor: Static Helper for Marquee

This commit is contained in:
lp-hub
2026-02-06 14:58:54 +02:00
parent a434812777
commit a4e277fa41
4 changed files with 20 additions and 4 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
@@ -220,8 +220,7 @@ public class CompressedExplorerAdapter extends RecyclerView.Adapter<CompressedIt
boolean enableMarquee =
sharedPrefs.getBoolean(PreferencesConstants.PREFERENCE_ENABLE_MARQUEE_FILENAME, true);
holder.txtTitle.setEllipsize(
enableMarquee ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.MIDDLE);
AnimUtils.configureTitleMarquee(holder.firstLine, enableMarquee);
final CompressedObjectParcelable rowItem = items.get(position);
GradientDrawable gradientDrawable = (GradientDrawable) holder.genericIcon.getBackground();
@@ -765,8 +765,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
mainFragment.adjustListViewForTv(holder, mainFragment.getMainActivity());
}
});
holder.txtTitle.setEllipsize(
enableMarquee ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.MIDDLE);
AnimUtils.configureTitleMarquee(holder.txtTitle, enableMarquee);
final boolean isBackButton = getItemsDigested().get(position).specialType == TYPE_BACK;
if (isBackButton) {
@@ -71,4 +71,19 @@ public class AnimUtilsTest {
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
assertTrue(mock.isSelected());
}
@Test
public static void configureTitleMarquee(TextView textView, boolean enableMarquee) {
if (enableMarquee) {
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
textView.setSelected(true); // Required for Marquee to move
} else {
// New custom behavior: Double line wrap!
textView.setSingleLine(false);
textView.setMaxLines(2);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setSelected(false);
}
}
}