Advertisement
Guest User

Untitled

a guest
May 26th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. @BindView(R.id.image_view)
  2. ImageView imageView;
  3. @BindView(R.id.profile_image)
  4. CircleImageView profileImage;
  5. @BindView(R.id.tv_store_name)
  6. TextView tvStoreName;
  7. @BindView(R.id.tv_harga)
  8. TextView tvHarga;
  9. @BindView(R.id.tv_description)
  10. TextView tvDescription;
  11. @BindView(R.id.btn_buy)
  12. Button btnBuy;
  13. @BindView(R.id.tv_price_old)
  14. TextView tvPriceOld;
  15. @BindView(R.id.tv_price)
  16. TextView tvPrice;
  17. @BindView(R.id.cv_detail_product)
  18. FrameLayout cvDetailProduct;
  19.  
  20. /*membuat variable productId untuk menyimpan value productId*/
  21. String productId;
  22. /*Membuat variable productDetail untuk mengakses POJO*/
  23. ProductDetail productDetail;
  24.  
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_product_detail);
  29. ButterKnife.bind(this);
  30.  
  31. productId = getIntent().getStringExtra("product_id");
  32. loadProductDetail();
  33. }
  34.  
  35. @OnClick(R.id.btn_buy)
  36. public void onViewClicked() {
  37.  
  38. }
  39.  
  40. private void loadProductDetail(){
  41. ApiEndPoint apiEndPoint = ApiClient.getClient(this).create(ApiEndPoint.class);
  42. Call<ProductDetail> call = apiEndPoint.getProductDetail(productId);
  43. call.enqueue(new Callback<ProductDetail>() {
  44. @Override
  45. public void onResponse(Call<ProductDetail> call, Response<ProductDetail> response) {
  46. productDetail = response.body();
  47. if (productDetail != null){
  48. runOnUiThread(new Runnable() {
  49. @Override
  50. public void run() {
  51. Picasso.with(ProductDetailActivity.this).load(productDetail.getPhoto()).into(imageView);
  52. Picasso.with(ProductDetailActivity.this).load(productDetail.getStorePhoto()).into(profileImage);
  53. tvStoreName.setText(productDetail.getStoreName());
  54. tvDescription.setText(productDetail.getDescription());
  55. tvPriceOld.setText(productDetail.getPriceOld());
  56. tvPriceOld.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
  57. tvPrice.setText(productDetail.getPrice());
  58. setTitle(productDetail.getName());
  59. }
  60. });
  61. }
  62. }
  63.  
  64. @Override
  65. public void onFailure(Call<ProductDetail> call, Throwable t) {
  66.  
  67. }
  68. });
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement