-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…. Refactor Param dialog
- Loading branch information
1 parent
9c12e5f
commit eceab7f
Showing
18 changed files
with
170 additions
and
60 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
38 changes: 38 additions & 0 deletions
38
app/src/main/java/io/github/pedalpi/displayview/activity/resume/effectview/ParamDialog.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,38 @@ | ||
package io.github.pedalpi.displayview.activity.resume.effectview | ||
|
||
import android.content.Context | ||
import android.view.ViewGroup | ||
import io.github.pedalpi.displayview.activity.params.ParamListItemDTO | ||
import io.github.pedalpi.displayview.activity.params.ParamListItemViewHolder | ||
import io.github.pedalpi.displayview.activity.params.ParamListItemViewHolderFactory | ||
import io.github.pedalpi.displayview.activity.params.ParamValueChangeNotifier | ||
import io.github.pedalpi.displayview.model.Param | ||
import io.github.pedalpi.displayview.util.generateCustomDialog | ||
import io.github.pedalpi.displayview.util.inflate | ||
|
||
|
||
class ParamDialog(private val context: Context, private val notifier: ParamValueChangeNotifier) { | ||
|
||
private var viewHolder: ParamListItemViewHolder? = null | ||
|
||
fun show(param: Param) { | ||
val dto = ParamListItemDTO(param) | ||
|
||
val viewHolder = ParamListItemViewHolderFactory.build(notifier, param.type) | ||
this.viewHolder = viewHolder | ||
|
||
val view = context.inflate(viewHolder.layout) as ViewGroup | ||
|
||
viewHolder.view = view | ||
dto.viewHolder = viewHolder | ||
viewHolder.update(context, dto) | ||
|
||
val dialog = context.generateCustomDialog(view) | ||
dialog.setOnCancelListener { this.viewHolder = null } | ||
dialog.show() | ||
} | ||
|
||
fun update() { | ||
this.viewHolder?.update(context) | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
...io/github/pedalpi/displayview/activity/resume/effectview/ParamGridItemViewHolderToggle.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,37 @@ | ||
package io.github.pedalpi.displayview.activity.resume.effectview | ||
|
||
import android.view.View | ||
import android.widget.TextView | ||
import android.widget.ToggleButton | ||
import io.github.pedalpi.displayview.R | ||
import io.github.pedalpi.displayview.activity.params.ParamValueChangeNotifier | ||
|
||
|
||
class ParamGridItemViewHolderToggle(private val notifier: ParamValueChangeNotifier) : ParamGridItemViewHolder { | ||
|
||
override val layout: Int = R.layout.resume_param_grid_item_toggle | ||
|
||
private lateinit var name: TextView | ||
private lateinit var toggle: ToggleButton | ||
|
||
override lateinit var dto: ParamGridItemDTO | ||
|
||
override var view: View? = null | ||
set(row) { | ||
field = row | ||
name = row?.findViewById(R.id.paramsGridItemName) as TextView | ||
toggle = row?.findViewById(R.id.paramGridItemToggle) as ToggleButton | ||
|
||
toggle.setOnClickListener { | ||
this.dto.param.value = if (this.dto.param.value == 1) 0 else 1 | ||
notifier.onParamValueChange(this.dto.param) | ||
} | ||
} | ||
|
||
override fun update(paramDTO: ParamGridItemDTO) { | ||
this.dto = paramDTO | ||
|
||
name.text = paramDTO.param.name | ||
toggle.isChecked = paramDTO.param.value.toInt() == 1 | ||
} | ||
} |
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.