package com.swiftcleaner.chovey.view.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.gyf.immersionbar.ImmersionBar;
import com.swiftcleaner.chovey.databinding.ActivityEndCleanJunkBinding;
import com.swiftcleaner.chovey.view.dialog.CustomScoreDialog;

public class EndCleanJunkActivity extends AppCompatActivity {
    ActivityEndCleanJunkBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityEndCleanJunkBinding.inflate(getLayoutInflater());
        View view = binding.getRoot();
        setContentView(view);
        initBar();
        initShow();
    }

    private void initShow() {
        Intent intent = getIntent();
        String stringExtra = intent.getStringExtra("cleanstr");
        binding.endCleanJunkFileNum.setText("Cleaned "+ stringExtra +" junk files");
        binding.ivReturn.setOnClickListener(v->{
            initCustDialog();
        });
        binding.buttonBatteryInfoCheckNo.setOnClickListener(v->{
            startActivity(new Intent(this, InfoActivity.class));
            finish();
        });
        binding.buttonAppManagerCheckNo.setOnClickListener(v->{
            startActivity(new Intent(this, BatteryInfoActivity.class));
            finish();
        });
        binding.buttonAppProcessCheckNo.setOnClickListener(v->{
            startActivity(new Intent(this, AppProcessActivity.class));
            finish();
        });
        binding.buttonCleanJunkCleanNo.setOnClickListener(v->{
            startActivity(new Intent(this, CleanJunkActivity.class));
            finish();
        });
        binding.buttonLargefilecleanerCleanUp.setOnClickListener(v->{
            startActivity(new Intent(this, LargeFileActivity.class));
            finish();
        });
        binding.buttonScreenshot.setOnClickListener(v->{
            startActivity(new Intent(this, ScreenShotActivity.class));
            finish();
        });
    }

    private void initBar() {
        ImmersionBar.with(this)
                .transparentStatusBar()  // 透明状态栏
                .statusBarDarkFont(false)  // 状态栏字体颜色为浅色
                .navigationBarDarkIcon(true)  // 导航栏图标颜色为浅色
                .init();
    }

    @Override
    public void onBackPressed() {
        initCustDialog();
    }

    private void initCustDialog(){
        CustomScoreDialog customScoreDialog = new CustomScoreDialog(this);
        customScoreDialog.setOnDialogClickListener(new CustomScoreDialog.OnDialogClickListener() {
            @Override
            public void onCancel() {
                customScoreDialog.dismiss();
            }

            @Override
            public void onSubmit() {
                customScoreDialog.dismiss();
                finish();
            }
        });
        customScoreDialog.show();
    }
}