mirror of
https://github.com/etesync/android
synced 2024-11-15 20:38:58 +00:00
LoginCredentials: fix crash with fragment.
All Fragment classes you create must have a public, no-arg constructor.
This commit is contained in:
parent
5cd8ea82ff
commit
841a1f0fd9
@ -73,7 +73,7 @@ class SignupFragment(private val initialUsername: String?, private val initialPa
|
||||
val login = v.findViewById<Button>(R.id.login)
|
||||
login.setOnClickListener {
|
||||
parentFragmentManager.commit {
|
||||
replace(android.R.id.content, LoginCredentialsFragment(editUserName.editText?.text.toString(), editPassword.editText?.text.toString()))
|
||||
replace(android.R.id.content, LoginCredentialsFragment.newInstance(editUserName.editText?.text.toString(), editPassword.editText?.text.toString()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class LoginActivity : BaseActivity() {
|
||||
if (savedInstanceState == null)
|
||||
// first call, add fragment
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(android.R.id.content, LoginCredentialsFragment(null, null))
|
||||
.replace(android.R.id.content, LoginCredentialsFragment())
|
||||
.commit()
|
||||
|
||||
}
|
||||
|
@ -29,13 +29,16 @@ import net.cachapa.expandablelayout.ExpandableLayout
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import java.net.URI
|
||||
|
||||
class LoginCredentialsFragment(private val initialUsername: String?, private val initialPassword: String?) : Fragment() {
|
||||
class LoginCredentialsFragment : Fragment() {
|
||||
internal lateinit var editUserName: EditText
|
||||
internal lateinit var editUrlPassword: TextInputLayout
|
||||
|
||||
internal lateinit var showAdvanced: CheckedTextView
|
||||
internal lateinit var customServer: EditText
|
||||
|
||||
internal var initialUsername: String? = null
|
||||
internal var initialPassword: String? = null
|
||||
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val v = inflater.inflate(R.layout.login_credentials_fragment, container, false)
|
||||
@ -119,4 +122,13 @@ class LoginCredentialsFragment(private val initialUsername: String?, private val
|
||||
|
||||
return if (valid) LoginCredentials(uri, userName, password) else null
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(initialUsername: String?, initialPassword: String?): LoginCredentialsFragment {
|
||||
val ret = LoginCredentialsFragment()
|
||||
ret.initialUsername = initialUsername
|
||||
ret.initialPassword = initialPassword
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user