Skip to content

Commit

Permalink
remove rxjava
Browse files Browse the repository at this point in the history
  • Loading branch information
MJLblabla committed Nov 8, 2022
1 parent 72e7ded commit 1b1e07b
Show file tree
Hide file tree
Showing 40 changed files with 300 additions and 506 deletions.
16 changes: 0 additions & 16 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30
compileSdkVersion 33
defaultConfig {
applicationId "com.app.hapimediapic"
minSdkVersion 15
targetSdkVersion 30
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand All @@ -24,9 +22,9 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
implementation project(":hapimediapicker")
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
24 changes: 11 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.github.MJLblabla:HapiDepend:1.0.2'

}
}

allprojects {
apply plugin: 'hapidepend'

repositories {
maven { url 'https://jitpack.io' }
google()
jcenter()
maven { url 'https://jitpack.io' }
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
18 changes: 4 additions & 14 deletions hapimediapicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'hapidepend'

apply plugin: 'com.github.dcendents.android-maven'
group='com.github.MJLblabla'


android {
compileSdkVersion depend.compileSdkVersion
compileSdkVersion 33
defaultConfig {
minSdkVersion 15
targetSdkVersion depend.targetSdkVersion
targetSdkVersion 33
versionCode 1
versionName "1.0"

Expand All @@ -27,18 +22,13 @@ android {
}
}



dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
implementation 'com.github.MJLblabla:android_dev_utils:1.0.2'
implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
implementation depend.appcompat_v7()
implementation 'androidx.appcompat:appcompat:1.5.1'

testImplementation 'junit:junit:4.12'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object ContentUriUtil {
}

@SuppressLint("NewApi")
fun getDataFromUri(context: Context, uri: Uri, contentType: ContentType?): String? {
fun getDataFromUri(context: Context, uri: Uri, contentType: ContentType): String? {
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) { // DocumentProvider
if (isExternalStorageDocument(uri)) { // ExternalStorageProvider
val docId = DocumentsContract.getDocumentId(uri)
Expand Down Expand Up @@ -75,7 +75,7 @@ object ContentUriUtil {
}
val selection = "_id=?"
val selectionArgs = arrayOf(split[1])
return getDataColumn(context, type, contentUri, selection, selectionArgs)
return getDataColumn(context, type, contentUri!!, selection, selectionArgs)
}
} else if (ContentResolver.SCHEME_CONTENT.equals(uri.scheme!!, ignoreCase = true)) { // DownloadsProvider
return getDataColumn(context, contentType, uri, null, null)
Expand Down Expand Up @@ -104,7 +104,7 @@ object ContentUriUtil {
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
fun getDataColumn(context: Context, type: ContentType?, contentUri: Uri?, selection: String?, selectionArgs: Array<String>?): String? {
fun getDataColumn(context: Context, type: ContentType, contentUri: Uri, selection: String?, selectionArgs: Array<String>?): String? {
var contentResolver = context.contentResolver
val mediaIdColumn = MediaStore.MediaColumns._ID
val mimeTypeColumn = MediaStore.MediaColumns.MIME_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class ImageCompression(context: Context) : AsyncTask<String, Void, String>() {
}
}


private fun compressImage(imagePath: String): String {
var scaledBitmap: Bitmap? = null

Expand Down Expand Up @@ -122,7 +121,7 @@ class ImageCompression(context: Context) : AsyncTask<String, Void, String>() {
scaleMatrix.setScale(ratioX, ratioY, middleX, middleY)

val canvas = Canvas(scaledBitmap!!)
canvas.matrix = scaleMatrix
canvas.setMatrix(scaleMatrix)
canvas.drawBitmap(bmp, middleX - bmp.width / 2, middleY - bmp.height / 2, Paint(Paint.FILTER_BITMAP_FLAG))

bmp.recycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ final class PhotoRequestFragment : androidx.fragment.app.Fragment() {
if (!checkSizeCrop()) {
val originFileData =
ContentUriUtil.getDataFromUri(
context!!,
data.data,
requireContext(),
data.data!!,
ContentUriUtil.ContentType.image
)
if(originFileData==null){
callback?.onSuccess("", data.data)
}else{
ImageCompression(context!!)
ImageCompression(requireContext())
.setOutputFilePath(ImageChooseHelper.compressFilePath)
.setCompressCallback(object : ImagePickCallback {

Expand All @@ -58,17 +58,17 @@ final class PhotoRequestFragment : androidx.fragment.app.Fragment() {
} else {
mTempFilePath = ImageChooseHelper.cropFilePath
val filePath = ContentUriUtil.getDataFromUri(
context!!,
data.data,
requireContext(),
data.data!!,
ContentUriUtil.ContentType.image
)
val imageUri = FileProvider.getUriForFile(
context!!,
requireContext(),
ImageChooseHelper.PROVIDER_KEY,
File(filePath!!)
)
val intent = ImageChooseHelper.cropImageIntent(
activity!!,
requireActivity(),
imageUri!!,
size!!,
mTempFilePath!!
Expand All @@ -81,7 +81,7 @@ final class PhotoRequestFragment : androidx.fragment.app.Fragment() {
}
PicPickHelper.REQUEST_CODE_CAMERA -> {
if (!checkSizeCrop()) {
ImageCompression(context!!)
ImageCompression(requireContext())
.setOutputFilePath(ImageChooseHelper.compressFilePath)
.setCompressCallback(object : ImagePickCallback {
override fun onSuccess(result: String?, uri: Uri?) {
Expand All @@ -91,13 +91,13 @@ final class PhotoRequestFragment : androidx.fragment.app.Fragment() {
} else {
val imageUri =
FileProvider.getUriForFile(
context!!,
requireContext(),
ImageChooseHelper.PROVIDER_KEY,
File(mCameraFilePath!!)
)
mTempFilePath = ImageChooseHelper.cropFilePath
val intent = ImageChooseHelper.cropImageIntent(
activity!!,
requireActivity(),
imageUri,
size!!,
mTempFilePath!!
Expand All @@ -106,7 +106,7 @@ final class PhotoRequestFragment : androidx.fragment.app.Fragment() {
}
}
PicPickHelper.REQUEST_CODE_CROP -> {// 所有图片选取都得走得这一步
ImageCompression(context!!)
ImageCompression(requireContext())
.setOutputFilePath(ImageChooseHelper.compressFilePath)
.setCompressCallback(object : ImagePickCallback {
override fun onSuccess(result: String?, uri: Uri?) {
Expand All @@ -116,7 +116,6 @@ final class PhotoRequestFragment : androidx.fragment.app.Fragment() {
}
else -> {
}

}
}

Expand Down
Loading

0 comments on commit 1b1e07b

Please sign in to comment.