Created
July 30, 2013 15:30
-
-
Save pulsation/6114018 to your computer and use it in GitHub Desktop.
Is the use of "val that = this" correct?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.pulsation.alarmsandbox | |
import android.accounts.{AccountAuthenticatorActivity, AccountManager} | |
import android.os.Bundle | |
import android.app.Activity | |
import android.widget.{Button, EditText} | |
import android.view.View.OnClickListener | |
import android.view.View | |
import android.accounts.Account | |
class AuthenticatorAccountActivity extends AccountAuthenticatorActivity { | |
val AccountType : String = "eu.pulsation.alarmsandbox.couchdb" | |
val that = this | |
override def onCreate(savedInstanceState: Bundle) { | |
lazy val proceedBtn = { | |
this.findViewById(R.id.ProceedBtn) match { | |
case btn : Button => btn | |
case _ => throw new ClassCastException | |
} | |
} | |
lazy val loginField = { | |
this.findViewById(R.id.LoginField) match { | |
case txt : EditText => txt | |
case _ => throw new ClassCastException | |
} | |
} | |
lazy val passwordField = { | |
this.findViewById(R.id.PasswordField) match { | |
case txt : EditText => txt | |
case _ => throw new ClassCastException | |
} | |
} | |
lazy val login = loginField.getText().toString() | |
lazy val password = passwordField.getText().toString() | |
val that = this | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.account) | |
// Bind buttons | |
proceedBtn.setOnClickListener(new OnClickListener() { | |
def onClick(v: View) { | |
val account : Account = new Account(login, AccountType) | |
AccountManager.get(that).addAccountExplicitly(account, password, null) | |
that.finish() | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment