parent
b44e7e21f4
commit
2473dbdd36
@ -0,0 +1,56 @@ |
||||
package net.pokeranalytics.android.ui.fragment.components.bottomsheet |
||||
|
||||
import android.os.Bundle |
||||
import android.text.InputType |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import androidx.core.widget.addTextChangedListener |
||||
import kotlinx.android.synthetic.main.bottom_sheet_edit_text_multi_lines.* |
||||
import kotlinx.android.synthetic.main.fragment_bottom_sheet.view.* |
||||
|
||||
|
||||
class BottomSheetEditTextMultiLinesFragment : BottomSheetFragment() { |
||||
|
||||
private var value = "" |
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
||||
super.onViewCreated(view, savedInstanceState) |
||||
initData() |
||||
initUI() |
||||
} |
||||
|
||||
override fun onStart() { |
||||
super.onStart() |
||||
editText1.requestFocus() |
||||
} |
||||
|
||||
override fun getValue(): Any? { |
||||
return value.trim() |
||||
} |
||||
|
||||
/** |
||||
* Init data |
||||
*/ |
||||
private fun initData() { |
||||
} |
||||
|
||||
/** |
||||
* Init UI |
||||
*/ |
||||
private fun initUI() { |
||||
|
||||
setAddButtonVisible(false) |
||||
|
||||
LayoutInflater.from(requireContext()).inflate(net.pokeranalytics.android.R.layout.bottom_sheet_edit_text_multi_lines, view?.bottomSheetContainer, true) |
||||
|
||||
val data = getData() |
||||
|
||||
if (data.size == 1) { |
||||
data[0].hint?.let { editText1.hint = getString(it) } |
||||
editText1.inputType = data[0].inputType ?: InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE or InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
||||
editText1.addTextChangedListener { value = it?.toString() ?: "" } |
||||
editText1.setText((data[0].defaultValue ?: "").toString()) |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,28 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="vertical" |
||||
tools:background="@color/gray_darker"> |
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText |
||||
android:id="@+id/editText1" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginStart="16dp" |
||||
android:layout_marginTop="16dp" |
||||
android:layout_marginEnd="16dp" |
||||
android:layout_marginBottom="16dp" |
||||
android:gravity="top|start" |
||||
android:inputType="textMultiLine" |
||||
android:minLines="10" |
||||
android:maxLines="10" |
||||
app:layout_constraintBottom_toBottomOf="parent" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" |
||||
tools:text="10" /> |
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
Loading…
Reference in new issue