🌄 a library that associated remote files and local files
implementation 'org.ithot.android.cache:rl:0.0.6'
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
// init once
Rl.init(context);
// debug mode
Rl.debug(true);
// put
Rl.put("remote path", "local path", true);
// get without checking local file and redownload
Rl.get("remote path");
// get with checking local file and redownload
Rl.get("remote path", new IRlStrict() {
@Override
public void get(String path) {
}
});
// work in with Glide
Glide.with(context).load(Rl.get("picture path")).into(imageView);
public class YourDownloader extends RlDownloader {
private IRlStrict strict;
@Override
public void start(String remote, IRlStrict strict) {
this.strict = strict;
// asynchronization code
strict.get(finished_path);
}
@Override
public void cancel() {
// cancel download resource
}
}
// call setter
Rl.downloader(YourDownloader.class);
public class YourUploader extends RlUploader {
@Override
public void upload(String remote, String local, RlUploaderStater stater) {
// synchronizing upload (because IntentService is used to upload files queue)
// upload succeed
stater.done();
// upload failed
stater.undone();
}
}
// call setter
Rl.uploader(YourUploader.class);
// select a time call (start upload files queue)
Rl.uploading();