Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void initCartList() {
- if (CartModel.cart_data == null) {
- no_data.setVisibility(View.VISIBLE);
- layout_content.setVisibility(View.GONE);
- dialog.cancel();
- }else {
- try {
- Gson gson = new Gson();
- CartModel cartModel = gson.fromJson(CartModel.cart_data, CartModel.class);
- List<CartModel.ItemsBean> itemsBeanList = cartModel.getItems();
- final LinearLayout list = (LinearLayout) findViewById(R.id.list);
- for (final CartModel.ItemsBean data : itemsBeanList) {
- final View vi = getLayoutInflater().inflate(R.layout.list_cart, null);
- LinearLayout itemCart = (LinearLayout) vi.findViewById(R.id.itemCart);
- final String item_id = String.valueOf(data.getId());
- String plan_logs = data.getPlanLogs().replace("\\","");
- JSONObject plan = new JSONObject(plan_logs);
- Log.e("logo",cartModel.getBaseUrl().concat("/") + data.getProduct().getLogo());
- ImageView cartLogo = (ImageView) vi.findViewById(R.id.ivLogo);
- Glide.with(ActivityCart.this)
- .load(cartModel.getBaseUrl().concat("/") + data.getProduct().getLogo())
- .placeholder(R.drawable.loading)
- .into(cartLogo);
- TextViewLatoRegular date = (TextViewLatoRegular) vi.findViewById(R.id.tv_date);
- // date.setText(plan.getString("start_date").concat(" - " ).concat(plan.getString("end_date")));
- final String item_price = data.getPremiumTotal();
- TextViewLatoBold hapusCart = (TextViewLatoBold) vi.findViewById(R.id.itemHapus);
- hapusCart.setOnClickListener(view -> {
- AlertDialog.Builder dialog = new AlertDialog.Builder(this);
- dialog.setTitle("Hapus Product")
- .setMessage("Apakah anda yakin ingin menghapus produk ini?")
- .setPositiveButton("Ya", (dialogInterface, i) -> {
- removeCart(item_id, list, vi, item_price);
- })
- .setNegativeButton("Tidak", (dialogInterface, i) -> {
- dialogInterface.dismiss();
- })
- .show();
- });
- TextViewLatoBold SubTotal = (TextViewLatoBold) vi.findViewById(R.id.itemSubTotal);
- SubTotal.setText(rupiah(data.getPremiumTotal()));
- list.addView(vi);
- }
- sub_total = Double.valueOf(cartModel.getTotalPrice());
- updateView();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement