mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
clean up view bindings
This commit is contained in:
parent
9d0c637ec1
commit
6c37b451c3
3 changed files with 8 additions and 21 deletions
|
|
@ -13,7 +13,6 @@ import android.text.method.LinkMovementMethod
|
|||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
|
|
@ -58,7 +57,7 @@ import kotlinx.coroutines.Job
|
|||
import kotlinx.coroutines.cancel
|
||||
import java.nio.charset.Charset
|
||||
import java.text.DateFormat
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
|
||||
/*
|
||||
|
|
@ -303,8 +302,7 @@ class MainActivity : BaseActivity(), Logging {
|
|||
}
|
||||
|
||||
private fun initToolbar() {
|
||||
val toolbar =
|
||||
findViewById<View>(R.id.toolbar) as Toolbar
|
||||
val toolbar = binding.toolbar as Toolbar
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||
}
|
||||
|
|
@ -497,11 +495,7 @@ class MainActivity : BaseActivity(), Logging {
|
|||
|
||||
private fun showSnackbar(msgId: Int) {
|
||||
try {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
msgId,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
Snackbar.make(binding.root, msgId, Snackbar.LENGTH_LONG).show()
|
||||
} catch (ex: IllegalStateException) {
|
||||
errormsg("Snackbar couldn't find view for msgId $msgId")
|
||||
}
|
||||
|
|
@ -509,11 +503,7 @@ class MainActivity : BaseActivity(), Logging {
|
|||
|
||||
private fun showSnackbar(msg: String) {
|
||||
try {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
msg,
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
)
|
||||
Snackbar.make(binding.root, msg, Snackbar.LENGTH_INDEFINITE)
|
||||
.apply { view.findViewById<TextView>(R.id.snackbar_text).isSingleLine = false }
|
||||
.setAction(R.string.okay) {
|
||||
// dismiss
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.geeksville.mesh.model.map.CustomOverlayManager
|
|||
import com.geeksville.mesh.model.map.CustomTileSource
|
||||
import com.geeksville.mesh.util.formatAgo
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.osmdroid.api.IMapController
|
||||
import org.osmdroid.config.Configuration
|
||||
|
|
@ -54,7 +53,6 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
// UI Elements
|
||||
private lateinit var binding: MapViewBinding
|
||||
private lateinit var map: MapView
|
||||
private lateinit var downloadBtn: FloatingActionButton
|
||||
private lateinit var cacheEstimate: TextView
|
||||
private lateinit var executeJob: Button
|
||||
private var downloadPrompt: AlertDialog? = null
|
||||
|
|
@ -92,8 +90,6 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = MapViewBinding.inflate(inflater)
|
||||
downloadBtn = binding.root.findViewById(R.id.downloadButton)
|
||||
binding.cacheLayout.visibility = View.GONE
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +130,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
}
|
||||
zoomToNodes(mapController)
|
||||
}
|
||||
downloadBtn.setOnClickListener(this)
|
||||
binding.downloadButton.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
|
|
@ -384,9 +380,9 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
|||
|
||||
private fun renderDownloadButton() {
|
||||
if (!(map.tileProvider.tileSource as OnlineTileSourceBase).tileSourcePolicy.acceptsBulkDownload()) {
|
||||
downloadBtn.hide()
|
||||
binding.downloadButton.hide()
|
||||
} else {
|
||||
downloadBtn.show()
|
||||
binding.downloadButton.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue