@@ -10,15 +10,14 @@ import android.util.Log
10
10
import android.view.Menu
11
11
import android.view.MenuItem
12
12
import android.widget.*
13
+ import kotlinx.android.synthetic.main.activity_main.*
13
14
import net.glxn.qrgen.android.QRCode
14
15
import net.glxn.qrgen.core.scheme.Wifi
15
16
16
17
const val TAG = " MainActivity"
17
18
const val QR_GENERATION_RESOLUTION = 300
18
19
19
20
class MainActivity : Activity () {
20
- // ListView reference object
21
- private lateinit var mWifiListView: ListView
22
21
// This variable holds an ArrayList of WifiEntry objects that each contain a saved wifi SSID and
23
22
// password. It is updated whenever focus returns to the app (onResume).
24
23
private lateinit var wifiEntries: ArrayList <WifiEntry >
@@ -30,9 +29,8 @@ class MainActivity: Activity() {
30
29
super .onCreate(savedInstanceState)
31
30
setContentView(R .layout.activity_main)
32
31
33
- mWifiListView = findViewById(R .id.wifi_ListView)
34
- mWifiListView.adapter = ArrayAdapter (this , android.R .layout.simple_list_item_1, wifiEntrySSIDs)
35
- mWifiListView.setOnItemClickListener { _, _, position, _ ->
32
+ wifi_ListView.adapter = ArrayAdapter (this , android.R .layout.simple_list_item_1, wifiEntrySSIDs)
33
+ wifi_ListView.setOnItemClickListener { _, _, position, _ ->
36
34
val qrCodeView = ImageView (this )
37
35
qrCodeView.setPadding(0 , 0 , 0 , - 60 )
38
36
qrCodeView.adjustViewBounds = true
@@ -50,7 +48,7 @@ class MainActivity: Activity() {
50
48
qrDialog = builder.create()
51
49
qrDialog.show()
52
50
}
53
- mWifiListView .setOnItemLongClickListener { _, _, position, _ ->
51
+ wifi_ListView .setOnItemLongClickListener { _, _, position, _ ->
54
52
val builder = AlertDialog .Builder (this )
55
53
builder.setMessage(Html .fromHtml(
56
54
" <b>SSID</b>: ${wifiEntries[position].title} <br>" +
@@ -95,7 +93,7 @@ class MainActivity: Activity() {
95
93
loadWifiEntries()
96
94
}
97
95
override fun onPostExecute (result : Unit? ) {
98
- (mWifiListView .adapter as ArrayAdapter <* >).notifyDataSetChanged()
96
+ (wifi_ListView .adapter as ArrayAdapter <* >).notifyDataSetChanged()
99
97
runOnUiThread { loadingDialog.dismiss() }
100
98
}
101
99
0 commit comments