-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
215 additions
and
78 deletions.
There are no files selected for viewing
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
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
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
58 changes: 58 additions & 0 deletions
58
...in/java/com/example/util/simpletimetracker/feature_widget/interactor/WidgetViewsHolder.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,58 @@ | ||
package com.example.util.simpletimetracker.feature_widget.interactor | ||
|
||
import android.content.Context | ||
import android.view.ContextThemeWrapper | ||
import com.example.util.simpletimetracker.core.extension.allowVmViolations | ||
import com.example.util.simpletimetracker.feature_views.IconView | ||
import com.example.util.simpletimetracker.feature_views.RecordTypeView | ||
import com.example.util.simpletimetracker.feature_widget.R | ||
import com.example.util.simpletimetracker.feature_widget.statistics.customView.WidgetStatisticsChartView | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
/** | ||
* Used inflate on app start views that would be used for widgets. | ||
*/ | ||
@Singleton | ||
class WidgetViewsHolder @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
) { | ||
|
||
private var recordTypeView: RecordTypeView? = null | ||
private var statisticsView: WidgetStatisticsChartView? = null | ||
private var statisticsRefreshView: IconView? = null | ||
|
||
fun initialize() { | ||
getRecordTypeView(context) | ||
getStatisticsView(context) | ||
getStatisticsRefreshView(context) | ||
} | ||
|
||
fun getRecordTypeView(context: Context): RecordTypeView { | ||
recordTypeView?.let { return it } | ||
val view = allowVmViolations { | ||
RecordTypeView(ContextThemeWrapper(context, R.style.AppTheme)) | ||
} | ||
recordTypeView = view | ||
return view | ||
} | ||
|
||
fun getStatisticsView(context: Context): WidgetStatisticsChartView { | ||
statisticsView?.let { return it } | ||
val view = allowVmViolations { | ||
WidgetStatisticsChartView(ContextThemeWrapper(context, R.style.AppTheme)) | ||
} | ||
statisticsView = view | ||
return view | ||
} | ||
|
||
fun getStatisticsRefreshView(context: Context): IconView { | ||
statisticsRefreshView?.let { return it } | ||
val view = allowVmViolations { | ||
IconView(ContextThemeWrapper(context, R.style.AppTheme)) | ||
} | ||
statisticsRefreshView = view | ||
return view | ||
} | ||
} |
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
Oops, something went wrong.