package com.xplora.xpsettings.Activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.ListView;

import androidx.annotation.NonNull;

import com.xplora.xpsettings.Adapter.BaseListAdapter;
import com.xplora.xpsettings.Data.DataManager;
import com.xplora.xpsettings.Model.BaseModel;
import com.xplora.xpsettings.R;
import com.xplora.xpsettings.Utils.Constant;
import com.xplora.xpsettings.Utils.ResUtils;

public class VoLTEActivity extends BaseActionActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);

        initData();
        initView();
    }

    private void initData() {
        String[] stringList = ResUtils.getStringArray("connections_title_array_", 4);
        BaseModel model = new BaseModel();
        model.title = stringList[3].trim();
        model.isOn = DataManager.getVoLTE() == 1;
        model.cellType = Constant.CellType.SWITCH;
        mDataList.add(model);
    }

    private void initView() {
        mAdapter = new BaseListAdapter(VoLTEActivity.this, R.layout.item_xpstyle, mDataList, mHandler);
        ListView listView = findViewById(R.id.activity_listview);
        listView.setAdapter(mAdapter);
    }

    Handler mHandler = new Handler(Looper.myLooper()) {
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);
            if (msg.what == Constant.MSG_SWITCH_CHANGE) {
                int index = msg.arg1;
                int isOn = msg.arg2;
                DataManager.setVoLET(isOn);
            }
        }
    };
}
