package com.nurulwafa.nufakuproject;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;

public class DetailBeritaActivity extends AppCompatActivity {

    TextView tvJudul, tvTanggal, tvDeskripsi;
    ImageView imgBerita;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail_berita);

        tvJudul = findViewById(R.id.tvJudul);
        tvTanggal = findViewById(R.id.tvTanggal);
        tvDeskripsi = findViewById(R.id.tvDeskripsi);
        imgBerita = findViewById(R.id.imgBerita);

        // Ambil data dari intent
        String judul = getIntent().getStringExtra("judul");
        String tanggal = getIntent().getStringExtra("tanggal");
        String deskripsi = getIntent().getStringExtra("deskripsi");
        String gambar = getIntent().getStringExtra("gambar");

        tvJudul.setText(judul);
        tvTanggal.setText(tanggal);
        tvDeskripsi.setText(deskripsi);
        Glide.with(this).load(gambar).into(imgBerita);
//        Glide.with(this)
//                .load(gambar)
//                .listener(new RequestListener<Drawable>() {
//                    @Override
//                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
//                        e.printStackTrace(); // cetak error ke logcat
//                        return false;
//                    }
//
//                    @Override
//                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
//                        return false;
//                    }
//                })
//                .into(imgBerita);
    }
}
