updated to android studio 3 beta 4, fixed a crash, fixed some warnings, suppressed some warnings.

This commit is contained in:
casey langen 2017-09-02 11:54:51 -07:00
parent 714fb62d17
commit 92db2d7006
7 changed files with 34 additions and 35 deletions

View File

@ -88,9 +88,9 @@ dependencies {
implementation 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar' implementation 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar'
implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support:appcompat-v7:26.0.1' implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:recyclerview-v7:26.0.1' implementation 'com.android.support:recyclerview-v7:26.0.2'
implementation 'com.android.support:design:26.0.1' implementation 'com.android.support:design:26.0.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true transitive = true

View File

@ -60,19 +60,20 @@ class ConnectionsActivity : WebSocketActivityBase() {
override val playbackServiceEventListener: (() -> Unit)? override val playbackServiceEventListener: (() -> Unit)?
get() = null get() = null
@Suppress("UNCHECKED_CAST")
override fun onTaskCompleted(taskName: String, taskId: Long, task: Task<*, *>, result: Any) { override fun onTaskCompleted(taskName: String, taskId: Long, task: Task<*, *>, result: Any) {
when (taskName) { when (taskName) {
LoadTask.NAME, LoadTask.NAME,
DeleteTask.NAME, DeleteTask.NAME,
RenameTask.NAME -> { RenameTask.NAME -> {
adapter.items = (result!! as List<Connection>) adapter.items = (result as List<Connection>)
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
updateViewState() updateViewState()
} }
} }
} }
fun updateViewState() { private fun updateViewState() {
val count = adapter.itemCount val count = adapter.itemCount
recycler.visibility = if (count == 0) View.GONE else View.VISIBLE recycler.visibility = if (count == 0) View.GONE else View.VISIBLE
emptyText.visibility = if (count == 0) View.VISIBLE else View.GONE emptyText.visibility = if (count == 0) View.VISIBLE else View.GONE

View File

@ -173,17 +173,17 @@ class SettingsActivity : WebSocketActivityBase() {
} }
private fun cacheViews() { private fun cacheViews() {
this.addressText = findViewById<EditText>(R.id.address) this.addressText = findViewById(R.id.address)
this.portText = findViewById<EditText>(R.id.port) this.portText = findViewById(R.id.port)
this.httpPortText = findViewById<EditText>(R.id.http_port) this.httpPortText = findViewById(R.id.http_port)
this.passwordText = findViewById<EditText>(R.id.password) this.passwordText = findViewById(R.id.password)
this.albumArtCheckbox = findViewById<CheckBox>(R.id.album_art_checkbox) this.albumArtCheckbox = findViewById(R.id.album_art_checkbox)
this.messageCompressionCheckbox = findViewById<CheckBox>(R.id.message_compression) this.messageCompressionCheckbox = findViewById(R.id.message_compression)
this.softwareVolume = findViewById<CheckBox>(R.id.software_volume) this.softwareVolume = findViewById(R.id.software_volume)
this.bitrateSpinner = findViewById<Spinner>(R.id.transcoder_bitrate_spinner) this.bitrateSpinner = findViewById(R.id.transcoder_bitrate_spinner)
this.cacheSpinner = findViewById<Spinner>(R.id.streaming_disk_cache_spinner) this.cacheSpinner = findViewById(R.id.streaming_disk_cache_spinner)
this.sslCheckbox = findViewById<CheckBox>(R.id.ssl_checkbox) this.sslCheckbox = findViewById(R.id.ssl_checkbox)
this.certCheckbox = findViewById<CheckBox>(R.id.cert_validation) this.certCheckbox = findViewById(R.id.cert_validation)
} }
private fun bindListeners() { private fun bindListeners() {
@ -274,9 +274,9 @@ class SettingsActivity : WebSocketActivityBase() {
override val playbackServiceEventListener: (() -> Unit)? override val playbackServiceEventListener: (() -> Unit)?
get() = null get() = null
override fun onTaskCompleted(name: String, id: Long, task: Task<*, *>, r: Any) { override fun onTaskCompleted(taskName: String, taskId: Long, task: Task<*, *>, result: Any) {
if (SaveAsTask.match(name)) { if (SaveAsTask.match(taskName)) {
if ((r as SaveAsTask.Result) == SaveAsTask.Result.Exists) { if ((result as SaveAsTask.Result) == SaveAsTask.Result.Exists) {
val connection = (task as SaveAsTask).connection val connection = (task as SaveAsTask).connection
if (!dialogVisible(ConfirmOverwiteDialog.TAG)) { if (!dialogVisible(ConfirmOverwiteDialog.TAG)) {
showDialog( showDialog(
@ -453,23 +453,17 @@ class SettingsActivity : WebSocketActivityBase() {
} }
} }
private class SaveAsTask : Tasks.Blocking<SaveAsTask.Result, Exception> { private class SaveAsTask(val connection: Connection,
var connection: Connection val overwrite: Boolean = false)
: Tasks.Blocking<SaveAsTask.Result, Exception>()
{
enum class Result { Exists, Added } enum class Result { Exists, Added }
val overwrite: Boolean
constructor(connection: Connection, overwrite: Boolean = false) {
this.connection = connection
this.overwrite = overwrite
}
override fun exec(context: Context?): Result { override fun exec(context: Context?): Result {
val dao = Application.connectionsDb?.connectionsDao()!! val dao = Application.connectionsDb?.connectionsDao()!!
if (!overwrite) { if (!overwrite) {
var existing: Connection? = dao.query(connection.name) val existing: Connection? = dao.query(connection.name)
if (existing != null) { if (existing != null) {
return Result.Exists return Result.Exists
} }

View File

@ -116,7 +116,7 @@ abstract class WebSocketActivityBase : AppCompatActivity(), Runner.TaskCallbacks
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
} }
override fun onTaskCompleted(s: String, l: Long, task: Task<*, *>, o: Any) { override fun onTaskCompleted(taskName: String, taskId: Long, task: Task<*, *>, result: Any) {
} }

View File

@ -3,6 +3,7 @@ package io.casey.musikcube.remote.ui.view
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.Color import android.graphics.Color
import android.os.Handler
import android.support.annotation.AttrRes import android.support.annotation.AttrRes
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.TextPaint import android.text.TextPaint
@ -41,7 +42,6 @@ class MainMetadataView : FrameLayout {
private var prefs: SharedPreferences? = null private var prefs: SharedPreferences? = null
private var isPaused = true private var isPaused = true
private lateinit var title: TextView private lateinit var title: TextView
private lateinit var artist: TextView private lateinit var artist: TextView
private lateinit var album: TextView private lateinit var album: TextView
@ -363,7 +363,7 @@ class MainMetadataView : FrameLayout {
private var albumArtRetrieved: (AlbumArtModel, String?) -> Unit = { private var albumArtRetrieved: (AlbumArtModel, String?) -> Unit = {
model: AlbumArtModel, _: String? -> model: AlbumArtModel, _: String? ->
handler.post { handler?.post {
if (model === albumArtModel) { if (model === albumArtModel) {
if (Strings.empty(model.url)) { if (Strings.empty(model.url)) {
setMetadataDisplayMode(DisplayMode.NoArtwork) setMetadataDisplayMode(DisplayMode.NoArtwork)

View File

@ -38,6 +38,7 @@ class SocketMessage private constructor(val name: String, val id: String, val ty
this.options = options ?: JSONObject() this.options = options ?: JSONObject()
} }
@Suppress("UNCHECKED_CAST")
fun <T> getOption(key: String): T? { fun <T> getOption(key: String): T? {
if (options.has(key)) { if (options.has(key)) {
try { try {

View File

@ -1,10 +1,13 @@
buildscript { buildscript {
ext.kotlin_version = '1.1.4-2' ext.kotlin_version = '1.1.4-3'
repositories { repositories {
jcenter() jcenter()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta3' classpath 'com.android.tools.build:gradle:3.0.0-beta4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }