-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add click on statistics total tracked
- Loading branch information
Showing
8 changed files
with
149 additions
and
40 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.../com/example/util/simpletimetracker/core/interactor/GetStatisticsDetailRangeInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.example.util.simpletimetracker.core.interactor | ||
|
||
import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor | ||
import com.example.util.simpletimetracker.domain.model.RangeLength | ||
import com.example.util.simpletimetracker.navigation.params.screen.StatisticsDetailParams.RangeLengthParams | ||
import javax.inject.Inject | ||
|
||
class GetStatisticsDetailRangeInteractor @Inject constructor( | ||
private val prefsInteractor: PrefsInteractor, | ||
) { | ||
|
||
suspend fun execute(): RangeLengthParams { | ||
return when (val rangeLength = getRangeLength()) { | ||
is RangeLength.Day -> RangeLengthParams.Day | ||
is RangeLength.Week -> RangeLengthParams.Week | ||
is RangeLength.Month -> RangeLengthParams.Month | ||
is RangeLength.Year -> RangeLengthParams.Year | ||
is RangeLength.All -> RangeLengthParams.All | ||
is RangeLength.Custom -> RangeLengthParams.Custom( | ||
start = rangeLength.range.timeStarted, | ||
end = rangeLength.range.timeEnded, | ||
) | ||
is RangeLength.Last -> RangeLengthParams.Last( | ||
days = rangeLength.days, | ||
) | ||
} | ||
} | ||
|
||
private suspend fun getRangeLength(): RangeLength { | ||
return if (prefsInteractor.getKeepStatisticsRange()) { | ||
prefsInteractor.getStatisticsRange() | ||
} else { | ||
prefsInteractor.getStatisticsDetailRange() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 14 additions & 10 deletions
24
...xample/util/simpletimetracker/feature_statistics/adapter/StatisticsInfoAdapterDelegate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
package com.example.util.simpletimetracker.feature_statistics.adapter | ||
|
||
import com.example.util.simpletimetracker.feature_base_adapter.createRecyclerBindingAdapterDelegate | ||
import com.example.util.simpletimetracker.feature_views.extension.setOnClick | ||
import com.example.util.simpletimetracker.feature_statistics.databinding.ItemStatisticsInfoLayoutBinding as Binding | ||
import com.example.util.simpletimetracker.feature_statistics.viewData.StatisticsInfoViewData as ViewData | ||
|
||
fun createStatisticsInfoAdapterDelegate() = | ||
createRecyclerBindingAdapterDelegate<ViewData, Binding>( | ||
Binding::inflate, | ||
) { binding, item, _ -> | ||
fun createStatisticsInfoAdapterDelegate( | ||
onClick: () -> Unit, | ||
) = createRecyclerBindingAdapterDelegate<ViewData, Binding>( | ||
Binding::inflate, | ||
) { binding, item, _ -> | ||
|
||
with(binding) { | ||
item as ViewData | ||
with(binding) { | ||
item as ViewData | ||
|
||
tvStatisticsInfoName.text = item.name | ||
tvStatisticsInfoText.text = item.text | ||
} | ||
} | ||
tvStatisticsInfoName.text = item.name | ||
tvStatisticsInfoText.text = item.text | ||
|
||
root.setOnClick(onClick) | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...le/util/simpletimetracker/feature_statistics/interactor/StatisticsDetailTotalNavigator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.example.util.simpletimetracker.feature_statistics.interactor | ||
|
||
import com.example.util.simpletimetracker.core.extension.toParams | ||
import com.example.util.simpletimetracker.core.interactor.GetStatisticsDetailRangeInteractor | ||
import com.example.util.simpletimetracker.domain.interactor.CategoryInteractor | ||
import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor | ||
import com.example.util.simpletimetracker.domain.interactor.RecordTagInteractor | ||
import com.example.util.simpletimetracker.domain.interactor.RecordTypeInteractor | ||
import com.example.util.simpletimetracker.domain.model.Category | ||
import com.example.util.simpletimetracker.domain.model.ChartFilterType | ||
import com.example.util.simpletimetracker.domain.model.RecordTag | ||
import com.example.util.simpletimetracker.domain.model.RecordType | ||
import com.example.util.simpletimetracker.domain.model.RecordsFilter | ||
import com.example.util.simpletimetracker.navigation.Router | ||
import com.example.util.simpletimetracker.navigation.params.screen.StatisticsDetailParams | ||
import javax.inject.Inject | ||
|
||
class StatisticsDetailTotalNavigator @Inject constructor( | ||
private val router: Router, | ||
private val prefsInteractor: PrefsInteractor, | ||
private val getStatisticsDetailRangeInteractor: GetStatisticsDetailRangeInteractor, | ||
private val recordTypeInteractor: RecordTypeInteractor, | ||
private val categoryInteractor: CategoryInteractor, | ||
private val recordTagInteractor: RecordTagInteractor, | ||
) { | ||
|
||
suspend fun execute( | ||
shift: Int, | ||
) { | ||
val filter = when (prefsInteractor.getChartFilterType()) { | ||
ChartFilterType.ACTIVITY -> { | ||
val typeIds = recordTypeInteractor.getAll() | ||
.map(RecordType::id) | ||
RecordsFilter.Activity(typeIds) | ||
} | ||
ChartFilterType.CATEGORY -> { | ||
val categoryIds = categoryInteractor.getAll() | ||
.map(Category::id) | ||
val items = categoryIds | ||
.map(RecordsFilter.CategoryItem::Categorized) + | ||
RecordsFilter.CategoryItem.Uncategorized | ||
RecordsFilter.Category(items) | ||
} | ||
ChartFilterType.RECORD_TAG -> { | ||
val tagIds = recordTagInteractor.getAll() | ||
.map(RecordTag::id) | ||
val items = tagIds | ||
.map(RecordsFilter.TagItem::Tagged) + | ||
RecordsFilter.TagItem.Untagged | ||
RecordsFilter.SelectedTags(items) | ||
} | ||
} | ||
|
||
val params = StatisticsDetailParams( | ||
transitionName = "", | ||
filter = filter.let(::listOf).map(RecordsFilter::toParams), | ||
range = getStatisticsDetailRangeInteractor.execute(), | ||
shift = shift, | ||
preview = null, | ||
) | ||
|
||
router.navigate(params) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters