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;
                int tais = itemobj.getAsJsonObject().get("tais").getAsInt();
                if (KcaApiData.isItemAircraft(type_t2) || type_t2 == T2_AUTOGYRO || type_t2 == T2_ANTISUB_PATROL) plane_tais_value += tais;

                if (type_t2 == T2_GUN_MEDIUM || type_t2 == T2_GUN_LARGE || type_t2 == T2_GUN_LARGE_II) {
                    total_firepower += Math.sqrt(level);
                } else if (type_t2 == T2_GUN_SMALL) {
                    total_firepower += 0.5 * Math.sqrt(level);
                } else if (type_t2 == T2_SUB_GUN) {
                    total_firepower += 0.15 * Math.sqrt(level);
                }

                if (type_t2 == T2_SONAR || type_t2 == T2_SONAR_LARGE || type_t2 == T2_DEPTH_CHARGE ) {
                    total_asw_bonus += Math.sqrt(level);
                }

                switch (slotitem_id) {
                    case 75:
                        drum_count += 1;
                        break;
                    case 68:
                        bonus_level += level;
                        bonus_count += 1.0;
                        daihatsu_count += 1;
                        break;
                    case 166:
                        bonus_level += level;
                        bonus_count += 1.0;
                        tank_count += 1;
                        break;
                    case 167:
                        bonus_level += level;
                        bonus_count += 1.0;
                        amp_count += 1;
                        break;
                    case 193:
                        bonus_level += level;
                        bonus_count += 1.0;
                        toku_count += 1;
                        break;
                    default:
                        break;
                }
            }
        }
        if (bonus_count > 0) bonus_level /= bonus_count;

        result.addProperty("kinu", kinu_exist);
        result.addProperty("drum", drum_count);
        result.addProperty("daihatsu", daihatsu_count);
        result.addProperty("tank", tank_count);
        result.addProperty("amp", amp_count);
        result.addProperty("toku", toku_count);
        result.addProperty("level", bonus_level);
        result.addProperty("firepower", (int) total_firepower);
        result.addProperty("asw", Math.floor(total_asw_value - plane_tais_value + total_asw_bonus * 2 / 3) );
        result.addProperty("los", total_los);
        return result;
    }

    private int calculateBonusValue(int value, JsonObject bonus_info, boolean is_gs) {
        int kinu_count = bonus_info.get("kinu").getAsBoolean() ? 1 : 0;
        int daihatsu_count = bonus_info.get("daihatsu").getAsInt();
        int tank_count = bonus_info.get("tank").getAsInt();
        int amp_count = bonus_info.get("amp").getAsInt();
        int toku_count = bonus_info.get("toku").getAsInt();
        double bonus_level = bonus_info.get("level").getAsDouble();

        int dlc_count = kinu_count + daihatsu_count + toku_count;
        int ntoku_count = Math.min(4, daihatsu_count + tank_count + amp_count);
        double bonus_default = Math.min(dlc_count * 0.05 + tank_count * 0.02 + amp_count * 0.01, 0.2);
        bonus_default += 0.002 * bonus_level;
        double bonus_toku = 0.0;
        if (toku_count > 0) {
            int toku_idx;
            if (toku_count > 4) toku_idx = 3;
            else toku_idx = toku_count - 1;
            bonus_toku = toku_bonus[toku_idx][ntoku_count] * 0.01;
        }

        int value_bonus = 0;
        if (is_gs) {
            value_bonus = (int)(value * 3 * (1 + bonus_default) / 2) + (int)(value * 3 * bonus_toku / 2);
        } else {
            value_bonus = (int)(value * (1 + bonus_default)) + (int)(value * bonus_toku);
        }
        return value_bonus;
    }

    private void setItemViewVisibilityById(int id, boolean visible) {
        int visible_value = visible ? View.VISIBLE : View.GONE;
        itemView.findViewById(id).setVisibility(visible_value);
    }

    private void setItemTextViewById(int id, String value) {
        ((TextView) itemView.findViewById(id)).setText(value);
    }

    private void setItemTextViewColorById(int id, boolean value, boolean is_option) {
        if (value) {
            ((TextView) itemView.findViewById(id)).setTextColor(ContextCompat
                    .getColor(getApplicationContext(), R.color.colorExpeditionBtnGoodBack));
        } else if (is_option) {
            ((TextView) itemView.findViewById(id)).setTextColor(ContextCompat
                    .getColor(getApplicationContext(), R.color.grey));
        } else {
            ((TextView) itemView.findViewById(id)).setTextColor(ContextCompat
                    .getColor(getApplicationContext(), R.color.colorExpeditionBtnFailBack));
        }
    }


    private String convertTotalCond(String str) {
        String[] ship_count = str.split("\\-");
        String ship_concat;
        if (ship_count[0].equals("7,11,16,18")) {
            ship_concat = getStringWithLocale(R.string.excheckview_ship_cvs);
        } else {
            String[] ship = ship_count[0].split(",");
            List<String> ship_list = new ArrayList<>();
            for (String s : ship) {
                ship_list.add(getShipTypeAbbr(Integer.parseInt(s)));