package com.example.myapplication6;

import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.button.MaterialButton;

public class DashboardActivity extends BaseActivity {

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

        MaterialButton btnSettings = findViewById(R.id.btnSettings);
        if (btnSettings != null) {
            btnSettings.setOnClickListener(v -> {
                Intent i = new Intent(this, SettingsActivity.class);
                startActivity(i);
            });
        }

        MaterialCardView cardMedia = findViewById(R.id.cardMedia);
        MaterialCardView cardReading = findViewById(R.id.cardReading);
        MaterialCardView cardWishlist = findViewById(R.id.cardWishlist);
        MaterialCardView cardTravel = findViewById(R.id.cardTravel);

        cardMedia.setOnClickListener(
                v -> {
                    Intent i = new Intent(this, goster.class);
                    i.putExtra(MainActivity.EXTRA_SHELF, bizimdb.SHELF_MEDIA);
                    startActivity(i);
                });

        cardReading.setOnClickListener(
                v -> openShelf(bizimdb.SHELF_READING));

        cardWishlist.setOnClickListener(
                v -> openShelf(bizimdb.SHELF_WISHLIST));

        cardTravel.setOnClickListener(
                v -> openShelf(bizimdb.SHELF_TRAVEL));
    }

    private void openShelf(String shelf) {
        Intent i = new Intent(this, ShelfBrowseActivity.class);
        i.putExtra(MainActivity.EXTRA_SHELF, shelf);
        startActivity(i);
    }
}
