mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-14 04:58:52 -06:00
Implement show sub habits
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.isoron.uhabits.activities.habits.show
|
||||
|
||||
import android.content.ContentUris
|
||||
import android.os.Bundle
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.Menu
|
||||
@@ -74,8 +73,15 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val appComponent = (applicationContext as HabitsApplication).component
|
||||
val habitList = appComponent.habitList
|
||||
habit = habitList.getById(ContentUris.parseId(intent.data!!))!!
|
||||
val habitGroupList = appComponent.habitGroupList
|
||||
val parentUUID = intent.getStringExtra("parentUUID")
|
||||
val habitList = if (parentUUID == null) {
|
||||
appComponent.habitList
|
||||
} else {
|
||||
habitGroupList.getByUUID(parentUUID)!!.habitList
|
||||
}
|
||||
val uuid = intent.getStringExtra("habitUUID")!!
|
||||
habit = habitList.getByUUID(uuid)!!
|
||||
preferences = appComponent.preferences
|
||||
commandRunner = appComponent.commandRunner
|
||||
widgetUpdater = appComponent.widgetUpdater
|
||||
|
||||
@@ -63,10 +63,12 @@ class IntentFactory
|
||||
fun startSettingsActivity(context: Context) =
|
||||
Intent(context, SettingsActivity::class.java)
|
||||
|
||||
fun startShowHabitActivity(context: Context, habit: Habit) =
|
||||
Intent(context, ShowHabitActivity::class.java).apply {
|
||||
data = Uri.parse(habit.uriString)
|
||||
}
|
||||
fun startShowHabitActivity(context: Context, habit: Habit): Intent {
|
||||
val intent = Intent(context, ShowHabitActivity::class.java)
|
||||
intent.putExtra("habitUUID", habit.uuid)
|
||||
intent.putExtra("parentUUID", habit.parentUUID)
|
||||
return intent
|
||||
}
|
||||
|
||||
fun startShowHabitGroupActivity(context: Context, habitGroup: HabitGroup) =
|
||||
Intent(context, ShowHabitGroupActivity::class.java).apply {
|
||||
|
||||
Reference in New Issue
Block a user