use of com.dropbox.core.json.JsonReadException in project dropbox-sdk-java by dropbox.
the class DropboxActivity method onResume.
// will use our Short Lived Token.
@Override
protected void onResume() {
super.onResume();
SharedPreferences prefs = getSharedPreferences("dropbox-sample", MODE_PRIVATE);
if (USE_SLT) {
String serailizedCredental = prefs.getString("credential", null);
if (serailizedCredental == null) {
DbxCredential credential = Auth.getDbxCredential();
if (credential != null) {
prefs.edit().putString("credential", credential.toString()).apply();
initAndLoadData(credential);
}
} else {
try {
DbxCredential credential = DbxCredential.Reader.readFully(serailizedCredental);
initAndLoadData(credential);
} catch (JsonReadException e) {
throw new IllegalStateException("Credential data corrupted: " + e.getMessage());
}
}
} else {
String accessToken = prefs.getString("access-token", null);
if (accessToken == null) {
accessToken = Auth.getOAuth2Token();
if (accessToken != null) {
prefs.edit().putString("access-token", accessToken).apply();
initAndLoadData(accessToken);
}
} else {
initAndLoadData(accessToken);
}
}
String uid = Auth.getUid();
String storedUid = prefs.getString("user-id", null);
if (uid != null && !uid.equals(storedUid)) {
prefs.edit().putString("user-id", uid).apply();
}
}
Aggregations