-
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.
Merge branch '1_2_release' into fixes
- Loading branch information
Showing
26 changed files
with
408 additions
and
218 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
57 changes: 57 additions & 0 deletions
57
app/src/main/java/com/example/sergey/shlypa2/screens/words_in/WordItem.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,57 @@ | ||
package com.example.sergey.shlypa2.screens.words_in | ||
|
||
|
||
import android.view.View | ||
import android.widget.ImageButton | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.sergey.shlypa2.R | ||
import com.example.sergey.shlypa2.beans.Word | ||
import com.example.sergey.shlypa2.extensions.gone | ||
import eu.davidea.flexibleadapter.FlexibleAdapter | ||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem | ||
import eu.davidea.flexibleadapter.items.IFlexible | ||
import eu.davidea.viewholders.FlexibleViewHolder | ||
|
||
|
||
class WordItem(private val flagChange: Boolean, | ||
private val word: Word, | ||
private val listenerAction:(Pair<WordAct,Int>)->Unit) : AbstractFlexibleItem<WordItem.ViewHolder>() { | ||
|
||
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>?, | ||
holder: ViewHolder, | ||
position: Int, | ||
payloads: MutableList<Any>) { | ||
with(holder){ | ||
tvName.text = word.word | ||
if (!flagChange) ibChangeWord.gone() | ||
|
||
ibDeleteWord.setOnClickListener { | ||
listenerAction.invoke(Pair(WordAct.DELETE,position)) | ||
} | ||
|
||
ibChangeWord.setOnClickListener { | ||
listenerAction.invoke(Pair(WordAct.CHANGE,position)) | ||
} | ||
} | ||
|
||
} | ||
|
||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>?) = WordItem.ViewHolder(view, adapter) | ||
|
||
override fun equals(other: Any?) = other is WordItem | ||
|
||
override fun getLayoutRes() = R.layout.holder_word | ||
|
||
class ViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>?) | ||
: FlexibleViewHolder(view, adapter) { | ||
val tvName: TextView = view.findViewById(R.id.wordInject) | ||
val ibDeleteWord: ImageButton = view.findViewById(R.id.ibDelWord) | ||
val ibChangeWord: ImageButton = view.findViewById(R.id.ibChangeWord) | ||
} | ||
} | ||
|
||
enum class WordAct{ | ||
DELETE, | ||
CHANGE | ||
} |
Oops, something went wrong.