package com.hyperling.carbupbeta;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

/**
 * Created by ling on 1/1/16.
 */
public class MySettings extends Activity {

    private DALIH dalih;

    Context context;

    LinearLayout settingsArea;
    MySettingItem quickLoad, rainbowLists, whiteOnBlack;

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

        // Set default context
        context = this;

        // Get DALIH ready to go!
        dalih = new DALIH(context);

        // Find the layout
        settingsArea = (LinearLayout) findViewById(R.id.settingsArea);

        // Instantiate settings
        quickLoad = new MySettingItem(context, new MySettingInfo());

        // Name them
        quickLoad.setName("Quick Load:");

        // Set the checkboxes
        dalih.open();
        quickLoad.setEnabled(dalih.getQuickLoad());
        dalih.close();

        // Set the checkbox actions
        quickLoad.btnItem.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dalih.setQuickLoad(!dalih.getQuickLoad());
                quickLoad.checkBox.setChecked(dalih.getQuickLoad());
            }
        });
        quickLoad.checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dalih.setQuickLoad(quickLoad.checkBox.isChecked());
            }
        });

        // Throw them onto the screen
        settingsArea.addView(quickLoad.getView());
    }

    @Override
    protected void onResume() {
        dalih.open();
        super.onResume();
    }

    @Override
    protected void onPause() {
        dalih.close();
        super.onPause();
    }
}
