@@ -2,23 +2,21 @@ package com.elementary.tasks.birthdays
2
2
3
3
import android.view.View
4
4
import com.elementary.tasks.R
5
- import com.elementary.tasks.birthdays.create.AddBirthdayActivity
6
- import com.elementary.tasks.birthdays.preview.BirthdayPreviewActivity
7
5
import com.elementary.tasks.core.data.ui.birthday.UiBirthdayList
8
6
import com.elementary.tasks.core.utils.ListActions
9
7
import com.github.naz013.ui.common.Dialogues
10
- import com.github.naz013.common.intent.IntentKeys
11
- import com.github.naz013.ui.common.login.LoginApi
12
8
13
9
class BirthdayResolver (
14
10
private val dialogAction : () -> Dialogues ,
15
- private val deleteAction : (birthday: UiBirthdayList ) -> Unit
11
+ private val deleteAction : (birthday: UiBirthdayList ) -> Unit ,
12
+ private val birthdayEditAction : (birthday: UiBirthdayList ) -> Unit ,
13
+ private val birthdayOpenAction : (birthday: UiBirthdayList ) -> Unit
16
14
) {
17
15
18
16
fun resolveAction (view : View , birthday : UiBirthdayList , listActions : ListActions ) {
19
17
when (listActions) {
20
- ListActions .EDIT -> editBirthday(view, birthday)
21
- ListActions .OPEN -> openBirthday(view, birthday)
18
+ ListActions .EDIT -> editBirthday(birthday)
19
+ ListActions .OPEN -> openBirthday(birthday)
22
20
ListActions .MORE -> showMore(view, birthday)
23
21
else -> {
24
22
}
@@ -30,7 +28,7 @@ class BirthdayResolver(
30
28
val items = arrayOf(context.getString(R .string.edit), context.getString(R .string.delete))
31
29
Dialogues .showPopup(view, { item ->
32
30
if (item == 0 ) {
33
- editBirthday(view, birthday)
31
+ editBirthday(birthday)
34
32
} else if (item == 1 ) {
35
33
askConfirmation(view, items[item]) {
36
34
if (it) deleteAction.invoke(birthday)
@@ -43,15 +41,11 @@ class BirthdayResolver(
43
41
dialogAction.invoke().askConfirmation(view.context, title, onAction)
44
42
}
45
43
46
- private fun openBirthday (view : View , birthday : UiBirthdayList ) {
47
- LoginApi .openLogged(view.context, BirthdayPreviewActivity ::class .java) {
48
- putExtra(IntentKeys .INTENT_ID , birthday.uuId)
49
- }
44
+ private fun openBirthday (birthday : UiBirthdayList ) {
45
+ birthdayOpenAction(birthday)
50
46
}
51
47
52
- private fun editBirthday (view : View , birthday : UiBirthdayList ) {
53
- LoginApi .openLogged(view.context, AddBirthdayActivity ::class .java) {
54
- putExtra(IntentKeys .INTENT_ID , birthday.uuId)
55
- }
48
+ private fun editBirthday (birthday : UiBirthdayList ) {
49
+ birthdayEditAction(birthday)
56
50
}
57
51
}
0 commit comments