From 7d56179afde21fd2730cda37da164af353f76623 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期五, 12 九月 2025 09:40:07 +0800
Subject: [PATCH] 2025年09月12日09:40:05
---
countrypicker/src/main/java/com/sahooz/library/countrypicker/Adapter.java | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/countrypicker/src/main/java/com/sahooz/library/countrypicker/Adapter.java b/countrypicker/src/main/java/com/sahooz/library/countrypicker/Adapter.java
index 9d4ab2b..78e7381 100644
--- a/countrypicker/src/main/java/com/sahooz/library/countrypicker/Adapter.java
+++ b/countrypicker/src/main/java/com/sahooz/library/countrypicker/Adapter.java
@@ -5,6 +5,7 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
+
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.ViewGroup;
@@ -17,6 +18,7 @@
private final LayoutInflater inflater;
private PickCountryCallback callback = null;
private final Context context;
+
public Adapter(Context ctx) {
inflater = LayoutInflater.from(ctx);
context = ctx;
@@ -25,6 +27,7 @@
public void setSelectedCountries(ArrayList<Country> selectedCountries) {
this.selectedCountries = selectedCountries;
notifyDataSetChanged();
+
}
public void setCallback(PickCountryCallback callback) {
@@ -38,8 +41,9 @@
}
private int itemHeight = -1;
+
public void setItemHeight(float dp) {
- itemHeight = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, dp, context.getResources().getDisplayMetrics());
+ itemHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, dp, context.getResources().getDisplayMetrics());
}
@SuppressLint("SetTextI18n")
@@ -49,13 +53,13 @@
holder.ivFlag.setImageResource(country.flag);
holder.tvName.setText(country.translate);
holder.tvCode.setText("+" + country.code);
- if(itemHeight != -1) {
+ if (itemHeight != -1) {
ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();
params.height = itemHeight;
holder.itemView.setLayoutParams(params);
}
holder.itemView.setOnClickListener(v -> {
- if(callback != null) callback.onPick(country);
+ if (callback != null) callback.onPick(country);
});
}
--
Gitblit v1.8.0