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

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;
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.adapter.TuijianAdapter;
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.MyService;
import com.lc.myapplication.security.locks.tool.MyTools;

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

public class TestimonialsActivity extends AppCompatActivity {

    private RecyclerView tuijian_re;
    private ImageView tuijian_back;
    private LinearLayout tuijain_main;
    private List<SecurityLockEntity> list;
    private boolean notlock = false;
    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_testimonials);
        MaxManager.onLoadAd();
        tuijian_re = findViewById(R.id.tuijian_apps_view);
        tuijian_back = findViewById(R.id.tuijian_back);
        tuijain_main = findViewById(R.id.tuijian_main);
        initbackground();
        tuijian_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        getNotLocked();
    }

    private void getNotLocked() {
        MyTools.RUNIO(new Runnable() {
            @Override
            public void run() {
                list = SecurityLockDataBase.getSecurityLockDataBase().getsecurityLockDAO().GetLockedApp(notlock);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        gotoGetRecycle();
                    }
                });
            }
        });
    }

    private void gotoGetRecycle() {
        MySpace mySpace = new MySpace(5,20,3);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(this,3);
        tuijian_re.setLayoutManager(gridLayoutManager);
        tuijian_re.addItemDecoration(mySpace);
        TuijianAdapter tuijianAdapter = new TuijianAdapter(this,list);
        tuijian_re.setAdapter(tuijianAdapter);
    }
    private void initbackground() {
        Window window = getWindow();
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        tuijain_main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }
}