package com.example.blu.toys.activity;

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

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

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.clj.fastble.data.BleDevice;
import com.example.blu.toys.R;
import com.example.blu.toys.adapter.BleDeviceAdapter;
import com.example.blu.toys.adapter.MusicAdapter;
import com.example.blu.toys.utils.SpUtils;

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

import butterknife.BindView;

public class SettingMusicActivity extends BaseActivity {


	@BindView(R.id.recyclerView)
	RecyclerView mRecyclerView;

	MusicAdapter musicAdapter;
	private List<Integer> integerList;
	private SpUtils spUtils;

	@Override
	public int getLayout() {
		return R.layout.activity_setting_music;
	}

	@Override
	public void init(Bundle savedInstanceState) {
		spUtils = SpUtils.getSpUtils(SettingMusicActivity.this);
		Intent intent = getIntent();
		String musicType = intent.getStringExtra("musicType");
		integerList = new ArrayList<>();
		for (int i = 0; i < 20; i++) {
			integerList.add(i);
		}
		mRecyclerView.setLayoutManager(getLinearLayout());
		musicAdapter = new MusicAdapter(R.layout.ble_devices_item, integerList, musicType);
		mRecyclerView.setAdapter(musicAdapter);
		musicAdapter.setOnItemClickListener((adapter, view, position) -> {
			Integer integer = integerList.get(position);
			if (musicType.equals("close")) {
				spUtils.putSPValue("close", integer);
			} else {
				spUtils.putSPValue("open", integer);
			}
		});
	}

	@Override
	public void initData() {

	}
}