Skip to content

Commit

Permalink
Merge pull request #207 from hannesa2/UseLatestTopicAsDefault
Browse files Browse the repository at this point in the history
Use latest topic as default
  • Loading branch information
hannesa2 authored Sep 12, 2021
2 parents 8eca33e + 7232480 commit d736451
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -26,15 +27,15 @@ 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 {
binding = SubscriptionListItemBinding.bind(row)
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -76,6 +76,6 @@ class PublishFragment : Fragment() {
}

companion object {
private const val DEFAULT_TOTPIC = "/test"
var DEFAULT_TOPIC = "/test"
}
}
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d736451

Please sign in to comment.