Java Code Examples for com.google.api.services.drive.model.File#getTitle()

The following examples show how to use com.google.api.services.drive.model.File#getTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DriveSyncService.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public  List<RemoteDataInfo> getRemoteEntries() throws SyncFailedException {
    LogUtil.log(getClass().getSimpleName(), "Files in Narrate Drive AppFolder:");
    List<RemoteDataInfo> dataObjects = new ArrayList<>();

    try {
        List<File> contents = getContents();
        if (contents != null) {

            Iterator<File> iter = contents.iterator();
            File f;
            while (iter.hasNext()) {
                f = iter.next();
                LogUtil.log(getClass().getSimpleName(), f.getTitle());
                if (!f.getTitle().equals("photos")) {
                    RemoteDataInfo info = new RemoteDataInfo();
                    info.name = f.getTitle();
                    info.isDirectory = f.getMimeType().equals(FOLDER_MIME);
                    info.isDeleted = f.getLabels().getTrashed();
                    info.modifiedDate = f.getModifiedDate().getValue();
                    info.revision = String.valueOf(f.getVersion());
                    dataObjects.add(info);
                }
            }

            return dataObjects;
        }
    } catch (Exception e) {
        if (!BuildConfig.DEBUG) Crashlytics.logException(e);
        e.printStackTrace();
        throw new SyncFailedException(e.getMessage());
    }

    return null;
}
 
Example 2
Source File: DriveSyncService.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public List<RemoteDataInfo> getRemotePhotos() throws SyncFailedException {
    LogUtil.log(DriveSyncService.class.getSimpleName(), "getRemotePhotos()");

    List<RemoteDataInfo> dataObjects = new ArrayList<>();
    try {
        List<File> result = getPhotosContents();

        LogUtil.log(getClass().getSimpleName(), "Files in Narrate Drive Photos Folder:");

        if (result.size() > 0) {
            for (File f : result) {
                LogUtil.log(getClass().getSimpleName(), f.getTitle());
                RemoteDataInfo info = new RemoteDataInfo();
                info.name = f.getTitle();
                info.isDirectory = f.getMimeType().equals(FOLDER_MIME);
                info.isDeleted = f.getLabels().getTrashed();
                info.modifiedDate = f.getModifiedDate().getValue();
                info.revision = String.valueOf(f.getVersion());
                dataObjects.add(info);
            }
        }
    } catch (Exception e) {
        if (!BuildConfig.DEBUG) Crashlytics.logException(e);
        e.printStackTrace();
        throw new SyncFailedException(e.getMessage());
    }

    return dataObjects;
}
 
Example 3
Source File: SyncTestUtils.java    From mytracks with Apache License 2.0 5 votes vote down vote up
/**
 * Finds whether a file is existed by the name of track.
 * 
 * @param trackName name of track
 * @param drive a Google Drive object
 * @return the file be found
 * @throws IOException
 */
public static File getFile(String trackName, Drive drive) throws IOException {
  List<File> files = getDriveFiles(EndToEndTestUtils.trackListActivity.getApplicationContext(),
      drive);
  for (int i = 0; i < files.size(); i++) {
    File file = files.get(i);
    String title = file.getTitle();
    if (title.equals(trackName + KML_FILE_POSTFIX)) {
      return file;
    }
  }
  return null;
}