Skip to content

Commit f990b64

Browse files
committed
相关操作隐藏键盘
1 parent 0860478 commit f990b64

File tree

4 files changed

+58
-16
lines changed

4 files changed

+58
-16
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
android:launchMode="singleTask"
217217
android:screenOrientation="portrait"
218218
android:configChanges="orientation|keyboardHidden"
219-
android:windowSoftInputMode="adjustPan|stateAlwaysVisible|adjustUnspecified|stateHidden"
219+
android:windowSoftInputMode="stateAlwaysVisible|adjustUnspecified|stateHidden"
220220
android:theme="@style/ActionbarSpannerTheme1" />
221221
<activity
222222
android:name=".LoginActivity_"

app/src/main/java/net/coding/program/MainActivity.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ public void onNavigationDrawerItemSelected(int position) {
347347
ViewCompat.setElevation(appbar, GlobalUnit.ACTIONBAR_SHADOW);
348348
}
349349

350+
taskOper(position);
350351
updateNotifyFromService();
351-
isOpenDrawerLayout(false);
352352
switch (position) {
353353
case 0://防止重复加载数据
354354
// fragment = new ProjectFragment_();
@@ -371,7 +371,6 @@ public void onNavigationDrawerItemSelected(int position) {
371371
case 1:
372372
// bottomBar.getTabWithId(R.id.tabProject).setBadgeCount(20);
373373
fragment = new TaskFragment_();
374-
isOpenDrawerLayout(true);
375374
break;
376375
case 2:
377376
// 进入冒泡页面,单独处理
@@ -423,6 +422,7 @@ public void onNavigationDrawerItemSelected(int position) {
423422
}
424423
}
425424

425+
426426
void visibleTitle(View title) {
427427
View[] titles = {
428428
toolbarTitle,
@@ -491,6 +491,15 @@ protected void onNewIntent(Intent intent) {
491491
super.onNewIntent(intent);
492492
}
493493

494+
/**
495+
* 任务列表特殊处理
496+
* 1.drawerLayout 手势
497+
* @param position
498+
*/
499+
private void taskOper(int position) {
500+
isOpenDrawerLayout(position == 2);
501+
}
502+
494503
private void isOpenDrawerLayout(boolean isOpen) {
495504
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
496505
if (drawer == null) return;

app/src/main/java/net/coding/program/common/DrawerLayoutHelper.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.support.v4.widget.DrawerLayout;
1212
import android.text.TextUtils;
1313
import android.view.LayoutInflater;
14+
import android.view.MotionEvent;
1415
import android.view.View;
1516
import android.view.inputmethod.EditorInfo;
1617
import android.widget.EditText;
@@ -59,8 +60,30 @@ public void initData(Context context, DrawerLayout drawerLayout, FilterModel fil
5960
green = mContext.getResources().getColor(R.color.green);
6061

6162
this.drawerLayout = drawerLayout;
63+
this.drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
64+
@Override
65+
public void onDrawerSlide(View drawerView, float slideOffset) {
66+
67+
}
68+
69+
@Override
70+
public void onDrawerOpened(View drawerView) {
71+
72+
}
6273

74+
@Override
75+
public void onDrawerClosed(View drawerView) {
76+
Global.hideSoftKeyboard((Activity) mContext);
77+
}
78+
79+
@Override
80+
public void onDrawerStateChanged(int newState) {
81+
82+
}
83+
});
6384
View reset = drawerLayout.findViewById(R.id.tv_reset);
85+
86+
6487
reset.setOnClickListener(v -> {
6588
if (filterListener != null) {
6689
filterListener.callback(new FilterModel());
@@ -74,6 +97,18 @@ public void initData(Context context, DrawerLayout drawerLayout, FilterModel fil
7497
iniLabels(filterListener, etSearch);
7598
}
7699

100+
private void setActionDown(View view) {
101+
view.setOnTouchListener(new View.OnTouchListener() {
102+
@Override
103+
public boolean onTouch(View v, MotionEvent event) {
104+
if (event.getAction() == MotionEvent.ACTION_DOWN) {
105+
Global.hideSoftKeyboard(((Activity) mContext));
106+
}
107+
return false;
108+
}
109+
});
110+
}
111+
77112
@NonNull
78113
private EditText initKeyword(FilterListener filterListener) {
79114
EditText etSearch = (EditText) drawerLayout.findViewById(R.id.et_search);
@@ -148,7 +183,7 @@ private void iniLabels(FilterListener filterListener, EditText etSearch) {
148183
}
149184
dismiss();
150185
});
151-
186+
setActionDown(labelItem);
152187
llLabels.addView(labelItem);
153188

154189
}
@@ -172,7 +207,7 @@ private void iniStatus(FilterListener filterListener, EditText etSearch) {
172207
}
173208
}
174209
taskView.setText(txt);
175-
210+
setActionDown(taskView);
176211
int status = i + 1;
177212
taskView.setOnClickListener(v -> {
178213
String keyword = etSearch.getText().toString();

app/src/main/res/layout/dialog_task_filter.xml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
android:clickable="true"
77
android:orientation="vertical">
88

9-
<RelativeLayout
9+
<FrameLayout
1010
android:layout_width="match_parent"
11-
android:layout_height="wrap_content"
11+
android:layout_height="match_parent"
1212
android:layout_gravity="right"
1313
android:background="@color/white">
1414

15-
<View
16-
style="@style/DivideLine"
17-
android:layout_above="@+id/rl_bottom"/>
18-
1915
<RelativeLayout
2016
android:id="@+id/rl_bottom"
2117
android:layout_width="match_parent"
2218
android:layout_height="wrap_content"
23-
android:layout_alignParentBottom="true">
19+
android:layout_gravity="bottom">
20+
21+
<View
22+
style="@style/DivideLine"/>
2423

2524
<TextView
2625
android:id="@+id/tv_reset"
@@ -37,9 +36,7 @@
3736
<LinearLayout
3837
android:layout_width="match_parent"
3938
android:layout_height="match_parent"
40-
android:layout_above="@+id/rl_bottom"
41-
android:layout_alignParentStart="true"
42-
android:layout_alignParentTop="true"
39+
android:layout_marginBottom="51dp"
4340
android:orientation="vertical">
4441

4542
<RelativeLayout
@@ -69,6 +66,7 @@
6966
android:background="@drawable/actionbar_shadow"/>
7067

7168
<ScrollView
69+
android:id="@+id/sv_main"
7270
android:layout_width="match_parent"
7371
android:layout_height="wrap_content">
7472

@@ -134,7 +132,7 @@
134132
</LinearLayout>
135133

136134

137-
</RelativeLayout>
135+
</FrameLayout>
138136

139137

140138
</LinearLayout>

0 commit comments

Comments
 (0)