|
|
@@ -1,10 +1,9 @@
|
|
|
package com.itant.shibei.ui.home.goods;
|
|
|
|
|
|
-import android.content.Context;
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.text.TextUtils;
|
|
|
-import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
@@ -24,12 +23,15 @@ import com.itant.shibei.manager.UserInfoManager;
|
|
|
import com.itant.shibei.tool.StringTool;
|
|
|
import com.itant.shibei.ui.TabActivity;
|
|
|
import com.itant.shibei.ui.home.goods.detail.GoodsDetailActivity;
|
|
|
-import com.itant.shibei.ui.home.goods.play.VideoPlayActivity;
|
|
|
import com.makeramen.roundedimageview.RoundedImageView;
|
|
|
import com.miekir.common.utils.ToastTool;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+import rx_activity_result2.RxActivityResult;
|
|
|
+
|
|
|
+import static android.app.Activity.RESULT_OK;
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*
|
|
|
@@ -38,10 +40,10 @@ import java.util.List;
|
|
|
* Description: 首页商品适配器
|
|
|
*/
|
|
|
public class GoodsAdapter extends BaseQuickAdapter<GoodsBean, BaseViewHolder> {
|
|
|
- private Context mContext;
|
|
|
+ private Activity mContext;
|
|
|
private int mRadius;
|
|
|
|
|
|
- public GoodsAdapter(Context context, @Nullable List<GoodsBean> data) {
|
|
|
+ public GoodsAdapter(Activity context, @Nullable List<GoodsBean> data) {
|
|
|
super(R.layout.item_goods, data);
|
|
|
mRadius = (int) context.getResources().getDimension(R.dimen.margin_ss);
|
|
|
mContext = context;
|
|
|
@@ -55,7 +57,7 @@ public class GoodsAdapter extends BaseQuickAdapter<GoodsBean, BaseViewHolder> {
|
|
|
holder.setText(R.id.tv_see_num, String.format(GoodsDetailActivity.FORMATTER_SEE_NUM, StringTool.getNumberString(goodsBean.seeNum)));
|
|
|
|
|
|
holder.setOnClickListener(R.id.cv_goods, v -> {
|
|
|
- if (!UserInfoManager.getInstance().getBeiUser().isVip) {
|
|
|
+ if (!UserInfoManager.getInstance().getBeiUser().vip) {
|
|
|
ToastTool.showShort("请先激活会员");
|
|
|
if (mContext instanceof TabActivity) {
|
|
|
((TabActivity) mContext).setCurrentPage(2);
|
|
|
@@ -71,7 +73,19 @@ public class GoodsAdapter extends BaseQuickAdapter<GoodsBean, BaseViewHolder> {
|
|
|
// 跳到详情界面
|
|
|
Intent detailIntent = new Intent(mContext, GoodsDetailActivity.class);
|
|
|
detailIntent.putExtra(GoodsDetailActivity.KEY_GOODS, goodsBean);
|
|
|
- mContext.startActivity(detailIntent);
|
|
|
+ RxActivityResult.on(mContext).startIntent(detailIntent)
|
|
|
+ .filter(result -> result.resultCode() == RESULT_OK)
|
|
|
+ .doOnNext(result -> {
|
|
|
+ // 刷新成功
|
|
|
+ GoodsBean afterBean = (GoodsBean) result.data().getSerializableExtra(GoodsDetailActivity.KEY_GOODS);
|
|
|
+ if (afterBean != null) {
|
|
|
+ goodsBean.isFavorite = afterBean.isFavorite;
|
|
|
+ goodsBean.favNum = afterBean.favNum;
|
|
|
+ goodsBean.seeNum = afterBean.seeNum;
|
|
|
+ notifyItemChanged(holder.getLayoutPosition());
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .subscribe();
|
|
|
});
|
|
|
|
|
|
// 解决图片错乱
|
|
|
@@ -111,14 +125,14 @@ public class GoodsAdapter extends BaseQuickAdapter<GoodsBean, BaseViewHolder> {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- View fl_video_play = holder.getView(R.id.fl_video_play);
|
|
|
+ /*View fl_video_play = holder.getView(R.id.fl_video_play);
|
|
|
View iv_video_play = holder.getView(R.id.iv_video_play);
|
|
|
if (!TextUtils.isEmpty(goodsBean.videoUrl)) {
|
|
|
iv_video_play.setVisibility(View.VISIBLE);
|
|
|
fl_video_play.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- if (!UserInfoManager.getInstance().getBeiUser().isVip) {
|
|
|
+ if (!UserInfoManager.getInstance().getBeiUser().vip) {
|
|
|
ToastTool.showShort("请先激活会员");
|
|
|
if (mContext instanceof TabActivity) {
|
|
|
((TabActivity) mContext).setCurrentPage(2);
|
|
|
@@ -140,7 +154,7 @@ public class GoodsAdapter extends BaseQuickAdapter<GoodsBean, BaseViewHolder> {
|
|
|
});
|
|
|
} else {
|
|
|
iv_video_play.setVisibility(View.GONE);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
// 暂时不需要长按弹出操作
|
|
|
/*if (UserInfoManager.getInstance().isLogin() &&
|