From f10cda784bede39a861566850898747c38e6c94f Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期二, 21 一月 2025 15:32:54 +0800 Subject: [PATCH] 2025年01月21日15:31:52 --- countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java | 33 ++++++++++++++++++++------------- 1 files changed, 20 insertions(+), 13 deletions(-) diff --git a/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java b/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java index a4d9f4b..cd57984 100644 --- a/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java +++ b/countrypicker/src/main/java/com/sahooz/library/countrypicker/Country.java @@ -1,6 +1,7 @@ package com.sahooz.library.countrypicker; import android.content.Context; + import androidx.annotation.NonNull; import android.text.TextUtils; @@ -50,12 +51,12 @@ '}'; } - public static ArrayList<Country> getAll(){ + public static ArrayList<Country> getAll() { return new ArrayList<>(countries); } - public static Country fromJson(String json){ - if(TextUtils.isEmpty(json)) return null; + public static Country fromJson(String json) { + if (TextUtils.isEmpty(json)) return null; try { JSONObject jo = new JSONObject(json); return new Country( @@ -99,25 +100,30 @@ JSONArray ja = new JSONArray(sb.toString()); for (int i = 0; i < ja.length(); i++) { JSONObject jo = ja.getJSONObject(i); + if (jo.getInt("code") == 886) { + //杩囨护鎺夊彴婀剧渷 + continue; + } int flag = 0; String translate = ""; String locale = jo.getString("locale"); - if(!TextUtils.isEmpty(locale)) { + if (!TextUtils.isEmpty(locale)) { flag = ctx.getResources().getIdentifier("flag_" + locale.toLowerCase(), "drawable", ctx.getPackageName()); translate = ctx.getString(ctx.getResources().getIdentifier("name_" + locale.toLowerCase(), "string", ctx.getPackageName())); } String name = jo.getString("name"); Locale defaultLoc = Locale.getDefault(); boolean inChina = "zh".equalsIgnoreCase(defaultLoc.getLanguage()); + countries.add( - new Country( - jo.getInt("code"), - name, - translate, - inChina ? jo.getString("pinyin") : name, - locale, - flag - ) + new Country( + jo.getInt("code"), + name, + translate, + inChina ? jo.getString("pinyin") : name, + locale, + flag + ) ); } @@ -133,7 +139,8 @@ return code; } - @NonNull @Override + @NonNull + @Override public String getPinyin() { return pinyin; } -- Gitblit v1.8.0