Linting fixes

This commit is contained in:
arkon
2020-04-25 14:24:45 -04:00
parent 4da760d614
commit 3f63b320c4
272 changed files with 4167 additions and 3602 deletions

View File

@@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.common_action_toolbar.view.common_action_t
* A toolbar holding only menu items.
*/
class ActionToolbar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
FrameLayout(context, attrs) {
FrameLayout(context, attrs) {
init {
inflate(context, R.layout.common_action_toolbar, this)

View File

@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
import kotlin.math.max
class AutofitRecyclerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
RecyclerView(context, attrs) {
RecyclerView(context, attrs) {
private val manager = GridLayoutManager(context, 1)

View File

@@ -13,11 +13,11 @@ import java.io.File
class CustomLayoutPickerActivity : FilePickerActivity() {
override fun getFragment(startPath: String?, mode: Int, allowMultiple: Boolean, allowCreateDir: Boolean):
AbstractFilePickerFragment<File> {
val fragment = CustomLayoutFilePickerFragment()
fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir)
return fragment
}
AbstractFilePickerFragment<File> {
val fragment = CustomLayoutFilePickerFragment()
fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir)
return fragment
}
}
class CustomLayoutFilePickerFragment : FilePickerFragment() {

View File

@@ -10,7 +10,7 @@ import kotlinx.android.synthetic.main.common_dialog_with_checkbox.view.checkbox_
import kotlinx.android.synthetic.main.common_dialog_with_checkbox.view.description
class DialogCheckboxView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
LinearLayout(context, attrs) {
LinearLayout(context, attrs) {
init {
addView(inflate(R.layout.common_dialog_with_checkbox))

View File

@@ -24,7 +24,7 @@ import timber.log.Timber
* Custom dialog to select how many chapters to download.
*/
class DialogCustomDownloadView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
LinearLayout(context, attrs) {
LinearLayout(context, attrs) {
private val scope = CoroutineScope(Job() + Dispatchers.Main)

View File

@@ -27,8 +27,10 @@ class ElevationAppBarLayout @JvmOverloads constructor(
val objAnimator = ObjectAnimator.ofFloat(this, "elevation", 0f)
// Enabled and collapsible, but not collapsed means not elevated
addState(intArrayOf(android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed),
objAnimator)
addState(
intArrayOf(android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed),
objAnimator
)
// Default enabled state
addState(intArrayOf(android.R.attr.enabled), objAnimator)

View File

@@ -15,7 +15,7 @@ import kotlinx.android.synthetic.main.common_view_empty.view.text_face
import kotlinx.android.synthetic.main.common_view_empty.view.text_label
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
RelativeLayout(context, attrs) {
RelativeLayout(context, attrs) {
init {
inflate(context, R.layout.common_view_empty, this)
@@ -46,7 +46,8 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
val button = AppCompatButton(context).apply {
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT)
LinearLayout.LayoutParams.WRAP_CONTENT
)
setText(it.resId)
setOnClickListener(it.listener)

View File

@@ -6,7 +6,7 @@ import android.widget.NumberPicker
import eu.kanade.tachiyomi.R
class MinMaxNumberPicker @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
NumberPicker(context, attrs) {
NumberPicker(context, attrs) {
init {
if (attrs != null) {

View File

@@ -9,7 +9,7 @@ import eu.kanade.tachiyomi.R
import kotlin.math.abs
class NegativeSeekBar @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
AppCompatSeekBar(context, attrs) {
AppCompatSeekBar(context, attrs) {
private var minValue: Int = 0
private var maxValue: Int = 0
@@ -17,8 +17,9 @@ class NegativeSeekBar @JvmOverloads constructor(context: Context, attrs: Attribu
init {
val styledAttributes = context.obtainStyledAttributes(
attrs,
R.styleable.NegativeSeekBar, 0, 0)
attrs,
R.styleable.NegativeSeekBar, 0, 0
)
try {
setMinSeek(styledAttributes.getInt(R.styleable.NegativeSeekBar_min_seek, 0))

View File

@@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.view.visible
class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
View(context, attrs) {
View(context, attrs) {
/**
* Hides the animation view with a animation
@@ -25,7 +25,8 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
// Create the animation (the final radius is zero).
val anim = ViewAnimationUtils.createCircularReveal(
this, centerX, centerY, initialRadius.toFloat(), 0f)
this, centerX, centerY, initialRadius.toFloat(), 0f
)
// Set duration of animation.
anim.duration = 500
@@ -57,7 +58,8 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att
// Create animation
val anim = ViewAnimationUtils.createCircularReveal(
this, centerX, centerY, 0f, height.toFloat())
this, centerX, centerY, 0f, height.toFloat()
)
// Set duration of animation
anim.duration = 350

View File

@@ -36,16 +36,23 @@ open class SimpleNavigationView @JvmOverloads constructor(
init {
// Custom attributes
val a = TintTypedArray.obtainStyledAttributes(context, attrs,
R.styleable.NavigationView, defStyleAttr,
R.style.Widget_Design_NavigationView)
val a = TintTypedArray.obtainStyledAttributes(
context, attrs,
R.styleable.NavigationView, defStyleAttr,
R.style.Widget_Design_NavigationView
)
ViewCompat.setBackground(
this, a.getDrawable(R.styleable.NavigationView_android_background))
this, a.getDrawable(R.styleable.NavigationView_android_background)
)
if (a.hasValue(R.styleable.NavigationView_elevation)) {
ViewCompat.setElevation(this, a.getDimensionPixelSize(
R.styleable.NavigationView_elevation, 0).toFloat())
ViewCompat.setElevation(
this,
a.getDimensionPixelSize(
R.styleable.NavigationView_elevation, 0
).toFloat()
)
}
a.recycle()

View File

@@ -8,7 +8,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.getResourceColor
class ThemedSwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
SwipeRefreshLayout(context, attrs) {
SwipeRefreshLayout(context, attrs) {
init {
setColors()
@@ -17,8 +17,9 @@ class ThemedSwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs
private fun setColors() {
setProgressBackgroundColorSchemeColor(context.getResourceColor(R.attr.colorAccent))
setColorSchemeColors(
ContextCompat.getColor(context, R.color.md_white_1000),
ContextCompat.getColor(context, R.color.md_white_1000),
ContextCompat.getColor(context, R.color.md_white_1000))
ContextCompat.getColor(context, R.color.md_white_1000),
ContextCompat.getColor(context, R.color.md_white_1000),
ContextCompat.getColor(context, R.color.md_white_1000)
)
}
}

View File

@@ -5,7 +5,7 @@ import android.util.AttributeSet
import androidx.preference.ListPreference
class IntListPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
ListPreference(context, attrs) {
ListPreference(context, attrs) {
override fun persistString(value: String?): Boolean {
return value != null && persistInt(value.toInt())

View File

@@ -36,8 +36,8 @@ abstract class LoginDialogPreference(
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
var dialog = MaterialDialog(activity!!)
.customView(R.layout.pref_account_login)
.negativeButton(android.R.string.cancel)
.customView(R.layout.pref_account_login)
.negativeButton(android.R.string.cancel)
if (titleRes != null) {
dialog = dialog.title(text = activity!!.getString(titleRes, titleFormatArgs))
@@ -51,10 +51,11 @@ abstract class LoginDialogPreference(
fun onViewCreated(view: View) {
v = view.apply {
show_password.setOnCheckedChangeListener { _, isChecked ->
if (isChecked)
if (isChecked) {
password.transformationMethod = null
else
} else {
password.transformationMethod = PasswordTransformationMethod()
}
}
if (usernameLabelRes != null) {

View File

@@ -8,7 +8,7 @@ import eu.kanade.tachiyomi.R
import kotlinx.android.synthetic.main.pref_widget_imageview.view.image_view
class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
Preference(context, attrs) {
Preference(context, attrs) {
init {
widgetLayoutResource = R.layout.pref_widget_imageview
@@ -17,10 +17,13 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
holder.itemView.image_view.setImageResource(if (getPersistedString("").isNullOrEmpty())
android.R.color.transparent
else
R.drawable.ic_done_green_24dp)
holder.itemView.image_view.setImageResource(
if (getPersistedString("").isNullOrEmpty()) {
android.R.color.transparent
} else {
R.drawable.ic_done_green_24dp
}
)
}
public override fun notifyChanged() {

View File

@@ -20,8 +20,9 @@ class SwitchPreferenceCategory @JvmOverloads constructor(
PreferenceCategory(
context,
attrs,
R.attr.switchPreferenceCompatStyle),
CompoundButton.OnCheckedChangeListener {
R.attr.switchPreferenceCompatStyle
),
CompoundButton.OnCheckedChangeListener {
private var mChecked = false
@@ -114,9 +115,12 @@ class SwitchPreferenceCategory @JvmOverloads constructor(
}
override fun onSetInitialValue(restoreValue: Boolean, defaultValue: Any?) {
setChecked(if (restoreValue)
getPersistedBoolean(mChecked)
else
defaultValue as Boolean)
setChecked(
if (restoreValue) {
getPersistedBoolean(mChecked)
} else {
defaultValue as Boolean
}
)
}
}

View File

@@ -27,7 +27,7 @@ class TrackLoginDialog(
constructor(service: TrackService) : this(service, null)
constructor(service: TrackService, @StringRes usernameLabelRes: Int?) :
this(R.string.login_title, service.name, usernameLabelRes, Bundle().apply { putInt("key", service.id) })
this(R.string.login_title, service.name, usernameLabelRes, Bundle().apply { putInt("key", service.id) })
override fun setCredentialsOnView(view: View) = with(view) {
username.setText(service.getUsername())
@@ -38,24 +38,28 @@ class TrackLoginDialog(
requestSubscription?.unsubscribe()
v?.apply {
if (username.text.isNullOrEmpty() || password.text.isNullOrEmpty())
if (username.text.isNullOrEmpty() || password.text.isNullOrEmpty()) {
return
}
login.progress = 1
val user = username.text.toString()
val pass = password.text.toString()
requestSubscription = service.login(user, pass)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
dialog?.dismiss()
context.toast(R.string.login_success)
}, { error ->
},
{ error ->
login.progress = -1
login.setText(R.string.unknown_error)
error.message?.let { context.toast(it) }
})
}
)
}
}

View File

@@ -19,13 +19,13 @@ class TrackLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
return MaterialDialog(activity!!)
.title(R.string.logout_title, service.name)
.positiveButton(R.string.logout) {
service.logout()
(targetController as? Listener)?.trackLogoutDialogClosed(service)
activity?.toast(R.string.logout_success)
}
.negativeButton(android.R.string.cancel)
.title(R.string.logout_title, service.name)
.positiveButton(R.string.logout) {
service.logout()
(targetController as? Listener)?.trackLogoutDialogClosed(service)
activity?.toast(R.string.logout_success)
}
.negativeButton(android.R.string.cancel)
}
interface Listener {