Search in sources :

Example 1 with FileOperationsHelper

use of com.owncloud.android.ui.helpers.FileOperationsHelper in project android by owncloud.

the class FileActivity method onCreate.

/**
     * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
     * the {@link FileActivity}.
     *
     * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user
     * is requested to create a new one.
     */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    mFileOperationsHelper = new FileOperationsHelper(this);
    Account account = null;
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
        mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
        mFileOperationsHelper.setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE));
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
        }
    } else {
        account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
        mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
    }
    // best place, before any access to AccountManager
    AccountUtils.updateAccountVersion(this);
    // or database
    setAccount(account, savedInstanceState != null);
    mOperationsServiceConnection = new OperationsServiceConnection();
    bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE);
    mDownloadServiceConnection = newTransferenceServiceConnection();
    if (mDownloadServiceConnection != null) {
        bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, Context.BIND_AUTO_CREATE);
    }
    mUploadServiceConnection = newTransferenceServiceConnection();
    if (mUploadServiceConnection != null) {
        bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE);
    }
}
Also used : FileOperationsHelper(com.owncloud.android.ui.helpers.FileOperationsHelper) Account(android.accounts.Account) OwnCloudAccount(com.owncloud.android.lib.common.OwnCloudAccount) FileUploader(com.owncloud.android.files.services.FileUploader) Handler(android.os.Handler) Intent(android.content.Intent) FileDownloader(com.owncloud.android.files.services.FileDownloader) OperationsService(com.owncloud.android.services.OperationsService)

Aggregations

Account (android.accounts.Account)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 FileDownloader (com.owncloud.android.files.services.FileDownloader)1 FileUploader (com.owncloud.android.files.services.FileUploader)1 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)1 OperationsService (com.owncloud.android.services.OperationsService)1 FileOperationsHelper (com.owncloud.android.ui.helpers.FileOperationsHelper)1