Commit fc1d78dc authored by fallenstardust's avatar fallenstardust

更改使用decklistadapter

parent 63375b8a
...@@ -9,7 +9,7 @@ public class DeckFile extends TextSelect { ...@@ -9,7 +9,7 @@ public class DeckFile extends TextSelect {
private final File path; private final File path;
private final String fullName; private final String fullName;
// //分类
private String typeName; private String typeName;
private int firstCode; private int firstCode;
......
package cn.garymb.ygomobile.ui.adapters; package cn.garymb.ygomobile.ui.adapters;
import android.content.Context; import android.annotation.SuppressLint;
import android.graphics.Color;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener; import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder; import com.chad.library.adapter.base.viewholder.BaseViewHolder;
...@@ -20,23 +19,24 @@ import cn.garymb.ygomobile.bean.events.DeckFile; ...@@ -20,23 +19,24 @@ import cn.garymb.ygomobile.bean.events.DeckFile;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.loader.ImageLoader; import cn.garymb.ygomobile.loader.ImageLoader;
import cn.garymb.ygomobile.ui.cards.deck.ImageTop; import cn.garymb.ygomobile.ui.cards.deck.ImageTop;
import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.data.LimitList; import ocgcore.data.LimitList;
public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPlus<DeckFile, BaseViewHolder>{ public class DeckListAdapter<T extends TextSelect> extends BaseQuickAdapter<T, DeckViewHolder> {
private ImageLoader imageLoader; private ImageLoader imageLoader;
private ImageTop mImageTop; private ImageTop mImageTop;
private LimitList mLimitList; private LimitList mLimitList;
private boolean mEnableSwipe = false; private boolean mEnableSwipe = false;
private DeckInfo deckInfo; private DeckInfo deckInfo;
private DeckFile deckFile; private DeckFile deckFile;
private TextSelectAdapter.OnItemSelectListener onItemSelectListener; private OnItemSelectListener onItemSelectListener;
private int selectPosition; private int selectPosition;
private boolean isSelect; private boolean isSelect;
private boolean isManySelect; private boolean isManySelect;
private List<T> selectList; private List<T> selectList;
public DeckListAdapter(Context context, List<T> data, int select) { public DeckListAdapter(List<T> data, int select) {
super(context, R.layout.item_server_info_swipe); super(R.layout.item_deck_list_swipe, data);
this.selectPosition = select; this.selectPosition = select;
if (select >= 0) if (select >= 0)
isSelect = true; isSelect = true;
...@@ -55,22 +55,31 @@ public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPl ...@@ -55,22 +55,31 @@ public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPl
onItemSelectListener.onItemSelect(position, data.get(position).getObject()); onItemSelectListener.onItemSelect(position, data.get(position).getObject());
} }
}); });
} }
@SuppressLint("ResourceType")
@Override @Override
protected void convert(@NonNull com.chad.library.adapter.base.viewholder.BaseViewHolder baseViewHolder, DeckFile deck) { protected void convert(DeckViewHolder holder, T item) {
imageLoader.bindImage(baseViewHolder.getView(R.id.card_image), deck.getFirstCode(), ImageLoader.Type.small); int position = holder.getAdapterPosition();
baseViewHolder.setText(R.id.tv_name,deck.getName());
baseViewHolder.setText(R.id.count_main,deckInfo.getMainCount()); holder.deckName.setText(item.getName());
baseViewHolder.setText(R.id.count_ex,deckInfo.getExtraCount()); if (isManySelect) {
baseViewHolder.setText(R.id.count_main,deckInfo.getSideCount()); if (selectList.contains(item))
holder.deckName.setBackgroundColor(YGOUtil.c(R.color.colorMain));
else
holder.deckName.setBackgroundResource(Color.TRANSPARENT);
} else if (isSelect) {
if (position == selectPosition) {
holder.deckName.setBackgroundColor(YGOUtil.c(R.color.colorMain));
} else {
holder.deckName.setBackgroundResource(Color.TRANSPARENT);
}
}else {
holder.deckName.setBackgroundResource(Color.TRANSPARENT);
}
imageLoader.bindImage(cardImage, item.getFirstCode(), ImageLoader.Type.small);
} }
public void setEnableSwipe(boolean enableSwipe) {
mEnableSwipe = enableSwipe;
}
public void setSelectPosition(int selectPosition) { public void setSelectPosition(int selectPosition) {
this.selectPosition = selectPosition; this.selectPosition = selectPosition;
} }
...@@ -106,7 +115,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPl ...@@ -106,7 +115,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPl
return selectPosition; return selectPosition;
} }
public void setOnItemSelectListener(TextSelectAdapter.OnItemSelectListener onItemSelectListener) { public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
this.onItemSelectListener = onItemSelectListener; this.onItemSelectListener = onItemSelectListener;
} }
...@@ -114,7 +123,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPl ...@@ -114,7 +123,7 @@ public class DeckListAdapter<T extends TextSelect> extends BaseRecyclerAdapterPl
void onItemSelect(int position, T item); void onItemSelect(int position, T item);
} }
} }
class DeckViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder { class DeckViewHolder extends com.chad.library.adapter.base.viewholder.BaseViewHolder {
ImageView cardImage; ImageView cardImage;
ImageView prerelease_star; ImageView prerelease_star;
TextView deckName; TextView deckName;
...@@ -125,11 +134,11 @@ class DeckViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder { ...@@ -125,11 +134,11 @@ class DeckViewHolder extends BaseRecyclerAdapterPlus.BaseViewHolder {
public DeckViewHolder(View view) { public DeckViewHolder(View view) {
super(view); super(view);
view.setTag(view.getId(), this); view.setTag(view.getId(), this);
cardImage = $(R.id.card_image); cardImage = findView(R.id.card_image);
deckName = $(R.id.deck_name); deckName = findView(R.id.deck_name);
main = $(R.id.count_main); main = findView(R.id.count_main);
extra = $(R.id.count_ex); extra = findView(R.id.count_ex);
side = $(R.id.count_ex); side = findView(R.id.count_ex);
prerelease_star = $(R.id.prerelease_star); prerelease_star = findView(R.id.prerelease_star);
} }
} }
\ No newline at end of file
...@@ -36,6 +36,7 @@ import cn.garymb.ygomobile.adapter.TextBaseAdapter; ...@@ -36,6 +36,7 @@ import cn.garymb.ygomobile.adapter.TextBaseAdapter;
import cn.garymb.ygomobile.bean.DeckType; import cn.garymb.ygomobile.bean.DeckType;
import cn.garymb.ygomobile.bean.events.DeckFile; import cn.garymb.ygomobile.bean.events.DeckFile;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.adapters.DeckListAdapter;
import cn.garymb.ygomobile.ui.adapters.TextSelectAdapter; import cn.garymb.ygomobile.ui.adapters.TextSelectAdapter;
import cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil; import cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil;
import cn.garymb.ygomobile.ui.plus.DialogPlus; import cn.garymb.ygomobile.ui.plus.DialogPlus;
...@@ -90,7 +91,7 @@ public class YGODialogUtil { ...@@ -90,7 +91,7 @@ public class YGODialogUtil {
private final TextView tv_copy; private final TextView tv_copy;
private final TextView tv_del; private final TextView tv_del;
private final TextSelectAdapter<DeckType> typeAdp; private final TextSelectAdapter<DeckType> typeAdp;
private final TextSelectAdapter<DeckFile> deckAdp; private final DeckListAdapter<DeckFile> deckAdp;
private final Dialog ygoDialog; private final Dialog ygoDialog;
public ViewHolder(Context context, String selectDeckPath, OnDeckMenuListener onDeckMenuListener) { public ViewHolder(Context context, String selectDeckPath, OnDeckMenuListener onDeckMenuListener) {
...@@ -156,7 +157,7 @@ public class YGODialogUtil { ...@@ -156,7 +157,7 @@ public class YGODialogUtil {
} }
} }
typeAdp = new TextSelectAdapter<>(typeList, typeSelectPosition); typeAdp = new TextSelectAdapter<>(typeList, typeSelectPosition);
deckAdp = new TextSelectAdapter<>(deckList, deckSelectPosition); deckAdp = new DeckListAdapter<>(deckList, deckSelectPosition);
rv_type.setAdapter(typeAdp); rv_type.setAdapter(typeAdp);
rv_deck.setAdapter(deckAdp); rv_deck.setAdapter(deckAdp);
typeAdp.setOnItemSelectListener(new TextSelectAdapter.OnItemSelectListener<DeckType>() { typeAdp.setOnItemSelectListener(new TextSelectAdapter.OnItemSelectListener<DeckType>() {
...@@ -177,7 +178,7 @@ public class YGODialogUtil { ...@@ -177,7 +178,7 @@ public class YGODialogUtil {
deckAdp.notifyDataSetChanged(); deckAdp.notifyDataSetChanged();
} }
}); });
deckAdp.setOnItemSelectListener(new TextSelectAdapter.OnItemSelectListener<DeckFile>() { deckAdp.setOnItemSelectListener(new DeckListAdapter.OnItemSelectListener<DeckFile>() {
@Override @Override
public void onItemSelect(int position, DeckFile item) { public void onItemSelect(int position, DeckFile item) {
if (deckAdp.isManySelect()) { if (deckAdp.isManySelect()) {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.tubb.smrv.SwipeHorizontalMenuLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sml="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipe_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:background="@drawable/radius"
sml:sml_auto_open_percent="0.2"
sml:sml_scroller_duration="250" <RelativeLayout
sml:sml_scroller_interpolator="@android:anim/bounce_interpolator"> android:layout_width="28dp"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<ImageView
android:id="@+id/card_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
tools:src="@drawable/unknown" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:id="@id/smContentView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<RelativeLayout <cn.garymb.ygomobile.ui.widget.AlwaysMarqueeTextView
android:layout_width="40dp" android:id="@+id/deck_name"
android:layout_height="58dp" android:layout_width="match_parent"
android:layout_marginLeft="5dp" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:maxLines="1"
android:layout_marginBottom="5dp"> android:singleLine="true"
android:textColor="@color/white"
tools:text="Deck Name" />
<ImageView
android:id="@+id/card_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
tools:src="@drawable/unknown" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginTop="3dp"
android:layout_gravity="center" android:orientation="horizontal">
android:orientation="vertical">
<cn.garymb.ygomobile.ui.widget.AlwaysMarqueeTextView <TextView
android:id="@+id/deck_name" android:id="@+id/count_main"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:textSize="10sp"
android:singleLine="true" android:textColor="@color/holo_blue_bright"
android:textAppearance="@style/TextAppearance.AppCompat.Title" tools:text="40" />
android:textColor="@color/item_title"
android:textSize="18sp"
tools:text="Deck Name" />
<TextView
<LinearLayout android:id="@+id/TextExtra"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="3dp" android:text="/"
android:orientation="horizontal"> android:textSize="10sp"
android:textColor="@android:color/holo_green_light" />
<LinearLayout
android:id="@+id/layout_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/count_ex"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:maxLines="1" android:layout_height="wrap_content"
android:singleLine="true" android:textColor="@color/holo_blue_bright"
android:text="main/" android:textSize="10sp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" tools:text="15" />
android:textColor="@android:color/holo_green_light" />
<TextView
android:id="@+id/count_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:minWidth="@dimen/label_width_small_32dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@color/holo_blue_bright"
tools:text="40" />
<View
android:layout_width="5dp"
android:layout_height="1dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_extra"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/TextExtra"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:singleLine="true"
android:text="extra/"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@android:color/holo_green_light" />
<TextView <TextView
android:id="@+id/count_ex" android:id="@+id/TextSide"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:text="/"
android:minWidth="@dimen/label_width_small_32dp" android:textSize="10sp"
android:singleLine="true" android:textColor="@android:color/holo_green_light" />
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@color/holo_blue_bright"
tools:text="15" />
</LinearLayout>
<LinearLayout <TextView
android:id="@+id/layout_side" android:id="@+id/count_side"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/holo_blue_bright"
android:textSize="10sp"
tools:text="15" />
<TextView
android:id="@+id/TextSide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:singleLine="true"
android:text="side/"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@android:color/holo_green_light" />
<TextView <View
android:id="@+id/count_side" android:layout_width="0dp"
android:layout_width="wrap_content" android:layout_height="1dp"
android:layout_height="wrap_content" android:layout_weight="1" />
android:maxLines="1"
android:minWidth="@dimen/label_width_small_32dp"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@color/holo_blue_bright"
tools:text="15" />
</LinearLayout>
<View <ImageView
android:layout_width="0dp" android:id="@+id/prerelease_star"
android:layout_height="1dp" android:layout_width="@dimen/right_size"
android:layout_weight="1" /> android:layout_height="@dimen/right_size"
<ImageView android:layout_marginRight="@dimen/dp_10"
android:id="@+id/prerelease_star" android:visibility="visible"
android:layout_width="@dimen/right_size" tools:src="@drawable/ic_close_black_24dp" />
android:layout_height="@dimen/right_size"
android:visibility="visible"
android:layout_marginRight="@dimen/dp_10"
tools:src="@drawable/ic_close_black_24dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</com.tubb.smrv.SwipeHorizontalMenuLayout> </LinearLayout>
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment