package com.xplora.xpsettings.Activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
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 java.util.ArrayList;
import java.util.List;

public class DataRoamingActivity extends BaseActivity {

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

        initData();
        initView();
    }

    private void initData() {
        String[] stringList = getResources().getStringArray(R.array.connections_title_array);
        BaseModel model = new BaseModel();
        model.title = stringList[2].trim();
        model.isOn = DataManager.getDataRoamingType() == 1;
        model.cellType = Constant.CellType.SWITCH;
        mDataList.add(model);
    }

    private void initView() {
        mAdapter = new BaseListAdapter(DataRoamingActivity.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_SWITCHC_CHANGE) {
                int index = msg.arg1;
                int isOn = msg.arg2;
                DataManager.setDataRoamingType(isOn);
            }
        }
    };
}
