Skip to content

Commit

Permalink
- Removing support for DuasLinhas
Browse files Browse the repository at this point in the history
- Using Spinnable as 'Alternativa'
  • Loading branch information
pedrofsn committed Nov 5, 2018
1 parent 8bf1597 commit 2433b12
Show file tree
Hide file tree
Showing 28 changed files with 95 additions and 263 deletions.
1 change: 1 addition & 0 deletions dataform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.github.pedrofsn:spinnable:1.0.4.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package br.redcode.dataform.lib.adapter

import android.view.View
import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.R
import br.redcode.dataform.lib.adapter.viewholder.ViewHolderCheckBox
import br.redcode.dataform.lib.domain.AdapterGeneric
import br.redcode.dataform.lib.interfaces.OnItemClickListener
import br.redcode.dataform.lib.model.Alternativa
import br.redcode.dataform.lib.model.ConfiguracaoFormulario

/**
* Created by pedrofsn on 31/10/2017.
*/
class AdapterCheckBox(override var myOnItemClickListener: OnItemClickListener?, val configuracaoFormulario: ConfiguracaoFormulario) : AdapterGeneric<Alternativa, ViewHolderCheckBox>() {
class AdapterCheckBox(override var myOnItemClickListener: OnItemClickListener?, val configuracaoFormulario: ConfiguracaoFormulario) : AdapterGeneric<Spinnable, ViewHolderCheckBox>() {

override val layout: Int = R.layout.adapter_checkbox

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package br.redcode.dataform.lib.adapter

import android.view.View
import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.R
import br.redcode.dataform.lib.adapter.viewholder.ViewHolderItemRemovivel
import br.redcode.dataform.lib.domain.AdapterGeneric
import br.redcode.dataform.lib.interfaces.DuasLinhas
import br.redcode.dataform.lib.interfaces.OnItemClickListener
import br.redcode.dataform.lib.model.ConfiguracaoFormulario

/**
* Created by pedrofsn on 31/10/2017.
*/
class AdapterItemRemovivel(override var myOnItemClickListener: OnItemClickListener?, val configuracao: ConfiguracaoFormulario) : AdapterGeneric<DuasLinhas, ViewHolderItemRemovivel>() {
class AdapterItemRemovivel(override var myOnItemClickListener: OnItemClickListener?, val configuracao: ConfiguracaoFormulario) : AdapterGeneric<Spinnable, ViewHolderItemRemovivel>() {

override val layout: Int = R.layout.adapter_item_removivel

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package br.redcode.dataform.lib.adapter

import android.view.View
import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.R
import br.redcode.dataform.lib.adapter.viewholder.ViewHolderRadioButton
import br.redcode.dataform.lib.domain.AdapterGeneric
import br.redcode.dataform.lib.interfaces.OnItemClickListener
import br.redcode.dataform.lib.model.Alternativa
import br.redcode.dataform.lib.model.ConfiguracaoFormulario

/**
* Created by pedrofsn on 31/10/2017.
*/
class AdapterRadioButton(override var myOnItemClickListener: OnItemClickListener?, val configuracao: ConfiguracaoFormulario) : AdapterGeneric<Alternativa, ViewHolderRadioButton>() {
class AdapterRadioButton(override var myOnItemClickListener: OnItemClickListener?, val configuracao: ConfiguracaoFormulario) : AdapterGeneric<Spinnable, ViewHolderRadioButton>() {

override val layout: Int = R.layout.adapter_radiobutton

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ package br.redcode.dataform.lib.adapter.viewholder

import android.view.View
import android.widget.CheckBox
import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.R
import br.redcode.dataform.lib.domain.ViewHolderGeneric
import br.redcode.dataform.lib.interfaces.OnItemClickListener
import br.redcode.dataform.lib.model.Alternativa
import br.redcode.dataform.lib.model.ConfiguracaoFormulario

/**
* Created by pedrofsn on 31/10/2017.
*/
class ViewHolderCheckBox(itemView: View) : ViewHolderGeneric<Alternativa>(itemView) {
class ViewHolderCheckBox(itemView: View) : ViewHolderGeneric<Spinnable>(itemView) {

private lateinit var checkBox: CheckBox

fun popular(obj: Alternativa, click: OnItemClickListener?, configuracaoFormulario: ConfiguracaoFormulario) {
fun popular(obj: Spinnable, click: OnItemClickListener?, configuracaoFormulario: ConfiguracaoFormulario) {
super.popular(obj, click)
checkBox.isEnabled = configuracaoFormulario.editavel
}

override fun popular(obj: Alternativa) {
checkBox = itemView.findViewById<CheckBox>(R.id.checkBox)
override fun popular(obj: Spinnable) {
checkBox = itemView.findViewById(R.id.checkBox)

checkBox.text = obj.descricao
checkBox.isChecked = obj.selecionado
checkBox.text = obj.description
checkBox.isChecked = obj.selected
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,34 @@ package br.redcode.dataform.lib.adapter.viewholder
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.R
import br.redcode.dataform.lib.domain.ViewHolderGeneric
import br.redcode.dataform.lib.extension.setTextOrHide
import br.redcode.dataform.lib.interfaces.DuasLinhas
import br.redcode.dataform.lib.interfaces.OnItemClickListener
import br.redcode.dataform.lib.model.ConfiguracaoFormulario

/**
* Created by pedrofsn on 31/10/2017.
*/
class ViewHolderItemRemovivel(itemView: View) : ViewHolderGeneric<DuasLinhas>(itemView) {
class ViewHolderItemRemovivel(itemView: View) : ViewHolderGeneric<Spinnable>(itemView) {

private lateinit var textViewLinha1: TextView
private lateinit var textViewLinha2: TextView
private lateinit var imageViewRemoverItem: ImageView

override fun popular(obj: DuasLinhas) {
textViewLinha1 = itemView.findViewById<TextView>(R.id.textViewLinha1)
textViewLinha2 = itemView.findViewById<TextView>(R.id.textViewLinha2)
imageViewRemoverItem = itemView.findViewById<ImageView>(R.id.imageViewRemoverItem)
override fun popular(obj: Spinnable) {
textViewLinha1 = itemView.findViewById(R.id.textViewLinha1)
imageViewRemoverItem = itemView.findViewById(R.id.imageViewRemoverItem)

textViewLinha1.setTextOrHide(obj.getId())
textViewLinha2.setTextOrHide(obj.getTexto())
textViewLinha1.setTextOrHide(obj.description)
}

override fun popular(obj: DuasLinhas, click: OnItemClickListener?) {
override fun popular(obj: Spinnable, click: OnItemClickListener?) {
super.popular(obj, click)
click?.let { imageViewRemoverItem.setOnClickListener { click.onItemClickListener(adapterPosition) } }
}

fun popular(duasLinhas: DuasLinhas, myOnItemClickListener: OnItemClickListener?, configuracao: ConfiguracaoFormulario) {
fun popular(duasLinhas: Spinnable, myOnItemClickListener: OnItemClickListener?, configuracao: ConfiguracaoFormulario) {
popular(duasLinhas, myOnItemClickListener)
imageViewRemoverItem.visibility = if (configuracao.editavel) View.VISIBLE else View.GONE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ package br.redcode.dataform.lib.adapter.viewholder

import android.view.View
import android.widget.RadioButton
import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.R
import br.redcode.dataform.lib.domain.ViewHolderGeneric
import br.redcode.dataform.lib.interfaces.OnItemClickListener
import br.redcode.dataform.lib.model.Alternativa
import br.redcode.dataform.lib.model.ConfiguracaoFormulario

/**
* Created by pedrofsn on 31/10/2017.
*/
class ViewHolderRadioButton(itemView: View) : ViewHolderGeneric<Alternativa>(itemView) {
class ViewHolderRadioButton(itemView: View) : ViewHolderGeneric<Spinnable>(itemView) {

private lateinit var radioButton: RadioButton

override fun popular(obj: Alternativa) {
override fun popular(obj: Spinnable) {
radioButton = itemView.findViewById<RadioButton>(R.id.radioButton)

radioButton.text = obj.descricao
radioButton.isChecked = obj.selecionado
radioButton.text = obj.description
radioButton.isChecked = obj.selected
}

fun popular(obj: Alternativa, click: OnItemClickListener?, configuracaoFormulario: ConfiguracaoFormulario) {
fun popular(obj: Spinnable, click: OnItemClickListener?, configuracaoFormulario: ConfiguracaoFormulario) {
super.popular(obj, click)
radioButton.isEnabled = configuracaoFormulario.editavel
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package br.redcode.dataform.lib.domain.handlers

import br.redcode.dataform.lib.interfaces.DuasLinhas
import br.com.redcode.spinnable.library.model.Spinnable

/**
* Created by pedrofsn on 13/11/2017.
Expand All @@ -9,7 +9,7 @@ abstract class HandlerInputPopup {

var idPergunta = -1

open fun chamarPopup(idPergunta: Int, functionAdicionarItem: (idPergunta: Int, duasLinhas: DuasLinhas) -> Unit) {
open fun chamarPopup(idPergunta: Int, functionAdicionarItem: (idPergunta: Int, spinnable: Spinnable) -> Unit) {
this.idPergunta = idPergunta
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package br.redcode.dataform.lib.extension

import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.model.payloads.AlternativaPayload

/**
* Created by pedrofsn on 31/10/2017.
*/
fun Spinnable.toDTO(): AlternativaPayload {
return AlternativaPayload(id.toLong(), selected)
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package br.redcode.dataform.lib.model

import br.com.redcode.spinnable.library.model.Spinnable
import br.redcode.dataform.lib.utils.Constantes
import java.io.Serializable

Expand All @@ -11,7 +12,7 @@ data class Campo(
val descricao: String,
val tipo: String,

val alternativas: List<Alternativa>? = null
val alternativas: List<Spinnable>? = null
) : Serializable {

fun isTextoData(): Boolean {
Expand Down
Loading

0 comments on commit 2433b12

Please sign in to comment.