Android 圖片單選/多選、拍照、裁剪、壓縮。視訊選擇和錄製
阿新 • • 發佈:2019-02-09
簡介
RxGalleryFinal 是一個 android 圖片/視訊檔案選擇器。其支援多選、單選、拍攝和裁剪,主題可自定義,無強制繫結第三方圖片載入器。
使用
下載或新增依賴
在 module gradle 中專案依賴程式碼:
compile 'cn.finalteam.rxgalleryfinal:library:0.0.3' //rxgalleryfinal 依賴 appcompat-v7 和 recyclerview-v7 擴充套件卡庫 compile 'com.android.support:recyclerview-v7:24.2.0' compile 'com.android.support:appcompat-v7:24.2.0' //支援以下主流圖片載入器,開發者自行選擇 compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.facebook.fresco:fresco:0.12.0' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
配置 manifest
- 新增許可權
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- 註冊 activity
<application ... android:theme="@style/Theme_Light"> <activity android:name="cn.finalteam.rxgalleryfinal.ui.activity.MediaActivity" android:screenOrientation="portrait" android:exported="true" android:theme="@style/Theme_Light.Default"/> <activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait" android:theme="@style/Theme_Light.Default"/> </application
這裡可以配置主題
- 開啟圖片瀏覽器
RxGalleryFinal .with(context) .image() .radio() .crop() .imageLoader(ImageLoaderType.GLIDE) .subscribe(new RxBusResultSubscriber<ImageRadioResultEvent>() { @Override protected void onEvent(ImageRadioResultEvent imageRadioResultEvent) throws Exception { //圖片選擇結果 ..... } }) .openGallery();
自定義主題
混淆配置
#1.support-v7-appcompat
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}
#2.rxjava
-keep class rx.schedulers.Schedulers {
public static <methods>;
}
-keep class rx.schedulers.ImmediateScheduler {
public <methods>;
}
-keep class rx.schedulers.TestScheduler {
public <methods>;
}
-keep class rx.schedulers.Schedulers {
public static ** test();
}
-dontwarn sun.misc.**
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}
#3.retrolambda
-dontwarn java.lang.invoke.*
#4.support-v4
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
#5.ucrop
-dontwarn com.yalantis.ucrop**
-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }
#6.photoview
-keep class uk.co.senab.photoview** { *; }
-keep interface uk.co.senab.photoview** { *; }
#7.rxgalleryfinal
-keep class cn.finalteam.rxgalleryfinal.ui.widget** { *; }
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepattributes *Annotation*
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}