From 7232480a60b52a9076f5ff95f3abc0d03c3dc6f6 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 12 Sep 2021 09:29:51 +0200 Subject: [PATCH] Use latest topic as default --- .../adapter/SubscriptionListItemAdapter.kt | 5 +++-- .../extsample/fragments/PublishFragment.kt | 4 ++-- .../fragments/SubscriptionFragment.kt | 21 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/adapter/SubscriptionListItemAdapter.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/adapter/SubscriptionListItemAdapter.kt index 4b4a1bd8..b0d2ecb2 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/adapter/SubscriptionListItemAdapter.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/adapter/SubscriptionListItemAdapter.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import android.widget.ArrayAdapter import info.mqtt.android.extsample.R import info.mqtt.android.extsample.databinding.SubscriptionListItemBinding +import info.mqtt.android.extsample.fragments.PublishFragment import info.mqtt.android.extsample.internal.Connection import info.mqtt.android.extsample.model.Subscription @@ -26,8 +27,7 @@ class SubscriptionListItemAdapter(context: Context, private val connection: Conn var row = convertView if (row == null) { - val inflater = - context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater + val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater binding = SubscriptionListItemBinding.inflate(inflater, parent, false) row = binding.root } else { @@ -35,6 +35,7 @@ class SubscriptionListItemAdapter(context: Context, private val connection: Conn } binding.messageText.text = connection.getSubscriptions()[position].topic + PublishFragment.DEFAULT_TOPIC = connection.getSubscriptions()[position].topic binding.qosLabel.text = "Qos: ${connection.getSubscriptions()[position].qos}(${connection.getSubscriptions()[position].qos.value})" val notifyString = context.getString(R.string.notify_text, connection.getSubscriptions()[position].isEnableNotifications.toString()) binding.showNotificationsLabel.text = notifyString diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt index d6ad36a7..4f820e58 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/PublishFragment.kt @@ -39,7 +39,7 @@ class PublishFragment : Fragment() { _binding = FragmentPublishBinding.inflate(inflater, container, false) val view = binding.root - binding.topic.setText(DEFAULT_TOTPIC) + binding.topic.setText(DEFAULT_TOPIC) binding.qosSpinner.onItemSelectedListener = object : OnItemSelectedListener { @@ -76,6 +76,6 @@ class PublishFragment : Fragment() { } companion object { - private const val DEFAULT_TOTPIC = "/test" + var DEFAULT_TOPIC = "/test" } } \ No newline at end of file diff --git a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt index 3f4b8ddd..bce7f167 100644 --- a/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt +++ b/extendedSample/src/main/java/info/mqtt/android/extsample/fragments/SubscriptionFragment.kt @@ -1,27 +1,27 @@ package info.mqtt.android.extsample.fragments -import info.mqtt.android.extsample.internal.Connections.Companion.getInstance import android.os.Bundle import android.view.LayoutInflater -import android.view.ViewGroup -import info.mqtt.android.extsample.adapter.SubscriptionListItemAdapter -import timber.log.Timber -import org.eclipse.paho.client.mqttv3.MqttException -import android.widget.AdapterView.OnItemSelectedListener import android.view.View +import android.view.ViewGroup import android.view.WindowManager -import android.widget.* +import android.widget.AdapterView +import android.widget.AdapterView.OnItemSelectedListener +import android.widget.ArrayAdapter import androidx.appcompat.app.AlertDialog import androidx.fragment.app.Fragment import info.mqtt.android.extsample.ActivityConstants import info.mqtt.android.extsample.R +import info.mqtt.android.extsample.adapter.SubscriptionListItemAdapter import info.mqtt.android.extsample.databinding.FragmentSubscriptionsBinding import info.mqtt.android.extsample.databinding.SubscriptionDialogBinding import info.mqtt.android.extsample.internal.Connection +import info.mqtt.android.extsample.internal.Connections.Companion.getInstance import info.mqtt.android.extsample.model.Subscription -import java.util.HashMap -import android.widget.ArrayAdapter import info.mqtt.android.service.QoS +import org.eclipse.paho.client.mqttv3.MqttException +import timber.log.Timber +import java.util.* class SubscriptionFragment : Fragment() { @@ -51,8 +51,7 @@ class SubscriptionFragment : Fragment() { } private fun showInputDialog() { - val dialogBinding = SubscriptionDialogBinding - .inflate(LayoutInflater.from(context)) + val dialogBinding = SubscriptionDialogBinding.inflate(LayoutInflater.from(context)) val adapter = ArrayAdapter(requireActivity(), android.R.layout.simple_spinner_dropdown_item, QoS.values()) adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)