RxFile
Rx methods to get a File and Image or Video thumbnails from a Document Provider on Android (Drive, Dropbox etc)
Install / Use
/learn @pavlospt/RxFileREADME
RxFile
Rx methods to get a File and Image or Video thumbnails from any DocumentProvider on Android (Drive, Dropbox, Photos etc)
How To Install
Available on jCenter() and mavenCentral()
compile 'com.github.pavlospt:rxfile:1.8'
How To Use
It is really easy to use it, depending on your needs it returns the appropriate file or Bitmap. You can fetch a Bitmap when you are selecting an Image or a Video. The fetched Bitmap is a thumbnail of the selected Image or Video. When you choose to select a file from Dropbox or Drive, the file is being downloaded and copied to the Library's cache folder. It then returns the File object and you have complete access over it in case you need to upload it to a server or in a similar use case.
To enable logging:
RxFile.setLoggingEnabled(true);
To get a File, use: (need to change the name of the method)
Observable<File> createFileFromUri(final Context context, final Uri data);
Observable<List<File>> createFileFromUri(final Context context, final ArrayList<Uri> uris);
Observable<List<File>> createFilesFromClipData(final Context context, final ClipData clipData);
To get a thumbnail, use:
Observable<Bitmap> getThumbnail(Context context, Uri uri);
Observable<Bitmap> getThumbnail(Context context, Uri uri, int requiredWidth, int requiredHeight);
Observable<Bitmap> getThumbnail(Context context, Uri uri, int requiredWidth, int requiredHeight, int kind);
Get files from a ClipData object (applies to multiple file selection through intent):
RxFile.createFilesFromClipData(this,clipData)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<File>>() {
@Override
public void onCompleted() {
Timber.e("onCompleted() for Files called");
}
@Override
public void onError(Throwable e) {
Timber.e("Error on files fetching:" + e.getMessage());
}
@Override
public void onNext(List<File> files) {
Timber.e("Files list size:" + files.size());
for(File f : files){
Timber.e("onNext() file called:" + f.getAbsolutePath());
}
}
});
Get file from single Uri:
RxFile.createFileFromUri(this,uri)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<File>() {
@Override
public void onCompleted() {
Timber.e("onCompleted() for File called");
}
@Override
public void onError(Throwable e) {
Timber.e("Error on file fetching:" + e.getMessage());
}
@Override
public void onNext(File file) {
Timber.e("onNext() file called:" + file.getAbsolutePath());
}
});
Get Thumbnail from Uri (photo or video):
RxFile.getThumbnail(this,data)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<Bitmap>() {
@Override
public void onCompleted() {
Timber.e("onCompleted() called");
}
@Override
public void onError(Throwable e) {
Timber.e("onError called with: " + e.getMessage());
}
@Override
public void onNext(Bitmap bitmap) {
mBitmap.setImageBitmap(bitmap);
}
});
For more, check the Wiki
Credits
Author : Pavlos-Petros Tournaris (p.tournaris@gmail.com)
Google+ : +Pavlos-Petros Tournaris
Facebook : Pavlos-Petros Tournaris
LinkedIn : Pavlos-Petros Tournaris
(In case you use this in your app let me know to make a list of apps that use it! )
License
Copyright 2015 Pavlos-Petros Tournaris
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Related Skills
qqbot-channel
347.0kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.1k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
347.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
Design
Campus Second-Hand Trading Platform \- General Design Document (v5.0 \- React Architecture \- Complete Final Version)1\. System Overall Design 1.1. Project Overview This project aims t
