public static final int STYPE_CVE = 27; public static final int T2_ANTISUB_PATROL = 26; public static final int T2_AUTOGYRO = 25; public static final int T2_DEPTH_CHARGE = 15; // 폭뢰 public static final int T2_GUN_LARGE = 3; public static final int T2_GUN_LARGE_II = 38; public static final int T2_GUN_MEDIUM = 2; public static final int T2_GUN_SMALL = 1; public static final int T2_RADAR_LARGE = 13; public static final int T2_RADAR_SMALL = 12; public static final int T2_RADER_LARGE_II = 93; public static final int T2_SONAR = 14; public static final int T2_SONAR_LARGE = 40; public static final int T2_SUB_GUN = 4; public static boolean checkUserShipDataLoaded() {
    return userShipData != null && userShipData.size() > 0;
} public static JsonObject getKcShipDataById(int id, String list) {
    if (kcGameData == null) return null;
    JsonObject temp = new JsonObject();
    if (kcShipData.containsKey(id)) {
        if (list.equals("all")) {
            return kcShipData.get(id);
        } else {
            String[] requestList = list.split(",");
            for (int i = 0; i < requestList.length; i++) {
                String orig_api_item = requestList[i];
                String api_item = orig_api_item;
                if (!api_item.startsWith("api_")) {
                    api_item = "api_" + api_item;
                }
                temp.add(orig_api_item, kcShipData.get(id).get(api_item));
            }
            return temp;
        }
    } else {
        Log.e("KCA", String.valueOf(id) + " not in list");
        return null;
    }
} public static String getShipTypeAbbr(int idx) {
    if (kcStypeData != null && idx < kcStypeData.size()) {
        return kcStypeData.get(idx).getAsString();
    } else {
        return "";
    }
} public static JsonObject getUserItemStatusById(int id, String list, String kclist) {
    if (helper == null || kcGameData == null) return null;
    String data = helper.getItemValue(id);
    if (data != null) {
        JsonObject userData = new JsonParser().parse(data).getAsJsonObject();
        int kc_item_id = userData.get("api_slotitem_id").getAsInt();
        JsonObject kcData = getKcItemStatusById(kc_item_id, kclist);

        if (list.equals("all")) {
            for (Map.Entry<String, JsonElement> k : userData.entrySet()) {
                kcData.add(k.getKey(), userData.get(k.getKey()));
            }
        } else {
            String[] requestList = list.split(",");
            for (int i = 0; i < requestList.length; i++) {
                String orig_api_item = requestList[i];
                String api_item = orig_api_item;
                if (!api_item.startsWith("api_")) {
                    api_item = "api_" + api_item;
                }
                if (userData.has(api_item)) {
                    kcData.add(orig_api_item, userData.get(api_item));
                }
            }
        }
        kcData.remove("");
        return kcData;
    } else {
        return null;
    }
} public static JsonObject getUserShipDataById(int id, String list) {
    JsonObject target_data = null;
    JsonObject return_data = new JsonObject();
    if (userShipData != null) {
        if (userShipData.containsKey(id)) {
            target_data = userShipData.get(id);
        }
    } else if (helper.getShipCount() > 0) {
        JsonArray data = helper.getJsonArrayValue(DB_KEY_SHIPIFNO);
        for (int i = 0; i < data.size(); i++) {
            JsonObject item = data.get(i).getAsJsonObject();
            int aid = item.get("api_id").getAsInt();
            if (aid == id) {
                target_data = item;
                break;
            }
        }
    }

    if (target_data != null) {
        if (list.equals("all")) {
            return target_data;
        } else {
            String[] requestList = list.split(",");
            for (String orig_api_item: requestList) {
                String api_item = orig_api_item;
                if (!api_item.startsWith("api_")) {
                    api_item = "api_" + api_item;
                }
                if (target_data.has(api_item)) {
                    return_data.add(orig_api_item, target_data.get(api_item));
                }
            }
        }
    }
    return return_data;
} public static final String DB_KEY_DECKPORT = "key_deckport"; public static final int KCANOTIFY_DB_VERSION = 5; public static final String PREF_KCA_LANGUAGE = "kca_language"; public static String getExpeditionHeader(int mission_no) {
    String mission_no_head = "";
    String mission_no_value = getExpeditionStr(mission_no);
    if (mission_no_value.matches("[A-Z][0-9]+")) {
        mission_no_head = "[".concat(mission_no_value).concat("] ");
    } else {
        mission_no_head = KcaUtils.format("[%02d] ", mission_no);
    }
    return mission_no_head;
} 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);
    }
} public static String getStringFromException(Exception ex) {
    StringWriter errors = new StringWriter();
    ex.printStackTrace(new PrintWriter(errors));
    return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
} public static String getTimeStr(int left_time, boolean is_min) {
    int sec, min, hour;
    sec = left_time;
    min = sec / 60;
    hour = min / 60;
    sec = sec % 60;
    min = min % 60;
    if (is_min) return KcaUtils.format("%02d:%02d", hour * 60 + min, sec);
    else return KcaUtils.format("%02d:%02d:%02d", hour, min, sec);
} public static int getWindowLayoutType() {
    int windowLayoutType = -1;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
    } else {
        windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
    }
    return windowLayoutType;
} public static String joinStr(List<String> list, String delim) {
    String resultStr = "";
    if (list.size() > 0) {
        int i;
        for (i = 0; i < list.size() - 1; i++) {
            resultStr = resultStr.concat(list.get(i));
            resultStr = resultStr.concat(delim);
        }
        resultStr = resultStr.concat(list.get(i));
    }
    return resultStr;
}
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.antest1.kcanotify.KcaApiData.STYPE_CVE;
import static com.antest1.kcanotify.KcaApiData.T2_ANTISUB_PATROL;
import static com.antest1.kcanotify.KcaApiData.T2_AUTOGYRO;
import static com.antest1.kcanotify.KcaApiData.T2_DEPTH_CHARGE;
import static com.antest1.kcanotify.KcaApiData.T2_GUN_LARGE;
import static com.antest1.kcanotify.KcaApiData.T2_GUN_LARGE_II;
import static com.antest1.kcanotify.KcaApiData.T2_GUN_MEDIUM;
import static com.antest1.kcanotify.KcaApiData.T2_GUN_SMALL;
import static com.antest1.kcanotify.KcaApiData.T2_RADAR_LARGE;
import static com.antest1.kcanotify.KcaApiData.T2_RADAR_SMALL;
import static com.antest1.kcanotify.KcaApiData.T2_RADER_LARGE_II;
import static com.antest1.kcanotify.KcaApiData.T2_SONAR;
import static com.antest1.kcanotify.KcaApiData.T2_SONAR_LARGE;
import static com.antest1.kcanotify.KcaApiData.T2_SUB_GUN;
import static com.antest1.kcanotify.KcaApiData.checkUserShipDataLoaded;
import static com.antest1.kcanotify.KcaApiData.getKcShipDataById;
import static com.antest1.kcanotify.KcaApiData.getShipTypeAbbr;
import static com.antest1.kcanotify.KcaApiData.getUserItemStatusById;
import static com.antest1.kcanotify.KcaApiData.getUserShipDataById;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_DECKPORT;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaExpedition2.getExpeditionHeader;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.getTimeStr;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
import static com.antest1.kcanotify.KcaUtils.joinStr;

        setItemViewVisibilityById(R.id.view_excheck_firepower, has_total_firepower);
        if (has_total_firepower) {
            int total_firepower = data.get("total-firepower").getAsInt();
            setItemTextViewById(R.id.view_excheck_total_firepower,
                    KcaUtils.format(getStringWithLocale(R.string.excheckview_total_format), total_firepower));
            setItemTextViewColorById(R.id.view_excheck_total_firepower,
                    check.get("total-firepower").getAsBoolean(), false);
        }

        itemView.setVisibility(View.VISIBLE);
    }

    public int setView() {
        try {
            expedition_data = KcaApiData.getExpeditionNumByWorld(world);
            JsonArray api_ship = deckdata.get(selected)
                    .getAsJsonObject().getAsJsonArray("api_ship");
            ship_data.clear();
            if (checkUserShipDataLoaded()) {
                for (int i = 0; i < api_ship.size(); i++) {
                    int id = api_ship.get(i).getAsInt();
                    if (id > 0) {
                        JsonObject data = new JsonObject();
                        JsonObject usershipinfo = getUserShipDataById(id, "ship_id,lv,slot,cond,karyoku,taisen,taiku,sakuteki");
                        JsonObject kcshipinfo = getKcShipDataById(usershipinfo.get("ship_id").getAsInt(), "stype");
                        data.addProperty("ship_id", usershipinfo.get("ship_id").getAsInt());
                        data.addProperty("lv", usershipinfo.get("lv").getAsInt());
                        data.addProperty("cond", usershipinfo.get("cond").getAsInt());
                        data.addProperty("stype", kcshipinfo.get("stype").getAsInt());
                        data.addProperty("karyoku", usershipinfo.getAsJsonArray("karyoku").get(0).getAsInt());
                        data.addProperty("taisen", usershipinfo.getAsJsonArray("taisen").get(0).getAsInt());
                        data.addProperty("taiku", usershipinfo.getAsJsonArray("taiku").get(0).getAsInt());
                        data.addProperty("sakuteki", usershipinfo.getAsJsonArray("sakuteki").get(0).getAsInt());
                        data.add("item", new JsonArray());
                        JsonArray shipslot = usershipinfo.getAsJsonArray("slot");
                        for (int j = 0; j < shipslot.size(); j++) {
                            int itemid = shipslot.get(j).getAsInt();
                            if (itemid > 0) {
                                JsonObject iteminfo = getUserItemStatusById(itemid, "slotitem_id,level", "type,tais");
                                if (iteminfo != null) data.getAsJsonArray("item").add(iteminfo);
                            }
                        }
                        ship_data.add(data);
                    }
                }

                checkdata = new HashMap<>();
                for (int i = 0; i < 15; i++) {
                    if (i < expedition_data.size()) {
                        int expd = expedition_data.get(i);
                        String key = String.valueOf(expd);
                        checkdata.put(key, checkCondition(expd));
                        JsonObject check_item = checkdata.get(key);
                        if (check_item != null) {
                            if (check_item.get("pass").getAsBoolean()) {
                                mView.findViewById(getId("expd_btn_".concat(String.valueOf(i)), R.id.class))
                                        .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorExpeditionBtnGoodBack));
                                ((TextView) mView.findViewById(getId("expd_btn_".concat(String.valueOf(i)), R.id.class)))
                                        .setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorExpeditionBtnGoodText));
                            } else {
                                mView.findViewById(getId("expd_btn_".concat(String.valueOf(i)), R.id.class))
                                        .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorExpeditionBtnFailBack));
                                ((TextView) mView.findViewById(getId("expd_btn_".concat(String.valueOf(i)), R.id.class)))
                                        .setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorExpeditionBtnFailText));
                            }
                        }
                    }
                }

                updateSelectedView(selected, world);

                JsonObject bonus_info = getBonusInfo();
                List<String> bonus_info_text = new ArrayList<>();

                int total_firepower = bonus_info.get("firepower").getAsInt();
                bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_firepower), total_firepower));

                int total_asw = bonus_info.get("asw").getAsInt();
                bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_asw), total_asw));

                int total_los = bonus_info.get("los").getAsInt();
                bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_los), total_los));

                int drum_count = bonus_info.get("drum").getAsInt();
                if (drum_count > 0) {
                    bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_drum), drum_count));
                } else {
                    bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_drum), 0));
                }
                if (bonus_info.get("kinu").getAsBoolean())
                    bonus_info_text.add(getStringWithLocale(R.string.excheckview_bonus_kinu));
                int daihatsu_count = bonus_info.get("daihatsu").getAsInt();
                if (daihatsu_count > 0)
                    bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_dlc), daihatsu_count));
                int tank_count = bonus_info.get("tank").getAsInt();
                if (tank_count > 0)
                    bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_tank), tank_count));
                int amp_count = bonus_info.get("amp").getAsInt();
                if (amp_count > 0)
                    bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_amp), amp_count));
                int toku_count = bonus_info.get("toku").getAsInt();
                if (toku_count > 0)
                    bonus_info_text.add(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_toku), toku_count));
                String bonus_info_content = joinStr(bonus_info_text, " / ");
                double bonus_value = (double) calculateBonusValue(100, bonus_info, false);
                if (bonus_value > 100.0) {
                    bonus_info_content = bonus_info_content.concat(KcaUtils.format(getStringWithLocale(R.string.excheckview_bonus_result), bonus_value - 100.0));
                }
                ((TextView) mView.findViewById(R.id.excheck_info)).setText(bonus_info_content);
                mView.findViewById(R.id.excheck_info).setBackgroundColor(
                        ContextCompat.getColor(getApplicationContext(), R.color.colorFleetInfoExpedition));
                setItemViewLayout(button, bonus_info);
            } else {
                ((TextView) mView.findViewById(R.id.excheck_info)).setText(getStringWithLocale(R.string.kca_init_content));
                mView.findViewById(R.id.excheck_info).setBackgroundColor(
                        ContextCompat.getColor(getApplicationContext(), R.color.colorFleetInfoNoShip));
            }
            return 0;
        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), getStringFromException(e), Toast.LENGTH_LONG).show();