List of usage examples for android.view.animation TranslateAnimation setDuration
public void setDuration(long durationMillis)
From source file:org.mozilla.gecko.home.BrowserSearch.java
private void setSuggestionsEnabled(final boolean enabled) { // Clicking the yes/no buttons quickly can cause the click events be // queued before the listeners are removed above, so it's possible // setSuggestionsEnabled() can be called twice. mSuggestionsOptInPrompt // can be null if this happens (bug 828480). if (mSuggestionsOptInPrompt == null) { return;/* ww w. j a va2s . co m*/ } // Make suggestions appear immediately after the user opts in ThreadUtils.postToBackgroundThread(new Runnable() { @Override public void run() { SuggestClient client = mSuggestClient; if (client != null) { client.query(mSearchTerm); } } }); // Pref observer in gecko will also set prompted = true PrefsHelper.setPref("browser.search.suggest.enabled", enabled); TranslateAnimation slideAnimation = new TranslateAnimation(0, mSuggestionsOptInPrompt.getWidth(), 0, 0); slideAnimation.setDuration(ANIMATION_DURATION); slideAnimation.setInterpolator(new AccelerateInterpolator()); slideAnimation.setFillAfter(true); final View prompt = mSuggestionsOptInPrompt.findViewById(R.id.prompt); TranslateAnimation shrinkAnimation = new TranslateAnimation(0, 0, 0, -1 * mSuggestionsOptInPrompt.getHeight()); shrinkAnimation.setDuration(ANIMATION_DURATION); shrinkAnimation.setFillAfter(true); shrinkAnimation.setStartOffset(slideAnimation.getDuration()); shrinkAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation a) { // Increase the height of the view so a gap isn't shown during animation mView.getLayoutParams().height = mView.getHeight() + mSuggestionsOptInPrompt.getHeight(); mView.requestLayout(); } @Override public void onAnimationRepeat(Animation a) { } @Override public void onAnimationEnd(Animation a) { // Removing the view immediately results in a NPE in // dispatchDraw(), possibly because this callback executes // before drawing is finished. Posting this as a Runnable fixes // the issue. mView.post(new Runnable() { @Override public void run() { mView.removeView(mSuggestionsOptInPrompt); mList.clearAnimation(); mSuggestionsOptInPrompt = null; if (enabled) { // Reset the view height mView.getLayoutParams().height = LayoutParams.MATCH_PARENT; mSuggestionsEnabled = enabled; mAnimateSuggestions = true; mAdapter.notifyDataSetChanged(); filterSuggestions(); } } }); } }); prompt.startAnimation(slideAnimation); mSuggestionsOptInPrompt.startAnimation(shrinkAnimation); mList.startAnimation(shrinkAnimation); }
From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java
private void highlightCurDot(int oldIndex, int newIndex) { Log.i("jim", "oldIndex = " + oldIndex + ">>>>newIndex = " + newIndex); if (mTopTextView == null || mTopFocusLine == null || newIndex < 0 || newIndex > mPageCount - 1 || oldIndex == newIndex) {/* w w w . j av a 2 s .c o m*/ return; } mTopTextView[oldIndex].setTextColor(this.getResources().getColor(R.color.grey)); mTopTextView[newIndex].setTextColor(this.getResources().getColor(R.color.blue)); int moveDistance = mTopTextView[newIndex].getLeft() - mTopTextView[oldIndex].getLeft(); TranslateAnimation animation = new TranslateAnimation(startLeft, startLeft + moveDistance, 0, 0); startLeft += moveDistance; animation.setDuration(300); animation.setFillAfter(true); mTopFocusLine.startAnimation(animation); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java
private void searchFood(final String item, final int page_num) { if (!NetworkConnectionStatus.isNetworkAvailable(getActivity())) { Toast.makeText(getActivity(), "Check your connection and try again", Toast.LENGTH_LONG).show(); } else {/*from w w w . j a v a 2 s .c o m*/ mAsyncTask = new AsyncTask<String, String, String>() { @Override protected void onPreExecute() { } @Override protected String doInBackground(String... arg0) { JSONObject food = mFatSecretSearch.searchFood(item, page_num); JSONArray FOODS_ARRAY; try { if (food != null) { FOODS_ARRAY = food.getJSONArray("food"); if (FOODS_ARRAY != null) { for (int i = 0; i < FOODS_ARRAY.length(); i++) { JSONObject food_items = FOODS_ARRAY.optJSONObject(i); String food_name = food_items.getString("food_name"); String food_description = food_items.getString("food_description"); String[] row = food_description.split("-"); String id = food_items.getString("food_type"); if (id.equals("Brand")) { brand = food_items.getString("brand_name"); } if (id.equals("Generic")) { brand = "Generic"; } String food_id = food_items.getString("food_id"); mItem.add(new SearchItemResult(food_name, row[1].substring(1), "" + brand, food_id)); } } } } catch (JSONException exception) { exception.printStackTrace(); return "Error"; } return ""; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); searchAdapter.notifyDataSetChanged(); if (listContainer.getCount() > 0) { searchBack.setVisibility(View.VISIBLE); TranslateAnimation slide = new TranslateAnimation(0, 0, listContainer.getHeight(), 0); slide.setStartTime(1000); listContainer.setVisibility(View.VISIBLE); slide.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); slide.setDuration(400); listContainer.startAnimation(slide); } else { searchBack.setVisibility(View.GONE); listContainer.setVisibility(View.GONE); } } @Override protected void onCancelled() { } }; mAsyncTask.execute(); } }
From source file:org.zywx.wbpalmstar.engine.EBrowserWidget.java
public void goMySpace(View view) { addView(view);//from w w w. jav a2s. co m TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(250); DecelerateInterpolator di = new DecelerateInterpolator(); anim.setInterpolator(di); view.startAnimation(anim); mBroWindow.setVisibility(GONE); }
From source file:org.zywx.wbpalmstar.engine.EBrowserWidget.java
public boolean exitMySpace(View view) { if (view.getParent() == this) { mBroWindow.setVisibility(VISIBLE); TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f); anim.setDuration(300); DecelerateInterpolator di = new DecelerateInterpolator(); anim.setInterpolator(di);/*from w ww .j a v a2 s. co m*/ view.startAnimation(anim); removeView(view); return true; } return false; }
From source file:com.example.testtab.fragment.TwitEyesPageFragment.java
public void showProgressBar(int percent) { TextView textLayer = (TextView) this.mRootView.findViewById(R.id.progress_bar); AnimationSet set = new AnimationSet(true); // ALPHA/*from w w w .jav a2 s . co m*/ AlphaAnimation alpha; switch (percent) { case 100: alpha = new AlphaAnimation(1.0f, 0.0f); break; case 0: alpha = new AlphaAnimation(0.0f, 1.0f); break; default: alpha = new AlphaAnimation(0.8f, 1.0f); } alpha.setDuration(500); TranslateAnimation translate; float toX = ((float) percent - 100.0f) / 100.0f; float fromX = toX - 0.1f; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); translate.setDuration(500); translate.setInterpolator(new BounceInterpolator()); set.addAnimation(alpha); set.addAnimation(translate); // set.setDuration(500); set.setFillBefore(true); set.setFillAfter(true); textLayer.startAnimation(set); }
From source file:com.smp.musicspeed.MainActivity.java
private void animateLinkOn() { TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f);// www . ja va2 s . c om anim.setDuration(TRANS_ANIMATION_TIME); anim.setInterpolator(new AnticipateOvershootInterpolator()); anim.setAnimationListener(new AnimationListenerAdaptor() { @Override public void onAnimationEnd(Animation animation) { rateText.setAlpha(0f); linkOn(); rateText.animate().alpha(1f).setDuration(TRANS_ANIMATION_TIME) .setListener(new AnimatorListenerAdapter() { }); } }); tempoCard.startAnimation(anim); tempoText.animate().alpha(0f).setDuration(TEXT_ANIMATION_TIME).setListener(new AnimatorListenerAdapter() { }); }
From source file:com.smp.musicspeed.MainActivity.java
private void animateLinkOff() { linkOff();//w w w .jav a 2s . c o m tempoCard.setVisibility(View.INVISIBLE); TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f); anim.setDuration(TRANS_ANIMATION_TIME); anim.setInterpolator(new AnticipateOvershootInterpolator()); anim.setAnimationListener(new AnimationListenerAdaptor() { @Override public void onAnimationEnd(Animation animation) { tempoText.setAlpha(0f); linkOff(); tempoText.animate().alpha(1f).setDuration(TEXT_ANIMATION_TIME) .setListener(new AnimatorListenerAdapter() { }); } }); rateCard.startAnimation(anim); rateText.animate().alpha(0f).setDuration(TRANS_ANIMATION_TIME).setListener(new AnimatorListenerAdapter() { }); }
From source file:com.juick.android.ThreadFragment.java
private void resetMainMenuButton(boolean animate) { if (navMenu != null) { TranslateAnimation immediate = new TranslateAnimation(Animation.ABSOLUTE, animate ? initNavMenuTranslationX + 100 : initNavMenuTranslationX, Animation.ABSOLUTE, initNavMenuTranslationX, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); immediate.setDuration(500); immediate.setFillEnabled(true);/* w w w .ja v a2 s . co m*/ immediate.setFillBefore(true); immediate.setFillAfter(true); navMenu.startAnimation(immediate); } //navMenu.startAnimation(immediate); }
From source file:com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.java
private void translateHeader(float of) { float ofCalculated = of * SCROLL_MULTIPLIER; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //Logs.d("ofCalculated " + ofCalculated+" "+mHeader.getHeight()); mHeader.setTranslationY(ofCalculated); } else {//from w w w.j a va 2 s.c o m TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated); anim.setFillAfter(true); anim.setDuration(0); mHeader.startAnimation(anim); } mHeader.setClipY(Math.round(ofCalculated)); if (mParallaxScroll != null) { float left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * SCROLL_MULTIPLIER))); mParallaxScroll.onParallaxScroll(left, of, mHeader); } }