Skip to content

Commit 1d94fe7

Browse files
committed
push
1 parent d4a38bb commit 1d94fe7

File tree

7 files changed

+125
-31
lines changed

7 files changed

+125
-31
lines changed

.idea/caches/build_file_checksums.ser

-1 Bytes
Binary file not shown.

.idea/caches/gradle_models.ser

86.3 KB
Binary file not shown.

.idea/codeStyles/Project.xml

Lines changed: 109 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/example/golfier/android_youtube_api/DataApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void getResultsFromApi() {
6060
} else if (!isDeviceOnline()) {
6161
sendError("No network connection available.");
6262
} else {
63-
new MakeRequestTask(mCredential,mProgress).execute();
63+
new MakeRequestTask(mCredential,mProgress, activity).execute();
6464
}
6565
}
6666

app/src/main/java/com/example/golfier/android_youtube_api/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public class MainActivity extends Activity {
1818
private Button mCallApiButton;
1919
private DataApi myApi;
2020

21-
private static final int REQUEST_ACCOUNT_PICKER = 1000;
22-
private static final int REQUEST_AUTHORIZATION = 1001;
23-
private static final int REQUEST_GOOGLE_PLAY_SERVICES = 1002;
21+
public static final int REQUEST_ACCOUNT_PICKER = 1000;
22+
public static final int REQUEST_AUTHORIZATION = 1001;
23+
public static final int REQUEST_GOOGLE_PLAY_SERVICES = 1002;
2424

2525
private static final String PREF_ACCOUNT_NAME = "accountName";
2626

app/src/main/java/com/example/golfier/android_youtube_api/MakeRequestTask.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.golfier.android_youtube_api;
22

3+
import android.app.Activity;
34
import android.app.ProgressDialog;
45
import android.os.AsyncTask;
56
import android.text.TextUtils;
@@ -31,8 +32,9 @@ public class MakeRequestTask extends AsyncTask<Void, Void, YoutubeUser> {
3132
private ProgressDialog mProgress;
3233
private YoutubeUser youtubeUser;
3334
private RequestInfo ri;
35+
private Activity activity;
3436

35-
MakeRequestTask(GoogleAccountCredential credential, ProgressDialog pd) {
37+
MakeRequestTask(GoogleAccountCredential credential, ProgressDialog pd, Activity activity) {
3638
this.credential =credential;
3739
HttpTransport transport = AndroidHttp.newCompatibleTransport();
3840
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
@@ -44,6 +46,7 @@ public class MakeRequestTask extends AsyncTask<Void, Void, YoutubeUser> {
4446
this.mProgress = pd;
4547
this.youtubeUser = new YoutubeUser();
4648
this.youtubeUser.setAccountMail(this.credential.getSelectedAccountName());
49+
this.activity = activity;
4750
}
4851

4952
@Override
@@ -108,7 +111,13 @@ private void getDataFromApi() {
108111
processInfo(playlistItemList.iterator());
109112
}
110113

111-
} catch (GoogleJsonResponseException e) {
114+
} catch (UserRecoverableAuthIOException e) {
115+
System.out.println("UserRecoverableAuthIOException");
116+
this.activity.startActivityForResult(
117+
((UserRecoverableAuthIOException) e).getIntent(),
118+
MainActivity.REQUEST_AUTHORIZATION);
119+
}
120+
catch (GoogleJsonResponseException e) {
112121
e.printStackTrace();
113122
System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage());
114123

0 commit comments

Comments
 (0)