List of usage examples for android.widget ImageView startAnimation
public void startAnimation(Animation animation)
From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { final MainActivity mainActivity = ((MainActivity) this.getActivity()); super.onViewCreated(view, savedInstanceState); if (this.isHidden()) return;/*from w ww .ja v a2s. c o m*/ DrawerAdapter drawerAdapter = ((DrawerAdapter) ((ListView) mainActivity.findViewById(R.id.drawer_list)) .getAdapter()); if (drawerAdapter.getSelectedItem() != 1) { drawerAdapter.setSelectedItem(1); drawerAdapter.notifyDataSetChanged(); } if (!megaListView.hasOnGroupClickListener()) megaListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator); RotateAnimation anim; if (megaListView.isGroupExpanded(groupPosition)) { megaListView.collapseGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(180f, 360f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(3)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } else { megaListView.expandGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(0f, 180f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(2)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } return true; } }); if (!megaListView.hasOnChildClickListener()) megaListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mSwiping) { mSwiping = false; return false; } final MainActivity mainActivity = (MainActivity) getActivity(); megaListView.setOnChildClickListener(null); // prevents bug on double tap mainActivity.updateLyricsFragment(R.animator.slide_out_start, R.animator.slide_in_start, true, ((LocalAdapter) megaListView.getExpandableListAdapter()).getChild(groupPosition, childPosition)); return true; } }); this.isActiveFragment = true; new DBContentLister(this).execute(); }
From source file:com.github.jthuraisamy.yellowusage.ui.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem refreshItem = menu.findItem(R.id.action_refresh); Log.d(TAG, "isMobileDataEnabled = " + isMobileDataEnabled(connectivityManager)); Log.d(TAG, "isMobileDataConnected = " + isMobileDataConnected(telephonyManager)); Log.d(TAG, "isWifiConnected = " + isWifiConnected(wifiManager)); // Stop refresh icon animation if it's already ongoing. if (refreshItemActionView != null) refreshItemActionView.clearAnimation(); refreshItem.setActionView(null);/*from w ww . ja v a2s .c om*/ boolean waitingForData = (!taskQueue.isEmpty()) && (!isMobileDataConnected(telephonyManager)); // (Re-)Start preparing refresh icon animation while waiting for mobile data connection. if (waitingForData) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") ImageView animatingRefreshIcon = (ImageView) layoutInflater.inflate(R.layout.icon_refresh, null); Animation clockwiseRotation = AnimationUtils.loadAnimation(this, R.anim.counterclockwise_refresh); animatingRefreshIcon.startAnimation(clockwiseRotation); refreshItem.setActionView(animatingRefreshIcon); // getActionView() always returns null in the else block, so it's assigned to a member variable. refreshItemActionView = refreshItem.getActionView(); } // (Re-)Start refresh icon animation only if there are ongoing tasks. if (ongoingTasks > 0) { LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") ImageView animatingRefreshIcon = (ImageView) layoutInflater.inflate(R.layout.icon_refresh, null); Animation clockwiseRotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_refresh); animatingRefreshIcon.startAnimation(clockwiseRotation); refreshItem.setActionView(animatingRefreshIcon); // getActionView() always returns null in the else block, so it's assigned to a member variable. refreshItemActionView = refreshItem.getActionView(); } return super.onPrepareOptionsMenu(menu); }
From source file:Steps.StepsFragment.java
/** * Determine if the sticker is new in order to set the top pulsing * "NEW" indicatior// w w w . j a v a 2 s. co m * @param imageCategory * @param sticker */ private void determineCategoty(ImageView imageCategory, Sticker sticker) { //new Sticker if (sticker.getCount() == 0) { Resources resources = getActivity().getResources(); int resourceId = resources.getIdentifier("neww", "drawable", getActivity().getPackageName()); imageCategory.setImageBitmap( SampleImage.decodeSampledBitmapFromResource(getResources(), resourceId, 250, 250)); //run the animation Animation pulse = AnimationUtils.loadAnimation(getActivity(), R.anim.pulse); pulse.setRepeatCount(Animation.INFINITE); imageCategory.startAnimation(pulse); } }
From source file:com.blueverdi.rosietheriveter.PhotoViewActivity.java
private void slide(final ImageView v, final Bitmap new_image, final int in, final int out, final TextView view, final String string) { final Animation anim_out = AnimationUtils.loadAnimation(this, out); final Animation anim_in = AnimationUtils.loadAnimation(this, in); anim_out.setAnimationListener(new AnimationListener() { @Override// www. j av a2 s. co m public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { v.setImageBitmap(new_image); anim_in.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.setText(string); } }); v.startAnimation(anim_in); } }); v.startAnimation(anim_out); }
From source file:com.pixelpixel.pyp.SplashActivity.java
/** Called when the activity is first created. */ @Override//from w w w .j a v a 2s.com public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); //Initializing the application cache final int memClass = ((ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); final int cacheSize = 1024 * 1024 * memClass / 4; mMemoryCache = new LruCache<String, Object>(cacheSize); /* * Setting up the animation for the logo * */ final ImageView splash_logo = (ImageView) findViewById(R.id.SplashLogo); Animation sa1 = AnimationUtils.loadAnimation(this, R.anim.splash_anim); sa1.setAnimationListener(new AnimationListener() { public void onAnimationEnd(Animation arg0) { /* * After the end of the "growing" animation, we call the "shrinking" animation. * */ Animation sa2 = AnimationUtils.loadAnimation(SplashActivity.this, R.anim.splash_anim2); sa2.setAnimationListener(new AnimationListener() { public void onAnimationEnd(Animation animation) { /* * After the end of the "shrinking" animation, we proceed to the * next screen, the start screen. * */ Handler mHandler = new Handler(); mHandler.postDelayed(new Runnable() { public void run() { startActivity(new Intent(SplashActivity.this, StartActivity.class)); SplashActivity.this.finish(); } }, 5000); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); splash_logo.startAnimation(sa2); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } }); splash_logo.startAnimation(sa1); }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Drop money from the top of the layout to the bottom simulating that a * coin or bill is inserted in the moneybox. * /*from ww w .ja v a2 s. c o m*/ * @param leftMargin * Left side of the coin/bill * @param width * Width of the image to slide down * @param m * Movement with the value of the money to drop */ protected void dropMoney(int leftMargin, int width, Movement m) { ImageView money; AnimationSet moneyDrop; RelativeLayout layout; RelativeLayout.LayoutParams lpParams; Rect r; Activity parent; CurrencyValueDef curr; parent = getActivity(); curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount())); r = curr.getDrawable().getBounds(); money = new ImageView(parent); money.setVisibility(View.INVISIBLE); money.setImageDrawable(curr.getDrawable().getConstantState().newDrawable()); money.setTag(curr); money.setId((int) m.getIdMovement()); layout = findLayout(); lpParams = new RelativeLayout.LayoutParams(r.width(), r.height()); lpParams.leftMargin = leftMargin; lpParams.rightMargin = layout.getWidth() - (leftMargin + width); lpParams.topMargin = 0; lpParams.bottomMargin = r.height(); layout.addView(money, lpParams); moneyDrop = createDropAnimation(money, layout, curr); money.setVisibility(View.VISIBLE); SoundsManager.playMoneySound(curr.getType()); VibratorManager.vibrateMoneyDrop(curr.getType()); money.startAnimation(moneyDrop); }
From source file:app.sunstreak.yourpisd.LoginActivity.java
/** * Shows the progress UI and hides the login form. *///from ww w .j a v a 2s.com @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void showProgress(final boolean show) { // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow // for very easy animations. If available, use these APIs to fade-in // the progress spinner. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); mLoginFormView.setVisibility(View.VISIBLE); mLoginFormView.animate().setDuration(shortAnimTime) //.translationY(-200) .alpha(show ? 0 : 1).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); } }); mLoginStatusView.setVisibility(View.VISIBLE); mLoginStatusView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); } }); // mLoginFormView.setVisibility(View.VISIBLE); // mLoginFormView.animate().setDuration(500).setInterpolator(new DecelerateInterpolator()) // .translationY(height*(show? -1 : 1)).setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginFormView.setVisibility(show ? View.INVISIBLE // : View.VISIBLE); // } // }); // mLoginStatusView.setVisibility(View.VISIBLE); // mLoginStatusView.animate().setDuration(shortAnimTime).translationY(0) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginStatusView.setVisibility(show ? View.VISIBLE // : View.INVISIBLE); // System.out.println("show loading: " + show); // } // }); if (DateHelper.isAprilFools()) { mLoginStatusView.removeAllViews(); try { ImageView img = new ImageView(this); //noinspection ResourceType img.setId(1337); InputStream is = getAssets().open("nyan.png"); img.setImageBitmap(BitmapFactory.decodeStream(is)); is.close(); TextView april = new TextView(this); april.setText( "Today and tomorrow, we shall pay \"homage\" to the numerous poor designs of the internet"); april.setGravity(Gravity.CENTER_HORIZONTAL); mLoginStatusView.addView(img); mLoginStatusView.addView(april); RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation1.setInterpolator(new LinearInterpolator()); rotateAnimation1.setDuration(500); rotateAnimation1.setRepeatCount(Animation.INFINITE); img.startAnimation(rotateAnimation1); } catch (Exception e) { e.printStackTrace(); return; } } // mLoginStatusView.animate().setDuration(shortAnimTime) // .alpha(show ? 1 : 0) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginStatusView.setVisibility(show ? View.VISIBLE // : View.GONE); // } // }); // mLoginFormView.setVisibility(View.VISIBLE); // mLoginFormView.animate().setDuration(shortAnimTime) // .alpha(show ? 0 : 1) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginFormView.setVisibility(show ? View.GONE // : View.VISIBLE); // } // }); } /* else if(getIntent().getExtras().getBoolean("Refresh")){ // The ViewPropertyAnimator APIs are not available, so simply show // and hide the relevant UI components. mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); }*/ }
From source file:com.brandao.tictactoe.board.BoardFragment.java
public void animateOut(final ImageView image, final int index) { Animation zoomOutOut = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_out); zoomOutOut.setInterpolator(// ww w .j a v a2s. co m AnimationUtils.loadInterpolator(getActivity(), android.R.anim.anticipate_interpolator)); zoomOutOut.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mAnimating = false; image.setBackgroundResource(R.drawable.transparent_image); if (index == 8) { initFirstTurn(); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mAnimating = true; } }); image.startAnimation(zoomOutOut); }
From source file:com.money.manager.ex.home.MainActivity.java
private void startSyncIconRotation(MenuItem item) { if (item == null) return;/*from www. ja v a 2 s . c o m*/ // define the animation for rotation Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(1200); // animRotate = AnimationUtils.loadAnimation(this, R.anim.rotation); animation.setRepeatCount(Animation.INFINITE); ImageView imageView = new ImageView(this); UIHelper uiHelper = new UIHelper(this); imageView.setImageDrawable( uiHelper.getIcon(GoogleMaterial.Icon.gmd_cached).color(uiHelper.getToolbarItemColor())); imageView.setPadding(8, 8, 8, 8); // imageView.setLayoutParams(new Toolbar.LayoutParams()); imageView.startAnimation(animation); item.setActionView(imageView); }
From source file:com.brandao.tictactoe.board.BoardFragment.java
public void panelInAnimate(ImageView i, final int symble) { boolean animate = mPrefs.getBoolean(Settings.PREF_ANIMATE, Settings.PREF_ANIMATE_DEFAULT); if (!animate) { finishMove(symble);/*from w w w . j a v a2 s . co m*/ return; } Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_in); anim.setInterpolator(AnimationUtils.loadInterpolator(getActivity(), android.R.anim.overshoot_interpolator)); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mAnimating = false; finishMove(symble); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mAnimating = true; } }); i.startAnimation(anim); }