File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed
Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,8 @@ package com.autocrop.activities.cropping
22
33import android.net.Uri
44import androidx.lifecycle.LiveData
5- import androidx.lifecycle.MutableLiveData
65import androidx.lifecycle.ViewModel
76import com.autocrop.collections.CropBundle
8- import com.autocrop.utilsandroid.asMutable
97
108class CroppingActivityViewModel (val uris : ArrayList <Uri >): ViewModel(){
119
@@ -15,10 +13,11 @@ class CroppingActivityViewModel(val uris: ArrayList<Uri>): ViewModel(){
1513 val nDismissedImages: Int
1614 get() = nSelectedImages - cropBundles.size
1715
18- val currentImageNumber: LiveData <Int > by lazy {
19- MutableLiveData (0 )
20- }
21- fun incrementCurrentImageNumber (){
22- currentImageNumber.asMutable.value = currentImageNumber.value?.plus(1 )
16+ val currentImageNumber: CurrentImageNumber = CurrentImageNumber ()
17+
18+ class CurrentImageNumber : LiveData <Int >(0 ){
19+ fun increment (){
20+ postValue(value?.plus(1 ))
21+ }
2322 }
2423}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import com.autocrop.collections.CropBundle
1616import com.autocrop.utils.executeAsyncTask
1717import com.autocrop.utils.logBeforehand
1818import com.autocrop.utilsandroid.openBitmap
19+ import com.lyrebirdstudio.croppylib.utils.extensions.asMutable
1920import com.w2sv.autocrop.R
2021import com.w2sv.autocrop.databinding.CroppingFragmentBinding
2122import kotlinx.coroutines.Job
@@ -37,7 +38,7 @@ class CroppingFragment
3738 // launch croppingJob
3839 croppingJob = lifecycleScope.executeAsyncTask(
3940 ::cropImages,
40- { sharedViewModel.incrementCurrentImageNumber() },
41+ { sharedViewModel.currentImageNumber.increment() },
4142 { startExaminationActivityOrInvokeCroppingFailureFragment() }
4243 )
4344 }
Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ abstract class FragmentHostingActivity<RF: Fragment>(
88 private val rootFragmentClass : Class <RF >) :
99 ViewBoundActivity (){
1010
11- private val layoutId: Int by lazy { binding.root.id }
11+ private val layoutId: Int by lazy {
12+ binding.root.id
13+ }
1214
13- protected fun onSavedInstanceStateNull () {
15+ protected open fun onSavedInstanceStateNull () {
1416 launchRootFragment()
1517 }
1618
Original file line number Diff line number Diff line change 2626 android : layout_marginEnd =" 10dp"
2727 android : layout_marginStart =" 10dp"
2828
29+ android : progress =" 0"
30+
2931 android : progressDrawable =" @drawable/progress_bar_cropping_activity_progress" />
3032
3133 <com .autocrop.activities.cropping.fragments.cropping.views.CurrentImageNumberTextView
You can’t perform that action at this time.
0 commit comments