Skip to content

Commit

Permalink
增加网络来源图片
Browse files Browse the repository at this point in the history
增加缓存加载完成回调
  • Loading branch information
BaojunCZ committed Jun 2, 2018
1 parent b2a3441 commit c6e2816
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fake3dview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ android {
}

dependencies {
implementation 'com.facebook.fresco:fresco:1.8.0'
api 'com.facebook.fresco:fresco:1.9.0'
}
5 changes: 4 additions & 1 deletion fake3dview/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="baojun.com.fake3dview" />
package="baojun.com.fake3dview">

<uses-permission android:name="android.permission.INTERNET" />
</manifest>
15 changes: 14 additions & 1 deletion fake3dview/src/main/java/baojun/com/fake3dview/Show3DView.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.net.Uri;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.ViewTreeObserver;
Expand Down Expand Up @@ -35,6 +36,7 @@ public class Show3DView extends LinearLayout {
private float start;
private int NowID = 1;
private long startTime;
private onCacheFinishListener cacheListener = null;

public Show3DView(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down Expand Up @@ -97,6 +99,10 @@ public void init(ArrayList<String> pics) {
initData();
}

public void setCacheListener(onCacheFinishListener cacheListener) {
this.cacheListener = cacheListener;
}

private void initData() {
iv = findViewById(R.id.iv);
setCache(0);
Expand Down Expand Up @@ -230,15 +236,22 @@ private void setCache(final int ID) {
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
super.onFinalImageSet(id, imageInfo, animatable);
Log.e(Tag, "onFinalImageSet");
setCache(ID + 1);
}
})
.build();
iv.setController(controller);
} else {
Uri uri = Uri.parse(pics.get(ID - 1));
Uri uri = Uri.parse(pics.get(0));
iv.setImageURI(uri);
if (cacheListener != null)
cacheListener.finish();
}
}

public interface onCacheFinishListener {
void finish();
}

}

0 comments on commit c6e2816

Please sign in to comment.