Fixed Kotlin compile against newer language and android platform

versions.
This commit is contained in:
casey langen 2017-07-12 00:12:37 -07:00
parent f2e3d94a14
commit 762b737d10
10 changed files with 30 additions and 30 deletions

View File

@ -13,13 +13,13 @@ apply plugin: 'io.fabric'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
android { android {
compileSdkVersion 25 compileSdkVersion 26
buildToolsVersion '25.0.3' buildToolsVersion '26.0.0'
defaultConfig { defaultConfig {
applicationId "io.casey.musikcube.remote" applicationId "io.casey.musikcube.remote"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 25 targetSdkVersion 26
versionCode 14 versionCode 14
versionName "0.11.0" versionName "0.11.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@ -196,7 +196,7 @@ class MainActivity : WebSocketActivityBase() {
val sb = Snackbar.make(mainLayout!!, stringId, Snackbar.LENGTH_LONG) val sb = Snackbar.make(mainLayout!!, stringId, Snackbar.LENGTH_LONG)
val sbView = sb.view val sbView = sb.view
sbView.setBackgroundColor(getColorCompat(R.color.color_primary)) sbView.setBackgroundColor(getColorCompat(R.color.color_primary))
val tv = sbView.findViewById(android.support.design.R.id.snackbar_text) as TextView val tv = sbView.findViewById<TextView>(android.support.design.R.id.snackbar_text)
tv.setTextColor(getColorCompat(R.color.theme_foreground)) tv.setTextColor(getColorCompat(R.color.theme_foreground))
sb.show() sb.show()
} }
@ -451,7 +451,7 @@ class MainActivity : WebSocketActivityBase() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val inflater = LayoutInflater.from(activity) val inflater = LayoutInflater.from(activity)
val view = inflater.inflate(R.layout.dialog_checkbox, null) val view = inflater.inflate(R.layout.dialog_checkbox, null)
val checkbox = view.findViewById(R.id.checkbox) as CheckBox val checkbox = view.findViewById<CheckBox>(R.id.checkbox)
checkbox.setText(R.string.update_check_dont_ask_again) checkbox.setText(R.string.update_check_dont_ask_again)
val version = arguments?.getString(EXTRA_VERSION) val version = arguments?.getString(EXTRA_VERSION)

View File

@ -135,8 +135,8 @@ class AlbumBrowseActivity : WebSocketActivityBase(), Filterable {
} }
private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) { private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val title: TextView = itemView.findViewById(R.id.title) as TextView private val title = itemView.findViewById<TextView>(R.id.title)
private val subtitle: TextView = itemView.findViewById(R.id.subtitle) as TextView private val subtitle = itemView.findViewById<TextView>(R.id.subtitle)
internal fun bind(entry: JSONObject) { internal fun bind(entry: JSONObject) {
val playingId = transport?.playbackService?.getTrackLong(Metadata.Track.ALBUM_ID, -1L) ?: -1L val playingId = transport?.playbackService?.getTrackLong(Metadata.Track.ALBUM_ID, -1L) ?: -1L

View File

@ -180,10 +180,10 @@ class CategoryBrowseActivity : WebSocketActivityBase(), Filterable {
} }
private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) { private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val title: TextView = itemView.findViewById(R.id.title) as TextView private val title: TextView = itemView.findViewById<TextView>(R.id.title)
init { init {
itemView.findViewById(R.id.subtitle).visibility = View.GONE itemView.findViewById<View>(R.id.subtitle).visibility = View.GONE
} }
internal fun bind(entry: JSONObject) { internal fun bind(entry: JSONObject) {

View File

@ -108,9 +108,9 @@ class PlayQueueActivity : WebSocketActivityBase() {
} }
private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) { private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val title: TextView = itemView.findViewById(R.id.title) as TextView private val title: TextView = itemView.findViewById<TextView>(R.id.title)
private val subtitle: TextView = itemView.findViewById(R.id.subtitle) as TextView private val subtitle: TextView = itemView.findViewById<TextView>(R.id.subtitle)
private val trackNum: TextView = itemView.findViewById(R.id.track_num) as TextView private val trackNum: TextView = itemView.findViewById<TextView>(R.id.track_num)
internal fun bind(entry: JSONObject?, position: Int) { internal fun bind(entry: JSONObject?, position: Int) {
trackNum.text = (position + 1).toString() trackNum.text = (position + 1).toString()

View File

@ -139,8 +139,8 @@ class TrackListActivity : WebSocketActivityBase(), Filterable {
} }
private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) { private inner class ViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val title: TextView = itemView.findViewById(R.id.title) as TextView private val title: TextView = itemView.findViewById<TextView>(R.id.title)
private val subtitle: TextView = itemView.findViewById(R.id.subtitle) as TextView private val subtitle: TextView = itemView.findViewById<TextView>(R.id.subtitle)
internal fun bind(entry: JSONObject?, position: Int) { internal fun bind(entry: JSONObject?, position: Int) {
itemView.tag = position itemView.tag = position

View File

@ -60,7 +60,7 @@ fun AppCompatActivity.addTransportFragment(
{ {
val root = this.findViewById(android.R.id.content) val root = this.findViewById(android.R.id.content)
if (root != null) { if (root != null) {
if (root.findViewById(R.id.transport_container) != null) { if (root.findViewById<View>(R.id.transport_container) != null) {
val fragment = TransportFragment.newInstance() val fragment = TransportFragment.newInstance()
this.supportFragmentManager this.supportFragmentManager

View File

@ -62,10 +62,10 @@ class TransportFragment : Fragment() {
} }
private fun bindEventHandlers() { private fun bindEventHandlers() {
this.title = this.rootView?.findViewById(R.id.track_title) as TextView this.title = this.rootView?.findViewById<TextView>(R.id.track_title)
this.buffering = this.rootView?.findViewById(R.id.buffering) this.buffering = this.rootView?.findViewById<View>(R.id.buffering)
val titleBar = this.rootView?.findViewById(R.id.title_bar) val titleBar = this.rootView?.findViewById<View>(R.id.title_bar)
titleBar?.setOnClickListener { _: View -> titleBar?.setOnClickListener { _: View ->
if (playbackService?.playbackState != PlaybackState.Stopped) { if (playbackService?.playbackState != PlaybackState.Stopped) {
@ -82,9 +82,9 @@ class TransportFragment : Fragment() {
true true
} }
this.rootView?.findViewById(R.id.button_prev)?.setOnClickListener { _: View -> playbackService?.prev() } this.rootView?.findViewById<View>(R.id.button_prev)?.setOnClickListener { _: View -> playbackService?.prev() }
this.playPause = this.rootView?.findViewById(R.id.button_play_pause) as TextView this.playPause = this.rootView?.findViewById<TextView>(R.id.button_play_pause)
this.playPause?.setOnClickListener { _: View -> this.playPause?.setOnClickListener { _: View ->
if (playbackService?.playbackState == PlaybackState.Stopped) { if (playbackService?.playbackState == PlaybackState.Stopped) {
@ -95,7 +95,7 @@ class TransportFragment : Fragment() {
} }
} }
this.rootView?.findViewById(R.id.button_next)?.setOnClickListener { _: View -> playbackService?.next() } this.rootView?.findViewById<View>(R.id.button_next)?.setOnClickListener { _: View -> playbackService?.next() }
} }
private fun rebindUi() { private fun rebindUi() {

View File

@ -88,7 +88,7 @@ class EmptyListView : FrameLayout {
offlineContainer = mainView?.findViewById(R.id.offline_container) offlineContainer = mainView?.findViewById(R.id.offline_container)
viewOfflineButton = mainView?.findViewById(R.id.offline_tracks_button) viewOfflineButton = mainView?.findViewById(R.id.offline_tracks_button)
reconnectButton = mainView?.findViewById(R.id.disconnected_button) reconnectButton = mainView?.findViewById(R.id.disconnected_button)
emptyTextView = mainView?.findViewById(R.id.empty_text_view) as TextView emptyTextView = mainView?.findViewById<TextView>(R.id.empty_text_view)
addView(mainView) addView(mainView)

View File

@ -307,19 +307,19 @@ class MainMetadataView : FrameLayout {
addView(child, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) addView(child, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
this.title = findViewById(R.id.track_title) as TextView this.title = findViewById<TextView>(R.id.track_title)
this.artist = findViewById(R.id.track_artist) as TextView this.artist = findViewById<TextView>(R.id.track_artist)
this.album = findViewById(R.id.track_album) as TextView this.album = findViewById<TextView>(R.id.track_album)
this.volume = findViewById(R.id.volume) as TextView this.volume = findViewById<TextView>(R.id.volume)
this.buffering = findViewById(R.id.buffering) this.buffering = findViewById(R.id.buffering)
this.titleWithArt = findViewById(R.id.with_art_track_title) as TextView this.titleWithArt = findViewById<TextView>(R.id.with_art_track_title)
this.artistAndAlbumWithArt = findViewById(R.id.with_art_artist_and_album) as TextView this.artistAndAlbumWithArt = findViewById<TextView>(R.id.with_art_artist_and_album)
this.volumeWithArt = findViewById(R.id.with_art_volume) as TextView this.volumeWithArt = findViewById<TextView>(R.id.with_art_volume)
this.mainTrackMetadataWithAlbumArt = findViewById(R.id.main_track_metadata_with_art) this.mainTrackMetadataWithAlbumArt = findViewById(R.id.main_track_metadata_with_art)
this.mainTrackMetadataNoAlbumArt = findViewById(R.id.main_track_metadata_without_art) this.mainTrackMetadataNoAlbumArt = findViewById(R.id.main_track_metadata_without_art)
this.albumArtImageView = findViewById(R.id.album_art) as ImageView this.albumArtImageView = findViewById<ImageView>(R.id.album_art)
this.album?.setOnClickListener { _ -> navigateToCurrentAlbum() } this.album?.setOnClickListener { _ -> navigateToCurrentAlbum() }
this.artist?.setOnClickListener { _ -> navigateToCurrentArtist() } this.artist?.setOnClickListener { _ -> navigateToCurrentArtist() }