/**
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.gms.drive.sample.demo;

import android.os.Bundle;

import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveFolder.DriveFileResult;
import com.google.android.gms.drive.MetadataChangeSet;

/**
 * An activity to illustrate how to create an empty file.
 */
public class CreateEmptyFileActivity extends BaseDemoActivity {

    @Override
    public void onConnected(Bundle connectionHint) {
        super.onConnected(connectionHint);

        // Perform I/O off the UI thread.
        new Thread() {
            @Override
            public void run() {
                MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                        .setTitle("New file")
                        .setMimeType("text/plain")
                        .setStarred(true).build();

                // Create an empty file on root folder.
                Drive.DriveApi.getRootFolder(getGoogleApiClient())
                        .createFile(getGoogleApiClient(), changeSet, null /* DriveContents */)
                        .setResultCallback(fileCallback);
            }
        }.start();
    }

    final private ResultCallback<DriveFileResult> fileCallback = new
            ResultCallback<DriveFileResult>() {
                @Override
                public void onResult(DriveFileResult result) {
                    if (!result.getStatus().isSuccess()) {
                        showMessage("Error while trying to create the file");
                        return;
                    }
                    showMessage("Created an empty file: "
                            + result.getDriveFile().getDriveId());
                }
            };


}

@@ -1149,135 +1149,8 @@
 );%0A%0A
-        // Perform I/O off the UI thread.%0A        new Thread() %7B%0A            @Override%0A            public void run() %7B%0A        
     
@@ -1215,24 +1215,16 @@
 ilder()%0A
-        
         
@@ -1265,32 +1265,24 @@
             
-        
 .setMimeType
@@ -1308,32 +1308,24 @@
             
-      
-  
 .setStarred(
@@ -1340,24 +1340,16 @@
 ild();%0A%0A
-        
         
@@ -1396,24 +1396,16 @@
         
-   
-     
 Drive.Dr
@@ -1447,24 +1447,16 @@
 ient())%0A
-        
         
@@ -1546,32 +1546,24 @@
             
- 
-       
 .setResultCa
@@ -1588,41 +1588,8 @@
 k);%0A
-            %7D%0A        %7D.start();%0A
     

Remove unnecessary thread.