package com.lc.myapplication.security.locks.activity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lc.myapplication.security.locks.R;
import com.lc.myapplication.security.locks.Securitylocks;
import com.lc.myapplication.security.locks.adapter.LockedAppAdapter;
import com.lc.myapplication.security.locks.draw.MySpace;
import com.lc.myapplication.security.locks.lockroom.SecurityLockDataBase;
import com.lc.myapplication.security.locks.lockroom.SecurityLockEntity;
import com.lc.myapplication.security.locks.max.MaxManager;
import com.lc.myapplication.security.locks.tool.MyTools;

import java.util.ArrayList;
import java.util.List;

public class LockedAppActivity extends AppCompatActivity {
   private RecyclerView locked_app;
   private ImageView locked_back;
   private boolean islock = true;
    private LinearLayout locked_main;
   private List<SecurityLockEntity> list;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_locked_app);
        MaxManager.onLoadAd();
        locked_app = findViewById(R.id.locked_apps_view);
        locked_back = findViewById(R.id.locked_back);
        locked_main = findViewById(R.id.locked_main);
        initbackground();
        locked_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        gotoGetLockedList();
    }
    private void initbackground() {
        Window window = getWindow();
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        locked_main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }
    private void gotoGetLockedList() {
        MyTools.RUNIO(new Runnable() {
            @Override
            public void run() {
                list = SecurityLockDataBase.getSecurityLockDataBase().getsecurityLockDAO().GetLockedApp(islock);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        gotoGetRecycle();
                    }
                });
            }
        });
    }
    private void gotoGetRecycle() {
        MySpace mySpace = new MySpace(5,20,3);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,3);
        locked_app.setLayoutManager(gridLayoutManager);
        locked_app.addItemDecoration(mySpace);
        LockedAppAdapter lockedAppAdapter = new LockedAppAdapter(this,list);
        locked_app.setAdapter(lockedAppAdapter);
    }
}