From f88c3087f0e192b82b560db8d44423a2d46b4773 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 22 一月 2025 16:53:55 +0800
Subject: [PATCH] 2025年01月22日16:53:53
---
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