package com.example.quiz.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.quiz.R;

public class LoaderDialog {

    private Dialog dialog;
    private TextView loaderText;

    public LoaderDialog(Context context) {
        dialog = new Dialog(context);
        View view = LayoutInflater.from(context).inflate(R.layout.dowload_loader, null);
        loaderText = view.findViewById(R.id.loaderText);

        dialog.setContentView(view);
        dialog.setCancelable(false); // Empêche fermeture en cliquant dehors
        dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    }

    public void show(String message) {
        loaderText.setText(message);
        dialog.show();
    }

    public void dismiss() {
        if (dialog.isShowing()) {
            dialog.dismiss();
        }
    }
}
