List of usage examples for android.widget LinearLayout setAnimation
public void setAnimation(Animation animation)
From source file:com.synox.android.ui.activity.FileActivity.java
/** * Retrieves user quota if available// ww w. j ava 2 s. co m * * @param navigationDrawerLayout */ private void getUserQuota(final NavigationView navigationDrawerLayout, final String user) { // set user space information Thread t = new Thread(new Runnable() { public void run() { try { OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, MainApp.getAppContext()); OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton() .getClientFor(ocAccount, MainApp.getAppContext()); GetMethod get = null; final ProgressBar quotaProgress = (ProgressBar) navigationDrawerLayout .findViewById(R.id.usage_progress); final LinearLayout quotaInformation = (LinearLayout) navigationDrawerLayout .findViewById(R.id.quotaInformation); try { get = new GetMethod( client.getBaseUri() + "/ocs/v1.php/cloud/users/" + user + "?format=json"); int status = client.executeMethod(get); if (status == HttpStatus.SC_OK) { JSONObject json = new JSONObject(get.getResponseBodyAsString()); JSONObject ocs = json.getJSONObject("ocs"); JSONObject meta = ocs.getJSONObject("meta"); JSONObject data = ocs.getJSONObject("data"); JSONObject quota = data.getJSONObject("quota"); if (meta.getString("statuscode").equals("100")) { try { final long used = Long.parseLong(quota.getString("used")); final long total = Long.parseLong(quota.getString("total")); final int relative = (int) Math.ceil(quota.getDouble("relative")); runOnUiThread(new Runnable() { @Override public void run() { if (quotaProgress != null) { if (quotaInformation.getVisibility() == View.INVISIBLE) { Animation animation = AnimationUtils.loadAnimation( navigationDrawerLayout.getContext(), R.anim.abc_slide_in_bottom); quotaInformation.setAnimation(animation); } quotaInformation.setVisibility(View.VISIBLE); quotaProgress.setProgress(relative); } else { quotaInformation.setVisibility(View.INVISIBLE); } TextView usageText = (TextView) navigationDrawerLayout .findViewById(R.id.usage_text); usageText.setText(String.format(getString(R.string.usage_text), DisplayUtils.bytesToHumanReadable(used), DisplayUtils.bytesToHumanReadable(total))); } }); } catch (NumberFormatException nfe) { Log_OC.e(this.getClass().getName(), "Error retrieving quota usage from server."); } } } else { client.exhaustResponse(get.getResponseBodyAsStream()); } } catch (final Exception e) { runOnUiThread(new Runnable() { @Override public void run() { quotaInformation.setVisibility(View.INVISIBLE); e.printStackTrace(); } }); } finally { if (get != null) { get.releaseConnection(); } } } catch (com.synox.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) { Log_OC.e(this.getClass().getName(), e.getMessage()); } catch (AuthenticatorException | OperationCanceledException | IOException e) { Log_OC.e(this.getClass().getName(), e.getMessage()); } } }); t.start(); }