Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. private void initCartList() {
  2. if (CartModel.cart_data == null) {
  3. no_data.setVisibility(View.VISIBLE);
  4. layout_content.setVisibility(View.GONE);
  5. dialog.cancel();
  6. }else {
  7. try {
  8. Gson gson = new Gson();
  9. CartModel cartModel = gson.fromJson(CartModel.cart_data, CartModel.class);
  10. List<CartModel.ItemsBean> itemsBeanList = cartModel.getItems();
  11.  
  12. final LinearLayout list = (LinearLayout) findViewById(R.id.list);
  13. for (final CartModel.ItemsBean data : itemsBeanList) {
  14. final View vi = getLayoutInflater().inflate(R.layout.list_cart, null);
  15. LinearLayout itemCart = (LinearLayout) vi.findViewById(R.id.itemCart);
  16.  
  17. final String item_id = String.valueOf(data.getId());
  18. String plan_logs = data.getPlanLogs().replace("\\","");
  19. JSONObject plan = new JSONObject(plan_logs);
  20. Log.e("logo",cartModel.getBaseUrl().concat("/") + data.getProduct().getLogo());
  21.  
  22. ImageView cartLogo = (ImageView) vi.findViewById(R.id.ivLogo);
  23. Glide.with(ActivityCart.this)
  24. .load(cartModel.getBaseUrl().concat("/") + data.getProduct().getLogo())
  25. .placeholder(R.drawable.loading)
  26. .into(cartLogo);
  27.  
  28. TextViewLatoRegular date = (TextViewLatoRegular) vi.findViewById(R.id.tv_date);
  29. // date.setText(plan.getString("start_date").concat(" - " ).concat(plan.getString("end_date")));
  30. final String item_price = data.getPremiumTotal();
  31. TextViewLatoBold hapusCart = (TextViewLatoBold) vi.findViewById(R.id.itemHapus);
  32. hapusCart.setOnClickListener(view -> {
  33. AlertDialog.Builder dialog = new AlertDialog.Builder(this);
  34. dialog.setTitle("Hapus Product")
  35. .setMessage("Apakah anda yakin ingin menghapus produk ini?")
  36. .setPositiveButton("Ya", (dialogInterface, i) -> {
  37. removeCart(item_id, list, vi, item_price);
  38. })
  39. .setNegativeButton("Tidak", (dialogInterface, i) -> {
  40. dialogInterface.dismiss();
  41. })
  42. .show();
  43.  
  44. });
  45.  
  46. TextViewLatoBold SubTotal = (TextViewLatoBold) vi.findViewById(R.id.itemSubTotal);
  47. SubTotal.setText(rupiah(data.getPremiumTotal()));
  48.  
  49. list.addView(vi);
  50. }
  51.  
  52. sub_total = Double.valueOf(cartModel.getTotalPrice());
  53.  
  54. updateView();
  55.  
  56. } catch (Exception e) {
  57. e.printStackTrace();
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement