e 6 years ago
parent
commit
e225582bec

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

4
 import android.view.View;
4
 import android.view.View;
5
 import android.widget.ImageView;
5
 import android.widget.ImageView;
6
 
6
 
7
+import com.bumptech.glide.Glide;
7
 import com.chad.library.adapter.base.BaseQuickAdapter;
8
 import com.chad.library.adapter.base.BaseQuickAdapter;
8
 import com.chad.library.adapter.base.BaseViewHolder;
9
 import com.chad.library.adapter.base.BaseViewHolder;
9
 import com.kuxuan.moneynote.R;
10
 import com.kuxuan.moneynote.R;
10
 import com.kuxuan.moneynote.common.Constant;
11
 import com.kuxuan.moneynote.common.Constant;
11
 import com.kuxuan.moneynote.json.netbody.RES;
12
 import com.kuxuan.moneynote.json.netbody.RES;
12
-import com.kuxuan.moneynote.utils.GlideUtil;
13
+import com.kuxuan.moneynote.utils.GlideRoundTransform;
13
 import com.kuxuan.moneynote.utils.SPUtil;
14
 import com.kuxuan.moneynote.utils.SPUtil;
14
 import com.kuxuan.moneynote.utils.SkinUtil;
15
 import com.kuxuan.moneynote.utils.SkinUtil;
15
 
16
 
52
         }
53
         }
53
 
54
 
54
         ImageView iv_skin = helper.getView(R.id.iv_skin);
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
 import android.view.Gravity;
16
 import android.view.Gravity;
17
 import android.view.LayoutInflater;
17
 import android.view.LayoutInflater;
18
 import android.view.View;
18
 import android.view.View;
19
+import android.view.WindowManager;
19
 import android.widget.ImageView;
20
 import android.widget.ImageView;
20
 import android.widget.LinearLayout;
21
 import android.widget.LinearLayout;
21
 import android.widget.PopupWindow;
22
 import android.widget.PopupWindow;
536
 
537
 
537
         popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtil.dip2px(138), true);
538
         popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtil.dip2px(138), true);
538
         popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
539
         popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
539
-        // 设置PopupWindow是否能响应外部点击事件
540
         popupWindow.setOutsideTouchable(true);
540
         popupWindow.setOutsideTouchable(true);
541
-        // 设置PopupWindow是否能响应点击事件
542
         popupWindow.setTouchable(true);
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
         popupWindow.showAtLocation(relativeLayout, Gravity.BOTTOM, 0, 0);
551
         popupWindow.showAtLocation(relativeLayout, Gravity.BOTTOM, 0, 0);
550
 
552
 
551
         final RecyclerView recyclerView = contentView.findViewById(R.id.recyclerview);
553
         final RecyclerView recyclerView = contentView.findViewById(R.id.recyclerview);
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
     private void setSkinData() {
652
     private void setSkinData() {
638
 
653
 

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

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

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

24
         radius = Resources.getSystem().getDisplayMetrics().density * dp;
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
     @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
33
     @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
28
         return roundCrop(pool, toTransform);
34
         return roundCrop(pool, toTransform);
29
     }
35
     }

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

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

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

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

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

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

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

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

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

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