Skip to content

Commit

Permalink
use View Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ekoby committed Jul 25, 2023
1 parent 6a18b5f commit ecd0b2b
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 166 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
plugins {
id('com.android.application')
id('kotlin-android')
id('kotlin-kapt')
id('kotlin-android-extensions')
}

version = parent.version

def vc = versionCode

android {
namespace = "org.openziti.mobile"
signingConfigs {
release {
keyAlias 'ziti1'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.openziti.mobile">
>
<!-- To access Google+ APIs: -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
45 changes: 15 additions & 30 deletions app/src/main/java/org/openziti/mobile/LineView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package org.openziti.mobile
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import android.widget.Toast
Expand All @@ -15,27 +14,14 @@ import org.openziti.mobile.databinding.LineBinding
/**
* Service List Line Items
*/
class LineView : RelativeLayout {
class LineView(context: Context) : RelativeLayout(context) {

var _label: String? = ""
var _value: String? = ""

var label: String
get() = this._label.toString()
set(value) {
this._label = value
binding.Label.text = this._label
}
private val binding = LineBinding.inflate(LayoutInflater.from(context), this, true)

var value: String
get() = this._value.toString()
set(value) {
this._value = value
binding.Value.text = this._value
}

constructor(context: Context) : super(context) {
init(null, 0)
init {
binding.Label.setOnClickListener {
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText("Label", binding.Label.text.toString())
Expand All @@ -52,18 +38,17 @@ class LineView : RelativeLayout {
}
}

constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(attrs, 0)
}

constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
init(attrs, defStyle)
}

private fun init(attrs: AttributeSet?, defStyle: Int) {
binding = LineBinding.inflate(LayoutInflater.from(context))
// LayoutInflater.from(context).inflate(R.layout.line, this, true)
}
var label: String
get() = this._label.toString()
set(value) {
this._label = value
binding.Label.text = this._label
}

private lateinit var binding: LineBinding
var value: String
get() = this._value.toString()
set(value) {
this._value = value
binding.Value.text = this._value
}
}
Loading

0 comments on commit ecd0b2b

Please sign in to comment.