Skip to content

Commit 54fec8d

Browse files
committed
Merge branch 'develop'
2 parents 3bcf36c + daa5578 commit 54fec8d

File tree

8 files changed

+41
-15
lines changed

8 files changed

+41
-15
lines changed

app/src/main/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:supportsRtl="true"
1212
android:theme="@style/AppTheme" >
13-
<activity android:name=".MainActivity" >
13+
<activity android:name=".MainActivity" android:windowSoftInputMode="adjustPan">
1414
<intent-filter>
1515
<action android:name="android.intent.action.MAIN"/>
1616

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 "1.0"
13+
versionName "0.2.0"
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}
1616

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

+3
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
interface BaseView {
66

77
void showView(View view);
8+
9+
void dismissView();
10+
811
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public void showView(View view) {
3636
this.show(mActivityCompat.getSupportFragmentManager(), "bottomsheet");
3737
}
3838

39+
@Override
40+
public void dismissView() {
41+
42+
this.dismiss();
43+
}
44+
45+
3946
public void setActivity(AppCompatActivity appCompatActivity) {
4047

4148
mActivityCompat = appCompatActivity;

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public interface OnAutoDetectCountryListener {
4646
private SearchView mSearchViewCountry;
4747
private int mStyle;
4848
private DetectionMethod mDetectionMethod = DetectionMethod.NONE;
49-
49+
private BaseView mBaseView;
5050
private RecyclerViewAdapter.OnCountryClickListener mOnCountryClickListener;
5151
private OnAutoDetectCountryListener mOnAutoDetectCountryListener;
5252
private View mView;
@@ -114,10 +114,14 @@ private void initView() {
114114
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
115115
mView = layoutInflater.inflate(R.layout.layout_countrypicker, null);
116116
mRecyclerView = mView.findViewById(R.id.recyclerview_countries);
117+
117118
mRecyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
118119
RecyclerViewAdapter recyclerViewAdapter = new RecyclerViewAdapter(mCountries, mPreSelectedCountry, mShowingFlag, mShowingDialCode);
119120
if (mOnCountryClickListener != null)
120-
recyclerViewAdapter.setListener(mOnCountryClickListener);
121+
recyclerViewAdapter.setListener(country -> {
122+
mOnCountryClickListener.onCountrySelected(country);
123+
dismiss();
124+
});
121125
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
122126
mRecyclerView.setHasFixedSize(true);
123127
mRecyclerView.setAdapter(recyclerViewAdapter);
@@ -236,8 +240,14 @@ private void detectByNetwork() {
236240

237241
public void show(AppCompatActivity activity) {
238242

239-
BaseView baseView = ViewFactory.create(mViewType, activity);
240-
baseView.showView(mView);
243+
mBaseView = ViewFactory.create(mViewType, activity);
244+
mBaseView.showView(mView);
245+
246+
}
247+
248+
public void dismiss() {
249+
250+
mBaseView.dismissView();
241251
}
242252

243253
@Override

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

+6
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ public void showView(View view) {
1818
this.setContentView(view);
1919
show();
2020
}
21+
22+
@Override
23+
public void dismissView() {
24+
25+
this.dismiss();
26+
}
2127
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapte
1818

1919
public interface OnCountryClickListener {
2020
void onCountrySelected(Country country);
21-
2221
}
2322

2423
private List<Country> mCountryList;
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/rootView"
4-
android:layout_width="match_parent"
5-
android:layout_height="match_parent"
6-
android:orientation="vertical">
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:id="@+id/rootView"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
76

87
<androidx.appcompat.widget.SearchView
98
android:id="@+id/searchview_country"
109
android:layout_width="match_parent"
11-
android:layout_height="wrap_content"/>
10+
android:layout_height="wrap_content"
11+
android:layout_alignParentTop="true"/>
1212

1313
<androidx.recyclerview.widget.RecyclerView
1414
android:id="@+id/recyclerview_countries"
1515
android:layout_width="match_parent"
16-
android:layout_height="match_parent"/>
16+
android:layout_height="match_parent"
17+
android:layout_below="@id/searchview_country"/>
1718

18-
</LinearLayout>
19+
</RelativeLayout>

0 commit comments

Comments
 (0)