|
@@ -11,9 +11,16 @@ import android.widget.TextView;
|
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
import com.chad.library.adapter.base.BaseViewHolder;
|
|
import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.module.user.model.BuyVipReq;
|
|
import com.sheep.gamegroup.module.user.model.BuyVipReq;
|
|
|
|
|
+import com.sheep.gamegroup.util.ApiJSONUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.ListUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -37,6 +44,16 @@ public class ActVip extends BaseActivity {
|
|
|
private List<BuyVipReq> list = new ArrayList<>();
|
|
private List<BuyVipReq> list = new ArrayList<>();
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
|
|
+ TitleBarUtils.getInstance()
|
|
|
|
|
+ .setShowOrHide(this, true)
|
|
|
|
|
+ .setTitleFinish(this)
|
|
|
|
|
+ .setTitle(this, "VIP");
|
|
|
|
|
+ list.add(new BuyVipReq().setPay_name("支付宝").setPay_type(BuyVipReq.PAY_TYPE_ALIPAY));
|
|
|
|
|
+ list.add(new BuyVipReq().setPay_name("微信").setPay_type(BuyVipReq.PAY_TYPE_WX));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void initListener() {
|
|
|
recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2));
|
|
recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2));
|
|
|
BaseQuickAdapter<BuyVipReq, BaseViewHolder> adapter = new BaseQuickAdapter<BuyVipReq, BaseViewHolder>(R.layout.rechargeprice_gridview_item, list) {
|
|
BaseQuickAdapter<BuyVipReq, BaseViewHolder> adapter = new BaseQuickAdapter<BuyVipReq, BaseViewHolder>(R.layout.rechargeprice_gridview_item, list) {
|
|
|
@Override
|
|
@Override
|
|
@@ -46,6 +63,7 @@ public class ActVip extends BaseActivity {
|
|
|
Context context = SheepApp.getInstance();
|
|
Context context = SheepApp.getInstance();
|
|
|
TextView item_tv_y = convertView.findViewById(R.id.item_tv_y);
|
|
TextView item_tv_y = convertView.findViewById(R.id.item_tv_y);
|
|
|
|
|
|
|
|
|
|
+ ViewUtil.setText(item_tv_y, item.getPay_name());
|
|
|
if (position == curPosition){
|
|
if (position == curPosition){
|
|
|
convertView.setBackground(context.getResources().getDrawable(R.drawable.layer_list_check_rectgangle_small));
|
|
convertView.setBackground(context.getResources().getDrawable(R.drawable.layer_list_check_rectgangle_small));
|
|
|
item_tv_y.setTextColor(ContextCompat.getColor(context,R.color.main_tab_activated));
|
|
item_tv_y.setTextColor(ContextCompat.getColor(context,R.color.main_tab_activated));
|
|
@@ -56,19 +74,32 @@ public class ActVip extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
adapter.bindToRecyclerView(recyclerView);
|
|
adapter.bindToRecyclerView(recyclerView);
|
|
|
- adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
|
|
- if(curPosition != position){
|
|
|
|
|
- curPosition = position;
|
|
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ adapter.setOnItemClickListener((adapter1, view, position) -> {
|
|
|
|
|
+ if(curPosition != position){
|
|
|
|
|
+ curPosition = position;
|
|
|
|
|
+ adapter1.notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private int curPosition = 0;
|
|
private int curPosition = 0;
|
|
|
|
|
|
|
|
public void onClickPay(View view) {
|
|
public void onClickPay(View view) {
|
|
|
|
|
+ BuyVipReq item = ListUtil.getItem(list, curPosition);
|
|
|
|
|
+ if(item != null){
|
|
|
|
|
+ ApiJSONUtil.postBuyVip(1, item.getPay_type())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|