Created
June 10, 2010 20:02
-
-
Save skyler/433557 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private void login(String username, String password) | |
{ | |
LoginCredentials creds = new LoginCredentials(username, password); | |
AsyncAPI.getInstance().login(this, creds, new ITaskCallback<Boolean>() { | |
@Override | |
public void onResult(AbstractRunnable<Boolean> task) | |
{ | |
handler.sendEmptyMessage(DISMISS_LOGIN_DIALOG); | |
boolean accountOK = false; | |
if (task.getResult()) { // boolean "logged-in" | |
LoggedInUser loggedInUser = GroovesharkAPI.getInstance().getLoggedInUser(); | |
if (loggedInUser.isPremium) { | |
accountOK = true; | |
} else { | |
TrialController trial = TrialController.getInstance(); | |
if (trial.isInTrial()) { | |
ExpirationInfo info = trial.getExpirationInfo(); | |
if (!info.hasExpired && info.numPlaysRemaining > 0) { | |
accountOK = true; | |
} else { | |
handler.sendEmptyMessage(SHOW_TRIAL_EXPIRED_DIALOG); | |
} | |
} else { | |
Log.d(TAG, "user NOT VIP, prompting upgrade/trial"); | |
handler.sendEmptyMessage(SHOW_START_TRIAL_DIALOG); | |
} | |
} | |
} else { | |
handler.sendEmptyMessage(DISMISS_LOGIN_DIALOG); | |
handler.sendEmptyMessage(SHOW_LOGIN_FAILED_DIALOG); | |
} | |
if (accountOK) { | |
FavoritesController.getInstance().loadFavorites(Login.this, loggedInUser.userID); | |
PlaylistsController.getInstance().clearPlaylists(Login.this); | |
Intent intent = new Intent(Login.this, Home.class); | |
startActivity(intent); | |
finish(); | |
} | |
} | |
@Override | |
public void onError() | |
{ | |
// | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment