Best android open-source packages and libraries.

Android sex cache

:memo: a library that associated remote files and local files
Updated 3 months ago

android-sex-cache

android-sex-cache Build Status

🌄 a library that associated remote files and local files

install

implementation 'org.ithot.android.cache:rl:0.0.6'

usage

  • permission (note the runtime permissions after Android6.0 (included))

<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" />
  • sample

// 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);
  • custom downloader

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);
  • custom uploader

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();
Tags cache file