Commit ce1517b59679e310aaf891ec846f007fdfc39322
1 parent
afd7573c
1 修复pop控件在安卓6.0以下点击空白区域,无法消失的问题
Showing
11 changed files
with
74 additions
and
11 deletions
app/build.gradle
| 1 | 1 | apply plugin: 'com.android.application' |
| 2 | + | |
| 2 | 3 | static def stringValue(def value) { |
| 3 | 4 | return "\"${value}\"" |
| 4 | 5 | } |
| 6 | + | |
| 5 | 7 | android { |
| 6 | 8 | compileSdkVersion 28 |
| 7 | 9 | defaultConfig { |
| ... | ... | @@ -61,6 +63,7 @@ android { |
| 61 | 63 | |
| 62 | 64 | dependencies { |
| 63 | 65 | implementation fileTree(dir: 'libs', include: ['*.jar']) |
| 66 | + implementation 'com.android.support.constraint:constraint-layout:1.1.3' | |
| 64 | 67 | testImplementation 'junit:junit:4.12' |
| 65 | 68 | implementation project(path: ':module_xiaojiaSoundBox') |
| 66 | 69 | implementation "com.android.support:support-v4:$rootProject.supportV4" | ... | ... |
app/src/main/AndroidManifest.xml
| ... | ... | @@ -2,8 +2,6 @@ |
| 2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | 3 | package="com.cnlive.strike.speaker"> |
| 4 | 4 | |
| 5 | - | |
| 6 | - | |
| 7 | 5 | <application |
| 8 | 6 | android:allowBackup="true" |
| 9 | 7 | android:icon="@mipmap/ic_launcher" |
| ... | ... | @@ -11,6 +9,7 @@ |
| 11 | 9 | android:roundIcon="@mipmap/ic_launcher_round" |
| 12 | 10 | android:supportsRtl="true" |
| 13 | 11 | android:theme="@style/AppTheme"> |
| 12 | + <activity android:name="com.cnlive.strike.xiaojiaspeaker.ToolBarTestActivity"></activity> | |
| 14 | 13 | <activity android:name="com.cnlive.strike.xiaojiaspeaker.MainActivity"> |
| 15 | 14 | <intent-filter> |
| 16 | 15 | <action android:name="android.intent.action.MAIN" /> | ... | ... |
app/src/main/java/com/cnlive/strike/xiaojiaspeaker/MainActivity.java
| ... | ... | @@ -13,6 +13,7 @@ import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceInstructionActivity; |
| 13 | 13 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceManagerActivity; |
| 14 | 14 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.FirmwareUpdateActivity; |
| 15 | 15 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.SearchDeviceActivity; |
| 16 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.SelectWifiActivity; | |
| 16 | 17 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.SpeakerMainActivity; |
| 17 | 18 | |
| 18 | 19 | public class MainActivity extends AppCompatActivity { |
| ... | ... | @@ -21,7 +22,7 @@ public class MainActivity extends AppCompatActivity { |
| 21 | 22 | protected void onCreate(Bundle savedInstanceState) { |
| 22 | 23 | super.onCreate(savedInstanceState); |
| 23 | 24 | setContentView(R.layout.activity_speaker_main); |
| 24 | -// startActivity(new Intent(MainActivity.this, SpeakerMainActivity.class)); | |
| 25 | +// startActivity(new Intent(MainActivity.this, ToolBarTestActivity.class)); | |
| 25 | 26 | // startActivity(new Intent(MainActivity.this, BluetoothConnActivity.class)); |
| 26 | 27 | // startActivity(new Intent(MainActivity.this, BlueToothStep1Activity.class)); |
| 27 | 28 | // startActivity(new Intent(MainActivity.this, ConnBluetoothSuccessActivity.class)); |
| ... | ... | @@ -29,6 +30,8 @@ public class MainActivity extends AppCompatActivity { |
| 29 | 30 | // startActivity(new Intent(MainActivity.this, DeviceInstructionActivity.class)); |
| 30 | 31 | // startActivity(new Intent(MainActivity.this, DeviceManagerActivity.class)); |
| 31 | 32 | // startActivity(new Intent(MainActivity.this, FirmwareUpdateActivity.class)); |
| 33 | +// startActivity(new Intent(MainActivity.this, SelectWifiActivity.class)); | |
| 34 | + | |
| 32 | 35 | finish(); |
| 33 | 36 | } |
| 34 | 37 | ... | ... |
app/src/main/java/com/cnlive/strike/xiaojiaspeaker/ToolBarTestActivity.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker; | |
| 2 | + | |
| 3 | +import android.databinding.DataBindingUtil; | |
| 4 | +import android.support.design.widget.AppBarLayout; | |
| 5 | +import android.support.v4.content.ContextCompat; | |
| 6 | +import android.support.v7.app.AppCompatActivity; | |
| 7 | +import android.os.Bundle; | |
| 8 | +import android.util.Log; | |
| 9 | + | |
| 10 | +import com.cnlive.strike.speaker.R; | |
| 11 | +import com.cnlive.strike.speaker.databinding.ActivityToolBarTestBinding; | |
| 12 | + | |
| 13 | +public class ToolBarTestActivity extends AppCompatActivity { | |
| 14 | + private ActivityToolBarTestBinding binding; | |
| 15 | + private String TAG = "ToolBarTestActivity"; | |
| 16 | + | |
| 17 | + @Override | |
| 18 | + protected void onCreate(Bundle savedInstanceState) { | |
| 19 | + super.onCreate(savedInstanceState); | |
| 20 | + binding = DataBindingUtil.setContentView(this, R.layout.activity_tool_bar_test); | |
| 21 | + } | |
| 22 | +} | ... | ... |
app/src/main/res/layout/activity_tool_bar_test.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout> | |
| 3 | + | |
| 4 | + <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 6 | + xmlns:tools="http://schemas.android.com/tools" | |
| 7 | + android:layout_width="match_parent" | |
| 8 | + android:layout_height="match_parent" | |
| 9 | + android:orientation="vertical" | |
| 10 | + tools:context="com.cnlive.strike.xiaojiaspeaker.ToolBarTestActivity" | |
| 11 | + tools:ignore="MissingDefaultResource"> | |
| 12 | + | |
| 13 | + <android.support.design.chip.Chip | |
| 14 | + android:layout_width="wrap_content" | |
| 15 | + android:layout_height="wrap_content" | |
| 16 | + android:text="text" /> | |
| 17 | + | |
| 18 | + </android.support.design.widget.CoordinatorLayout> | |
| 19 | +</layout> | |
| 0 | 20 | \ No newline at end of file | ... | ... |
app/src/main/res/values/strings.xml
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/AllDeviceFragmentView.java
| ... | ... | @@ -2,8 +2,11 @@ package com.cnlive.strike.xiaojiaspeaker.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | 4 | import android.graphics.Color; |
| 5 | +import android.support.design.widget.BottomSheetBehavior; | |
| 6 | +import android.support.design.widget.BottomSheetDialog; | |
| 5 | 7 | import android.support.v7.widget.LinearLayoutManager; |
| 6 | 8 | import android.util.Log; |
| 9 | +import android.view.LayoutInflater; | |
| 7 | 10 | import android.view.View; |
| 8 | 11 | |
| 9 | 12 | import com.cnlive.strike.xiaojiaspeaker.R; |
| ... | ... | @@ -59,6 +62,18 @@ public class AllDeviceFragmentView implements MvpView { |
| 59 | 62 | } |
| 60 | 63 | |
| 61 | 64 | public void initPopView() { |
| 65 | +// View contentView = LayoutInflater.from(getContext()) | |
| 66 | +// .inflate(R.layout.activity_all_device, null); | |
| 67 | +// BottomSheetDialog dialog = new BottomSheetDialog(getContext()); | |
| 68 | +// dialog.setContentView(contentView); | |
| 69 | +// dialog.setCancelable(false); | |
| 70 | +// BottomSheetBehavior sheetBehavior = BottomSheetBehavior.from((View) contentView.getParent()); | |
| 71 | +// sheetBehavior.setPeekHeight(200); | |
| 72 | + //给布局设置透明背景色,让图片突出来 | |
| 73 | +// bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet) | |
| 74 | +// .setBackgroundColor(getResources().getColor(android.R.color.transparent)); | |
| 75 | +// dialog.show(); | |
| 76 | + | |
| 62 | 77 | popMenuInfoList = new ArrayList<>(); |
| 63 | 78 | PopMenuInfo popMenuInfo = new PopMenuInfo(); |
| 64 | 79 | popMenuInfo.setTitle("使用者管理"); |
| ... | ... | @@ -84,7 +99,7 @@ public class AllDeviceFragmentView implements MvpView { |
| 84 | 99 | .setLineVisible(View.VISIBLE) |
| 85 | 100 | // .setArrowHeight(30f) |
| 86 | 101 | // .setArrowHeight(30f) |
| 87 | - //.setCancelable(false) | |
| 102 | + .setCancelable(false) | |
| 88 | 103 | .setCornerRadius(10f) |
| 89 | 104 | .build(); |
| 90 | 105 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/AllDeviceAdapter.java
| ... | ... | @@ -93,12 +93,10 @@ public class AllDeviceAdapter extends RecyclerView.Adapter { |
| 93 | 93 | if (null != onItemClickListener) { |
| 94 | 94 | onItemClickListener.onItemClick(getAdapterPosition(), allDeviceInfos.get(getAdapterPosition())); |
| 95 | 95 | } |
| 96 | - Log.e(TAG, "onClick: " + getAdapterPosition()); | |
| 97 | 96 | } else if (R.id.ll_add == view.getId()) { |
| 98 | 97 | if (null != onAddClickListener) { |
| 99 | 98 | onAddClickListener.onAddClick(); |
| 100 | 99 | } |
| 101 | - Log.e(TAG, "onAddClickListener: " + getAdapterPosition()); | |
| 102 | 100 | } |
| 103 | 101 | } |
| 104 | 102 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/AllDeviceFragment.java
| ... | ... | @@ -24,7 +24,6 @@ import java.util.List; |
| 24 | 24 | public class AllDeviceFragment extends MvpBindingFragment<AllDeviceFragmentView, AllDeviceFragmentPresenter, Object, FragmentAllDeviceBinding> { |
| 25 | 25 | private UIPopup qmuiPopup; |
| 26 | 26 | private QMUIAlphaImageButton addButton; |
| 27 | - ; | |
| 28 | 27 | |
| 29 | 28 | public static AllDeviceFragment newInstance() { |
| 30 | 29 | AllDeviceFragment fragment = new AllDeviceFragment(); | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/widget/popmenu/PopMenu.java
| ... | ... | @@ -7,11 +7,13 @@ import android.app.Activity; |
| 7 | 7 | import android.graphics.Color; |
| 8 | 8 | import android.graphics.PointF; |
| 9 | 9 | import android.graphics.RectF; |
| 10 | +import android.graphics.drawable.BitmapDrawable; | |
| 10 | 11 | import android.graphics.drawable.GradientDrawable; |
| 11 | 12 | import android.os.Build; |
| 12 | 13 | import android.support.annotation.ColorInt; |
| 13 | 14 | import android.support.annotation.DimenRes; |
| 14 | 15 | import android.support.annotation.NonNull; |
| 16 | +import android.support.design.widget.BottomSheetDialog; | |
| 15 | 17 | import android.support.v7.widget.LinearLayoutManager; |
| 16 | 18 | import android.support.v7.widget.RecyclerView; |
| 17 | 19 | import android.util.DisplayMetrics; |
| ... | ... | @@ -84,8 +86,8 @@ public final class PopMenu { |
| 84 | 86 | mScreenHeightPixels = dm.heightPixels; |
| 85 | 87 | mScreenWidthPixels = dm.widthPixels; |
| 86 | 88 | mPopupWindow = new PopupWindow(builder.mContext); |
| 87 | - mPopupWindow.setBackgroundDrawable(null); | |
| 88 | - mPopupWindow.setClippingEnabled(false); | |
| 89 | +// mPopupWindow.setBackgroundDrawable(null); | |
| 90 | + mPopupWindow.setBackgroundDrawable(new BitmapDrawable());//必须这么设置,要不安卓6.0以后,点击空白区域,无法消失 | |
| 89 | 91 | mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); |
| 90 | 92 | mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); |
| 91 | 93 | mPopupWindow.setContentView(getContentView(builder)); |
| ... | ... | @@ -182,6 +184,7 @@ public final class PopMenu { |
| 182 | 184 | } |
| 183 | 185 | |
| 184 | 186 | public void show(final View anchorView) { |
| 187 | + | |
| 185 | 188 | if (!isShowing()) { |
| 186 | 189 | // 是否设置设置背景颜色变暗 |
| 187 | 190 | if (builder.isShowDarkenBackground) { |
| ... | ... | @@ -202,6 +205,8 @@ public final class PopMenu { |
| 202 | 205 | mPopupWindow.showAtLocation(mAnchorView, 0, 0, 0); |
| 203 | 206 | } |
| 204 | 207 | }); |
| 208 | + } else { | |
| 209 | + mPopupWindow.dismiss(); | |
| 205 | 210 | } |
| 206 | 211 | } |
| 207 | 212 | ... | ... |
module_xiaojiaSoundBox/src/main/res/layout/fragment_search_device.xml
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | android:id="@+id/rvBlueTooth" |
| 26 | 26 | android:layout_width="match_parent" |
| 27 | 27 | android:layout_height="match_parent" |
| 28 | + android:overScrollMode="never" | |
| 28 | 29 | android:paddingTop="10dp" /> |
| 29 | 30 | <!-- loading视图--> |
| 30 | 31 | <LinearLayout |
| ... | ... | @@ -49,7 +50,6 @@ |
| 49 | 50 | android:id="@+id/ll_retry" |
| 50 | 51 | android:layout_width="match_parent" |
| 51 | 52 | android:layout_height="match_parent" |
| 52 | - android:background="@color/white" | |
| 53 | 53 | android:gravity="center" |
| 54 | 54 | android:orientation="vertical" |
| 55 | 55 | android:visibility="gone"> | ... | ... |