mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-01-19 21:21:43 -06:00
selected card style
This commit is contained in:
@@ -3,6 +3,7 @@ package com.liskovsoft.smartyoutubetv2.tv.presenter;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.leanback.widget.ImageCardView;
|
||||
import androidx.leanback.widget.Presenter;
|
||||
@@ -25,16 +26,22 @@ import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
|
||||
*/
|
||||
public class CardPresenter extends Presenter {
|
||||
private static final String TAG = CardPresenter.class.getSimpleName();
|
||||
private int mSelectedBackgroundColor = -1;
|
||||
private int mDefaultBackgroundColor = -1;
|
||||
private int mDefaultTextColor = -1;
|
||||
private int mSelectedBackgroundColor = -1;
|
||||
private int mSelectedTextColor = -1;
|
||||
private Drawable mDefaultCardImage;
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent) {
|
||||
mDefaultBackgroundColor =
|
||||
ContextCompat.getColor(parent.getContext(), R.color.card_default_background);
|
||||
mDefaultTextColor =
|
||||
ContextCompat.getColor(parent.getContext(), R.color.card_default_text);
|
||||
mSelectedBackgroundColor =
|
||||
ContextCompat.getColor(parent.getContext(), R.color.card_selected_background);
|
||||
ContextCompat.getColor(parent.getContext(), R.color.card_selected_background2);
|
||||
mSelectedTextColor =
|
||||
ContextCompat.getColor(parent.getContext(), R.color.card_selected_text2);
|
||||
mDefaultCardImage = ContextCompat.getDrawable(parent.getContext(), R.drawable.movie);
|
||||
|
||||
ImageCardView cardView = new ImageCardView(parent.getContext()) {
|
||||
@@ -52,14 +59,24 @@ public class CardPresenter extends Presenter {
|
||||
}
|
||||
|
||||
private void updateCardBackgroundColor(ImageCardView view, boolean selected) {
|
||||
int color = selected ? mSelectedBackgroundColor : mDefaultBackgroundColor;
|
||||
int backgroundColor = selected ? mSelectedBackgroundColor : mDefaultBackgroundColor;
|
||||
int textColor = selected ? mSelectedTextColor : mDefaultTextColor;
|
||||
|
||||
// Both background colors should be set because the view's
|
||||
// background is temporarily visible during animations.
|
||||
view.setBackgroundColor(color);
|
||||
view.setBackgroundColor(backgroundColor);
|
||||
View infoField = view.findViewById(R.id.info_field);
|
||||
if (infoField != null) {
|
||||
infoField.setBackgroundColor(color);
|
||||
infoField.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
TextView titleText = view.findViewById(R.id.title_text);
|
||||
if (titleText != null) {
|
||||
titleText.setTextColor(textColor);
|
||||
}
|
||||
TextView contentText = view.findViewById(R.id.content_text);
|
||||
if (contentText != null) {
|
||||
contentText.setTextColor(textColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.List;
|
||||
|
||||
public class HeaderGridFragment extends GridFragment implements VideoGroupFragment {
|
||||
private static final String TAG = HeaderGridFragment.class.getSimpleName();
|
||||
private static final int COLUMNS = 5;
|
||||
private final int ZOOM_FACTOR = FocusHighlight.ZOOM_FACTOR_SMALL;
|
||||
private static final int COLUMNS_NUM = 4;
|
||||
private static final int ZOOM_FACTOR = FocusHighlight.ZOOM_FACTOR_SMALL;
|
||||
private VideoGroupObjectAdapter mGridAdapter;
|
||||
private final List<VideoGroup> mPendingUpdates = new ArrayList<>();
|
||||
private UriBackgroundManager mBackgroundManager;
|
||||
@@ -64,7 +64,7 @@ public class HeaderGridFragment extends GridFragment implements VideoGroupFragme
|
||||
|
||||
private void setupAdapter() {
|
||||
VerticalGridPresenter presenter = new VerticalGridPresenter(ZOOM_FACTOR, false);
|
||||
presenter.setNumberOfColumns(COLUMNS);
|
||||
presenter.setNumberOfColumns(COLUMNS_NUM);
|
||||
setGridPresenter(presenter);
|
||||
|
||||
if (mGridAdapter == null) {
|
||||
|
||||
@@ -5,7 +5,13 @@
|
||||
<color name="fastlane_background">#0096a6</color>
|
||||
<color name="search_opaque">#ffaa3f</color>
|
||||
<color name="card_selected_background">#ffaa3f</color>
|
||||
<color name="card_selected_background2">#FFFFFF</color>
|
||||
<color name="card_selected_background3">#343434</color>
|
||||
<color name="card_selected_text">#000000</color>
|
||||
<color name="card_selected_text2">#343434</color>
|
||||
<color name="card_default_background">#0096a6</color>
|
||||
<color name="card_default_background2">#343434</color>
|
||||
<color name="card_default_text">#FFFFFF</color>
|
||||
<color name="shelf_background">#282828</color>
|
||||
<color name="icon_background">#4A4F51</color>
|
||||
<color name="icon_alt_background">#2A2F51</color>
|
||||
|
||||
Reference in New Issue
Block a user