e il y a 6 ans
Parent
commit
e225582bec

+ 4 - 2
app/src/main/java/com/kuxuan/moneynote/ui/adapter/SkinAdapter.java

@@ -4,12 +4,13 @@ import android.support.annotation.Nullable;
4 4
 import android.view.View;
5 5
 import android.widget.ImageView;
6 6
 
7
+import com.bumptech.glide.Glide;
7 8
 import com.chad.library.adapter.base.BaseQuickAdapter;
8 9
 import com.chad.library.adapter.base.BaseViewHolder;
9 10
 import com.kuxuan.moneynote.R;
10 11
 import com.kuxuan.moneynote.common.Constant;
11 12
 import com.kuxuan.moneynote.json.netbody.RES;
12
-import com.kuxuan.moneynote.utils.GlideUtil;
13
+import com.kuxuan.moneynote.utils.GlideRoundTransform;
13 14
 import com.kuxuan.moneynote.utils.SPUtil;
14 15
 import com.kuxuan.moneynote.utils.SkinUtil;
15 16
 
@@ -52,7 +53,8 @@ public class SkinAdapter extends BaseQuickAdapter<RES,BaseViewHolder> {
52 53
         }
53 54
 
54 55
         ImageView iv_skin = helper.getView(R.id.iv_skin);
55
-        GlideUtil.setImageWithNoCache(mContext,item.getPreview_img(),iv_skin,false);
56
+//        GlideUtil.setImageWithNoCache(mContext,item.getPreview_img(),iv_skin,false);
57
+        Glide.with(mContext).load(item.getPreview_img()).bitmapTransform(new GlideRoundTransform(mContext,4,true)).into(iv_skin);
56 58
 
57 59
 
58 60
     }

+ 23 - 8
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialFragment.java

@@ -16,6 +16,7 @@ import android.util.Log;
16 16
 import android.view.Gravity;
17 17
 import android.view.LayoutInflater;
18 18
 import android.view.View;
19
+import android.view.WindowManager;
19 20
 import android.widget.ImageView;
20 21
 import android.widget.LinearLayout;
21 22
 import android.widget.PopupWindow;
@@ -536,16 +537,17 @@ public class DetialFragment extends MVPFragment<DetialPresent, DetialModel> impl
536 537
 
537 538
         popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtil.dip2px(138), true);
538 539
         popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
539
-        // 设置PopupWindow是否能响应外部点击事件
540 540
         popupWindow.setOutsideTouchable(true);
541
-        // 设置PopupWindow是否能响应点击事件
542 541
         popupWindow.setTouchable(true);
543
-        // 显示PopupWindow,其中:
544
-        // 第一个参数是PopupWindow的锚点,第二和第三个参数分别是PopupWindow相对锚点的x、y偏移
545
-//        popupWindow.showAsDropDown(anchor, xoff, yoff);
546
-        // 或者也可以调用此方法显示PopupWindow,其中:
547
-        // 第一个参数是PopupWindow的父View,第二个参数是PopupWindow相对父View的位置,
548
-        // 第三和第四个参数分别是PopupWindow相对父View的x、y偏移
542
+
543
+        setBackgroundAlpha(0.5f);
544
+        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
545
+            @Override
546
+            public void onDismiss() {
547
+                // popupWindow隐藏时恢复屏幕正常透明度
548
+                setBackgroundAlpha(1.0f);
549
+            }
550
+        });
549 551
         popupWindow.showAtLocation(relativeLayout, Gravity.BOTTOM, 0, 0);
550 552
 
551 553
         final RecyclerView recyclerView = contentView.findViewById(R.id.recyclerview);
@@ -633,6 +635,19 @@ public class DetialFragment extends MVPFragment<DetialPresent, DetialModel> impl
633 635
 
634 636
     }
635 637
 
638
+    /**
639
+     * 设置添加屏幕的背景透明度
640
+     *
641
+     * @param bgAlpha
642
+     *            屏幕透明度0.0-1.0 1表示完全不透明
643
+     */
644
+    public void setBackgroundAlpha(float bgAlpha) {
645
+        WindowManager.LayoutParams lp = getActivity().getWindow()
646
+                .getAttributes();
647
+        lp.alpha = bgAlpha;
648
+        getActivity().getWindow().setAttributes(lp);
649
+    }
650
+
636 651
 
637 652
     private void setSkinData() {
638 653
 

+ 22 - 24
app/src/main/java/com/kuxuan/moneynote/ui/fragments/details/DetialModel.java

@@ -95,7 +95,7 @@ public class DetialModel implements DetialContract.DetialModel {
95 95
 
96 96
 
97 97
 
98
-    Thread mThread;
98
+
99 99
     @Override
100 100
     public void getDataListsForDB(final String year, final String month, final HashMap<String, Integer> maps, final MVPListener<UserAllBillJson> listMVPListener) {
101 101
         io.reactivex.Observable.create(new ObservableOnSubscribe<UserAllBillJson>() {
@@ -130,7 +130,7 @@ public class DetialModel implements DetialContract.DetialModel {
130 130
 
131 131
     }
132 132
 
133
-    String  mVideoPath;
133
+    String  mPICPath;
134 134
     File mFile;
135 135
     @Override
136 136
     public void downLoadPic(String url, int size, int position, final DetialContract.DownloadListener downloadListener) {
@@ -144,33 +144,24 @@ public class DetialModel implements DetialContract.DetialModel {
144 144
             file.mkdirs() ;
145 145
         }
146 146
         switch (size){
147
-
148 147
             case 0:
149
-
150
-                mVideoPath = fileheader + Constant.Skin.SKINICON+position+".png";
151
-
148
+                mPICPath = fileheader + Constant.Skin.SKINICON+position+".png";
152 149
                 break;
153
-
154 150
             case 1:
155
-
156
-                mVideoPath = fileheader + Constant.Skin.MINE+position+".png";
157
-
151
+                mPICPath = fileheader + Constant.Skin.MINE+position+".png";
158 152
                 break;
159
-
160 153
             case 2:
161
-
162
-                mVideoPath = fileheader + Constant.Skin.HOMEPICNAME+position+".png";
163
-
154
+                mPICPath = fileheader + Constant.Skin.HOMEPICNAME+position+".png";
164 155
                 break;
165 156
         }
166 157
 
167
-        if (TextUtils.isEmpty(mVideoPath)) {
158
+        if (TextUtils.isEmpty(mPICPath)) {
168 159
             Log.e(TAG, "存储路径为空");
169 160
             return;
170 161
         }
171 162
 
172 163
         //建立一个文件
173
-        mFile = new File(mVideoPath);
164
+        mFile = new File(mPICPath);
174 165
 
175 166
         Call<ResponseBody> mCall= ApiHelper.getInstance().buildRetrofit().createService(ApiService.class).downloadPic(url);
176 167
 
@@ -179,16 +170,13 @@ public class DetialModel implements DetialContract.DetialModel {
179 170
             public void onResponse(Call<ResponseBody> call, final Response<ResponseBody> response) {
180 171
 
181 172
 
182
-                //下载文件放在子线程
183
-                mThread = new Thread() {
173
+                new Thread(new Runnable() {
184 174
                     @Override
185 175
                     public void run() {
186
-                        super.run();
187
-                        //保存到本地
188 176
                         writeFile2Disk(response, mFile, downloadListener);
189 177
                     }
190
-                };
191
-                mThread.start();
178
+                }).start();
179
+
192 180
 
193 181
             }
194 182
 
@@ -203,7 +191,9 @@ public class DetialModel implements DetialContract.DetialModel {
203 191
     }
204 192
 
205 193
 
206
-    private void writeFile2Disk(Response<ResponseBody> response, File file, DetialContract.DownloadListener downloadListener) {
194
+    private  void writeFile2Disk(Response<ResponseBody> response, File file, DetialContract.DownloadListener downloadListener) {
195
+
196
+
207 197
         downloadListener.onStart();
208 198
         long currentLength = 0;
209 199
         OutputStream os = null;
@@ -220,10 +210,18 @@ public class DetialModel implements DetialContract.DetialModel {
220 210
                 currentLength += len;
221 211
 //                Log.e(TAG, "当前进度: " + currentLength);
222 212
                 //计算当前下载百分比,并经由回调传出
213
+
214
+                try {
215
+                    Thread.sleep(10);
216
+                } catch (InterruptedException e) {
217
+                    e.printStackTrace();
218
+                }
219
+
220
+
223 221
                 downloadListener.onProgress((int) (100 * currentLength / totalLength));
224 222
                 //当百分比为100时下载结束,调用结束回调,并传出下载后的本地路径
225 223
                 if ((int) (100 * currentLength / totalLength) == 100) {
226
-                    downloadListener.onFinish(mVideoPath); //下载完成
224
+                    downloadListener.onFinish(mPICPath); //下载完成
227 225
                 }
228 226
             }
229 227
         } catch (FileNotFoundException e) {

+ 6 - 0
app/src/main/java/com/kuxuan/moneynote/utils/GlideRoundTransform.java

@@ -24,6 +24,12 @@ public class GlideRoundTransform extends BitmapTransformation {
24 24
         radius = Resources.getSystem().getDisplayMetrics().density * dp;
25 25
     }
26 26
 
27
+    public GlideRoundTransform(Context context, int px,boolean isPx) {
28
+        super(context);
29
+        radius = px;
30
+    }
31
+
32
+
27 33
     @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
28 34
         return roundCrop(pool, toTransform);
29 35
     }

+ 26 - 0
app/src/main/res/drawable/corn.xml

@@ -0,0 +1,26 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+
5
+    <!-- 设置矩形的四个角为弧形 -->
6
+    <corners
7
+        android:topLeftRadius="10px"
8
+        android:topRightRadius="10px"
9
+        android:bottomLeftRadius="10px"
10
+        android:bottomRightRadius="10px" />
11
+
12
+
13
+    <!-- 各方向的间隔 -->
14
+    <!-- 大小 -->
15
+    <size
16
+        android:width="80px"
17
+        android:height="50px"/>
18
+
19
+
20
+    <solid
21
+        android:color="#66000000"
22
+        />
23
+
24
+
25
+
26
+</shape>

+ 10 - 10
app/src/main/res/drawable/progressbar_my.xml

@@ -2,28 +2,27 @@
2 2
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3 3
 
4 4
     <item android:id="@android:id/background">
5
-
6 5
         <shape >
7
-
8
-            <stroke android:color="#0d0f11" android:width="1dp"/>
6
+            <stroke android:color="#ffffff" android:width="1dp"/>
7
+            <corners android:radius="5dip" />
9 8
             <gradient
10 9
                 android:angle="270"
11 10
                 android:centerY="0.75"
12
-                android:endColor="#F5F5F5"
13
-                android:startColor="#BEBEBE" />
11
+                android:endColor="#ffffff"
12
+                android:startColor="#ffffff" />
14 13
         </shape>
15 14
     </item>
16 15
 
17 16
     <item android:id="@android:id/secondaryProgress">
18 17
         <clip >
19 18
             <shape >
20
-                <corners android:radius="0dip" />
19
+                <corners android:radius="5dip" />
21 20
 
22 21
                 <gradient
23 22
                     android:angle="270"
24 23
                     android:centerY="0.75"
25
-                    android:endColor="#165CBC"
26
-                    android:startColor="#85B0E9" />
24
+                    android:endColor="#ffffff"
25
+                    android:startColor="#ffffff" />
27 26
             </shape>
28 27
         </clip>
29 28
     </item>
@@ -32,11 +31,12 @@
32 31
 
33 32
         <clip >
34 33
             <shape >
34
+                <corners android:radius="5dip" />
35 35
                 <gradient
36 36
                     android:angle="270"
37 37
                     android:centerY="0.75"
38
-                    android:endColor="#FE7F00"
39
-                    android:startColor="#FE7F00" />
38
+                    android:endColor="@color/bu_yellow_bg"
39
+                    android:startColor="@color/bu_yellow_bg" />
40 40
             </shape>
41 41
         </clip>
42 42
     </item>

+ 3 - 4
app/src/main/res/layout/skinadapter_item.xml

@@ -12,7 +12,6 @@
12 12
         android:layout_marginLeft="10px"
13 13
         android:layout_marginRight="10px"
14 14
         android:layout_marginTop="5px"
15
-        android:scaleType="fitXY"
16 15
         android:src="@drawable/skin_icon"
17 16
         />
18 17
 
@@ -23,14 +22,14 @@
23 22
         android:layout_marginLeft="10px"
24 23
         android:layout_marginRight="10px"
25 24
         android:layout_marginTop="5px"
26
-        android:background="#66000000"
25
+        android:background="@drawable/corn"
27 26
         />
28 27
 
29 28
 
30 29
     <ProgressBar
31 30
         android:id="@+id/progressbar"
32
-        android:layout_width="80px"
33
-        android:layout_height="3px"
31
+        android:layout_width="60px"
32
+        android:layout_height="5px"
34 33
         android:progress="0"
35 34
         style="@style/progressbar_my"
36 35
         android:layout_centerInParent="true"

+ 2 - 0
app/src/main/res/values-v19/styles.xml

@@ -16,6 +16,8 @@
16 16
     <style name="progressbar_my" parent="@android:style/Widget.ProgressBar.Horizontal">
17 17
         <item name="android:maxHeight" >50px</item>
18 18
         <item name="android:minHeight">8px</item>
19
+        <item name="android:maxWidth">80px</item>
20
+        <item name="android:minWidth">50px</item>
19 21
         <item name="android:indeterminateOnly">false</item>
20 22
         <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
21 23
         <item name="android:progressDrawable">@drawable/progressbar_my</item>

+ 2 - 0
app/src/main/res/values-v21/styles.xml

@@ -17,6 +17,8 @@
17 17
     <style name="progressbar_my" parent="@android:style/Widget.ProgressBar.Horizontal">
18 18
         <item name="android:maxHeight" >50px</item>
19 19
         <item name="android:minHeight">8px</item>
20
+        <item name="android:maxWidth">80px</item>
21
+        <item name="android:minWidth">50px</item>
20 22
         <item name="android:indeterminateOnly">false</item>
21 23
         <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
22 24
         <item name="android:progressDrawable">@drawable/progressbar_my</item>

+ 2 - 0
app/src/main/res/values/styles.xml

@@ -95,6 +95,8 @@
95 95
     <style name="progressbar_my" parent="@android:style/Widget.ProgressBar.Horizontal">
96 96
         <item name="android:maxHeight" >50px</item>
97 97
         <item name="android:minHeight">8px</item>
98
+        <item name="android:maxWidth">80px</item>
99
+        <item name="android:minWidth">50px</item>
98 100
         <item name="android:indeterminateOnly">false</item>
99 101
         <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
100 102
         <item name="android:progressDrawable">@drawable/progressbar_my</item>