Skip to content

Commit 6064e62

Browse files
committed
Merge branch 'develop'
2 parents 54fec8d + 795ff94 commit 6064e62

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

library/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
minSdkVersion 17
1111
targetSdkVersion 28
1212
versionCode 1
13-
versionName "0.2.0"
13+
versionName "0.3.0"
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}
1616

library/src/main/java/com/ehsanmashhadi/library/view/CountryPicker.java

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ public List<Country> getCountries() {
137137
private void initSearchView() {
138138

139139
mSearchViewCountry = mView.findViewById(R.id.searchview_country);
140+
mSearchViewCountry.setOnClickListener(v -> mSearchViewCountry.setIconified(false));
141+
140142
if (mEnablingSearch) {
141143
mSearchViewCountry.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
142144
@Override

library/src/main/java/com/ehsanmashhadi/library/view/RecyclerViewAdapter.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.ehsanmashhadi.library.view;
22

3+
import android.content.res.Resources;
4+
import android.util.TypedValue;
35
import android.view.LayoutInflater;
46
import android.view.View;
57
import android.view.ViewGroup;
@@ -11,6 +13,7 @@
1113

1214
import java.util.List;
1315

16+
import androidx.annotation.ColorInt;
1417
import androidx.annotation.NonNull;
1518
import androidx.recyclerview.widget.RecyclerView;
1619

@@ -45,6 +48,7 @@ void setListener(OnCountryClickListener onCountryClickListener) {
4548
public CountryHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
4649

4750
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_country, parent, false);
51+
4852
return new CountryHolder(itemView, position -> {
4953
mOnCountryClickListener.onCountrySelected(mCountryList.get(position));
5054
itemView.setSelected(true);
@@ -66,8 +70,20 @@ public void onBindViewHolder(@NonNull CountryHolder holder, int position) {
6670
if (sPreselectCountry != null)
6771
if (mCountryList.get(position).getName().toLowerCase().equals(sPreselectCountry.toLowerCase())) {
6872
holder.itemView.setSelected(true);
73+
//Not setting background in XML because of not supporting reference attributes in pre-lollipop Android version
74+
TypedValue typedValue = new TypedValue();
75+
Resources.Theme theme = holder.itemView.getContext().getTheme();
76+
theme.resolveAttribute(R.attr.rowBackgroundSelectedColor, typedValue, true);
77+
@ColorInt int color = typedValue.data;
78+
holder.itemView.setBackgroundColor(color);
79+
6980
} else {
7081
holder.itemView.setSelected(false);
82+
TypedValue typedValue = new TypedValue();
83+
Resources.Theme theme = holder.itemView.getContext().getTheme();
84+
theme.resolveAttribute(R.attr.rowBackgroundColor, typedValue, true);
85+
@ColorInt int color = typedValue.data;
86+
holder.itemView.setBackgroundColor(color);
7187
}
7288
if (sShowingFlag)
7389
holder.mImageViewFlag.setVisibility(View.VISIBLE);

library/src/main/res/drawable/row_color_states.xml

-15
This file was deleted.

library/src/main/res/layout/layout_countrypicker.xml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<androidx.recyclerview.widget.RecyclerView
1414
android:id="@+id/recyclerview_countries"
1515
android:layout_width="match_parent"
16+
android:background="?rowBackgroundColor"
1617
android:layout_height="match_parent"
1718
android:layout_below="@id/searchview_country"/>
1819

library/src/main/res/layout/row_country.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:id="@+id/relativelayout_rowcountry"
55
android:layout_width="match_parent"
66
android:layout_height="56dp"
7-
android:background="@drawable/row_color_states"
7+
android:background="?rowBackgroundColor"
88
android:gravity="center_vertical">
99

1010
<ImageView

0 commit comments

Comments
 (0)