List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator
public AccelerateInterpolator()
From source file:org.numixproject.hermes.activity.ConversationActivity.java
private void showConversationLayout() { // get the final radius for the clipping circle int finalRadius = Math.max(roomsLayout.getWidth(), roomsLayout.getHeight()); final FrameLayout colorLayout = (FrameLayout) findViewById(R.id.colorLayout); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // create the animator for this view (the start radius is zero) Animator colorAnim;//from w ww . j av a 2 s . co m colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) roomsLayout.getLeft(), (int) roomsLayout.getTop(), 0, finalRadius); final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f); fadeAnim.setDuration(250); fadeAnim.setInterpolator(new AccelerateInterpolator()); fadeAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { conversationLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { colorLayout.setVisibility(View.GONE); invalidateOptionsMenu(); } @Override public void onAnimationRepeat(Animation animation) { } }); colorAnim.setInterpolator(new AccelerateInterpolator()); colorAnim.addListener(new android.animation.Animator.AnimatorListener() { @Override public void onAnimationStart(android.animation.Animator animation) { } @Override public void onAnimationRepeat(android.animation.Animator animation) { } @Override public void onAnimationEnd(android.animation.Animator animation) { colorLayout.startAnimation(fadeAnim); } @Override public void onAnimationCancel(android.animation.Animator animation) { } }); colorLayout.setVisibility(View.VISIBLE); colorAnim.start(); } else { conversationLayout.setVisibility(View.VISIBLE); conversationLayout.setAlpha(0.f); conversationLayout.setScaleX(0.f); conversationLayout.setScaleY(0.f); conversationLayout.animate().alpha(1.f).scaleX(1.f).scaleY(1.f).setDuration(300).start(); } }
From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java
public void dismissWithButtonClick(final int item) { if (dismissed) { return;//from ww w .j a v a 2s.co m } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); animatorSet.setDuration(180); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, item); } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
public void dismissWithButtonClick(final int item) { if (dismissed) { return;/* w w w. j a v a 2 s . com*/ } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); animatorSet.setDuration(180); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, item); } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } catch (Exception e) { FileLog.e("messenger", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; }
From source file:self.philbrown.droidQuery.$.java
/** * This reusable chunk of code can set up the given animation using the given animation options * @param options the options used to manipulate how the animation behaves * @return the container for placing views that will be animated using the given options *///from w ww . j ava 2 s . c o m private AnimatorSet animationWithOptions(final AnimationOptions options, List<Animator> animators) { AnimatorSet animation = new AnimatorSet(); animation.playTogether(animators); animation.setDuration(options.duration()); animation.addListener(new AnimatorListener() { @Override public void onAnimationCancel(Animator animation) { if (options.fail() != null) options.fail().invoke($.this); if (options.complete() != null) options.complete().invoke($.this); } @Override public void onAnimationEnd(Animator animation) { if (options.success() != null) options.success().invoke($.this); if (options.complete() != null) options.complete().invoke($.this); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationStart(Animator animation) { } }); Interpolator interpolator = null; if (options.easing() == null) options.easing(Easing.LINEAR); final Easing easing = options.easing(); switch (easing) { case ACCELERATE: { interpolator = new AccelerateInterpolator(); break; } case ACCELERATE_DECELERATE: { interpolator = new AccelerateDecelerateInterpolator(); break; } case ANTICIPATE: { interpolator = new AnticipateInterpolator(); break; } case ANTICIPATE_OVERSHOOT: { interpolator = new AnticipateOvershootInterpolator(); break; } case BOUNCE: { interpolator = new BounceInterpolator(); break; } case DECELERATE: { interpolator = new DecelerateInterpolator(); break; } case OVERSHOOT: { interpolator = new OvershootInterpolator(); break; } //linear is default. case LINEAR: default: interpolator = new LinearInterpolator(); break; } //allow custom interpolator if (options.specialEasing() != null) interpolator = options.specialEasing(); animation.setInterpolator(interpolator); return animation; }
From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java
@Override public void dismiss() { if (dismissed) { return;/*from w w w. j a va 2 s . com*/ } dismissed = true; cancelSheetAnimation(); if (!allowCustomAnimation || !onCustomCloseAnimation()) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); if (useFastDismiss) { int height = containerView.getMeasuredHeight(); animatorSet.setDuration( Math.max(60, (int) (180 * (height - containerView.getTranslationY()) / (float) height))); useFastDismiss = false; } else { animatorSet.setDuration(180); } animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { dismissInternal(); } catch (Exception e) { FileLog.e("tmessages", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; } }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
private void dismissWithButtonClick(final int viewId) { if (dismissed) { return;/*from ww w. j a va 2s . co m*/ } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + Utils.dp(getContext(), 10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); animatorSet.setDuration(180); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; if (onClickListener != null) { onClickListener.onClick(BottomSheet.this, viewId); } handler.post(new Runnable() { @Override public void run() { try { BottomSheet.super.dismiss(); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } }); } } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; if (bottomSheetCallBack != null) { bottomSheetCallBack.onClose(); } }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
@Override public void dismiss() { if (dismissed) { return;/* w ww.jav a 2 s. c o m*/ } dismissed = true; cancelSheetAnimation(); if (!allowCustomAnimation || !onCustomCloseAnimation()) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + AndroidUtilities.dp(10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); if (useFastDismiss) { int height = containerView.getMeasuredHeight(); animatorSet.setDuration( Math.max(60, (int) (180 * (height - containerView.getTranslationY()) / (float) height))); useFastDismiss = false; } else { animatorSet.setDuration(180); } animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { dismissInternal(); } catch (Exception e) { FileLog.e("messenger", e); } } }); } } @Override public void onAnimationCancel(Animator animation) { if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; } }
From source file:org.torproject.android.Orbot.java
public void spinOrbot(float direction) { startService(TorServiceConstants.CMD_NEWNYM); Toast.makeText(this, R.string.newnym, Toast.LENGTH_SHORT).show(); // Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO * direction, imgStatus.getWidth() / 2f, imgStatus.getWidth() / 2f, 20f, false); rotation.setFillAfter(true);/*from w w w . j a v a 2 s. c om*/ rotation.setInterpolator(new AccelerateInterpolator()); rotation.setDuration((long) 2 * 1000); rotation.setRepeatCount(0); imgStatus.startAnimation(rotation); }
From source file:com.brandroidtools.filemanager.fragments.NavigationFragment.java
/** * Method that changes the current directory of the view. * * @param newDir The new directory location * @param addToHistory Add the directory to history * @param reload Force the reload of the data * @param useCurrent If this method must use the actual data (for back actions) * @param searchInfo The search information (if calling activity is {@link "SearchActivity"}) * @param scrollTo If not null, then listview must scroll to this item *//* w w w. ja v a2 s . c o m*/ private void changeCurrentDir(final String newDir, final boolean addToHistory, final boolean reload, final boolean useCurrent, final SearchInfoParcelable searchInfo, final FileSystemObject scrollTo) { // Check navigation security (don't allow to go outside the ChRooted environment if one // is created) final String fNewDir = checkChRootedNavigation(newDir); synchronized (this.mSync) { //Check that it is really necessary change the directory if (!reload && this.mCurrentDir != null && this.mCurrentDir.compareTo(fNewDir) == 0) { return; } final boolean hasChanged = !(this.mCurrentDir != null && this.mCurrentDir.compareTo(fNewDir) == 0); final boolean isNewHistory = (this.mCurrentDir != null); //Execute the listing in a background process AsyncTask<String, Integer, List<FileSystemObject>> task = new AsyncTask<String, Integer, List<FileSystemObject>>() { /** * {@inheritDoc} */ @Override protected List<FileSystemObject> doInBackground(String... params) { try { //Reset the custom title view and returns to breadcrumb if (NavigationFragment.this.mTitle != null) { NavigationFragment.this.mTitle.post(new Runnable() { @Override public void run() { try { NavigationFragment.this.mTitle.restoreView(); } catch (Exception e) { e.printStackTrace(); } } }); } //Start of loading data if (NavigationFragment.this.mBreadcrumb != null) { try { NavigationFragment.this.mBreadcrumb.startLoading(); } catch (Throwable ex) { /**NON BLOCK**/ } } //Get the files, resolve links and apply configuration //(sort, hidden, ...) List<FileSystemObject> files = NavigationFragment.this.mFiles; if (!useCurrent) { files = CommandHelper.listFiles(mActivity, fNewDir, null); } return files; } catch (final ConsoleAllocException e) { //Show exception and exists mNavigationViewHolder.post(new Runnable() { @Override public void run() { Log.e(TAG, mActivity.getString(R.string.msgs_cant_create_console), e); DialogHelper.showToast(mActivity, R.string.msgs_cant_create_console, Toast.LENGTH_LONG); mActivity.finish(); } }); return null; } catch (Exception ex) { //End of loading data if (NavigationFragment.this.mBreadcrumb != null) { try { NavigationFragment.this.mBreadcrumb.endLoading(); } catch (Throwable ex2) { /**NON BLOCK**/ } } //Capture exception (attach task, and use listener to do the anim) ExceptionUtil.attachAsyncTask(ex, new AsyncTask<Object, Integer, Boolean>() { private List<FileSystemObject> mTaskFiles = null; @Override @SuppressWarnings({ "unchecked", "unqualified-field-access" }) protected Boolean doInBackground(Object... taskParams) { mTaskFiles = (List<FileSystemObject>) taskParams[0]; return Boolean.TRUE; } @Override @SuppressWarnings("unqualified-field-access") protected void onPostExecute(Boolean result) { if (!result.booleanValue()) { return; } onPostExecuteTask(mTaskFiles, addToHistory, isNewHistory, hasChanged, searchInfo, fNewDir, scrollTo); } }); final ExceptionUtil.OnRelaunchCommandResult exListener = new ExceptionUtil.OnRelaunchCommandResult() { @Override public void onSuccess() { // Do animation fadeEfect(false); } @Override public void onFailed(Throwable cause) { // Do animation fadeEfect(false); } @Override public void onCancelled() { // Do animation fadeEfect(false); } }; ExceptionUtil.translateException(mActivity, ex, false, true, exListener); } return null; } /** * {@inheritDoc} */ @Override protected void onPreExecute() { // Do animation fadeEfect(true); } /** * {@inheritDoc} */ @Override protected void onPostExecute(List<FileSystemObject> files) { if (files != null) { onPostExecuteTask(files, addToHistory, isNewHistory, hasChanged, searchInfo, fNewDir, scrollTo); // Do animation fadeEfect(false); } } /** * Method that performs a fade animation. * * @param out Fade out (true); Fade in (false) */ void fadeEfect(final boolean out) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { Animation fadeAnim = out ? new AlphaAnimation(1, 0) : new AlphaAnimation(0, 1); fadeAnim.setDuration(50L); fadeAnim.setFillAfter(true); fadeAnim.setInterpolator(new AccelerateInterpolator()); mNavigationViewHolder.startAnimation(fadeAnim); } }); } }; task.execute(fNewDir); } }
From source file:com.irccloud.android.activity.MainActivity.java
private void update_suggestions(boolean force) { if (buffer != null && suggestionsContainer != null && messageTxt != null && messageTxt.getText() != null) { String text;// ww w . j ava2s .c o m try { text = messageTxt.getText().toString(); } catch (Exception e) { text = ""; } if (text.lastIndexOf(' ') > 0 && text.lastIndexOf(' ') < text.length() - 1) { text = text.substring(text.lastIndexOf(' ') + 1); } if (text.endsWith(":")) text = text.substring(0, text.length() - 1); text = text.toLowerCase(); final ArrayList<String> sugs = new ArrayList<String>(); HashSet<String> sugs_set = new HashSet<String>(); if (text.length() > 2 || force || (text.length() > 0 && suggestionsAdapter.activePos != -1)) { ArrayList<ChannelsDataSource.Channel> channels = sortedChannels; if (channels == null) { channels = ChannelsDataSource.getInstance().getChannels(); Collections.sort(channels, new Comparator<ChannelsDataSource.Channel>() { @Override public int compare(ChannelsDataSource.Channel lhs, ChannelsDataSource.Channel rhs) { return lhs.name.compareTo(rhs.name); } }); sortedChannels = channels; } if (buffer != null && messageTxt.getText().length() > 0 && buffer.type.equals("channel") && buffer.name.toLowerCase().startsWith(text) && !sugs_set.contains(buffer.name)) { sugs_set.add(buffer.name); sugs.add(buffer.name); } if (channels != null) { for (ChannelsDataSource.Channel channel : channels) { if (text.length() > 0 && text.charAt(0) == channel.name.charAt(0) && channel.name.toLowerCase().startsWith(text) && !sugs_set.contains(channel.name)) { sugs_set.add(channel.name); sugs.add(channel.name); } } } JSONObject disableAutoSuggest = null; if (NetworkConnection.getInstance().getUserInfo() != null && NetworkConnection.getInstance().getUserInfo().prefs != null) { try { if (NetworkConnection.getInstance().getUserInfo().prefs.has("channel-disableAutoSuggest")) disableAutoSuggest = NetworkConnection.getInstance().getUserInfo().prefs .getJSONObject("channel-disableAutoSuggest"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } boolean disabled; try { disabled = disableAutoSuggest != null && disableAutoSuggest.has(String.valueOf(buffer.bid)) && disableAutoSuggest.getBoolean(String.valueOf(buffer.bid)); } catch (JSONException e) { disabled = false; } ArrayList<UsersDataSource.User> users = sortedUsers; if (users == null && buffer != null && (force || !disabled)) { users = UsersDataSource.getInstance().getUsersForBuffer(buffer.bid); if (users != null) { Collections.sort(users, new Comparator<UsersDataSource.User>() { @Override public int compare(UsersDataSource.User lhs, UsersDataSource.User rhs) { if (lhs.last_mention > rhs.last_mention) return -1; if (lhs.last_mention < rhs.last_mention) return 1; return lhs.nick.compareToIgnoreCase(rhs.nick); } }); } sortedUsers = users; } if (users != null) { for (UsersDataSource.User user : users) { String nick = user.nick_lowercase; if (text.matches("^[a-zA-Z0-9]+.*")) nick = nick.replaceFirst("^[^a-zA-Z0-9]+", ""); if (nick.startsWith(text) && !sugs_set.contains(user.nick)) { sugs_set.add(user.nick); sugs.add(user.nick); } } } } if (Build.VERSION.SDK_INT >= 14 && text.startsWith(":") && text.length() > 1) { String q = text.toLowerCase().substring(1); for (String emocode : ColorFormatter.emojiMap.keySet()) { if (emocode.startsWith(q)) { String emoji = ColorFormatter.emojiMap.get(emocode); if (!sugs_set.contains(emoji)) { sugs_set.add(emoji); sugs.add(emoji); } } } } if (sugs.size() == 0 && suggestionsContainer.getVisibility() == View.INVISIBLE) return; runOnUiThread(new Runnable() { @Override public void run() { if (sugs.size() > 0) { if (suggestionsAdapter.activePos == -1) { suggestionsAdapter.clear(); for (String s : sugs) { suggestionsAdapter.add(s); } suggestionsAdapter.notifyDataSetChanged(); suggestions.smoothScrollToPosition(0); } if (suggestionsContainer.getVisibility() == View.INVISIBLE) { if (Build.VERSION.SDK_INT < 16) { AlphaAnimation anim = new AlphaAnimation(0, 1); anim.setDuration(250); anim.setFillAfter(true); suggestionsContainer.startAnimation(anim); } else { suggestionsContainer.setAlpha(0); suggestionsContainer.setTranslationY(1000); suggestionsContainer.animate().alpha(1).translationY(0) .setInterpolator(new DecelerateInterpolator()); } suggestionsContainer.setVisibility(View.VISIBLE); runOnUiThread(new Runnable() { @Override public void run() { if (suggestionsContainer.getHeight() < 48) { getSupportActionBar().hide(); } } }); } } else { if (suggestionsContainer.getVisibility() == View.VISIBLE) { if (Build.VERSION.SDK_INT < 16) { AlphaAnimation anim = new AlphaAnimation(1, 0); anim.setDuration(250); anim.setFillAfter(true); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { suggestionsContainer.setVisibility(View.INVISIBLE); suggestionsAdapter.clear(); suggestionsAdapter.notifyDataSetChanged(); } @Override public void onAnimationRepeat(Animation animation) { } }); suggestionsContainer.startAnimation(anim); } else { suggestionsContainer.animate().alpha(1).translationY(1000) .setInterpolator(new AccelerateInterpolator()) .withEndAction(new Runnable() { @Override public void run() { suggestionsContainer.setVisibility(View.INVISIBLE); suggestionsAdapter.clear(); suggestionsAdapter.notifyDataSetChanged(); } }); } sortedUsers = null; sortedChannels = null; if (!getSupportActionBar().isShowing()) getSupportActionBar().show(); } } } }); } }