Kotlinize some widgets

This commit is contained in:
len
2016-03-08 01:22:56 +01:00
parent 0ddbfd1036
commit 05adde552d
12 changed files with 142 additions and 210 deletions
@@ -4,12 +4,8 @@ import android.content.Context
import android.support.v7.preference.ListPreference
import android.util.AttributeSet
class IntListPreference : ListPreference {
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
}
constructor(context: Context) : super(context) {
}
class IntListPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
ListPreference(context, attrs) {
override fun persistString(value: String?): Boolean {
return value != null && persistInt(value.toInt())
@@ -34,10 +34,10 @@ class MangaSyncLoginDialog : LoginDialogPreference() {
sync = (activity as SettingsActivity).syncManager.getService(syncId)
}
override fun setCredentialsOnView(view: View) {
view.accounts_login.text = getString(R.string.accounts_login_title, sync.name)
view.username.setText(preferences.getMangaSyncUsername(sync))
view.password.setText(preferences.getMangaSyncPassword(sync))
override fun setCredentialsOnView(view: View) = with(view) {
accounts_login.text = getString(R.string.accounts_login_title, sync.name)
username.setText(preferences.getMangaSyncUsername(sync))
password.setText(preferences.getMangaSyncPassword(sync))
}
override fun checkLogin() {
@@ -34,10 +34,10 @@ class SourceLoginDialog : LoginDialogPreference() {
source = (activity as SettingsActivity).sourceManager.get(sourceId)!!
}
override fun setCredentialsOnView(view: View) {
view.accounts_login.text = getString(R.string.accounts_login_title, source.name)
view.username.setText(preferences.getSourceUsername(source))
view.password.setText(preferences.getSourcePassword(source))
override fun setCredentialsOnView(view: View) = with(view) {
accounts_login.text = getString(R.string.accounts_login_title, source.name)
username.setText(preferences.getSourceUsername(source))
password.setText(preferences.getSourcePassword(source))
}
override fun checkLogin() {