Skip to content

Commit e77fa80

Browse files
authored
Refactoring: Remove unused function, duplicate documentation & leverage named arguments. (#514)
1 parent 87c2845 commit e77fa80

4 files changed

Lines changed: 9 additions & 34 deletions

File tree

cropper/src/main/kotlin/com/canhub/cropper/BitmapLoadingWorkerJob.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.canhub.cropper
33
import android.content.Context
44
import android.graphics.Bitmap
55
import android.net.Uri
6-
import com.canhub.cropper.utils.getFilePathFromUri
76
import kotlinx.coroutines.CoroutineScope
87
import kotlinx.coroutines.Dispatchers
98
import kotlinx.coroutines.Job
@@ -96,7 +95,6 @@ internal class BitmapLoadingWorkerJob internal constructor(
9695
internal companion object class Result {
9796
/**
9897
* The Android URI of the image to load.
99-
* NOT a file path, for it use [getUriFilePath]
10098
*/
10199
val uriContent: Uri
102100

@@ -118,16 +116,6 @@ internal class BitmapLoadingWorkerJob internal constructor(
118116
/** The error that occurred during async bitmap loading. */
119117
val error: Exception?
120118

121-
/**
122-
* The file path of the image to load
123-
*
124-
* [context] used to access Android APIs, like content resolve, it is your activity/fragment/widget.
125-
* [uniqueName] If true, make each image cropped have a different file name, this could
126-
* cause memory issues, use wisely. [Default: false]
127-
*/
128-
fun getUriFilePath(context: Context, uniqueName: Boolean = false): String =
129-
getFilePathFromUri(context, uriContent, uniqueName)
130-
131119
internal constructor(
132120
uri: Uri,
133121
bitmap: Bitmap?,

cropper/src/main/kotlin/com/canhub/cropper/CropImageActivity.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,14 @@ open class CropImageActivity : AppCompatActivity(), OnSetImageUriCompleteListene
407407
*/
408408
open fun getResultIntent(uri: Uri?, error: Exception?, sampleSize: Int): Intent {
409409
val result = CropImage.ActivityResult(
410-
cropImageView?.imageUri,
411-
uri,
412-
error,
413-
cropImageView?.cropPoints,
414-
cropImageView?.cropRect,
415-
cropImageView?.rotatedDegrees ?: 0,
416-
cropImageView?.wholeImageRect,
417-
sampleSize,
410+
originalUri = cropImageView?.imageUri,
411+
uriContent = uri,
412+
error = error,
413+
cropPoints = cropImageView?.cropPoints,
414+
cropRect = cropImageView?.cropRect,
415+
rotation = cropImageView?.rotatedDegrees ?: 0,
416+
wholeImageRect = cropImageView?.wholeImageRect,
417+
sampleSize = sampleSize,
418418
)
419419
val intent = Intent()
420420
intent.extras?.let(intent::putExtras)

cropper/src/main/kotlin/com/canhub/cropper/CropImageView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ class CropImageView @JvmOverloads constructor(
17551755
*
17561756
* [context] used to access Android APIs, like content resolve, it is your activity/fragment/widget.
17571757
* [uniqueName] If true, make each image cropped have a different file name, this could
1758-
* cause memory issues, use wisely. [Default: false]
1758+
* cause memory issues, use wisely.
17591759
*/
17601760
fun getUriFilePath(context: Context, uniqueName: Boolean = false): String? =
17611761
uriContent?.let { getFilePathFromUri(context, it, uniqueName) }

cropper/src/main/kotlin/com/canhub/cropper/utils/GetFilePathFromUri.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@ import java.text.SimpleDateFormat
1313
import java.util.Date
1414
import java.util.Locale.getDefault
1515

16-
/**
17-
* This class will create a temporary file in the cache if you need.
18-
*
19-
* When the uri already have `file://` schema we don't need to create a new file.
20-
* The temporary file will always override a previous one, saving memory.
21-
* Using the cache memory(context.cacheDir) we guarantee to not leak memory
22-
*
23-
* [context] used to access Android APIs, like content resolve, it is your activity/fragment.
24-
* [uri] the URI to load the image from.
25-
* [uniqueName] If true, make each image cropped have a different file name, this could cause memory issues, use wisely.
26-
*
27-
* @return string value of the File path.
28-
*/
2916
internal fun getFilePathFromUri(context: Context, uri: Uri, uniqueName: Boolean): String =
3017
if (uri.path?.contains("file://") == true) {
3118
uri.path!!

0 commit comments

Comments
 (0)