Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false

GROUP=com.robotemi
VERSION_NAME=1.137.0.1-SNAPSHOT
VERSION_NAME=1.137.0.2-SNAPSHOT
POM_URL=https://github.com/robotemi/sdk/
POM_SCM_URL=https://github.com/robotemi/sdk/
POM_SCM_CONNECTION=scm:git:git://github.com/robotemi/sdk.git
Expand Down
1 change: 1 addition & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ dependencies {
implementation project(':sdk')
// implementation 'com.robotemi:sdk:1.134.1'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'androidx.core:core-ktx:1.8.0'
}
74 changes: 74 additions & 0 deletions sample/src/main/java/com/robotemi/sdk/sample/EditDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.robotemi.sdk.sample

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.BaseAdapter
import android.widget.Button
import android.widget.EditText
import android.widget.ListView
import androidx.core.widget.doAfterTextChanged

class EditDialog(
context: Context, private val locations: MutableList<String>,
private val editorActionListener: EditorActionListener
) : Dialog(context) {
private lateinit var listView: ListView
private lateinit var confirmBtn: Button
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.dialog_edit_locations)
listView = findViewById(R.id.listView)
val adapter = EditableListAdapter(
context,
locations
)
listView.adapter = adapter
confirmBtn = findViewById(R.id.confirmBtn)
confirmBtn.setOnClickListener {
editorActionListener.editCompleted(this, adapter.oldText, adapter.newText)
}
}

override fun dismiss() {
val view = currentFocus
if (view is EditText) {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
super.dismiss()
}
class EditableListAdapter(
private val context: Context,
private val dataList: MutableList<String>
) : BaseAdapter() {
var newText: String = ""
var oldText: String = ""

override fun getCount(): Int = dataList.size
override fun getItem(position: Int): Any = dataList[position]
override fun getItemId(position: Int): Long = position.toLong()

override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = convertView ?: LayoutInflater.from(context)
.inflate(R.layout.item_editable_dialog_row, parent, false)

val editText = view.findViewById<EditText>(R.id.name)
editText.setText(dataList[position])

editText.doAfterTextChanged {
oldText = dataList[position]
newText = it.toString()
}
return view
}
}

interface EditorActionListener {
fun editCompleted(editDialog: EditDialog, oldLocationName: String, newLocationName: String)
}
}
Loading