本文整理汇总了Java中com.alwaysallthetime.adnlib.data.Token类的典型用法代码示例。如果您正苦于以下问题:Java Token类的具体用法?Java Token怎么用?Java Token使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Token类属于com.alwaysallthetime.adnlib.data包,在下文中一共展示了Token类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setToken
import com.alwaysallthetime.adnlib.data.Token; //导入依赖的package包/类
public static void setToken(Token token) {
final SharedPreferences.Editor editor = sPrefs.edit();
if(token != null) {
editor.putString(TOKEN_OBJECT, gson.toJson(token));
} else {
editor.remove(TOKEN_OBJECT);
}
editor.commit();
}
示例2: saveCredentials
import com.alwaysallthetime.adnlib.data.Token; //导入依赖的package包/类
public static void saveCredentials(String accessToken, Token token) {
final SharedPreferences.Editor editor = sPrefs.edit();
final String tokenJson = gson.toJson(token);
editor.putString(TOKEN_OBJECT, tokenJson);
editor.putString(ACCESS_TOKEN, accessToken);
editor.commit();
}
示例3: attemptLogin
import com.alwaysallthetime.adnlib.data.Token; //导入依赖的package包/类
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
public void attemptLogin() {
String clientID = AccessKeys.CLIENT_ID;
String pwGrantSecret = AccessKeys.PASSWORD_GRANT_SECRET;
AppDotNetClient client = new AppDotNetClient(clientID, pwGrantSecret);
final LoginActivity closure = this;
mUser = mUserView.getText().toString();
mPassword = mPasswordView.getText().toString();
showProgress(true); // Switch!
client.authenticateWithPassword(mUser, mPassword, SCOPE, new LoginResponseHandler() {
@Override
public void onSuccess(String accessToken, Token token) {
// The access token has already been set on the client; you don't need to call setToken() here.
// This also happens on the main thread.
Log.d("onSuccess", "got token?");
Log.d("onSuccess", accessToken);
SettingsDAO dao = new SettingsDAO(closure);
dao.open();
// Settings settings = dao.getSettings();
Settings settings = new Settings();
settings.setClientID( accessToken );
dao.save( settings );
dao.close();
// the settings object should now have an id!
Log.d("Settings ID", settings.getColumnId().toString());
// Let's redirect to the main thing now.
Intent mainActivity = new Intent(getApplicationContext(), MainActivity.class);
// Could set some things up here to pass it forwards.
startActivity(mainActivity);
finish();
}
// @Override
// public void onError() {
// Log.d("error!", "error");
// }
});
}
示例4: getToken
import com.alwaysallthetime.adnlib.data.Token; //导入依赖的package包/类
public static Token getToken() {
final String tokenJson = sPrefs.getString(TOKEN_OBJECT, null);
return gson.fromJson(tokenJson, Token.class);
}
示例5: TokenResponseHandler
import com.alwaysallthetime.adnlib.data.Token; //导入依赖的package包/类
protected TokenResponseHandler() {
super(new TypeToken<ResponseEnvelope<Token>>(){});
}
示例6: onSuccess
import com.alwaysallthetime.adnlib.data.Token; //导入依赖的package包/类
public abstract void onSuccess(String accessToken, Token token);