12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package com.epson.iprint.storage.dropbox;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import com.dropbox.core.DbxException;
- import com.dropbox.core.p005v2.DbxClientV2;
- import com.epson.iprint.storage.StorageSignInActivity;
- public class DropboxV2SignInActivity extends StorageSignInActivity {
- private static final String LOG_TAG = "DropboxV2SignInActivity";
- private boolean mAuthActivityStarted;
- public StorageSignInActivity.BasicSignIn getBasicSignIn() {
- return null;
- }
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- }
- private void startAuthActivity() {
- DropboxV2Adapter.init(this);
- DropboxV2Adapter.startAuthentication(this);
- }
- protected void onResume() {
- super.onResume();
- if (mAuthActivityStarted) {
- startAuthActivity();
- mAuthActivityStarted = true;
- return;
- }
- new Task().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, new Void[0]);
- }
- class Task extends AsyncTask<Void, Void, Boolean> {
- Task() {
- }
- protected void onPostExecute(Boolean bool) {
- if (bool == null || !bool.booleanValue()) {
- showLoginErrorAndFinish();
- } else {
- finish();
- }
- }
- protected Boolean doInBackground(Void... voidArr) {
- DropboxV2Adapter.getTokenAndInitClient (getApplicationContext());
- DbxClientV2 client = DropboxV2Adapter.getClient();
- if (client == null) {
- return false;
- }
- try {
- client.users().getCurrentAccount();
- return true;
- } catch (DbxException e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- }
|