1
1
/**
2
2
* Copyright 2013 Google Inc. All Rights Reserved.
3
3
*
4
- * <p> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5
5
* except in compliance with the License. You may obtain a copy of the License at
6
6
*
7
- * <p> http://www.apache.org/licenses/LICENSE-2.0
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
8
*
9
- * <p> Unless required by applicable law or agreed to in writing, software distributed under the
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the
10
10
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11
11
* express or implied. See the License for the specific language governing permissions and
12
12
* limitations under the License.
@@ -49,7 +49,6 @@ public class MainActivity extends Activity {
49
49
private static final int REQUEST_CODE_CAPTURE_IMAGE = 1 ;
50
50
private static final int REQUEST_CODE_CREATOR = 2 ;
51
51
52
- private GoogleSignInClient mGoogleSignInClient ;
53
52
private DriveClient mDriveClient ;
54
53
private DriveResourceClient mDriveResourceClient ;
55
54
private Bitmap mBitmapToSave ;
@@ -63,8 +62,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
63
62
/** Start sign in activity. */
64
63
private void signIn () {
65
64
Log .i (TAG , "Start sign in" );
66
- mGoogleSignInClient = buildGoogleSignInClient ();
67
- startActivityForResult (mGoogleSignInClient .getSignInIntent (), REQUEST_CODE_SIGN_IN );
65
+ GoogleSignInClient GoogleSignInClient = buildGoogleSignInClient ();
66
+ startActivityForResult (GoogleSignInClient .getSignInIntent (), REQUEST_CODE_SIGN_IN );
68
67
}
69
68
70
69
/** Build a Google SignIn client. */
@@ -85,19 +84,9 @@ private void saveFileToDrive() {
85
84
mDriveResourceClient
86
85
.createContents ()
87
86
.continueWithTask (
88
- new Continuation <DriveContents , Task <Void >>() {
89
- @ Override
90
- public Task <Void > then (@ NonNull Task <DriveContents > task ) throws Exception {
91
- return createFileIntentSender (task .getResult (), image );
92
- }
93
- })
87
+ task -> createFileIntentSender (task .getResult (), image ))
94
88
.addOnFailureListener (
95
- new OnFailureListener () {
96
- @ Override
97
- public void onFailure (@ NonNull Exception e ) {
98
- Log .w (TAG , "Failed to create new contents." , e );
99
- }
100
- });
89
+ e -> Log .w (TAG , "Failed to create new contents." , e ));
101
90
}
102
91
103
92
/**
@@ -134,13 +123,10 @@ private Task<Void> createFileIntentSender(DriveContents driveContents, Bitmap im
134
123
return mDriveClient
135
124
.newCreateFileActivityIntentSender (createFileActivityOptions )
136
125
.continueWith (
137
- new Continuation <IntentSender , Void >() {
138
- @ Override
139
- public Void then (@ NonNull Task <IntentSender > task ) throws Exception {
140
- startIntentSenderForResult (task .getResult (), REQUEST_CODE_CREATOR , null , 0 , 0 , 0 );
141
- return null ;
142
- }
143
- });
126
+ task -> {
127
+ startIntentSenderForResult (task .getResult (), REQUEST_CODE_CREATOR , null , 0 , 0 , 0 );
128
+ return null ;
129
+ });
144
130
}
145
131
146
132
@ Override
0 commit comments