Skip to content

Commit

Permalink
多张处理逻辑初步完成, 准备测试
Browse files Browse the repository at this point in the history
  • Loading branch information
suzeyu1992 committed Dec 8, 2016
1 parent f563521 commit b097eae
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 23 deletions.
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -18,16 +18,16 @@
</activity>

<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".PhotoWallActivity">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
</application>
Expand Down
Expand Up @@ -15,8 +15,10 @@
import android.widget.ImageView;

import com.szysky.customize.siv.SImageView;
import com.szysky.customize.siv.imgprocess.ImageLoader;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
Expand All @@ -39,11 +41,34 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);


mSImageView = (SImageView) findViewById(R.id.siv_main);
//mSImageView = (SImageView) findViewById(R.id.siv_main);

findViewById(R.id.btn_crop).setOnClickListener(this);
findViewById(R.id.btn_fix_xy).setOnClickListener(this);
findViewById(R.id.btn_inside).setOnClickListener(this);
// findViewById(R.id.btn_crop).setOnClickListener(this);
// findViewById(R.id.btn_fix_xy).setOnClickListener(this);
// findViewById(R.id.btn_inside).setOnClickListener(this);

// 测试网络
SImageView sImageViewForHttp = (SImageView) findViewById(R.id.siv_url);

List<String> urls = new ArrayList<>();

for (int i = 0; i < 1; i++) {
// urls.add("http://szysky.com/2016/12/05/%E5%B9%B4%E7%BB%88%E7%A6%8F%E5%88%A9-SImageView%E5%AE%9E%E7%94%A8%E7%9A%84%E5%9B%BE%E7%89%87%E6%8E%A7%E4%BB%B6/sample_2.gif");
urls.add("http://img9.dzdwl.com/img/11543935W-1.jpg");
urls.add("http://img02.tooopen.com/images/20160408/tooopen_sy_158723161481.jpg");
// urls.add("http://img02.tooopen.com/images/20160404/tooopen_sy_158262392146.jpg");
urls.add("http://img02.tooopen.com/images/20160318/tooopen_sy_156339294124.jpg");
// urls.add("http://img06.tooopen.com/images/20160823/tooopen_sy_176393394325.jpg");
// urls.add("http://img06.tooopen.com/images/20160821/tooopen_sy_176144979595.jpg");
// urls.add("http://img06.tooopen.com/images/20160723/tooopen_sy_171462742667.jpg");
// urls.add("http://img05.tooopen.com/images/20150417/tooopen_sy_119014046478.jpg");
// urls.add("http://img02.tooopen.com/images/20150318/tooopen_sy_82853534894.jpg");
// urls.add("http://img05.tooopen.com/images/20150204/tooopen_sy_80359399983.jpg");
// urls.add("http://img01.tooopen.com/Downs/images/2010/4/9/sy_20100409135808693051.jpg");
// urls.add("http://pics.sc.chinaz.com/files/pic/pic9/201410/apic7065.jpg");
}

ImageLoader.getInstance(getApplicationContext()).setMulPicture(urls, sImageViewForHttp, 0,0);

}

Expand Down
23 changes: 14 additions & 9 deletions app/src/main/res/layout/activity_second.xml
Expand Up @@ -6,16 +6,21 @@
android:paddingTop="5dp"
android:layout_height="match_parent">

<!--<com.szysky.customize.siv.SImageView-->
<!--android:id="@+id/siv_main"-->
<!--android:background="@color/colorAccent"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="200dp"-->
<!--app:displayType="rect"-->
<!--app:border_color="@color/colorPrimary"-->
<!--app:border_width="0dp"-->
<!--app:img="@mipmap/ic_1"-->
<!--app:scaleType="center_inside"/>-->

<com.szysky.customize.siv.SImageView
android:id="@+id/siv_main"
android:background="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="200dp"
app:displayType="rect"
app:border_color="@color/colorPrimary"
app:border_width="0dp"
app:img="@mipmap/ic_1"
app:scaleType="center_inside"/>
android:id="@+id/siv_url"
android:layout_width="100dp"
android:layout_height="100dp" />

<View
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' //用于打包Maven所需文件
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3' //用于上传Maven生成的文件到Bintray

Expand Down
Expand Up @@ -284,13 +284,22 @@ public void run() {
Log.e(TAG, "在磁盘获取缓存失败发送handler后, 无法从网络获取到bitmap对象!!! " );
}
};


// 添加任务到线程池
THREAD_POOL_EXECUTOR.execute(loadBitmapTask);
break;

// 多张图片从磁盘获取成功
case MESSAGE_MULTI_DISK_GET_OK:

RequestBean requestOk = (RequestBean) msg.obj;
// 进行控件是否需要有效的判断
if (requestOk.sImageView.getTag().equals(requestOk.getTag())){
requestOk.sImageView.setImages(requestOk.asListBitmap());
}else{
Log.w(TAG, "多张图片>>>>控件的url发生改变, so取消设置图片");
}

break;

default:
super.handleMessage(msg);
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class RequestBean {
public long startTime = System.currentTimeMillis();
public int loadTotal; // 需要下载的总数
public volatile int loadedNum; // 已经完成的数量
private String mTag ; // 设置图片对应的控件的tag
private String mTag = "" ; // 设置图片对应的控件的tag


public RequestBean(List<String> urls, SImageView sImageView, int reqWidth, int reqHeight) {
Expand All @@ -50,10 +50,11 @@ public RequestBean(List<String> urls, SImageView sImageView, int reqWidth, int r
getTag();
sImageView.setTag(mTag);

noLoadUrls = new CopyOnWriteArrayList<>();
bitmaps = new ConcurrentHashMap<>();

// 创建图片地址, 对应map
for (String url:urls) {
bitmaps.put(url, null);
noLoadUrls.add(url);
}

Expand All @@ -63,7 +64,13 @@ public RequestBean(List<String> urls, SImageView sImageView, int reqWidth, int r
* 检测对应的url, 是否已经存在bitmap
*/
public String[] checkNoLoadUrl(){
return (String[]) noLoadUrls.toArray();

String [] strs = new String[noLoadUrls.size()];
for (int i = 0; i < strs.length;i++) {
strs[i] = noLoadUrls.get(i);
}

return strs ;
}

/**
Expand Down

0 comments on commit b097eae

Please sign in to comment.