List of usage examples for android.view.animation Animation setDuration
public void setDuration(long durationMillis)
From source file:com.example.xyzreader.util.ScrollAwareFABBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; }/*www.j a v a 2 s . co m*/ public void onAnimationCancel(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:com.simon.dribbble.widget.navigationbar.behavior.BehaviorScrollZoomFab.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { BehaviorScrollZoomFab.this.mIsAnimatingOut = true; }//w w w .j a va 2 s . c om public void onAnimationCancel(View view) { BehaviorScrollZoomFab.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { BehaviorScrollZoomFab.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { BehaviorScrollZoomFab.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { BehaviorScrollZoomFab.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:com.koushikdutta.superuser.FragmentIntro.java
@Nullable @Override//from ww w.j a v a 2s .co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View parent = inflater.inflate(layoutResId, container, false); if (layoutResId != R.layout.fragment_intro_0) return parent; final ImageView superuser = (ImageView) parent.findViewById(R.id.superuser); final ImageView background = (ImageView) parent.findViewById(R.id.superuser_back); final TextView title = (TextView) parent.findViewById(R.id.title); final TextView desc = (TextView) parent.findViewById(R.id.tour); final Animation fadeIn, zoomIn; fadeIn = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in); zoomIn = AnimationUtils.loadAnimation(getContext(), R.anim.zoom_in); fadeIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { background.startAnimation(zoomIn); background.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); zoomIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { Animation fadeIn2 = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in); fadeIn2.setDuration(1000); fadeIn2.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { Animation fadeIn3 = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in); fadeIn3.setDuration(400); fadeIn3.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { ((ActivityIntro) getActivity()).setProgressButtonEnabled(true); } @Override public void onAnimationRepeat(Animation animation) { } }); desc.startAnimation(fadeIn3); desc.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); title.startAnimation(fadeIn2); title.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); new Handler().postDelayed(new Runnable() { @Override public void run() { superuser.startAnimation(fadeIn); superuser.setVisibility(View.VISIBLE); } }, 600); return parent; }
From source file:com.geecko.QuickLyric.utils.ScreenSlidePagerAdapter.java
public void exitAction() { Animation slideOut = new TranslateAnimation(0f, -2000f, 0f, 0f); slideOut.setInterpolator(new AccelerateInterpolator()); slideOut.setDuration(700); slideOut.setAnimationListener(new Animation.AnimationListener() { public void onAnimationEnd(Animation animation) { ((RelativeLayout) mPager.getParent()).setVisibility(View.GONE); ((MainActivity) mActivity).focusOnFragment = true; if (((MainActivity) mActivity).mDrawerToggle != null) { ((MainActivity) mActivity).getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((MainActivity) mActivity).mDrawerToggle.setDrawerIndicatorEnabled(true); }//from w w w . java 2 s . c o m mActivity.invalidateOptionsMenu(); SharedPreferences.Editor editor = mActivity.getSharedPreferences("tutorial", Context.MODE_PRIVATE) .edit(); editor.putBoolean("seen", true); editor.apply(); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); ((MainActivity) mActivity).setStatusBarColor(null); ((MainActivity) mActivity).setNavBarColor(null); ((RelativeLayout) mPager.getParent()).startAnimation(slideOut); }
From source file:eu.power_switch.gui.animation.ScrollAwareFABBehavior.java
/** * Same animation that FloatingActionButton.Behavior uses to * hide the FAB when the AppBarLayout exits * * @param floatingActionButton FAB/* w ww.j a v a2 s . c om*/ */ private void animateOut(final FloatingActionButton floatingActionButton) { if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) { return; } if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(floatingActionButton).scaleX(0.0F).scaleY(0.0F).alpha(0.0F) .setInterpolator(INTERPOLATOR).withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationCancel(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(), android.R.anim.fade_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; floatingActionButton.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); floatingActionButton.startAnimation(anim); } }
From source file:com.tr4android.support.extension.widget.LabelView.java
private void showEclairMr1() { clearAnimation();/*from w ww . ja v a 2s.c om*/ setVisibility(VISIBLE); Animation anim = createAnimationSet(0.0f, 1.0f, Math.round(mAnimationOffset), 0); anim.setDuration(SHOW_HIDE_ANIM_DURATION); anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR); startAnimation(anim); }
From source file:com.artur.softwareproject.BluetoothConnectionListAdapter.java
@Override @NonNull/*from w w w . j a v a2s .c om*/ public View getView(final int position, View convertView, @NonNull ViewGroup parent) { ViewHolder mViewHolder; if (convertView == null) { mViewHolder = new ViewHolder(); LayoutInflater ListInflater = LayoutInflater.from(getContext()); convertView = ListInflater.inflate(R.layout.bluetooth_list_pattern, parent, false); mViewHolder.bluetoothConnectionName = (TextView) convertView .findViewById(R.id.bluetooth_connection_name); mViewHolder.bluetoothConnectionStatus = (TextView) convertView .findViewById(R.id.bluetooth_connection_status); convertView.setTag(mViewHolder); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //What happens if you press on the list items at the bluetooth activity. Animation animation = new AlphaAnimation(0.3f, 1.0f); animation.setDuration(1000); v.startAnimation(animation); intent = new Intent(contextActivity, BluetoothService.class); intent.putExtra("device", bDevices.get(position)); intent.putExtra("deviceList", bDevices); contextActivity.startService(intent); final ProgressDialog connectingDialog = new ProgressDialog(contextActivity); connectDialog = connectingDialog; connectingDialog.setMessage("Connecting..."); connectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); connectingDialog.setCancelable(false); connectingDialog.show(); final ConnectionHandlerClass connectHandler = new ConnectionHandlerClass(bclaReference); connectThread = new Thread(new Runnable() { @Override public void run() { int stop = 0; int counter = 0; //Timeout after 10 seconds. while (stop == 0 && counter < 5) { stop = getConnected(); counter++; sleep(2000); } //Timeout occurred after 10s of waiting and stop is still 0. if (stop == 0 && counter == 4) { timeout = true; } connectHandler.sendEmptyMessage(0); } }); connectThread.start(); } }); } else { mViewHolder = (ViewHolder) convertView.getTag(); } mViewHolder.bluetoothConnectionName.setText(bluetoothAddress.get(position)); mViewHolder.bluetoothConnectionStatus.setText(bluetoothName.get(position)); return convertView; }
From source file:org.cm.podd.report.activity.ReportTypeActivity.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, final int position, long id) { Animation animation = new AlphaAnimation(0.3f, 1f); animation.setDuration(600); view.startAnimation(animation);/* w ww . j a v a 2 s .co m*/ ReportType item = adapter.getItem(position); if (item.getId() == -99) { if (RequestDataUtil.hasNetworkConnection(this)) { listView.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.VISIBLE); startSyncReportType(); // send event hit Tracker tracker = ((PoddApplication) getApplication()) .getTracker(PoddApplication.TrackerName.APP_TRACKER); tracker.send( new HitBuilders.EventBuilder().setCategory("ReportType").setAction("syncReport").build()); } } else { if (item.getId() == 0) { long reportId = reportDataSource.createPositiveReport(); // after save positive report, submit to queue right away reportQueueDataSource.addDataQueue(reportId); broadcastReportSubmission(); finish(); } else { Log.d(TAG, String.format("select report type = %d", item.getId(), testCheckbox.isChecked())); Intent intent = new Intent(this, ReportActivity.class); intent.putExtra("reportType", item.getId()); intent.putExtra("test", testCheckbox.isChecked()); startActivity(intent); } // send event hit Tracker tracker = ((PoddApplication) getApplication()) .getTracker(PoddApplication.TrackerName.APP_TRACKER); tracker.send( new HitBuilders.EventBuilder().setCategory("ReportType").setAction(item.getName()).build()); } }
From source file:com.flan.stock.view.TouTiaoPagerView.java
/** * ? ?/*ww w. j av a2s. c o m*/ * @param position */ private void setCurrentTab(int position) { Animation animation = null; animation = new TranslateAnimation(tabImgWidth * currentTab, tabImgWidth * position, 0, 0); animation.setFillAfter(true);//True:??? animation.setDuration(300); //? img_tab.startAnimation(animation); currentTab = position; }
From source file:com.codefororlando.transport.MapsActivity.java
private void removeSelectableItemFragment() { final Fragment selectableItemFragment = getFragmentManager().findFragmentByTag(ISelectableItemFragment.TAG); if (selectableItemFragment != null) { final View view = selectableItemFragment.getView(); if (view == null) { return; }/*w ww .j a va 2s. c o m*/ final int animationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); { final Animation animation = new TranslateAnimation(0, 0, 0, view.getHeight()); animation.setDuration(animationDuration); animation.setInterpolator(new AccelerateDecelerateInterpolator()); filterView.startAnimation(animation); } { final FragmentManager fragmentManager = getFragmentManager(); final Animation animation = new TranslateAnimation(0, 0, 0, view.getHeight()); animation.setDuration(animationDuration); animation.setAnimationListener(new EmptyAnimationListener() { @Override public void onAnimationEnd(Animation animation) { try { fragmentManager.beginTransaction().remove(selectableItemFragment) .commitAllowingStateLoss(); } catch (Exception e) { e.printStackTrace(); } } }); view.startAnimation(animation); } } }