Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @BindView(R.id.image_view)
- ImageView imageView;
- @BindView(R.id.profile_image)
- CircleImageView profileImage;
- @BindView(R.id.tv_store_name)
- TextView tvStoreName;
- @BindView(R.id.tv_harga)
- TextView tvHarga;
- @BindView(R.id.tv_description)
- TextView tvDescription;
- @BindView(R.id.btn_buy)
- Button btnBuy;
- @BindView(R.id.tv_price_old)
- TextView tvPriceOld;
- @BindView(R.id.tv_price)
- TextView tvPrice;
- @BindView(R.id.cv_detail_product)
- FrameLayout cvDetailProduct;
- /*membuat variable productId untuk menyimpan value productId*/
- String productId;
- /*Membuat variable productDetail untuk mengakses POJO*/
- ProductDetail productDetail;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_product_detail);
- ButterKnife.bind(this);
- productId = getIntent().getStringExtra("product_id");
- loadProductDetail();
- }
- @OnClick(R.id.btn_buy)
- public void onViewClicked() {
- }
- private void loadProductDetail(){
- ApiEndPoint apiEndPoint = ApiClient.getClient(this).create(ApiEndPoint.class);
- Call<ProductDetail> call = apiEndPoint.getProductDetail(productId);
- call.enqueue(new Callback<ProductDetail>() {
- @Override
- public void onResponse(Call<ProductDetail> call, Response<ProductDetail> response) {
- productDetail = response.body();
- if (productDetail != null){
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Picasso.with(ProductDetailActivity.this).load(productDetail.getPhoto()).into(imageView);
- Picasso.with(ProductDetailActivity.this).load(productDetail.getStorePhoto()).into(profileImage);
- tvStoreName.setText(productDetail.getStoreName());
- tvDescription.setText(productDetail.getDescription());
- tvPriceOld.setText(productDetail.getPriceOld());
- tvPriceOld.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
- tvPrice.setText(productDetail.getPrice());
- setTitle(productDetail.getName());
- }
- });
- }
- }
- @Override
- public void onFailure(Call<ProductDetail> call, Throwable t) {
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement