// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static int loadSimpleExpeditionInfoFromStorage(Context context) {
//     JsonArray data = getJsonArrayFromStorage(context, "expedition.json");
//     if (data != null) {
//         for (JsonElement item : data) {
//             JsonObject expdata = item.getAsJsonObject();
//             kcExpeditionData.add(expdata.get("no").getAsString(), expdata);
//         }
//         return 1;
//     } else {
//         return -1;
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
//     loadTranslationData(context, false);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
// 
// 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 showDataLoadErrorToast(Context ac, Context bc, String text) {
//     if (getBooleanPreferences(ac, PREF_DATALOAD_ERROR_FLAG)) {
//         KcaCustomToast customToast = new KcaCustomToast(ac);
//         showCustomToast(ac, bc, customToast, text, Toast.LENGTH_LONG, ContextCompat.getColor(ac, R.color.colorHeavyDmgStatePanel));
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/LocaleUtils.java
// public static String getResourceLocaleCode(String pref) {
//     String locale = getLocaleCode(pref);
//     if (locale.equals("es")) locale = "en";
//     return locale;
// }


import android.content.Intent;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import java.util.Locale;
import static android.widget.Toast.makeText;
import static com.antest1.kcanotify.KcaApiData.loadSimpleExpeditionInfoFromStorage;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.showDataLoadErrorToast;
import static com.antest1.kcanotify.LocaleUtils.getResourceLocaleCode;
        loadTranslationData(getApplicationContext());
        loadSimpleExpeditionInfoFromStorage(getApplicationContext());

        AssetManager assetManager = getAssets();

        String locale = getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE);
        adapter = new KcaExpeditionTableViewAdpater(getApplicationContext(), getBaseContext(), getResourceLocaleCode(locale));

        for (int i = 0; i <= 7; i++) {
            final int target = i;
            TextView w_btn = findViewById(getId(KcaUtils.format("btn_w%d", i), R.id.class));
            w_btn.setOnClickListener(view -> {
                world_idx = target;
                adapter.setListViewItemList(expeditionData, world_idx);
                listview = findViewById(R.id.expeditiontable_listiview);
                listview.setAdapter(adapter);
            });
        }

        greatscbtn = findViewById(R.id.btn_success_type);
        setGsButtonStyle(greatscbtn);
        greatscbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TextView tv = (TextView) view;
                is_great_success = !is_great_success;
                setGsButtonStyle(tv);
                adapter.setGreatSuccess(is_great_success);
                adapter.notifyDataSetChanged();
            }
// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static int loadSimpleExpeditionInfoFromStorage(Context context) {
//     JsonArray data = getJsonArrayFromStorage(context, "expedition.json");
//     if (data != null) {
//         for (JsonElement item : data) {
//             JsonObject expdata = item.getAsJsonObject();
//             kcExpeditionData.add(expdata.get("no").getAsString(), expdata);
//         }
//         return 1;
//     } else {
//         return -1;
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
//     loadTranslationData(context, false);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
// 
// 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 showDataLoadErrorToast(Context ac, Context bc, String text) {
//     if (getBooleanPreferences(ac, PREF_DATALOAD_ERROR_FLAG)) {
//         KcaCustomToast customToast = new KcaCustomToast(ac);
//         showCustomToast(ac, bc, customToast, text, Toast.LENGTH_LONG, ContextCompat.getColor(ac, R.color.colorHeavyDmgStatePanel));
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/LocaleUtils.java
// public static String getResourceLocaleCode(String pref) {
//     String locale = getLocaleCode(pref);
//     if (locale.equals("es")) locale = "en";
//     return locale;
// }


// Path: app/src/main/java/com/antest1/kcanotify/ExpeditionTableActivity.java
import android.content.Intent;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import java.util.Locale;
import static android.widget.Toast.makeText;
import static com.antest1.kcanotify.KcaApiData.loadSimpleExpeditionInfoFromStorage;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.showDataLoadErrorToast;
import static com.antest1.kcanotify.LocaleUtils.getResourceLocaleCode;

        loadTranslationData(getApplicationContext());
        loadSimpleExpeditionInfoFromStorage(getApplicationContext());

        AssetManager assetManager = getAssets();

        String locale = getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE);
        adapter = new KcaExpeditionTableViewAdpater(getApplicationContext(), getBaseContext(), getResourceLocaleCode(locale));

        for (int i = 0; i <= 7; i++) {
            final int target = i;
            TextView w_btn = findViewById(getId(KcaUtils.format("btn_w%d", i), R.id.class));
            w_btn.setOnClickListener(view -> {
                world_idx = target;
                adapter.setListViewItemList(expeditionData, world_idx);
                listview = findViewById(R.id.expeditiontable_listiview);
                listview.setAdapter(adapter);
            });
        }

        greatscbtn = findViewById(R.id.btn_success_type);
        setGsButtonStyle(greatscbtn);
        greatscbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TextView tv = (TextView) view;
                is_great_success = !is_great_success;
                setGsButtonStyle(tv);
                adapter.setGreatSuccess(is_great_success);
                adapter.notifyDataSetChanged();
            }
        });