Use bundleOf().

This commit is contained in:
Isira Seneviratne 2023-01-20 09:53:12 +05:30
parent 5337083bdb
commit b2e32105d3
3 changed files with 31 additions and 32 deletions

View File

@ -269,9 +269,7 @@ class MainActivity : BaseActivity() {
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
val bundle = Bundle()
bundle.putString("query", query)
navController.navigate(R.id.searchResultFragment, bundle)
navController.navigate(R.id.searchResultFragment, bundleOf("query" to query))
searchViewModel.setQuery("")
searchView.clearFocus()
return true
@ -299,9 +297,7 @@ class MainActivity : BaseActivity() {
}
if (navController.currentDestination?.id != R.id.searchFragment) {
val bundle = Bundle()
bundle.putString("query", newText)
navController.navigate(R.id.searchFragment, bundle)
navController.navigate(R.id.searchFragment, bundleOf("query" to newText))
} else {
searchViewModel.setQuery(newText)
}

View File

@ -5,7 +5,6 @@ import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
@ -81,13 +80,13 @@ object NavigationHelper {
return
}
val bundle = Bundle().apply {
putString(IntentData.videoId, videoId.toID())
putString(IntentData.playlistId, playlistId)
putString(IntentData.channelId, channelId)
putBoolean(IntentData.keepQueue, keepQueue)
timeStamp?.let { putLong(IntentData.timeStamp, it) }
}
val bundle = bundleOf(
IntentData.videoId to videoId.toID(),
IntentData.playlistId to playlistId,
IntentData.channelId to channelId,
IntentData.keepQueue to keepQueue,
IntentData.timeStamp to timeStamp
)
val activity = context as AppCompatActivity
activity.supportFragmentManager.beginTransaction()
@ -111,9 +110,10 @@ object NavigationHelper {
if (playlistId == null) return
val activity = unwrap(context)
val bundle = Bundle()
bundle.putString(IntentData.playlistId, playlistId)
bundle.putSerializable(IntentData.playlistType, playlistType)
val bundle = bundleOf(
IntentData.playlistId to playlistId,
IntentData.playlistType to playlistType
)
activity.navController.navigate(R.id.playlistFragment, bundle)
}

View File

@ -16,6 +16,7 @@ import android.support.v4.media.session.MediaSessionCompat
import android.support.v4.media.session.PlaybackStateCompat
import androidx.annotation.DrawableRes
import androidx.core.app.NotificationCompat
import androidx.core.os.bundleOf
import coil.request.ImageRequest
import com.github.libretube.R
import com.github.libretube.api.obj.Streams
@ -196,21 +197,23 @@ class NowPlayingNotification(
player: Player,
windowIndex: Int
): MediaDescriptionCompat {
return MediaDescriptionCompat.Builder().apply {
setTitle(streams?.title!!)
setSubtitle(streams?.uploader)
val appIcon = BitmapFactory.decodeResource(
context.resources,
R.drawable.ic_launcher_monochrome
)
val extras = Bundle().apply {
putParcelable(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, appIcon)
putString(MediaMetadataCompat.METADATA_KEY_TITLE, streams?.title!!)
putString(MediaMetadataCompat.METADATA_KEY_ARTIST, streams?.uploader)
}
setIconBitmap(appIcon)
setExtras(extras)
}.build()
val title = streams?.title!!
val uploader = streams?.uploader
val extras = bundleOf(
MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON to appIcon,
MediaMetadataCompat.METADATA_KEY_TITLE to title,
MediaMetadataCompat.METADATA_KEY_ARTIST to uploader
)
return MediaDescriptionCompat.Builder()
.setTitle(title)
.setSubtitle(uploader)
.setIconBitmap(appIcon)
.setExtras(extras)
.build()
}
override fun getSupportedQueueNavigatorActions(player: Player): Long {