-
Notifications
You must be signed in to change notification settings - Fork 503
/
ViewTargetActivity.java
49 lines (39 loc) · 1.48 KB
/
ViewTargetActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package sample.kingja.loadsir.target;
import android.os.Bundle;
import android.widget.ImageView;
import com.kingja.loadsir.callback.Callback;
import com.kingja.loadsir.core.LoadService;
import com.kingja.loadsir.core.LoadSir;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import sample.kingja.loadsir.PostUtil;
import sample.kingja.loadsir.R;
import sample.kingja.loadsir.callback.LoadingCallback;
import sample.kingja.loadsir.callback.TimeoutCallback;
/**
* Description:TODO
* Create Time:2017/9/3 11:22
* Author:KingJA
* Email:kingjavip@gmail.com
*/
public class ViewTargetActivity extends AppCompatActivity {
private LoadService loadService;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
ImageView imageView = findViewById(R.id.iv_img);
LoadSir loadSir = new LoadSir.Builder()
.addCallback(new TimeoutCallback())
.addCallback(new LoadingCallback())
.setDefaultCallback(LoadingCallback.class)
.build();
loadService = loadSir.register(imageView, (Callback.OnReloadListener) v -> {
loadService.showCallback(LoadingCallback.class);
//do retry logic...
//callback
PostUtil.postSuccessDelayed(loadService);
});
PostUtil.postCallbackDelayed(loadService, TimeoutCallback.class);
}
}