周心愿单的设置与展示
This commit is contained in:
parent
5095de3c43
commit
55290a71aa
@ -79,6 +79,20 @@ public class LiveNewWishAdapter extends RecyclerView.Adapter {
|
||||
});
|
||||
} else if (holder instanceof WeekWishItemViewHolder) {
|
||||
WeekWishItemViewHolder weekWishItemViewHolder = (WeekWishItemViewHolder) holder;
|
||||
weekWishItemViewHolder.steWeekWishData(wishList.get(position), position, new WeekWishItemViewHolder.WeekWishItemListener() {
|
||||
@Override
|
||||
public void onDelete(int index) {
|
||||
wishList.remove(index);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(WishModel model, int index) {
|
||||
wishList.remove(index);
|
||||
wishList.add(index, model);
|
||||
notifyItemChanged(index);
|
||||
}
|
||||
});
|
||||
} else if (holder instanceof LunarWishItemViewHolder) {
|
||||
LunarWishItemViewHolder lunarWishItemViewHolder = (LunarWishItemViewHolder) holder;
|
||||
} else if (holder instanceof SeasonalWishItemViewHolder) {
|
||||
|
@ -1,12 +1,103 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class WeekWishItemViewHolder extends RecyclerView.ViewHolder {
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.WishModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.WordsTypeUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
public class WeekWishItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView wishTab, wishlistName, wishlistProgress, wishlistNum, wishlistNum2, subtraction, addition;
|
||||
private ImageView wishIcon;
|
||||
private FrameLayout wishIconBg, tabBg, iconCancel;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
public WeekWishItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
wishTab = itemView.findViewById(R.id.wish_tab);
|
||||
wishIcon = itemView.findViewById(R.id.wish_icon);
|
||||
tabBg = itemView.findViewById(R.id.tab_bg);
|
||||
wishIconBg = itemView.findViewById(R.id.wish_icon_bg);
|
||||
iconCancel = itemView.findViewById(R.id.icon_cancel);
|
||||
wishlistName = itemView.findViewById(R.id.wishlist_name);
|
||||
progressBar = itemView.findViewById(R.id.progressBar);
|
||||
wishlistProgress = itemView.findViewById(R.id.wishlist_progress);
|
||||
wishlistNum = itemView.findViewById(R.id.wishlist_num);
|
||||
wishlistNum2 = itemView.findViewById(R.id.wishlist_num2);
|
||||
subtraction = itemView.findViewById(R.id.subtraction);
|
||||
addition = itemView.findViewById(R.id.addition);
|
||||
}
|
||||
|
||||
public void steWeekWishData(WishModel model, int index, WeekWishItemListener listener) {
|
||||
if (model != null) {
|
||||
itemView.findViewById(R.id.hind_layout).setVisibility(View.VISIBLE);
|
||||
itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.VISIBLE);
|
||||
itemView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE);
|
||||
iconCancel.setVisibility(View.VISIBLE);
|
||||
wishTab.setVisibility(View.VISIBLE);
|
||||
wishlistName.setVisibility(View.VISIBLE);
|
||||
wishTab.setText(String.format(itemView.getContext().getString(R.string.wish_number), WordsTypeUtil.numberConvertToUppercase(index + 1)));
|
||||
ImgLoader.display(itemView.getContext(), model.getWishlistIcon(), wishIcon);
|
||||
tabBg.setBackgroundResource(R.mipmap.bg_day_wish);
|
||||
wishIconBg.setBackgroundResource(R.mipmap.background_wish_item);
|
||||
wishlistName.setText(model.getWishlistName());
|
||||
progressBar.setMax(model.wishProgress());
|
||||
progressBar.setProgress(model.wishCurrent());//当前进度
|
||||
wishlistProgress.setText(model.getWishlistProgress());
|
||||
wishlistNum.setText(String.format("/%s", model.getWishlistNum()));
|
||||
wishlistNum2.setText(String.format("x%s", model.getWishlistNum()));
|
||||
ViewClicksAntiShake.clicksAntiShake(iconCancel, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (listener != null) {
|
||||
listener.onDelete(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(addition, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
int number = model.wishProgress();
|
||||
model.setWishlistNum(String.valueOf(number + 1));
|
||||
if (listener != null) {
|
||||
listener.onUpdate(model, index);
|
||||
}
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(subtraction, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
int number = model.wishProgress();
|
||||
model.setWishlistNum(String.valueOf(number - 1));
|
||||
if (listener != null) {
|
||||
listener.onUpdate(model, index);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
itemView.findViewById(R.id.hind_layout).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.progress_bar).setVisibility(View.GONE);
|
||||
tabBg.setBackground(null);
|
||||
wishTab.setVisibility(View.GONE);
|
||||
wishlistName.setVisibility(View.GONE);
|
||||
iconCancel.setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface WeekWishItemListener {
|
||||
void onDelete(int index);
|
||||
|
||||
void onUpdate(WishModel model, int index);
|
||||
}
|
||||
}
|
||||
|
@ -3,31 +3,42 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="119dp"
|
||||
android:layout_margin="4dp"
|
||||
android:id="@+id/tab_bg"
|
||||
android:background="@mipmap/bg_day_wish">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/icon_cancel"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="19dp"
|
||||
android:background="@mipmap/icon_cancel" />
|
||||
android:layout_marginEnd="19dp">
|
||||
|
||||
<ImageView
|
||||
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="end"
|
||||
android:background="@mipmap/icon_cancel" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wish_tab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="18dp"
|
||||
android:layout_marginStart="13dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="心願二"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/wish_icon_bg"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginStart="11dp"
|
||||
android:layout_marginTop="40dp"
|
||||
android:background="@drawable/background_wish_item">
|
||||
android:layout_marginTop="40dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/wish_icon"
|
||||
@ -35,4 +46,86 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="3dp" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/wishlist_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="85dp"
|
||||
android:layout_marginTop="49dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="85dp"
|
||||
android:layout_marginTop="78dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="11dp"
|
||||
android:max="100"
|
||||
android:progress="30"
|
||||
android:progressDrawable="@drawable/progress_wishlist2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wishlist_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="9dp"
|
||||
android:text="2"
|
||||
android:textColor="#FFE062"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wishlist_num"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="/20"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/hind_layout"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="77dp"
|
||||
android:layout_marginEnd="19dp"
|
||||
android:background="@drawable/bg_xyd_number"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subtraction"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="-"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wishlist_num2"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="x23"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/addition"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="+"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user