Commit fc1d78dc authored by fallenstardust's avatar fallenstardust

更改使用decklistadapter

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