Skip to content

Commit

Permalink
1.0.2 增加网络加载长图 支持进度监听
Browse files Browse the repository at this point in the history
  • Loading branch information
yangkun19921001 committed May 28, 2019
1 parent 86279ab commit cef556c
Show file tree
Hide file tree
Showing 9 changed files with 458 additions and 63 deletions.
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
bigView.setImage(BIG_IMAGE_PAHT);
//加载 InputStream
bigView.setImage(InputStream is)
//加载网络图片 callBack : 加载中的回调
bigView.setNetUrl(String url,LoadNetImageCallBack callBack);
```

### 效果对比
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(path: ':big_picture_library')
// implementation 'com.github.yangkun19921001:long_picture_view:1.0.1'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
Expand Down
43 changes: 38 additions & 5 deletions app/src/main/java/com/yk/big_picture/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.yk.big_picture;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.yk.big_picture_library.BigView;

import java.io.FileNotFoundException;
import com.yk.big_picture_library.LoadNetImageCallBack;

public class MainActivity extends AppCompatActivity {

Expand All @@ -16,6 +15,12 @@ public class MainActivity extends AppCompatActivity {
*/
private final String BIG_IMAGE_PAHT = Environment.getExternalStorageDirectory() + "/big_img.png";

/**
* 网络图片地址
*/
private String URL = "https://file.digitaling.com/eImg/uimages/20170104/1483513576654699.jpg";


private String TAG = this.getClass().getSimpleName();

@Override
Expand All @@ -25,10 +30,38 @@ protected void onCreate(Bundle savedInstanceState) {

BigView bigView=findViewById(R.id.bv_img);

try {

//本地文件
/* try {
bigView.setImage(BIG_IMAGE_PAHT);
} catch (FileNotFoundException e) {
Log.e(TAG,e.getMessage());
}
}*/
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("加载中....");
progressDialog.setMax(100);

//网络地址
bigView.setNetUrl(URL, new LoadNetImageCallBack() {
@Override
public void onStart() {
progressDialog.show();
}

@Override
public void onLoadSucceed() {
progressDialog.cancel();
}

@Override
public void onLoadFail(Exception e) {

}

@Override
public void onLoadProgress(int progress) {
progressDialog.setProgress(progress);
}
});
}
}
Loading

0 comments on commit cef556c

Please sign in to comment.