package com.sketch.art.trace.activity;

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

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

import com.sketch.art.trace.adapter.AdapterMain;
import com.sketch.art.trace.databinding.ActivityMainLayoutBinding;
import com.sketch.art.trace.listener.OnMyClickListener;
import com.sketch.art.trace.tools.App;
import com.sketch.art.trace.tools.ComManager;

public class MainActivity extends AppCompatActivity implements OnMyClickListener,View.OnClickListener {

    private ActivityMainLayoutBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ComManager.setStatusBarTextColor(this, true);
        binding = ActivityMainLayoutBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        onInitRecycler();
        binding.rlUpload.setOnClickListener(this);
        binding.rlLike.setOnClickListener(this);
    }


    private void onInitRecycler() {
        AdapterMain adapterMain = new AdapterMain(this);
        adapterMain.setListener(this);
        binding.recyclerview.setAdapter(adapterMain);
        binding.recyclerview.setLayoutManager(new GridLayoutManager(this, 1));
    }


    @Override
    public void onClickItem(int type, String dir) {
        switch (type) {
            case 0:
                Intent intent = new Intent(this, CategoryAllActivity.class);
                intent.putExtra(App.Key_ViewDir, dir);
                startActivity(intent);
                break;
            case 1:
                Intent intent1 = new Intent(this, CameraActivity.class);
                intent1.putExtra(App.Key_Camera, dir);
                startActivity(intent1);
                break;
        }
    }

    @Override
    public void onClick(View v) {
        if(v.equals(binding.rlUpload)){
            Intent intent = new Intent(this, UploadActivity.class);
            startActivity(intent);
        }else if(v.equals(binding.rlLike)){
            Intent intent = new Intent(this, AddLikeActivity.class);
            startActivity(intent);
        }
    }
}