Commit d1cb2a918002c192d33993d218820c06d7bda4e0

Authored by YangShuai
2 parents ce60638e e25988c4

Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/newModuleStrike

app/strike/src/main/AndroidManifest.xml
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 android:theme="@style/AppTheme"> 18 android:theme="@style/AppTheme">
19 <activity android:name=".demo.activity.DemoActivity" /> 19 <activity android:name=".demo.activity.DemoActivity" />
20 <activity android:name=".MyActivity"></activity> 20 <activity android:name=".MyActivity"></activity>
  21 + <activity android:name=".imgutil.ImgActivity"/>
21 <activity android:name=".MainActivity"> 22 <activity android:name=".MainActivity">
22 <intent-filter> 23 <intent-filter>
23 <action android:name="android.intent.action.MAIN" /> 24 <action android:name="android.intent.action.MAIN" />
app/strike/src/main/assets/timgs.png 0 → 100644

48.7 KB

app/strike/src/main/java/com/cnlive/strike/imgutil/ImgActivity.java
@@ -3,20 +3,32 @@ package com.cnlive.strike.imgutil; @@ -3,20 +3,32 @@ package com.cnlive.strike.imgutil;
3 import androidx.appcompat.app.AppCompatActivity; 3 import androidx.appcompat.app.AppCompatActivity;
4 4
5 import android.animation.ObjectAnimator; 5 import android.animation.ObjectAnimator;
  6 +import android.graphics.Bitmap;
  7 +import android.graphics.Rect;
6 import android.os.Bundle; 8 import android.os.Bundle;
  9 +import android.os.Handler;
  10 +import android.os.Message;
  11 +import android.util.Log;
7 import android.view.View; 12 import android.view.View;
8 -import android.view.ViewPropertyAnimator;  
9 import android.widget.ImageView; 13 import android.widget.ImageView;
  14 +import android.widget.Toast;
10 15
  16 +import com.bumptech.glide.load.engine.DiskCacheStrategy;
11 import com.bumptech.glide.request.transition.ViewPropertyTransition; 17 import com.bumptech.glide.request.transition.ViewPropertyTransition;
  18 +import com.cnlive.core.imageload.callback.ImageDownLoadCallBack;
  19 +import com.cnlive.core.imageload.config.PriorityMode;
  20 +import com.cnlive.core.imageload.config.ScaleMode;
12 import com.cnlive.core.imageload.loader.ImageLoader; 21 import com.cnlive.core.imageload.loader.ImageLoader;
  22 +import com.cnlive.core.imageload.util.DownLoadImageService;
13 import com.cnlive.strike.R; 23 import com.cnlive.strike.R;
14 24
  25 +import java.io.File;
  26 +import java.util.ArrayList;
  27 +
15 public class ImgActivity extends AppCompatActivity { 28 public class ImgActivity extends AppCompatActivity {
16 29
17 private ImageView iv_test1; 30 private ImageView iv_test1;
18 private ImageView iv_test2; 31 private ImageView iv_test2;
19 - private ImageView iv_test02;  
20 private ImageView iv_test3; 32 private ImageView iv_test3;
21 private ImageView iv_test4; 33 private ImageView iv_test4;
22 private ImageView iv_test5; 34 private ImageView iv_test5;
@@ -26,12 +38,28 @@ public class ImgActivity extends AppCompatActivity { @@ -26,12 +38,28 @@ public class ImgActivity extends AppCompatActivity {
26 private ImageView iv_test9; 38 private ImageView iv_test9;
27 private ImageView iv_test10; 39 private ImageView iv_test10;
28 private ImageView iv_test11; 40 private ImageView iv_test11;
29 - private ImageView iv_test12;  
30 - private ImageView iv_test13;  
31 - private ImageView iv_test14;  
32 - private ImageView iv_test15; 41 +
  42 +
  43 + Handler handler = new Handler() {
  44 + @Override
  45 + public void handleMessage(Message msg) {
  46 + super.handleMessage(msg);
  47 + if (msg.what == 1) {
  48 + iv_test11.setImageBitmap(bitmaps);
  49 + }
  50 + }
  51 + };
  52 +
33 53
34 String URL1 = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574403931080&di=ea10bd1adb20025f02e296d8694f7bb4&imgtype=0&src=http%3A%2F%2Fimg3.duitang.com%2Fuploads%2Fitem%2F201506%2F23%2F20150623164841_jtvR3.thumb.700_0.jpeg"; 54 String URL1 = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574403931080&di=ea10bd1adb20025f02e296d8694f7bb4&imgtype=0&src=http%3A%2F%2Fimg3.duitang.com%2Fuploads%2Fitem%2F201506%2F23%2F20150623164841_jtvR3.thumb.700_0.jpeg";
  55 + String URL2 = "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1035013881,3985887911&fm=26&gp=0.jpg";
  56 +
  57 +
  58 + String FOREWARD_SLASH = "/";
  59 + String ASSERTS_PATH ="file:///android_asset/" ;
  60 + String ANDROID_RESOURCE ="android.resource://" ;
  61 + String RAW ="/raw/" ;
  62 + Bitmap bitmaps;
35 63
36 @Override 64 @Override
37 protected void onCreate(Bundle savedInstanceState) { 65 protected void onCreate(Bundle savedInstanceState) {
@@ -45,7 +73,6 @@ public class ImgActivity extends AppCompatActivity { @@ -45,7 +73,6 @@ public class ImgActivity extends AppCompatActivity {
45 private void findview() { 73 private void findview() {
46 iv_test1 = findViewById(R.id.iv_test1); 74 iv_test1 = findViewById(R.id.iv_test1);
47 iv_test2 = findViewById(R.id.iv_test2); 75 iv_test2 = findViewById(R.id.iv_test2);
48 - iv_test02 = findViewById(R.id.iv_test02);  
49 iv_test3 = findViewById(R.id.iv_test3); 76 iv_test3 = findViewById(R.id.iv_test3);
50 iv_test4 = findViewById(R.id.iv_test4); 77 iv_test4 = findViewById(R.id.iv_test4);
51 iv_test5 = findViewById(R.id.iv_test5); 78 iv_test5 = findViewById(R.id.iv_test5);
@@ -55,10 +82,6 @@ public class ImgActivity extends AppCompatActivity { @@ -55,10 +82,6 @@ public class ImgActivity extends AppCompatActivity {
55 iv_test9 = findViewById(R.id.iv_test9); 82 iv_test9 = findViewById(R.id.iv_test9);
56 iv_test10 = findViewById(R.id.iv_test10); 83 iv_test10 = findViewById(R.id.iv_test10);
57 iv_test11 = findViewById(R.id.iv_test11); 84 iv_test11 = findViewById(R.id.iv_test11);
58 - iv_test12 = findViewById(R.id.iv_test12);  
59 - iv_test13 = findViewById(R.id.iv_test13);  
60 - iv_test14 = findViewById(R.id.iv_test14);  
61 - iv_test15 = findViewById(R.id.iv_test15);  
62 } 85 }
63 86
64 87
@@ -74,21 +97,126 @@ public class ImgActivity extends AppCompatActivity { @@ -74,21 +97,126 @@ public class ImgActivity extends AppCompatActivity {
74 } 97 }
75 }; 98 };
76 99
  100 +
  101 +// //组织数据
  102 +// ArrayList<ThumbViewInfo> mThumbViewInfoList = new ArrayList<>(); // 这个最好定义成成员变量
  103 +// ThumbViewInfo item;
  104 +// mThumbViewInfoList.clear();
  105 +// for (int i = 0;i < resultList.size(); i++) {
  106 +// Rect bounds = new Rect();
  107 +// //new ThumbViewInfo(图片地址);
  108 +// item=new ThumbViewInfo(resultList.get(i).getOriginUrl());
  109 +// item.setBounds(bounds);
  110 +// mThumbViewInfoList.add(item);
  111 +// }
  112 +//
  113 +////打开预览界面
  114 +// GPreviewBuilder.from(Context context)
  115 +// //是否使用自定义预览界面,当然8.0之后因为配置问题,必须要使用
  116 +// .to(ImageLookActivity.class)
  117 +// .setData(mThumbViewInfoList)
  118 +// .setCurrentIndex(position)
  119 +// .setSingleFling(true)
  120 +// .setType(GPreviewBuilder.IndicatorType.Number)
  121 +// // 小圆点
  122 +//// .setType(GPreviewBuilder.IndicatorType.Dot)
  123 +// .start();//启动
  124 +
77 ImageLoader.with(this) 125 ImageLoader.with(this)
78 .url(URL1) 126 .url(URL1)
79 .animate(animation) 127 .animate(animation)
  128 + .scale(ScaleMode.CENTER_CROP)
80 .into(iv_test1); 129 .into(iv_test1);
81 130
82 ImageLoader.with(this) 131 ImageLoader.with(this)
83 .url(URL1) 132 .url(URL1)
84 - .scale(1)//缩放几倍  
85 - .into(iv_test02); 133 + .scale(ScaleMode.FIT_CENTER)
  134 + .into(iv_test2);
  135 +
  136 +// Glide.with(this).asGif().diskCacheStrategy(DiskCacheStrategy.RESOURCE).load(URL2).into(iv_test3);
86 137
87 ImageLoader.with(this) 138 ImageLoader.with(this)
88 - .url(URL1)  
89 - .scale(3)  
90 - .into(iv_test2); 139 + .url(URL2)
  140 + .placeHolder(R.mipmap.ic_launcher)
  141 + .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
  142 + .scale(ScaleMode.FIT_CENTER)
  143 + .into(iv_test3);
  144 +
  145 + ImageLoader.with(this)
  146 + .res(R.mipmap.timg)
  147 + .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
  148 + .into(iv_test4);
91 149
  150 + ImageLoader.with(this)
  151 + .res(R.mipmap.timgs)
  152 + .into(iv_test5);
  153 +
  154 + ImageLoader.with(this)
  155 + .res(R.mipmap.timgs)
  156 + .vignetteFilter()//晕映
  157 + .priority(PriorityMode.PRIORITY_NORMAL)//优先级
  158 + .into(iv_test6);
  159 +
  160 + ImageLoader.with(this)
  161 + .res(R.mipmap.timgs)
  162 + .sketchFilter()
  163 + .into(iv_test7);
  164 +
  165 + ImageLoader.with(this)
  166 + .res(R.mipmap.timgs)
  167 + .sketchFilter()
  168 + .into(iv_test7);
  169 +
  170 + //加载本地图片
  171 +// ImageLoader.with(this)
  172 +// .file(new File(getFilesDir(), IMG_NAME_C))
  173 +// .placeHolder(R.mipmap.ic_launcher)
  174 +// .scale(ScaleMode.FIT_CENTER)
  175 +// .into(iv_test7);
92 176
  177 + ImageLoader.with(this)
  178 + .asserts(ASSERTS_PATH + "timgs.png")
  179 + .into(iv_test8);
  180 +
  181 + ImageLoader.with(this)
  182 + .raw(ANDROID_RESOURCE+getPackageName()+RAW+R.raw.timgs)
  183 + .placeHolder(R.mipmap.ic_launcher)
  184 + .scale(ScaleMode.FIT_CENTER)
  185 + .asCircle()
  186 + .into(iv_test9);
  187 +
  188 + ImageLoader.with(this)
  189 + .res(R.mipmap.timgs)
  190 + .placeHolder(R.mipmap.ic_launcher)
  191 + .scale(ScaleMode.FIT_CENTER)
  192 + .rectRoundCorner(50)
  193 + .into(iv_test10);
  194 +
  195 + // .asSquare()//正方形
  196 +
  197 + findViewById(R.id.down).setOnClickListener(view -> {
  198 + ImageLoader.saveImageIntoGallery(new DownLoadImageService(ImgActivity.this, URL1, true, "lala", new ImageDownLoadCallBack() {
  199 +
  200 + @Override
  201 + public void onDownLoadSuccess(Bitmap bitmap) {
  202 + Log.e("sssssss", "onDownLoadSuccess: " );
  203 + //网络请求
  204 + bitmaps = bitmap;
  205 + Message msg = new Message();
  206 + //将获取到的String装载到msg中
  207 + msg.what = 1;
  208 + //发消息到主线程
  209 + handler.sendMessage(msg);
  210 + }
  211 +
  212 + @Override
  213 + public void onDownLoadFailed() {
  214 +// Toast.makeText(ImgActivity.this,"下载",Toast.LENGTH_SHORT).show();
  215 + }
  216 +
  217 + }));
  218 + });
93 } 219 }
  220 +
  221 +
94 } 222 }
app/strike/src/main/res/layout/activity_img.xml
@@ -23,100 +23,122 @@ @@ -23,100 +23,122 @@
23 android:layout_height="wrap_content" 23 android:layout_height="wrap_content"
24 android:text="放大缩小:" 24 android:text="放大缩小:"
25 /> 25 />
26 - <LinearLayout  
27 - android:layout_width="wrap_content"  
28 - android:layout_height="wrap_content"  
29 - android:orientation="vertical">  
30 - <ImageView  
31 - android:id="@+id/iv_test02"  
32 - android:layout_width="300dp"  
33 - android:layout_height="300dp"  
34 - android:padding="10dp" />  
35 <ImageView 26 <ImageView
36 android:id="@+id/iv_test2" 27 android:id="@+id/iv_test2"
37 - android:layout_width="300dp"  
38 - android:layout_height="300dp" 28 + android:layout_width="200dp"
  29 + android:layout_height="200dp"
39 android:padding="10dp" /> 30 android:padding="10dp" />
40 - </LinearLayout> 31 +
  32 + <TextView
  33 + android:layout_width="wrap_content"
  34 + android:layout_height="wrap_content"
  35 + android:text="网络gif:"
  36 + />
41 37
42 <ImageView 38 <ImageView
43 android:id="@+id/iv_test3" 39 android:id="@+id/iv_test3"
44 android:layout_width="300dp" 40 android:layout_width="300dp"
45 android:layout_height="300dp" 41 android:layout_height="300dp"
46 - android:padding="30dp" />  
47 - 42 + android:padding="10dp" />
  43 + <TextView
  44 + android:layout_width="wrap_content"
  45 + android:layout_height="wrap_content"
  46 + android:text="mipmap下的gif:"
  47 + />
48 <ImageView 48 <ImageView
49 android:id="@+id/iv_test4" 49 android:id="@+id/iv_test4"
50 android:layout_width="300dp" 50 android:layout_width="300dp"
51 android:layout_height="300dp" 51 android:layout_height="300dp"
52 - android:padding="30dp" /> 52 + android:padding="10dp" />
53 53
  54 + <TextView
  55 + android:layout_width="wrap_content"
  56 + android:layout_height="wrap_content"
  57 + android:text="mipmap下的图片:"
  58 + />
54 <ImageView 59 <ImageView
55 android:id="@+id/iv_test5" 60 android:id="@+id/iv_test5"
56 android:layout_width="300dp" 61 android:layout_width="300dp"
57 android:layout_height="300dp" 62 android:layout_height="300dp"
58 - android:padding="30dp" /> 63 + android:padding="10dp" />
59 64
  65 + <TextView
  66 + android:layout_width="wrap_content"
  67 + android:layout_height="wrap_content"
  68 + android:text="滤镜优先级设置"
  69 + />
60 <ImageView 70 <ImageView
61 android:id="@+id/iv_test6" 71 android:id="@+id/iv_test6"
62 android:layout_width="300dp" 72 android:layout_width="300dp"
63 android:layout_height="300dp" 73 android:layout_height="300dp"
64 android:padding="30dp" /> 74 android:padding="30dp" />
65 75
  76 + <TextView
  77 + android:layout_width="wrap_content"
  78 + android:layout_height="wrap_content"
  79 + android:text="素描"
  80 + />
66 <ImageView 81 <ImageView
67 android:id="@+id/iv_test7" 82 android:id="@+id/iv_test7"
68 android:layout_width="300dp" 83 android:layout_width="300dp"
69 android:layout_height="300dp" 84 android:layout_height="300dp"
70 android:padding="30dp" /> 85 android:padding="30dp" />
71 86
  87 + <TextView
  88 + android:layout_width="wrap_content"
  89 + android:layout_height="wrap_content"
  90 + android:text="加载asserts下面的图片"
  91 + />
  92 +
72 <ImageView 93 <ImageView
73 android:id="@+id/iv_test8" 94 android:id="@+id/iv_test8"
74 android:layout_width="300dp" 95 android:layout_width="300dp"
75 android:layout_height="300dp" 96 android:layout_height="300dp"
76 android:padding="30dp" /> 97 android:padding="30dp" />
77 98
  99 + <TextView
  100 + android:layout_width="wrap_content"
  101 + android:layout_height="wrap_content"
  102 + android:text="加载raw下面的图片为圆"
  103 + />
78 <ImageView 104 <ImageView
79 android:id="@+id/iv_test9" 105 android:id="@+id/iv_test9"
80 android:layout_width="300dp" 106 android:layout_width="300dp"
81 android:layout_height="300dp" 107 android:layout_height="300dp"
82 android:padding="30dp" /> 108 android:padding="30dp" />
83 109
  110 + <TextView
  111 + android:layout_width="wrap_content"
  112 + android:layout_height="wrap_content"
  113 + android:text="图片设置圆角"
  114 + />
84 <ImageView 115 <ImageView
85 android:id="@+id/iv_test10" 116 android:id="@+id/iv_test10"
86 android:layout_width="300dp" 117 android:layout_width="300dp"
87 android:layout_height="300dp" 118 android:layout_height="300dp"
88 android:padding="30dp" /> 119 android:padding="30dp" />
89 120
90 - <ImageView  
91 - android:id="@+id/iv_test11"  
92 - android:layout_width="300dp"  
93 - android:layout_height="300dp"  
94 - android:padding="30dp" />  
95 -  
96 - <ImageView  
97 - android:id="@+id/iv_test12"  
98 - android:layout_width="300dp"  
99 - android:layout_height="300dp"  
100 - android:padding="30dp" />  
101 -  
102 - <ImageView  
103 - android:id="@+id/iv_test13"  
104 - android:layout_width="300dp"  
105 - android:layout_height="300dp"  
106 - android:padding="30dp" />  
107 -  
108 - <ImageView  
109 - android:id="@+id/iv_test14"  
110 - android:layout_width="300dp"  
111 - android:layout_height="300dp"  
112 - android:padding="30dp" /> 121 + <TextView
  122 + android:layout_width="wrap_content"
  123 + android:layout_height="wrap_content"
  124 + android:text="图片下载显示"
  125 + />
  126 + <Button
  127 + android:id="@+id/down"
  128 + android:layout_width="wrap_content"
  129 + android:layout_height="wrap_content"
  130 + android:text="下载"/>
113 131
114 <ImageView 132 <ImageView
115 - android:id="@+id/iv_test15" 133 + android:id="@+id/iv_test11"
116 android:layout_width="300dp" 134 android:layout_width="300dp"
117 android:layout_height="300dp" 135 android:layout_height="300dp"
118 android:padding="30dp" /> 136 android:padding="30dp" />
119 137
  138 + <TextView
  139 + android:layout_width="wrap_content"
  140 + android:layout_height="wrap_content"
  141 + android:text="直接代码设置,五边形"/>
120 142
121 <com.cnlive.core.imageload.util.MultiView 143 <com.cnlive.core.imageload.util.MultiView
122 android:layout_width="300dp" 144 android:layout_width="300dp"
@@ -124,8 +146,14 @@ @@ -124,8 +146,14 @@
124 android:layout_margin="30dp" 146 android:layout_margin="30dp"
125 lb:angleCount="5" 147 lb:angleCount="5"
126 lb:type="multi" 148 lb:type="multi"
  149 + android:src="@mipmap/timgs"
127 /> 150 />
128 151
  152 + <TextView
  153 + android:layout_width="wrap_content"
  154 + android:layout_height="wrap_content"
  155 + android:text="直接代码设置,设置圆角"/>
  156 +
129 <com.cnlive.core.imageload.util.MultiView 157 <com.cnlive.core.imageload.util.MultiView
130 android:layout_width="200dp" 158 android:layout_width="200dp"
131 android:layout_height="200dp" 159 android:layout_height="200dp"
@@ -133,13 +161,20 @@ @@ -133,13 +161,20 @@
133 android:layout_gravity="center" 161 android:layout_gravity="center"
134 lb:borderRadius="10dp" 162 lb:borderRadius="10dp"
135 lb:type="round" 163 lb:type="round"
  164 + android:src="@mipmap/timgs"
136 /> 165 />
137 166
  167 + <TextView
  168 + android:layout_width="wrap_content"
  169 + android:layout_height="wrap_content"
  170 + android:text="直接代码设置圆"/>
  171 +
138 <com.cnlive.core.imageload.util.MultiView 172 <com.cnlive.core.imageload.util.MultiView
139 android:layout_margin="30dp" 173 android:layout_margin="30dp"
140 android:layout_width="200dp" 174 android:layout_width="200dp"
141 android:layout_height="200dp" 175 android:layout_height="200dp"
142 android:layout_gravity="center" 176 android:layout_gravity="center"
  177 + android:src="@mipmap/timgs"
143 lb:type="circle" 178 lb:type="circle"
144 /> 179 />
145 180
app/strike/src/main/res/mipmap-hdpi/timg.gif 0 → 100644

264 KB

app/strike/src/main/res/mipmap-hdpi/timgs.png 0 → 100644

48.7 KB

app/strike/src/main/res/raw/timgs.png 0 → 100644

48.7 KB

core/imageload/build.gradle
@@ -37,4 +37,6 @@ dependencies { @@ -37,4 +37,6 @@ dependencies {
37 implementation 'jp.wasabeef:glide-transformations:3.0.1' 37 implementation 'jp.wasabeef:glide-transformations:3.0.1'
38 //滤镜 38 //滤镜
39 implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1' 39 implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
  40 + //图片预览
  41 +// implementation 'com.ycjiang:imgepreviewlibrary:1.1.3'
40 } 42 }
core/imageload/src/androidTest/java/com/mm999/imageload/ExampleInstrumentedTest.java deleted 100644 → 0
1 -package com.mm999.imageload;  
2 -  
3 -import android.content.Context;  
4 -  
5 -import androidx.test.platform.app.InstrumentationRegistry;  
6 -import androidx.test.ext.junit.runners.AndroidJUnit4;  
7 -  
8 -import org.junit.Test;  
9 -import org.junit.runner.RunWith;  
10 -  
11 -import static org.junit.Assert.*;  
12 -  
13 -/**  
14 - * Instrumented test, which will execute on an Android device.  
15 - *  
16 - * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>  
17 - */  
18 -@RunWith(AndroidJUnit4.class)  
19 -public class ExampleInstrumentedTest {  
20 - @Test  
21 - public void useAppContext() {  
22 - // Context of the app under test.  
23 - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();  
24 -  
25 - assertEquals("com.mm999.imageload.test", appContext.getPackageName());  
26 - }  
27 -}  
core/imageload/src/test/java/com/mm999/imageload/ExampleUnitTest.java deleted 100644 → 0
1 -package com.mm999.imageload;  
2 -  
3 -import org.junit.Test;  
4 -  
5 -import static org.junit.Assert.*;  
6 -  
7 -/**  
8 - * Example local unit test, which will execute on the development machine (host).  
9 - *  
10 - * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>  
11 - */  
12 -public class ExampleUnitTest {  
13 - @Test  
14 - public void addition_isCorrect() {  
15 - assertEquals(4, 2 + 2);  
16 - }  
17 -}  
18 \ No newline at end of file 0 \ No newline at end of file