Skip to content

Commit f483517

Browse files
authored
Sample: Use AIC-Sample as logging Tag and log a few more things. (#510)
1 parent 4a48210 commit f483517

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

sample/src/main/kotlin/com/canhub/cropper/sample/SampleCropFragment.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ internal class SampleCropFragment : Fragment() {
3737
private val cropImage = registerForActivityResult(CropImageContract()) { result ->
3838
when {
3939
result.isSuccessful -> {
40-
Timber.tag("Bitmap").v(result.bitmap.toString())
41-
Timber.tag("File Path").v(context?.let { result.getUriFilePath(it) }.toString())
40+
Timber.tag("AIC-Sample").i("Original bitmap: ${result.originalBitmap}")
41+
Timber.tag("AIC-Sample").i("Original uri: ${result.originalUri}")
42+
Timber.tag("AIC-Sample").i("Output bitmap: ${result.bitmap}")
43+
Timber.tag("AIC-Sample").i("Output uri: ${result.getUriFilePath(requireContext())}")
4244
handleCropImageResult(result.uriContent.toString())
4345
}
4446
result is CropImage.CancelledResult -> showErrorMessage("cropping image was cancelled by the user")
@@ -106,7 +108,7 @@ internal class SampleCropFragment : Fragment() {
106108
}
107109

108110
private fun showErrorMessage(message: String) {
109-
Timber.tag("Camera Error:").e(message)
111+
Timber.tag("AIC-Sample").e("Camera error: $message")
110112
Toast.makeText(activity, "Crop failed: $message", Toast.LENGTH_SHORT).show()
111113
}
112114

sample/src/main/kotlin/com/canhub/cropper/sample/SampleCustomActivity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ internal class SampleCustomActivity : CropImageActivity() {
9393
sampleSize = sampleSize,
9494
)
9595

96-
Timber.tag("File Path").v(result.getUriFilePath(this).toString())
96+
Timber.tag("AIC-Sample").i("Original bitmap: ${result.originalBitmap}")
97+
Timber.tag("AIC-Sample").i("Original uri: ${result.originalUri}")
98+
Timber.tag("AIC-Sample").i("Output bitmap: ${result.bitmap}")
99+
Timber.tag("AIC-Sample").i("Output uri: ${result.getUriFilePath(this)}")
97100
binding.cropImageView.setImageUriAsync(result.uriContent)
98101
}
99102

100103
override fun setResultCancel() {
101-
Timber.tag("extend").i("User this override to change behaviour when cancel")
104+
Timber.tag("AIC-Sample").i("User this override to change behaviour when cancel")
102105
super.setResultCancel()
103106
}
104107

105108
override fun updateMenuItemIconColor(menu: Menu, itemId: Int, color: Int) {
106-
Timber.tag("extend")
107-
.i(
108-
"If not using your layout, this can be one option to change colours. Check README and wiki for more",
109-
)
109+
Timber.tag("AIC-Sample").i("If not using your layout, this can be one option to change colours")
110110
super.updateMenuItemIconColor(menu, itemId, color)
111111
}
112112

sample/src/main/kotlin/com/canhub/cropper/sample/SampleUsingImageViewFragment.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ internal class SampleUsingImageViewFragment : Fragment(), SampleOptionsBottomShe
113113

114114
override fun onSetImageUriComplete(view: CropImageView, uri: Uri, error: Exception?) {
115115
if (error != null) {
116-
Timber.tag("AIC").e(error, "Failed to load image by URI")
116+
Timber.tag("AIC-Sample").e(error, "Failed to load image by URI")
117117
Toast.makeText(activity, "Image load failed: " + error.message, Toast.LENGTH_LONG)
118118
.show()
119119
}
@@ -126,10 +126,13 @@ internal class SampleUsingImageViewFragment : Fragment(), SampleOptionsBottomShe
126126
} else {
127127
result.bitmap
128128
}
129-
context?.let { Timber.tag("File Path").v(result.getUriFilePath(it).toString()) }
129+
Timber.tag("AIC-Sample").i("Original bitmap: ${result.originalBitmap}")
130+
Timber.tag("AIC-Sample").i("Original uri: ${result.originalUri}")
131+
Timber.tag("AIC-Sample").i("Output bitmap: $imageBitmap")
132+
Timber.tag("AIC-Sample").i("Output uri: ${result.getUriFilePath(view.context)}")
130133
SampleResultScreen.start(this, imageBitmap, result.uriContent, result.sampleSize)
131134
} else {
132-
Timber.tag("AIC").e(result.error, "Failed to crop image")
135+
Timber.tag("AIC-Sample").e(result.error, "Failed to crop image")
133136
Toast
134137
.makeText(activity, "Crop failed: ${result.error?.message}", Toast.LENGTH_SHORT)
135138
.show()

0 commit comments

Comments
 (0)