Commit c14df5e9e6927206d06445656ad9896a8e30ea3d
1 parent
4a4f3240
1 优化pop控件
Showing
22 changed files
with
431 additions
and
108 deletions
app/src/main/java/com/cnlive/strike/xiaojiaspeaker/MainActivity.java
| @@ -11,12 +11,12 @@ import com.cnlive.strike.xiaojiaspeaker.ui.activity.BluetoothConnActivity; | @@ -11,12 +11,12 @@ import com.cnlive.strike.xiaojiaspeaker.ui.activity.BluetoothConnActivity; | ||
| 11 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.ConnBluetoothSuccessActivity; | 11 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.ConnBluetoothSuccessActivity; |
| 12 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceInstructionActivity; | 12 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceInstructionActivity; |
| 13 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceManagerActivity; | 13 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceManagerActivity; |
| 14 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.FirmwareUpdateActivity; | ||
| 14 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.SearchDeviceActivity; | 15 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.SearchDeviceActivity; |
| 15 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.SpeakerMainActivity; | 16 | import com.cnlive.strike.xiaojiaspeaker.ui.activity.SpeakerMainActivity; |
| 16 | 17 | ||
| 17 | public class MainActivity extends AppCompatActivity { | 18 | public class MainActivity extends AppCompatActivity { |
| 18 | private static final String TAG = "MainActivity"; | 19 | private static final String TAG = "MainActivity"; |
| 19 | - | ||
| 20 | @Override | 20 | @Override |
| 21 | protected void onCreate(Bundle savedInstanceState) { | 21 | protected void onCreate(Bundle savedInstanceState) { |
| 22 | super.onCreate(savedInstanceState); | 22 | super.onCreate(savedInstanceState); |
| @@ -25,9 +25,10 @@ public class MainActivity extends AppCompatActivity { | @@ -25,9 +25,10 @@ public class MainActivity extends AppCompatActivity { | ||
| 25 | // startActivity(new Intent(MainActivity.this, BluetoothConnActivity.class)); | 25 | // startActivity(new Intent(MainActivity.this, BluetoothConnActivity.class)); |
| 26 | // startActivity(new Intent(MainActivity.this, BlueToothStep1Activity.class)); | 26 | // startActivity(new Intent(MainActivity.this, BlueToothStep1Activity.class)); |
| 27 | // startActivity(new Intent(MainActivity.this, ConnBluetoothSuccessActivity.class)); | 27 | // startActivity(new Intent(MainActivity.this, ConnBluetoothSuccessActivity.class)); |
| 28 | -// startActivity(new Intent(MainActivity.this, AllDeviceActivity.class)); | 28 | + startActivity(new Intent(MainActivity.this, AllDeviceActivity.class)); |
| 29 | // startActivity(new Intent(MainActivity.this, DeviceInstructionActivity.class)); | 29 | // startActivity(new Intent(MainActivity.this, DeviceInstructionActivity.class)); |
| 30 | - startActivity(new Intent(MainActivity.this, DeviceManagerActivity.class)); | 30 | +// startActivity(new Intent(MainActivity.this, DeviceManagerActivity.class)); |
| 31 | +// startActivity(new Intent(MainActivity.this, FirmwareUpdateActivity.class)); | ||
| 31 | finish(); | 32 | finish(); |
| 32 | } | 33 | } |
| 33 | 34 |
module_xiaojiaSoundBox/src/main/AndroidManifest.xml
| @@ -17,7 +17,8 @@ | @@ -17,7 +17,8 @@ | ||
| 17 | <uses-permission android:name="android.permission.INTERNET" /> | 17 | <uses-permission android:name="android.permission.INTERNET" /> |
| 18 | 18 | ||
| 19 | <application> | 19 | <application> |
| 20 | - <activity android:name=".ui.activity.DeviceManagerActivity"></activity> | 20 | + <activity android:name=".ui.activity.FirmwareUpdateActivity"></activity> |
| 21 | + <activity android:name=".ui.activity.DeviceManagerActivity" /> | ||
| 21 | <activity android:name=".ui.activity.DeviceInstructionActivity" /> | 22 | <activity android:name=".ui.activity.DeviceInstructionActivity" /> |
| 22 | <activity android:name=".ui.activity.AllDeviceActivity" /> | 23 | <activity android:name=".ui.activity.AllDeviceActivity" /> |
| 23 | <activity android:name=".ui.activity.ConnBluetoothSuccessActivity" /> | 24 | <activity android:name=".ui.activity.ConnBluetoothSuccessActivity" /> |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/FirmwareUpdateFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.FirmwareUpdateFragmentView; | ||
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 5 | + | ||
| 6 | +public class FirmwareUpdateFragmentPresenter extends MvpBasePresenter<FirmwareUpdateFragmentView> { | ||
| 7 | +} |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/FirmwareUpdateFragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | + | ||
| 5 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.FirmwareUpdateFragment; | ||
| 6 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 7 | + | ||
| 8 | +public class FirmwareUpdateFragmentView implements MvpView { | ||
| 9 | + private FirmwareUpdateFragment fragment; | ||
| 10 | + | ||
| 11 | + public FirmwareUpdateFragmentView(FirmwareUpdateFragment fragment) { | ||
| 12 | + this.fragment = fragment; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + public Activity getContext() { | ||
| 16 | + return fragment == null ? null : fragment.getActivity(); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public void initView() { | ||
| 20 | + } | ||
| 21 | +} |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/FirmwareUpdateActivity.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.activity; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Intent; | ||
| 5 | +import android.support.v7.app.AppCompatActivity; | ||
| 6 | +import android.os.Bundle; | ||
| 7 | + | ||
| 8 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 9 | +import com.cnlive.strike.xiaojiaspeaker.databinding.FragmentFirmwareUpdateBinding; | ||
| 10 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.DeviceManagerFragment; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.FirmwareUpdateFragment; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 固件升级 | ||
| 15 | + */ | ||
| 16 | +public class FirmwareUpdateActivity extends AppCompatActivity { | ||
| 17 | + | ||
| 18 | + @Override | ||
| 19 | + protected void onCreate(Bundle savedInstanceState) { | ||
| 20 | + super.onCreate(savedInstanceState); | ||
| 21 | + setContentView(R.layout.activity_search_device); | ||
| 22 | + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, FirmwareUpdateFragment.newInstance()).commitAllowingStateLoss(); | ||
| 23 | + | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public static void startActivity(Activity activity) { | ||
| 27 | + activity.startActivity(new Intent(activity, FirmwareUpdateActivity.class)); | ||
| 28 | + } | ||
| 29 | +} |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/AllDeviceAdapter.java
| @@ -2,7 +2,6 @@ package com.cnlive.strike.xiaojiaspeaker.ui.adapter; | @@ -2,7 +2,6 @@ package com.cnlive.strike.xiaojiaspeaker.ui.adapter; | ||
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.databinding.DataBindingUtil; | 4 | import android.databinding.DataBindingUtil; |
| 5 | -import android.graphics.Color; | ||
| 6 | import android.support.annotation.NonNull; | 5 | import android.support.annotation.NonNull; |
| 7 | import android.support.v4.content.ContextCompat; | 6 | import android.support.v4.content.ContextCompat; |
| 8 | import android.support.v7.widget.RecyclerView; | 7 | import android.support.v7.widget.RecyclerView; |
| @@ -11,16 +10,11 @@ import android.view.LayoutInflater; | @@ -11,16 +10,11 @@ import android.view.LayoutInflater; | ||
| 11 | import android.view.View; | 10 | import android.view.View; |
| 12 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
| 13 | 12 | ||
| 14 | -import com.clj.fastble.data.BleDevice; | ||
| 15 | import com.cnlive.strike.application.GlideApp; | 13 | import com.cnlive.strike.application.GlideApp; |
| 16 | import com.cnlive.strike.xiaojiaspeaker.R; | 14 | import com.cnlive.strike.xiaojiaspeaker.R; |
| 17 | import com.cnlive.strike.xiaojiaspeaker.databinding.ListItemAllDeviceBinding; | 15 | import com.cnlive.strike.xiaojiaspeaker.databinding.ListItemAllDeviceBinding; |
| 18 | -import com.cnlive.strike.xiaojiaspeaker.databinding.ListItemBluetoothDeviceBinding; | ||
| 19 | import com.cnlive.strike.xiaojiaspeaker.model.AllDeviceInfo; | 16 | import com.cnlive.strike.xiaojiaspeaker.model.AllDeviceInfo; |
| 20 | -import com.cnlive.strike.xiaojiaspeaker.model.PopMenuInfo; | ||
| 21 | -import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenu; | ||
| 22 | 17 | ||
| 23 | -import java.util.ArrayList; | ||
| 24 | import java.util.List; | 18 | import java.util.List; |
| 25 | 19 | ||
| 26 | public class AllDeviceAdapter extends RecyclerView.Adapter { | 20 | public class AllDeviceAdapter extends RecyclerView.Adapter { |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/AllDeviceFragment.java
| 1 | package com.cnlive.strike.xiaojiaspeaker.ui.fragment; | 1 | package com.cnlive.strike.xiaojiaspeaker.ui.fragment; |
| 2 | 2 | ||
| 3 | -import android.Manifest; | ||
| 4 | -import android.content.Intent; | ||
| 5 | import android.graphics.Color; | 3 | import android.graphics.Color; |
| 6 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 7 | import android.support.annotation.Nullable; | 5 | import android.support.annotation.Nullable; |
| 8 | import android.support.v4.content.ContextCompat; | 6 | import android.support.v4.content.ContextCompat; |
| 9 | -import android.support.v7.widget.LinearLayoutManager; | ||
| 10 | -import android.support.v7.widget.RecyclerView; | ||
| 11 | -import android.view.Display; | ||
| 12 | -import android.view.LayoutInflater; | ||
| 13 | import android.view.View; | 7 | import android.view.View; |
| 14 | -import android.view.ViewGroup; | ||
| 15 | -import android.widget.Button; | ||
| 16 | -import android.widget.LinearLayout; | ||
| 17 | -import android.widget.PopupWindow; | ||
| 18 | -import android.widget.RelativeLayout; | ||
| 19 | 8 | ||
| 20 | -import com.cnlive.libs.base.application.AppConfig; | ||
| 21 | import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | 9 | import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; |
| 22 | -import com.cnlive.libs.base.util.AlertUtil; | ||
| 23 | import com.cnlive.libs.base.util.StatusBarUtil; | 10 | import com.cnlive.libs.base.util.StatusBarUtil; |
| 24 | import com.cnlive.libs.base.util.StatusBarUtil2; | 11 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 25 | import com.cnlive.strike.ui.widget.UIPopup; | 12 | import com.cnlive.strike.ui.widget.UIPopup; |
| @@ -27,13 +14,9 @@ import com.cnlive.strike.xiaojiaspeaker.R; | @@ -27,13 +14,9 @@ import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 27 | import com.cnlive.strike.xiaojiaspeaker.databinding.FragmentAllDeviceBinding; | 14 | import com.cnlive.strike.xiaojiaspeaker.databinding.FragmentAllDeviceBinding; |
| 28 | import com.cnlive.strike.xiaojiaspeaker.frame.presenter.AllDeviceFragmentPresenter; | 15 | import com.cnlive.strike.xiaojiaspeaker.frame.presenter.AllDeviceFragmentPresenter; |
| 29 | import com.cnlive.strike.xiaojiaspeaker.frame.view.AllDeviceFragmentView; | 16 | import com.cnlive.strike.xiaojiaspeaker.frame.view.AllDeviceFragmentView; |
| 30 | -import com.cnlive.strike.xiaojiaspeaker.model.PopMenuInfo; | ||
| 31 | -import com.cnlive.strike.xiaojiaspeaker.ui.activity.BlueToothStep1Activity; | ||
| 32 | -import com.cnlive.strike.xiaojiaspeaker.ui.adapter.PopMenuAdapter; | 17 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenuInfo; |
| 33 | import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenu; | 18 | import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenu; |
| 34 | -import com.qmuiteam.qmui.alpha.QMUIAlphaButton; | ||
| 35 | import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton; | 19 | import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton; |
| 36 | -import com.qmuiteam.qmui.widget.popup.QMUIPopup; | ||
| 37 | 20 | ||
| 38 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
| 39 | import java.util.List; | 22 | import java.util.List; |
| @@ -96,19 +79,22 @@ public class AllDeviceFragment extends MvpBindingFragment<AllDeviceFragmentView, | @@ -96,19 +79,22 @@ public class AllDeviceFragment extends MvpBindingFragment<AllDeviceFragmentView, | ||
| 96 | List<PopMenuInfo> popMenuInfoList = new ArrayList<>(); | 79 | List<PopMenuInfo> popMenuInfoList = new ArrayList<>(); |
| 97 | PopMenuInfo popMenuInfo = new PopMenuInfo(); | 80 | PopMenuInfo popMenuInfo = new PopMenuInfo(); |
| 98 | popMenuInfo.setTitle("下载中"); | 81 | popMenuInfo.setTitle("下载中"); |
| 82 | +// popMenuInfo.setNetImag("zsdfs"); | ||
| 99 | popMenuInfoList.add(popMenuInfo); | 83 | popMenuInfoList.add(popMenuInfo); |
| 100 | popMenuInfo = new PopMenuInfo(); | 84 | popMenuInfo = new PopMenuInfo(); |
| 101 | popMenuInfo.setTitle("历史记录"); | 85 | popMenuInfo.setTitle("历史记录"); |
| 86 | +// popMenuInfo.setNetImag("zsdfs"); | ||
| 102 | popMenuInfoList.add(popMenuInfo); | 87 | popMenuInfoList.add(popMenuInfo); |
| 103 | popMenuInfo = new PopMenuInfo(); | 88 | popMenuInfo = new PopMenuInfo(); |
| 104 | popMenuInfo.setTitle("设备管理"); | 89 | popMenuInfo.setTitle("设备管理"); |
| 90 | +// popMenuInfo.setNetImag("zsdfs"); | ||
| 105 | popMenuInfoList.add(popMenuInfo); | 91 | popMenuInfoList.add(popMenuInfo); |
| 106 | 92 | ||
| 107 | PopMenu mPopMenu = new PopMenu.Builder(getActivity()) | 93 | PopMenu mPopMenu = new PopMenu.Builder(getActivity()) |
| 108 | .addData(popMenuInfoList) | 94 | .addData(popMenuInfoList) |
| 109 | - .setBackgroundColor(Color.parseColor("#FA3a3a3a")) | 95 | + .setBackgroundColorArray(new int[]{Color.parseColor("#363636"), Color.parseColor("#BF000000"), Color.parseColor("#BF000000")}) |
| 110 | .setLeftAndRightMargin(20) | 96 | .setLeftAndRightMargin(20) |
| 111 | - .setHeightMargin(20) | 97 | + .setTopMargin(20) |
| 112 | .setLineColor(R.color.white_50) | 98 | .setLineColor(R.color.white_50) |
| 113 | .setTextColor(R.color.white) | 99 | .setTextColor(R.color.white) |
| 114 | .setLineVisible(View.VISIBLE) | 100 | .setLineVisible(View.VISIBLE) |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/FirmwareUpdateFragment.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.fragment; | ||
| 2 | + | ||
| 3 | +import android.os.Bundle; | ||
| 4 | +import android.support.annotation.Nullable; | ||
| 5 | +import android.support.v4.content.ContextCompat; | ||
| 6 | +import android.view.View; | ||
| 7 | + | ||
| 8 | +import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; | ||
| 9 | +import com.cnlive.libs.base.util.StatusBarUtil; | ||
| 10 | +import com.cnlive.libs.base.util.StatusBarUtil2; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.databinding.FragmentFirmwareUpdateBinding; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.frame.presenter.FirmwareUpdateFragmentPresenter; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.FirmwareUpdateFragmentView; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 固件升级 | ||
| 18 | + */ | ||
| 19 | +public class FirmwareUpdateFragment extends MvpBindingFragment<FirmwareUpdateFragmentView, FirmwareUpdateFragmentPresenter, Object, FragmentFirmwareUpdateBinding> { | ||
| 20 | + public static FirmwareUpdateFragment newInstance() { | ||
| 21 | + FirmwareUpdateFragment fragment = new FirmwareUpdateFragment(); | ||
| 22 | + return fragment; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + protected int getLayoutId() { | ||
| 27 | + return R.layout.fragment_firmware_update; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public void onActivityCreated(@Nullable Bundle savedInstanceState) { | ||
| 32 | + super.onActivityCreated(savedInstanceState); | ||
| 33 | + StatusBarUtil.setStatusBarWrite(getActivity()); | ||
| 34 | + StatusBarUtil2.setColor(getActivity(), ContextCompat.getColor(getActivity(), R.color.white), 0); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
| 39 | + super.onViewCreated(view, savedInstanceState); | ||
| 40 | + initTopBar(); | ||
| 41 | + if (null != getMvpView()) { | ||
| 42 | + getMvpView().initView(); | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + private void initTopBar() { | ||
| 47 | + if (null != binding) { | ||
| 48 | + binding.topbar.setTitle("固件升级"); | ||
| 49 | + //设置返回按钮 | ||
| 50 | + binding.topbar.addLeftImageButton(R.drawable.icon_back, R.id.left_back).setOnClickListener(new View.OnClickListener() { | ||
| 51 | + @Override | ||
| 52 | + public void onClick(View view) { | ||
| 53 | + getActivity().finish(); | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | +} |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/widget/popmenu/PopMenu.java
| @@ -3,7 +3,7 @@ package com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu; | @@ -3,7 +3,7 @@ package com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu; | ||
| 3 | import android.animation.AnimatorSet; | 3 | import android.animation.AnimatorSet; |
| 4 | import android.animation.ObjectAnimator; | 4 | import android.animation.ObjectAnimator; |
| 5 | import android.annotation.SuppressLint; | 5 | import android.annotation.SuppressLint; |
| 6 | -import android.content.Context; | 6 | +import android.app.Activity; |
| 7 | import android.graphics.Color; | 7 | import android.graphics.Color; |
| 8 | import android.graphics.PointF; | 8 | import android.graphics.PointF; |
| 9 | import android.graphics.RectF; | 9 | import android.graphics.RectF; |
| @@ -12,25 +12,20 @@ import android.os.Build; | @@ -12,25 +12,20 @@ import android.os.Build; | ||
| 12 | import android.support.annotation.ColorInt; | 12 | import android.support.annotation.ColorInt; |
| 13 | import android.support.annotation.DimenRes; | 13 | import android.support.annotation.DimenRes; |
| 14 | import android.support.annotation.NonNull; | 14 | import android.support.annotation.NonNull; |
| 15 | -import android.support.annotation.Size; | ||
| 16 | -import android.support.v4.content.ContextCompat; | ||
| 17 | import android.support.v7.widget.LinearLayoutManager; | 15 | import android.support.v7.widget.LinearLayoutManager; |
| 18 | import android.support.v7.widget.RecyclerView; | 16 | import android.support.v7.widget.RecyclerView; |
| 19 | import android.util.DisplayMetrics; | 17 | import android.util.DisplayMetrics; |
| 20 | -import android.util.Log; | ||
| 21 | import android.view.Gravity; | 18 | import android.view.Gravity; |
| 22 | import android.view.View; | 19 | import android.view.View; |
| 23 | import android.view.ViewGroup; | 20 | import android.view.ViewGroup; |
| 24 | import android.view.ViewTreeObserver; | 21 | import android.view.ViewTreeObserver; |
| 22 | +import android.view.WindowManager; | ||
| 25 | import android.view.animation.DecelerateInterpolator; | 23 | import android.view.animation.DecelerateInterpolator; |
| 26 | import android.widget.ImageView; | 24 | import android.widget.ImageView; |
| 27 | import android.widget.LinearLayout; | 25 | import android.widget.LinearLayout; |
| 28 | import android.widget.PopupWindow; | 26 | import android.widget.PopupWindow; |
| 29 | 27 | ||
| 30 | -import com.cnlive.libs.base.util.AlertUtil; | ||
| 31 | import com.cnlive.strike.xiaojiaspeaker.R; | 28 | import com.cnlive.strike.xiaojiaspeaker.R; |
| 32 | -import com.cnlive.strike.xiaojiaspeaker.model.PopMenuInfo; | ||
| 33 | -import com.cnlive.strike.xiaojiaspeaker.ui.adapter.PopMenuAdapter; | ||
| 34 | 29 | ||
| 35 | import java.util.ArrayList; | 30 | import java.util.ArrayList; |
| 36 | import java.util.List; | 31 | import java.util.List; |
| @@ -38,6 +33,7 @@ import java.util.List; | @@ -38,6 +33,7 @@ import java.util.List; | ||
| 38 | 33 | ||
| 39 | /** | 34 | /** |
| 40 | * PopMenu | 35 | * PopMenu |
| 36 | + * modify by ShinnyYang | ||
| 41 | */ | 37 | */ |
| 42 | public final class PopMenu { | 38 | public final class PopMenu { |
| 43 | 39 | ||
| @@ -60,13 +56,14 @@ public final class PopMenu { | @@ -60,13 +56,14 @@ public final class PopMenu { | ||
| 60 | private List<PopMenuInfo> mData = new ArrayList<>(); | 56 | private List<PopMenuInfo> mData = new ArrayList<>(); |
| 61 | private String TAG = "PopMenu"; | 57 | private String TAG = "PopMenu"; |
| 62 | private Builder builder; | 58 | private Builder builder; |
| 59 | + private OnItemClickListener onItemClickListener; | ||
| 63 | 60 | ||
| 64 | - public interface OnItemClickListener { | ||
| 65 | -// void onItemClickListener(ActionItem item, int position); | 61 | + public void setmItemClickListener(OnItemClickListener mItemClickListener) { |
| 62 | + this.mItemClickListener = mItemClickListener; | ||
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | - public void setOnItemClickListener(OnItemClickListener onItemClickListener) { | ||
| 69 | - mItemClickListener = onItemClickListener; | 65 | + public interface OnItemClickListener { |
| 66 | + void onClick(int position, PopMenuInfo popMenuInfo); | ||
| 70 | } | 67 | } |
| 71 | 68 | ||
| 72 | public void addData(List<PopMenuInfo> data) { | 69 | public void addData(List<PopMenuInfo> data) { |
| @@ -99,13 +96,17 @@ public final class PopMenu { | @@ -99,13 +96,17 @@ public final class PopMenu { | ||
| 99 | @SuppressLint("WrongConstant") | 96 | @SuppressLint("WrongConstant") |
| 100 | private View getContentView(final Builder builder) { | 97 | private View getContentView(final Builder builder) { |
| 101 | GradientDrawable drawable = new GradientDrawable(); | 98 | GradientDrawable drawable = new GradientDrawable(); |
| 102 | - mBackgroundColor = builder.mBackgroundColor; | ||
| 103 | - drawable.setColor(mBackgroundColor); | ||
| 104 | drawable.setCornerRadius(builder.mCornerRadius); | 99 | drawable.setCornerRadius(builder.mCornerRadius); |
| 105 | //设置颜色为渐变 | 100 | //设置颜色为渐变 |
| 106 | -// drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); | ||
| 107 | -// drawable.setColors(new int[]{mBackgroundColor,Color.parseColor("#BF000000")}); | ||
| 108 | -// drawable.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM); | 101 | + drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); |
| 102 | + if (null != builder.mBackgroundColorArray && builder.mBackgroundColorArray.length > 0) { | ||
| 103 | + mBackgroundColor = builder.mBackgroundColorArray[0]; | ||
| 104 | + drawable.setColors(builder.mBackgroundColorArray); | ||
| 105 | + } else { | ||
| 106 | + mBackgroundColor = builder.mBackgroundColor; | ||
| 107 | + drawable.setColor(mBackgroundColor); | ||
| 108 | + } | ||
| 109 | + drawable.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM); | ||
| 109 | mRecyclerView = new RecyclerView(builder.mContext); | 110 | mRecyclerView = new RecyclerView(builder.mContext); |
| 110 | mRecyclerView.setLayoutManager(new LinearLayoutManager(builder.mContext)); | 111 | mRecyclerView.setLayoutManager(new LinearLayoutManager(builder.mContext)); |
| 111 | mRecyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER); | 112 | mRecyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER); |
| @@ -125,40 +126,14 @@ public final class PopMenu { | @@ -125,40 +126,14 @@ public final class PopMenu { | ||
| 125 | mAdapter.setLineVisible(builder.lineVisible); | 126 | mAdapter.setLineVisible(builder.lineVisible); |
| 126 | } | 127 | } |
| 127 | mData.addAll(builder.mData); | 128 | mData.addAll(builder.mData); |
| 128 | -// mAdapter = new CommonAdapter<ActionItem>(builder.mContext, | ||
| 129 | -// R.layout.list_item_popmenu, mData) { | ||
| 130 | -// | ||
| 131 | -// @Override | ||
| 132 | -// protected void convert(final ViewHolder holder, final ActionItem item, final int position) { | ||
| 133 | -// holder.setText(R.id.tv_pop_menu, item.getText()); | ||
| 134 | -// holder.setTextColor(R.id.tv_pop_menu, builder.mTextColor); | ||
| 135 | -// ImageView iv = holder.getView(R.id.iv_pop_menu); | ||
| 136 | -// if (builder.mIsShowImage) { | ||
| 137 | -// if (item.getResId() != 0) { | ||
| 138 | -// iv.setImageResource(item.getResId()); | ||
| 139 | -// iv.setVisibility(View.VISIBLE); | ||
| 140 | -// } else { | ||
| 141 | -// iv.setVisibility(View.INVISIBLE); | ||
| 142 | -// } | ||
| 143 | -// } else { | ||
| 144 | -// iv.setVisibility(View.GONE); | ||
| 145 | -// } | ||
| 146 | -// if (mItemClickListener == null) | ||
| 147 | -// return; | ||
| 148 | -// holder.getConvertView().setOnClickListener(new View.OnClickListener() { | ||
| 149 | -// @Override | ||
| 150 | -// public void onClick(View v) { | ||
| 151 | -// mItemClickListener.onItemClickListener(item, position); | ||
| 152 | -// dismiss(); | ||
| 153 | -// } | ||
| 154 | -// }); | ||
| 155 | -// } | ||
| 156 | -// }; | ||
| 157 | mRecyclerView.setAdapter(mAdapter); | 129 | mRecyclerView.setAdapter(mAdapter); |
| 158 | mAdapter.setOnItemClickListener(new PopMenuAdapter.OnItemClickListener() { | 130 | mAdapter.setOnItemClickListener(new PopMenuAdapter.OnItemClickListener() { |
| 159 | @Override | 131 | @Override |
| 160 | public void onClick(int position, PopMenuInfo popMenuInfo) { | 132 | public void onClick(int position, PopMenuInfo popMenuInfo) { |
| 161 | - AlertUtil.showDeftToast(builder.mContext, position + ""); | 133 | + if (null != onItemClickListener) { |
| 134 | + onItemClickListener.onClick(position, popMenuInfo); | ||
| 135 | + } | ||
| 136 | + dismiss(); | ||
| 162 | } | 137 | } |
| 163 | }); | 138 | }); |
| 164 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | 139 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
| @@ -187,6 +162,18 @@ public final class PopMenu { | @@ -187,6 +162,18 @@ public final class PopMenu { | ||
| 187 | mContentView.setOrientation(LinearLayout.VERTICAL); | 162 | mContentView.setOrientation(LinearLayout.VERTICAL); |
| 188 | mContentView.addView(mArrowView); | 163 | mContentView.addView(mArrowView); |
| 189 | mContentView.addView(mRecyclerView);//为了计算高度 | 164 | mContentView.addView(mRecyclerView);//为了计算高度 |
| 165 | + mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { | ||
| 166 | + @Override | ||
| 167 | + public void onDismiss() { | ||
| 168 | + //是否有背景色显示 | ||
| 169 | + if (builder.isShowDarkenBackground) { | ||
| 170 | + //恢复背景色 | ||
| 171 | + WindowManager.LayoutParams lp = builder.mContext.getWindow().getAttributes(); | ||
| 172 | + lp.alpha = 1f; | ||
| 173 | + builder.mContext.getWindow().setAttributes(lp); | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + }); | ||
| 190 | return mContentView; | 177 | return mContentView; |
| 191 | } | 178 | } |
| 192 | 179 | ||
| @@ -196,14 +183,23 @@ public final class PopMenu { | @@ -196,14 +183,23 @@ public final class PopMenu { | ||
| 196 | 183 | ||
| 197 | public void show(final View anchorView) { | 184 | public void show(final View anchorView) { |
| 198 | if (!isShowing()) { | 185 | if (!isShowing()) { |
| 186 | + // 是否设置设置背景颜色变暗 | ||
| 187 | + if (builder.isShowDarkenBackground) { | ||
| 188 | + WindowManager.LayoutParams lp = builder.mContext.getWindow().getAttributes(); | ||
| 189 | + lp.alpha = 0.7f; | ||
| 190 | + builder.mContext.getWindow().setAttributes(lp); | ||
| 191 | + } | ||
| 199 | mAnchorView = anchorView; | 192 | mAnchorView = anchorView; |
| 200 | mContentView.getViewTreeObserver().addOnGlobalLayoutListener(mLocationLayoutListener); | 193 | mContentView.getViewTreeObserver().addOnGlobalLayoutListener(mLocationLayoutListener); |
| 201 | - | ||
| 202 | anchorView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); | 194 | anchorView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); |
| 203 | anchorView.post(new Runnable() { | 195 | anchorView.post(new Runnable() { |
| 204 | @Override | 196 | @Override |
| 205 | public void run() { | 197 | public void run() { |
| 206 | - mPopupWindow.showAsDropDown(anchorView); | 198 | + //设置高度,不立即生效,调用show之后,才生效 |
| 199 | +// mPopupWindow.showAsDropDown(anchorView); | ||
| 200 | + // 设置popWindow的显示和消失动画 | ||
| 201 | + mPopupWindow.setAnimationStyle(R.style.contextMenuAnim); | ||
| 202 | + mPopupWindow.showAtLocation(mAnchorView, 0, 0, 0); | ||
| 207 | } | 203 | } |
| 208 | }); | 204 | }); |
| 209 | } | 205 | } |
| @@ -245,8 +241,8 @@ public final class PopMenu { | @@ -245,8 +241,8 @@ public final class PopMenu { | ||
| 245 | } else if (location.x < marginX) { | 241 | } else if (location.x < marginX) { |
| 246 | location.x = marginX; | 242 | location.x = marginX; |
| 247 | } | 243 | } |
| 248 | - if (null != builder && 0 != builder.HEIGHT_MARGIN) { | ||
| 249 | - location.y -= builder.HEIGHT_MARGIN; | 244 | + if (null != builder && 0 != builder.TOP_MARGIN) { |
| 245 | + location.y -= builder.TOP_MARGIN; | ||
| 250 | } | 246 | } |
| 251 | 247 | ||
| 252 | return location; | 248 | return location; |
| @@ -336,7 +332,7 @@ public final class PopMenu { | @@ -336,7 +332,7 @@ public final class PopMenu { | ||
| 336 | } else { | 332 | } else { |
| 337 | mContentView.setPivotY(y); | 333 | mContentView.setPivotY(y); |
| 338 | } | 334 | } |
| 339 | - animatorSet.setDuration(300); | 335 | + animatorSet.setDuration(200); |
| 340 | animatorSet.setInterpolator(new DecelerateInterpolator()); | 336 | animatorSet.setInterpolator(new DecelerateInterpolator()); |
| 341 | animatorSet.play(scaleX).with(scaleY).with(alpha);//两个动画同时开始 | 337 | animatorSet.play(scaleX).with(scaleY).with(alpha);//两个动画同时开始 |
| 342 | animatorSet.start(); | 338 | animatorSet.start(); |
| @@ -357,6 +353,7 @@ public final class PopMenu { | @@ -357,6 +353,7 @@ public final class PopMenu { | ||
| 357 | public static final class Builder { | 353 | public static final class Builder { |
| 358 | 354 | ||
| 359 | private int mBackgroundColor = Color.BLACK; | 355 | private int mBackgroundColor = Color.BLACK; |
| 356 | + private int[] mBackgroundColorArray; | ||
| 360 | private int mTextColor = -1; | 357 | private int mTextColor = -1; |
| 361 | private boolean isCancelable = true; | 358 | private boolean isCancelable = true; |
| 362 | 359 | ||
| @@ -364,31 +361,54 @@ public final class PopMenu { | @@ -364,31 +361,54 @@ public final class PopMenu { | ||
| 364 | private float mArrowHeight; | 361 | private float mArrowHeight; |
| 365 | private float mArrowWidth; | 362 | private float mArrowWidth; |
| 366 | 363 | ||
| 367 | - private Context mContext; | 364 | + private Activity mContext; |
| 368 | private List<PopMenuInfo> mData = new ArrayList<>(); | 365 | private List<PopMenuInfo> mData = new ArrayList<>(); |
| 369 | private int mLineColor = -1; | 366 | private int mLineColor = -1; |
| 370 | - private boolean mIsShowImage = true; | ||
| 371 | private int LEFT_TO_RIGHT_MARGIN;//弹窗左右边距 | 367 | private int LEFT_TO_RIGHT_MARGIN;//弹窗左右边距 |
| 372 | - private int HEIGHT_MARGIN;//纵坐标边距 | 368 | + private int TOP_MARGIN;//上边距 |
| 373 | private int itemBackGround = -1; | 369 | private int itemBackGround = -1; |
| 374 | private int lineVisible = -1; | 370 | private int lineVisible = -1; |
| 371 | + private boolean isShowDarkenBackground = false;//是否背景变暗 | ||
| 375 | 372 | ||
| 376 | - public Builder(@NonNull Context context) { | 373 | + public Builder(@NonNull Activity context) { |
| 377 | mContext = context; | 374 | mContext = context; |
| 378 | } | 375 | } |
| 379 | 376 | ||
| 377 | + /** | ||
| 378 | + * 设置背景是否变暗 | ||
| 379 | + * | ||
| 380 | + * @param showDarkenBackground | ||
| 381 | + * @return | ||
| 382 | + */ | ||
| 383 | + public Builder setShowDarkenBackground(boolean showDarkenBackground) { | ||
| 384 | + isShowDarkenBackground = showDarkenBackground; | ||
| 385 | + return this; | ||
| 386 | + } | ||
| 387 | + | ||
| 380 | public Builder setLineVisible(int visible) { | 388 | public Builder setLineVisible(int visible) { |
| 381 | lineVisible = visible; | 389 | lineVisible = visible; |
| 382 | return this; | 390 | return this; |
| 383 | } | 391 | } |
| 384 | 392 | ||
| 393 | + /** | ||
| 394 | + * 设置左右边距 | ||
| 395 | + * | ||
| 396 | + * @param margin | ||
| 397 | + * @return | ||
| 398 | + */ | ||
| 385 | public Builder setLeftAndRightMargin(int margin) { | 399 | public Builder setLeftAndRightMargin(int margin) { |
| 386 | LEFT_TO_RIGHT_MARGIN = margin; | 400 | LEFT_TO_RIGHT_MARGIN = margin; |
| 387 | return this; | 401 | return this; |
| 388 | } | 402 | } |
| 389 | 403 | ||
| 390 | - public Builder setHeightMargin(int margin) { | ||
| 391 | - HEIGHT_MARGIN = margin; | 404 | + /** |
| 405 | + * 设置上边距 | ||
| 406 | + * | ||
| 407 | + * @param margin | ||
| 408 | + * @return | ||
| 409 | + */ | ||
| 410 | + public Builder setTopMargin(int margin) { | ||
| 411 | + TOP_MARGIN = margin; | ||
| 392 | return this; | 412 | return this; |
| 393 | } | 413 | } |
| 394 | 414 | ||
| @@ -402,6 +422,18 @@ public final class PopMenu { | @@ -402,6 +422,18 @@ public final class PopMenu { | ||
| 402 | return this; | 422 | return this; |
| 403 | } | 423 | } |
| 404 | 424 | ||
| 425 | + /** | ||
| 426 | + * 设置背景渐变色,一般在设置透明度的时候使用,因为半透明颜色时,箭头与下边recycleview会显得不是一个整体 | ||
| 427 | + * 纯色背景没事 | ||
| 428 | + * | ||
| 429 | + * @param color | ||
| 430 | + * @return | ||
| 431 | + */ | ||
| 432 | + public Builder setBackgroundColorArray(@ColorInt int[] color) { | ||
| 433 | + mBackgroundColorArray = color; | ||
| 434 | + return this; | ||
| 435 | + } | ||
| 436 | + | ||
| 405 | public Builder setTextColor(int color) { | 437 | public Builder setTextColor(int color) { |
| 406 | mTextColor = color; | 438 | mTextColor = color; |
| 407 | return this; | 439 | return this; |
| @@ -412,15 +444,17 @@ public final class PopMenu { | @@ -412,15 +444,17 @@ public final class PopMenu { | ||
| 412 | return this; | 444 | return this; |
| 413 | } | 445 | } |
| 414 | 446 | ||
| 447 | + /** | ||
| 448 | + * 设置item点击效果 | ||
| 449 | + * | ||
| 450 | + * @param drawable | ||
| 451 | + * @return | ||
| 452 | + */ | ||
| 415 | public Builder setItemBackGround(int drawable) { | 453 | public Builder setItemBackGround(int drawable) { |
| 416 | itemBackGround = drawable; | 454 | itemBackGround = drawable; |
| 417 | return this; | 455 | return this; |
| 418 | } | 456 | } |
| 419 | 457 | ||
| 420 | - public Builder setShowImage(boolean isShowImage) { | ||
| 421 | - mIsShowImage = isShowImage; | ||
| 422 | - return this; | ||
| 423 | - } | ||
| 424 | 458 | ||
| 425 | public Builder setCornerRadius(@DimenRes int resId) { | 459 | public Builder setCornerRadius(@DimenRes int resId) { |
| 426 | return setCornerRadius(mContext.getResources().getDimension(resId)); | 460 | return setCornerRadius(mContext.getResources().getDimension(resId)); |
| @@ -431,6 +465,12 @@ public final class PopMenu { | @@ -431,6 +465,12 @@ public final class PopMenu { | ||
| 431 | return this; | 465 | return this; |
| 432 | } | 466 | } |
| 433 | 467 | ||
| 468 | + /** | ||
| 469 | + * 设置箭头高度 | ||
| 470 | + * | ||
| 471 | + * @param resId | ||
| 472 | + * @return | ||
| 473 | + */ | ||
| 434 | public Builder setArrowHeight(@DimenRes int resId) { | 474 | public Builder setArrowHeight(@DimenRes int resId) { |
| 435 | return setArrowHeight(mContext.getResources().getDimension(resId)); | 475 | return setArrowHeight(mContext.getResources().getDimension(resId)); |
| 436 | } | 476 | } |
| @@ -440,6 +480,12 @@ public final class PopMenu { | @@ -440,6 +480,12 @@ public final class PopMenu { | ||
| 440 | return this; | 480 | return this; |
| 441 | } | 481 | } |
| 442 | 482 | ||
| 483 | + /** | ||
| 484 | + * 设置箭头宽度 | ||
| 485 | + * | ||
| 486 | + * @param resId | ||
| 487 | + * @return | ||
| 488 | + */ | ||
| 443 | public Builder setArrowWidth(@DimenRes int resId) { | 489 | public Builder setArrowWidth(@DimenRes int resId) { |
| 444 | return setArrowWidth(mContext.getResources().getDimension(resId)); | 490 | return setArrowWidth(mContext.getResources().getDimension(resId)); |
| 445 | } | 491 | } |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/adapter/PopMenuAdapter.java renamed to module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/widget/popmenu/PopMenuAdapter.java
| 1 | -package com.cnlive.strike.xiaojiaspeaker.ui.adapter; | 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.databinding.DataBindingUtil; | 4 | import android.databinding.DataBindingUtil; |
| @@ -10,10 +10,10 @@ import android.view.LayoutInflater; | @@ -10,10 +10,10 @@ import android.view.LayoutInflater; | ||
| 10 | import android.view.View; | 10 | import android.view.View; |
| 11 | import android.view.ViewGroup; | 11 | import android.view.ViewGroup; |
| 12 | 12 | ||
| 13 | +import com.cnlive.strike.application.GlideApp; | ||
| 13 | import com.cnlive.strike.xiaojiaspeaker.R; | 14 | import com.cnlive.strike.xiaojiaspeaker.R; |
| 14 | -import com.cnlive.strike.xiaojiaspeaker.databinding.ListItemWifi1Binding; | ||
| 15 | import com.cnlive.strike.xiaojiaspeaker.databinding.PopItemMenuBinding; | 15 | import com.cnlive.strike.xiaojiaspeaker.databinding.PopItemMenuBinding; |
| 16 | -import com.cnlive.strike.xiaojiaspeaker.model.PopMenuInfo; | 16 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenuInfo; |
| 17 | 17 | ||
| 18 | import java.util.List; | 18 | import java.util.List; |
| 19 | 19 | ||
| @@ -72,10 +72,16 @@ public class PopMenuAdapter extends RecyclerView.Adapter { | @@ -72,10 +72,16 @@ public class PopMenuAdapter extends RecyclerView.Adapter { | ||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | //判断图标是否显示 | 74 | //判断图标是否显示 |
| 75 | - if (0 == popMenuInfoList.get(i).getImgDraw()) { | 75 | + if (0 == popMenuInfoList.get(i).getImgDrawable() && TextUtils.isEmpty(popMenuInfoList.get(i).getNetImag())) { |
| 76 | binding.ivIcon.setVisibility(View.GONE); | 76 | binding.ivIcon.setVisibility(View.GONE); |
| 77 | } else { | 77 | } else { |
| 78 | binding.ivIcon.setVisibility(View.VISIBLE); | 78 | binding.ivIcon.setVisibility(View.VISIBLE); |
| 79 | + //优先显示网络图片 | ||
| 80 | + if (!TextUtils.isEmpty(popMenuInfoList.get(i).getNetImag())) { | ||
| 81 | + GlideApp.with(context).load(popMenuInfoList.get(i).getNetImag()).placeholder(R.color.white_50).into(binding.ivIcon); | ||
| 82 | + } else { | ||
| 83 | + GlideApp.with(context).load(popMenuInfoList.get(i).getImgDrawable()).placeholder(R.color.white_50).into(binding.ivIcon); | ||
| 84 | + } | ||
| 79 | } | 85 | } |
| 80 | //点击 | 86 | //点击 |
| 81 | } | 87 | } |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/model/PopMenuInfo.java renamed to module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/widget/popmenu/PopMenuInfo.java
| 1 | -package com.cnlive.strike.xiaojiaspeaker.model; | 1 | +package com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu; |
| 2 | 2 | ||
| 3 | public class PopMenuInfo { | 3 | public class PopMenuInfo { |
| 4 | private String title; | 4 | private String title; |
| 5 | - private int imgDraw; | 5 | + private int imgDrawable; |
| 6 | + private String netImag; | ||
| 7 | + | ||
| 8 | + public int getImgDrawable() { | ||
| 9 | + return imgDrawable; | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + public void setImgDrawable(int imgDrawable) { | ||
| 13 | + this.imgDrawable = imgDrawable; | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + public String getNetImag() { | ||
| 17 | + return netImag; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public void setNetImag(String netImag) { | ||
| 21 | + this.netImag = netImag; | ||
| 22 | + } | ||
| 6 | 23 | ||
| 7 | public String getTitle() { | 24 | public String getTitle() { |
| 8 | return title; | 25 | return title; |
| @@ -12,11 +29,4 @@ public class PopMenuInfo { | @@ -12,11 +29,4 @@ public class PopMenuInfo { | ||
| 12 | this.title = title; | 29 | this.title = title; |
| 13 | } | 30 | } |
| 14 | 31 | ||
| 15 | - public int getImgDraw() { | ||
| 16 | - return imgDraw; | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - public void setImgDraw(int imgDraw) { | ||
| 20 | - this.imgDraw = imgDraw; | ||
| 21 | - } | ||
| 22 | } | 32 | } |
module_xiaojiaSoundBox/src/main/res/anim/context_menu_enter.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<set xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + > | ||
| 4 | +<!-- <alpha--> | ||
| 5 | +<!-- android:duration="200"--> | ||
| 6 | +<!-- android:fromAlpha="0.0"--> | ||
| 7 | +<!-- android:toAlpha="1.0"/>--> | ||
| 8 | +<!-- 什么都不做--> | ||
| 9 | +<!-- <scale--> | ||
| 10 | +<!-- android:duration="200"--> | ||
| 11 | +<!-- android:fromXScale="0.0"--> | ||
| 12 | +<!-- android:fromYScale="0.0"--> | ||
| 13 | +<!-- android:interpolator="@android:anim/accelerate_interpolator"--> | ||
| 14 | +<!-- android:pivotX="100%"--> | ||
| 15 | +<!-- android:pivotY="0%"--> | ||
| 16 | +<!-- android:toXScale="1"--> | ||
| 17 | +<!-- android:toYScale="1"/>--> | ||
| 18 | +</set> | ||
| 0 | \ No newline at end of file | 19 | \ No newline at end of file |
module_xiaojiaSoundBox/src/main/res/anim/context_menu_exit.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <alpha | ||
| 4 | + android:duration="300" | ||
| 5 | + android:fromAlpha="1.0" | ||
| 6 | + android:toAlpha="0.0" /> | ||
| 7 | + <!-- <scale--> | ||
| 8 | + <!-- android:duration="200"--> | ||
| 9 | + <!-- android:fromXScale="1.0"--> | ||
| 10 | + <!-- android:fromYScale="1.0"--> | ||
| 11 | + <!-- android:interpolator="@android:anim/accelerate_interpolator"--> | ||
| 12 | + <!-- android:pivotX="100%"--> | ||
| 13 | + <!-- android:pivotY="0%"--> | ||
| 14 | + <!-- android:toXScale="1.0"--> | ||
| 15 | + <!-- android:toYScale="0"/>--> | ||
| 16 | +</set> | ||
| 0 | \ No newline at end of file | 17 | \ No newline at end of file |
module_xiaojiaSoundBox/src/main/res/drawable-hdpi/icon_big_xiaojia.png
0 → 100644
22.8 KB
module_xiaojiaSoundBox/src/main/res/drawable-xhdpi/icon_big_xiaojia.png
0 → 100644
40 KB
module_xiaojiaSoundBox/src/main/res/drawable-xxhdpi/icon_big_xiaojia.png
0 → 100644
76 KB
module_xiaojiaSoundBox/src/main/res/drawable/shape_red_circle.xml
0 → 100644
module_xiaojiaSoundBox/src/main/res/layout/activity_firmware_update.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="match_parent" | ||
| 7 | + tools:context=".ui.activity.FirmwareUpdateActivity"> | ||
| 8 | + | ||
| 9 | +</android.support.constraint.ConstraintLayout> | ||
| 0 | \ No newline at end of file | 10 | \ No newline at end of file |
module_xiaojiaSoundBox/src/main/res/layout/activity_search_device.xml
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | tools:context=".ui.activity.SearchDeviceActivity"> | 7 | tools:context=".ui.activity.SearchDeviceActivity"> |
| 8 | 8 | ||
| 9 | + | ||
| 9 | <RelativeLayout | 10 | <RelativeLayout |
| 10 | android:id="@+id/fragment_container" | 11 | android:id="@+id/fragment_container" |
| 11 | android:layout_width="match_parent" | 12 | android:layout_width="match_parent" |
module_xiaojiaSoundBox/src/main/res/layout/fragment_firmware_update.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<layout> | ||
| 3 | + | ||
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 5 | + android:layout_width="match_parent" | ||
| 6 | + android:layout_height="match_parent" | ||
| 7 | + android:background="@color/white" | ||
| 8 | + android:orientation="vertical"> | ||
| 9 | + | ||
| 10 | + <com.qmuiteam.qmui.widget.QMUITopBar | ||
| 11 | + android:id="@+id/topbar" | ||
| 12 | + android:layout_width="match_parent" | ||
| 13 | + android:layout_height="?attr/qmui_topbar_height" /> | ||
| 14 | + | ||
| 15 | + <LinearLayout | ||
| 16 | + android:layout_width="match_parent" | ||
| 17 | + android:layout_height="0dp" | ||
| 18 | + android:layout_weight="2" | ||
| 19 | + android:gravity="center" | ||
| 20 | + android:orientation="vertical"> | ||
| 21 | + | ||
| 22 | + <ImageView | ||
| 23 | + android:layout_width="350dp" | ||
| 24 | + android:layout_height="200dp" | ||
| 25 | + android:layout_gravity="center_horizontal" | ||
| 26 | + android:background="@drawable/icon_big_xiaojia" | ||
| 27 | + android:scaleType="fitXY" /> | ||
| 28 | + | ||
| 29 | + <LinearLayout | ||
| 30 | + android:layout_width="wrap_content" | ||
| 31 | + android:layout_height="wrap_content" | ||
| 32 | + android:layout_marginTop="30dp"> | ||
| 33 | + | ||
| 34 | + <TextView | ||
| 35 | + android:layout_width="wrap_content" | ||
| 36 | + android:layout_height="wrap_content" | ||
| 37 | + android:text="当前版本v:" | ||
| 38 | + android:textColor="@color/color_282828" | ||
| 39 | + android:textSize="16sp" /> | ||
| 40 | + | ||
| 41 | + <TextView | ||
| 42 | + android:id="@+id/tv_current_version" | ||
| 43 | + android:layout_width="wrap_content" | ||
| 44 | + android:layout_height="wrap_content" | ||
| 45 | + android:text="1.0.39.20190516" | ||
| 46 | + android:textColor="@color/color_282828" | ||
| 47 | + android:textSize="16sp" /> | ||
| 48 | + </LinearLayout> | ||
| 49 | + | ||
| 50 | + <LinearLayout | ||
| 51 | + android:layout_width="wrap_content" | ||
| 52 | + android:layout_height="wrap_content" | ||
| 53 | + android:layout_marginTop="20dp"> | ||
| 54 | + | ||
| 55 | + <TextView | ||
| 56 | + android:layout_width="wrap_content" | ||
| 57 | + android:layout_height="wrap_content" | ||
| 58 | + android:text="最新版本v:" | ||
| 59 | + android:textColor="@color/color_282828" | ||
| 60 | + android:textSize="16sp" /> | ||
| 61 | + | ||
| 62 | + <TextView | ||
| 63 | + android:id="@+id/tv_new_version" | ||
| 64 | + android:layout_width="wrap_content" | ||
| 65 | + android:layout_height="wrap_content" | ||
| 66 | + android:text="1.0.39.20190516" | ||
| 67 | + android:textColor="@color/color_282828" | ||
| 68 | + android:textSize="16sp" /> | ||
| 69 | + </LinearLayout> | ||
| 70 | + </LinearLayout> | ||
| 71 | + | ||
| 72 | + <LinearLayout | ||
| 73 | + android:layout_width="match_parent" | ||
| 74 | + android:layout_height="0dp" | ||
| 75 | + android:layout_weight="1" | ||
| 76 | + android:gravity="center"> | ||
| 77 | + | ||
| 78 | + <FrameLayout | ||
| 79 | + android:layout_width="match_parent" | ||
| 80 | + android:layout_height="wrap_content" | ||
| 81 | + android:layout_marginLeft="20dp" | ||
| 82 | + android:layout_marginRight="20dp"> | ||
| 83 | + | ||
| 84 | + <Button | ||
| 85 | + android:id="@+id/btn_check_update" | ||
| 86 | + android:layout_width="match_parent" | ||
| 87 | + android:layout_height="45dp" | ||
| 88 | + android:background="@drawable/selector_btn_green" | ||
| 89 | + android:gravity="center" | ||
| 90 | + android:text="检查更新" | ||
| 91 | + android:textColor="@color/white" | ||
| 92 | + android:textSize="18sp" | ||
| 93 | + android:textStyle="bold" /> | ||
| 94 | + | ||
| 95 | + <View | ||
| 96 | + android:layout_width="9dp" | ||
| 97 | + android:layout_height="9dp" | ||
| 98 | + android:layout_gravity="center" | ||
| 99 | + android:layout_marginLeft="50dp" | ||
| 100 | + android:layout_marginBottom="10dp" | ||
| 101 | + android:background="@drawable/shape_red_circle" /> | ||
| 102 | + </FrameLayout> | ||
| 103 | + | ||
| 104 | + </LinearLayout> | ||
| 105 | + </LinearLayout> | ||
| 106 | +</layout> | ||
| 0 | \ No newline at end of file | 107 | \ No newline at end of file |
module_xiaojiaSoundBox/src/main/res/layout/pop_item_menu.xml
| @@ -6,9 +6,9 @@ | @@ -6,9 +6,9 @@ | ||
| 6 | android:layout_width="wrap_content" | 6 | android:layout_width="wrap_content" |
| 7 | android:layout_height="wrap_content" | 7 | android:layout_height="wrap_content" |
| 8 | android:background="@drawable/selectable_pop_item_background" | 8 | android:background="@drawable/selectable_pop_item_background" |
| 9 | + android:clickable="true" | ||
| 9 | android:gravity="center_vertical" | 10 | android:gravity="center_vertical" |
| 10 | android:minWidth="100dp" | 11 | android:minWidth="100dp" |
| 11 | - android:clickable="true" | ||
| 12 | android:orientation="vertical"> | 12 | android:orientation="vertical"> |
| 13 | 13 | ||
| 14 | <LinearLayout | 14 | <LinearLayout |
| @@ -20,14 +20,16 @@ | @@ -20,14 +20,16 @@ | ||
| 20 | android:id="@+id/iv_icon" | 20 | android:id="@+id/iv_icon" |
| 21 | android:layout_width="20dp" | 21 | android:layout_width="20dp" |
| 22 | android:layout_height="20dp" | 22 | android:layout_height="20dp" |
| 23 | - android:layout_marginLeft="10dp" | ||
| 24 | - android:background="@drawable/key_instruction" /> | 23 | + android:layout_marginLeft="10dp" /> |
| 25 | 24 | ||
| 26 | <TextView | 25 | <TextView |
| 27 | android:id="@+id/tv_tip" | 26 | android:id="@+id/tv_tip" |
| 28 | android:layout_width="wrap_content" | 27 | android:layout_width="wrap_content" |
| 29 | android:layout_height="wrap_content" | 28 | android:layout_height="wrap_content" |
| 30 | android:layout_marginLeft="10dp" | 29 | android:layout_marginLeft="10dp" |
| 30 | + android:layout_marginTop="2dp" | ||
| 31 | + android:layout_marginRight="10dp" | ||
| 32 | + android:layout_marginBottom="2dp" | ||
| 31 | android:gravity="center_vertical" | 33 | android:gravity="center_vertical" |
| 32 | android:minHeight="35dp" | 34 | android:minHeight="35dp" |
| 33 | android:textColor="@color/color_282828" | 35 | android:textColor="@color/color_282828" |
| @@ -37,7 +39,7 @@ | @@ -37,7 +39,7 @@ | ||
| 37 | <View | 39 | <View |
| 38 | android:id="@+id/view_line" | 40 | android:id="@+id/view_line" |
| 39 | android:layout_width="match_parent" | 41 | android:layout_width="match_parent" |
| 40 | - android:layout_height="0.2dp" | 42 | + android:layout_height="0.1dp" |
| 41 | android:background="@color/line" /> | 43 | android:background="@color/line" /> |
| 42 | 44 | ||
| 43 | </LinearLayout> | 45 | </LinearLayout> |
module_xiaojiaSoundBox/src/main/res/values/styles.xml
| @@ -27,4 +27,11 @@ | @@ -27,4 +27,11 @@ | ||
| 27 | <item name="kswThumbWidth">@dimen/ksw_md_thumb_ripple_size</item> | 27 | <item name="kswThumbWidth">@dimen/ksw_md_thumb_ripple_size</item> |
| 28 | <item name="kswThumbHeight">@dimen/ksw_md_thumb_ripple_size</item> | 28 | <item name="kswThumbHeight">@dimen/ksw_md_thumb_ripple_size</item> |
| 29 | </style> | 29 | </style> |
| 30 | + <!--pop特效--> | ||
| 31 | + <style name="contextMenuAnim" parent="@android:style/Animation.Activity"> | ||
| 32 | + <item name="android:windowEnterAnimation">@anim/context_menu_enter</item> | ||
| 33 | + <!-- 指定显示时的动画xml --> | ||
| 34 | + <item name="android:windowExitAnimation">@anim/context_menu_exit</item> | ||
| 35 | + <!-- 指定消失时的动画xml --> | ||
| 36 | + </style> | ||
| 30 | </resources> | 37 | </resources> |