• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompletionEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.drive.events.CompletionEvent的典型用法代码示例。如果您正苦于以下问题:Java CompletionEvent类的具体用法?Java CompletionEvent怎么用?Java CompletionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompletionEvent类属于com.google.android.gms.drive.events包,在下文中一共展示了CompletionEvent类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onCompletion

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
@Override
public void onCompletion(CompletionEvent event) {
    Log.d(TAG, "Action completed with status: " + event.getStatus());

    Intent intent = new Intent();
    intent.setAction(CUSTOM_INTENT)
            .putExtra(BUNDLE_SUCCESS, event.getStatus())
            .putExtra(BUNDLE_DRIVEID, event.getDriveId());
    sendBroadcast(intent);

    event.dismiss();
}
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:13,代码来源:GDriveEventService.java


示例2: ConflictResolver

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
ConflictResolver(CompletionEvent conflictedCompletionEvent, Context context,
        ExecutorService executorService) {
    this.mConflictedCompletionEvent = conflictedCompletionEvent;
    mBroadcaster = LocalBroadcastManager.getInstance(context);
    mContext = context;
    mExecutorService = executorService;
}
 
开发者ID:googledrive,项目名称:android-conflict,代码行数:8,代码来源:ConflictResolver.java


示例3: onCompletion

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
@Override
public void onCompletion(CompletionEvent event) {
    boolean eventHandled = false;
    switch (event.getStatus()) {
        case CompletionEvent.STATUS_SUCCESS:
            // Commit completed successfully.
            // Can now access the remote resource Id
            // [START_EXCLUDE]
            String resourceId = event.getDriveId().getResourceId();
            Log.d(TAG, "Remote resource ID: " + resourceId);
            eventHandled = true;
            // [END_EXCLUDE]
            break;
        case CompletionEvent.STATUS_FAILURE:
            // Handle failure....
            // Modified contents and metadata failed to be applied to the server.
            // They can be retrieved from the CompletionEvent to try to be applied later.
            // [START_EXCLUDE]
            // CompletionEvent is only dismissed here. In a real world application failure
            // should be handled before the event is dismissed.
            eventHandled = true;
            // [END_EXCLUDE]
            break;
        case CompletionEvent.STATUS_CONFLICT:
            // Handle completion conflict.
            // [START_EXCLUDE]
            ConflictResolver conflictResolver =
                    new ConflictResolver(event, this, mExecutorService);
            conflictResolver.resolve();
            eventHandled = false; // Resolver will snooze or dismiss
            // [END_EXCLUDE]
            break;
    }

    if (eventHandled) {
        event.dismiss();
    }
}
 
开发者ID:googledrive,项目名称:android-conflict,代码行数:39,代码来源:MyDriveEventService.java


示例4: onCompletion

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
@Override
public void onCompletion(CompletionEvent event) {
    Log.d(TBDrive.TAG, "Action completed for Google Drive file with status: " + event.getStatus());
    this.eventCompletion = event;
    
    //Handle completion event here.
    doOnCompletionWork();
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:9,代码来源:TBDriveEventService.java


示例5: uploadFile

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
@Override
public int uploadFile(File tempFile) {
    DriveFile driveFile;
    MetadataResult metadataResult;
    Metadata metadata;
    DriveContents driveContents = null;
    DriveContentsResult driveContentsResult;
    OutputStream outputStream;
    ExecutionOptions executionOptions;
    int complentionStatus;

    Log.i(TAG, "start upload of DB file temp:" + tempFile.getName());

    try {
        driveFile = mDriveId.asDriveFile();

        // Get metadata
        metadataResult = driveFile.getMetadata(mGoogleApiClient).await();
        checkStatus(metadataResult);

        metadata = metadataResult.getMetadata();

        Log.i(TAG, "try to upload of DB file:" + metadata.getOriginalFilename());

        if (!metadata.isPinned()) {
            pinFile(driveFile);
        }

        // Writing file
        driveContentsResult = mDriveContent.reopenForWrite(mGoogleApiClient).await();
        checkStatus(driveContentsResult);

        driveContents = driveContentsResult.getDriveContents();

        outputStream  = driveContents.getOutputStream();

        // Copio il file
        FileUtils.copyFile(tempFile, outputStream);
        Log.i(TAG, "try to commit file copy done");

        // Commit del file
        executionOptions = new ExecutionOptions.Builder()
                .setNotifyOnCompletion(true)
                .setConflictStrategy(ExecutionOptions.CONFLICT_STRATEGY_KEEP_REMOTE)
                .build();

        driveContents.commit(mGoogleApiClient, null, executionOptions);

        Log.i(TAG, "file committed - wait for complention");

        // Wait for complention
        complentionStatus = mGDriveCompletionRecevier.waitCompletion();

        Log.i(TAG, "received complention status:" + complentionStatus);

        if (complentionStatus == CompletionEvent.STATUS_CONFLICT) {
            return UPLOAD_CONFLICT;
        } else if (complentionStatus == CompletionEvent.STATUS_FAILURE) {
            throw new SyncException(SyncStatus.Code.ERROR_UPLOAD_CLOUD, "Error writing file to GDrive (FAILURE of commit)");
        }

        return UPLOAD_OK;
    } catch (IOException e) {
        if (driveContents != null) {
            driveContents.discard(mGoogleApiClient);
        }
        throw new SyncException(SyncStatus.Code.ERROR_UPLOAD_CLOUD, "Error writing file to GDrive message:" + e.getMessage());
    }
}
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:70,代码来源:GDriveCloudProvider.java


示例6: onCompletion

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("MethodDoesntCallSuperMethod")
public void onCompletion(CompletionEvent event) {
    Log.i(TAG, "Received completion event from Drive.");
    if(event.getStatus() == CompletionEvent.STATUS_SUCCESS) {
        final MetadataChangeSet metadata = event.getModifiedMetadataChangeSet();
        final String hash = metadata.getCustomPropertyChangeMap().get(sHashKey);
        Log.i(TAG, "Photo hash: " + hash);
        if(hash != null) {
            final ContentResolver cr = getContentResolver();

            final String[] projection = new String[] {
                    Tables.Photos._ID,
                    Tables.Photos.ENTRY
            };
            final String where = Tables.Photos.HASH + " = ?";
            final String[] whereArgs = new String[] {hash};
            final Cursor cursor =
                    cr.query(Tables.Photos.CONTENT_URI, projection, where, whereArgs, null);
            if(cursor != null) {
                try {
                    if(cursor.moveToFirst()) {
                        final long id =
                                cursor.getLong(cursor.getColumnIndex(Tables.Photos._ID));
                        final long entryId =
                                cursor.getLong(cursor.getColumnIndex(Tables.Photos.ENTRY));
                        final ContentValues values = new ContentValues();
                        values.put(Tables.Photos.DRIVE_ID, event.getDriveId().getResourceId());
                        cr.update(ContentUris.withAppendedId(Tables.Photos.CONTENT_ID_URI_BASE,
                                id), values, null, null);
                        EntryUtils.markChanged(cr, entryId);
                        BackendUtils.requestDataSync(this);
                    }
                } finally {
                    cursor.close();
                }
            }
        }
    }
    event.dismiss();
}
 
开发者ID:ultramega,项目名称:flavordex,代码行数:42,代码来源:DriveService.java


示例7: onCompletion

import com.google.android.gms.drive.events.CompletionEvent; //导入依赖的package包/类
@Override
    public void onCompletion(CompletionEvent event) {
        super.onCompletion(event);
        DriveId driveId = event.getDriveId();
        if (LDebug.ON) Log.d(LOG_TAG, "XXX Resource ID: " + driveId.getResourceId()); // returns the final part of the URL
        if (LDebug.ON) Log.d(LOG_TAG, "XXX Tracking Tags: " + event.getTrackingTags()); // first one is tracking tag sent
        if (LDebug.ON) Log.d(LOG_TAG, "XXX Account Name: " + event.getAccountName()); // returns null
        if (LDebug.ON) Log.d(LOG_TAG, "XXX DriveID: " + event.getDriveId()); // returns cryptic string something like expanded form of Drive ID sent
        if (LDebug.ON) Log.d(LOG_TAG, "XXX toString: " + event.toString()); // returns DriveID, status, and trackingTag
        if (LDebug.ON) Log.d(LOG_TAG, "XXX describe: " + event.describeContents()); // returns zero

          String resID = driveId.getResourceId();
          List tags = event.getTrackingTags();
          String trackTag;
          try {
              trackTag = tags.get(0).toString();
          } catch (Exception e) {
              trackTag = "Error: " + event.toString();
          }

          if (LDebug.ON) Log.d(LOG_TAG, "XXX first tracking tag: " + trackTag); //
          int cmpStatus = event.getStatus() + 1; // status code to store in DB is 1-based

          // following is redundant and can be removed
/*
        switch (event.getStatus()) {
            case CompletionEvent.STATUS_CONFLICT:
                if (LDebug.ON) Log.d(LOG_TAG, "XXX STATUS_CONFLICT");
                cmpStatus = 3;
                event.dismiss();
                break;
            case CompletionEvent.STATUS_FAILURE:
                if (LDebug.ON) Log.d(LOG_TAG, "XXX STATUS_FAILURE");
                cmpStatus = 2;
                event.dismiss();
                break;
            case CompletionEvent.STATUS_SUCCESS:
                if (LDebug.ON) Log.d(LOG_TAG, "XXX STATUS_SUCCESS ");
                cmpStatus = 1;
                event.dismiss();
                break;
        }
*/

        Uri uri, docsUri = Uri.withAppendedPath(ContentProvider_VegNab.CONTENT_URI, "docs");
        ContentResolver rs = getContentResolver();
        ContentValues contentValues = new ContentValues();
        contentValues.put("DocStatusID", cmpStatus); // ' try to update status ...
        contentValues.put("DocResourceID", resID);
        SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
        contentValues.put("TimePosted", dateTimeFormat.format(new Date()));
        String whereClause = "DocName = ?"; // ... of record where filename was sent as the tracking tag
        String[] whereArgs = new String[] {trackTag};
        int numUpdated = rs.update(docsUri, contentValues, whereClause, whereArgs);
        if (LDebug.ON) Log.d(LOG_TAG, "Updated doc record in onCompletion; numUpdated: " + numUpdated);
        if (numUpdated == 0) { // did not find a record to update
            // create a new record
            // following putNull's may not be necessary, but flag that this does not match a found record
            contentValues.putNull("DocTypeID");
            contentValues.putNull("DocSourceTypeID");
            contentValues.putNull("DocSourceRecID");
            contentValues.put("DocName", resID); // same as field 'DocResourceID'
            uri = rs.insert(docsUri, contentValues);
        }
          event.dismiss();
    }
 
开发者ID:rickshory,项目名称:VegNabAS,代码行数:67,代码来源:VNDriveEventService.java



注:本文中的com.google.android.gms.drive.events.CompletionEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OutputUtil类代码示例发布时间:2022-05-23
下一篇:
Java JournalArticleConstants类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap