package com.xplora.xpsettings.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.xplora.xpsettings.Adapter.BaseListAdapter;
import com.xplora.xpsettings.Data.DataManager;
import com.xplora.xpsettings.Model.ApnModel;
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 ApnDeleteActivity extends BaseActivity {
    public int mIndex = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_action);
        initData();
        initView();
    }

    private void initData() {
        mIndex = getIntent().getIntExtra(Constant.INENT_LIST_INDEX, 0);
    }

    private void initView() {
        TextView textView = findViewById(R.id.text_content);
        Button cancelButton = findViewById(R.id.button_cancel);
        Button sureButton = findViewById(R.id.button_sure);

        if (textView != null) {
            textView.setText(R.string.apn_delete_content);
        }

        if (cancelButton != null) {
            cancelButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    clickCancelButton();
                }
            });
        }
        if (sureButton != null) {
            sureButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    clickSureButton();
                }
            });
        }
    }

    public void clickCancelButton() {
        Intent intent = new Intent();
        intent.setAction(Constant.INENT_RESULT_ACTION_CANCEL);
        setResult(RESULT_OK, intent);
        finish();
    }

    public void clickSureButton() {
        Intent intent = new Intent();
        intent.setAction(Constant.INENT_RESULT_ACTION_REMOVE);
        intent.putExtra(Constant.INENT_RESULT_VALUE, mIndex);
        setResult(RESULT_OK, intent);
        finish();
    }
}
