/** {@inheritDoc} */ @Override public void onActivityCreated(Bundle savedInstanceState) { Log_OC.i(TAG, "onActivityCreated() start"); super.onActivityCreated(savedInstanceState); mAdapter = new LocalFileListAdapter(mContainerActivity.getInitialDirectory(), getActivity()); setListAdapter(mAdapter); Log_OC.i(TAG, "onActivityCreated() stop"); }
/** {@inheritDoc} */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.i(TAG, "onCreateView() start"); View v = super.onCreateView(inflater, container, savedInstanceState); setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); setSwipeEnabled(false); // Disable pull-to-refresh setFabEnabled(false); // Disable FAB setMessageForEmptyList(getString(R.string.local_file_list_empty)); Log_OC.i(TAG, "onCreateView() end"); return v; }
@Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result = null; /// download will be performed to a temporal file, then moved to the final location File tmpFile = new File(getTmpPath()); /// perform the download try { tmpFile.getParentFile().mkdirs(); int status = downloadFile(client, tmpFile); result = new RemoteOperationResult( isSuccess(status), status, (mGet != null ? mGet.getResponseHeaders() : null)); Log_OC.i( TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult(e); Log_OC.e( TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage(), e); } return result; }
@Override protected RemoteOperationResult run(OwnCloudClient client) { AccountManager accountMngr = AccountManager.get(mContext); String statUrl = accountMngr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); statUrl += AccountUtils.STATUS_PATH; RemoteOperationResult result = null; GetMethod get = null; try { get = new GetMethod(statUrl); int status = client.executeMethod(get); if (status != HttpStatus.SC_OK) { client.exhaustResponse(get.getResponseBodyAsStream()); result = new RemoteOperationResult(false, status, get.getResponseHeaders()); } else { String response = get.getResponseBodyAsString(); if (response != null) { JSONObject json = new JSONObject(response); if (json != null && json.getString("version") != null) { String version = json.getString("version"); mOwnCloudVersion = new OwnCloudVersion(version); if (mOwnCloudVersion.isVersionValid()) { accountMngr.setUserData( mAccount, Constants.KEY_OC_VERSION, mOwnCloudVersion.getVersion()); Log_OC.d(TAG, "Got new OC version " + mOwnCloudVersion.toString()); result = new RemoteOperationResult(ResultCode.OK); } else { Log_OC.w( TAG, "Invalid version number received from server: " + json.getString("version")); result = new RemoteOperationResult(RemoteOperationResult.ResultCode.BAD_OC_VERSION); } } } if (result == null) { result = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); } } Log_OC.i( TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage()); } catch (JSONException e) { result = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); Log_OC.e( TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e); } catch (Exception e) { result = new RemoteOperationResult(e); Log_OC.e( TAG, "Check for update of ownCloud server version at " + client.getWebdavUri() + ": " + result.getLogMessage(), e); } finally { if (get != null) get.releaseConnection(); } return result; }