// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static final int T3_COUNT = 49;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_EQUIPINFO_FILTCOND = "equipinfo_filtcond";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
//     try {
//         Field idField = c.getDeclaredField(resourceName);
//         return idField.getInt(idField);
//     } catch (Exception e) {
//         throw new RuntimeException("No resource ID found for: "
//                 + resourceName + " / " + c, e);
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     try {
//         return String.valueOf(pref.getInt(key, 0));
//     } catch (Exception e) {
//         // Nothing to do
//     }
//     return pref.getString(key, "");
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     SharedPreferences.Editor editor = pref.edit();
//     if (value instanceof String) {
//         editor.putString(key, (String) value);
//     } else if (value instanceof Boolean) {
//         editor.putBoolean(key, (Boolean) value);
//     } else if (value instanceof Integer) {
//         editor.putString(key, String.valueOf(value));
//     } else {
//         editor.putString(key, value.toString());
//     }
//     editor.commit();
// }


import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.T3_COUNT;
import static com.antest1.kcanotify.KcaConstants.PREF_EQUIPINFO_FILTCOND;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
                adapter.unselectAll();
            } else if (view.getId() == btnReverse.getId()) {
                adapter.reverseSelect();
            }
            gv.invalidateViews();
        }
    };

    private void setValueAndFinish() {
        setPreferences(getApplicationContext(), PREF_EQUIPINFO_FILTCOND, adapter.getPreference());
        Intent intent = new Intent();
        setResult(RESULT_OK, intent);
        finish();
    }

    @Override
    public void onBackPressed() { setValueAndFinish(); }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                setValueAndFinish();
                return true;
            default:
// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static final int T3_COUNT = 49;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_EQUIPINFO_FILTCOND = "equipinfo_filtcond";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
//     try {
//         Field idField = c.getDeclaredField(resourceName);
//         return idField.getInt(idField);
//     } catch (Exception e) {
//         throw new RuntimeException("No resource ID found for: "
//                 + resourceName + " / " + c, e);
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     try {
//         return String.valueOf(pref.getInt(key, 0));
//     } catch (Exception e) {
//         // Nothing to do
//     }
//     return pref.getString(key, "");
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     SharedPreferences.Editor editor = pref.edit();
//     if (value instanceof String) {
//         editor.putString(key, (String) value);
//     } else if (value instanceof Boolean) {
//         editor.putBoolean(key, (Boolean) value);
//     } else if (value instanceof Integer) {
//         editor.putString(key, String.valueOf(value));
//     } else {
//         editor.putString(key, value.toString());
//     }
//     editor.commit();
// }


// Path: app/src/main/java/com/antest1/kcanotify/EquipmentListFilterActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import static com.antest1.kcanotify.KcaApiData.T3_COUNT;
import static com.antest1.kcanotify.KcaConstants.PREF_EQUIPINFO_FILTCOND;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;

                adapter.unselectAll();
            } else if (view.getId() == btnReverse.getId()) {
                adapter.reverseSelect();
            }
            gv.invalidateViews();
        }
    };

    private void setValueAndFinish() {
        setPreferences(getApplicationContext(), PREF_EQUIPINFO_FILTCOND, adapter.getPreference());
        Intent intent = new Intent();
        setResult(RESULT_OK, intent);
        finish();
    }

    @Override
    public void onBackPressed() { setValueAndFinish(); }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                setValueAndFinish();
                return true;
            default:
                return super.onOptionsItemSelected(item);