Example usage for android.view.animation RotateAnimation setRepeatCount

List of usage examples for android.view.animation RotateAnimation setRepeatCount

Introduction

In this page you can find the example usage for android.view.animation RotateAnimation setRepeatCount.

Prototype

public void setRepeatCount(int repeatCount) 

Source Link

Document

Sets how many times the animation should be repeated.

Usage

From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java

private ImageView getRotationImage() {
    RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(1000L);// ww  w  . j  a va  2s .  c om
    rotateAnimation.setRepeatMode(Animation.INFINITE);
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    rotateAnimation.setFillEnabled(false);
    rotateAnimation.setInterpolator(new LinearInterpolator());

    Drawable drawable = MBResourceService.getInstance().getImageByID(_refreshToolDef.getIcon());
    ImageView rotationImage = new ImageView(_context);
    rotationImage.setImageDrawable(drawable);
    rotationImage.setAnimation(rotateAnimation);

    return rotationImage;
}

From source file:com.nextgis.mobile.fragment.LayersFragment.java

public void refresh(boolean start) {
    if (mSyncButton == null) {
        return;//from www  .  j  ava2 s . c  o m
    }
    if (start) {
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setFillAfter(true);
        rotateAnimation.setDuration(700);
        rotateAnimation.setRepeatCount(500);

        mSyncButton.startAnimation(rotateAnimation);
    } else {
        mSyncButton.clearAnimation();
    }
}

From source file:com.rks.musicx.misc.utils.Helper.java

/**
 * Rotate ImageView// www.ja  v a  2 s.c  o m
 *
 * @param view
 */
public static void rotationAnim(@NonNull View view) {
    RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation1.setInterpolator(new LinearInterpolator());
    rotateAnimation1.setDuration(300);
    rotateAnimation1.setRepeatCount(0);
    view.startAnimation(rotateAnimation1);
}

From source file:app.sunstreak.yourpisd.LoginActivity.java

/**
 * Shows the progress UI and hides the login form.
 *//*  w  w w .ja  va  2  s.co  m*/
@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:fr.shywim.antoinedaniel.ui.fragment.VideoDetailsFragment.java

private void bindSound(View view, Cursor cursor) {
    AppState appState = AppState.getInstance();

    final View card = view;
    final View downloadFrame = view.findViewById(R.id.sound_download_frame);
    final TextView tv = (TextView) view.findViewById(R.id.grid_text);
    final SquareImageView siv = (SquareImageView) view.findViewById(R.id.grid_image);
    final ImageView star = (ImageView) view.findViewById(R.id.ic_sound_fav);
    final ImageView menu = (ImageView) view.findViewById(R.id.ic_sound_menu);

    final String soundName = cursor
            .getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_SOUND_NAME));
    String imgId = cursor.getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_IMAGE_NAME));
    final String description = cursor.getString(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_DESC));
    final boolean favorite = appState.favSounds.contains(soundName)
            || cursor.getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_FAVORITE)) == 1;
    final boolean widget = appState.widgetSounds.contains(soundName)
            || cursor.getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_WIDGET)) == 1;
    final boolean downloaded = cursor
            .getInt(cursor.getColumnIndex(ProviderContract.SoundEntry.COLUMN_DOWNLOADED)) != 0;

    new Handler().post(new Runnable() {
        @Override/*from  ww w  .j  a v a  2  s.c o  m*/
        public void run() {
            ContentValues cv = new ContentValues();
            File sndFile = new File(mContext.getExternalFilesDir(null) + "/snd/" + soundName + ".ogg");

            if (downloaded && !sndFile.exists()) {
                cv.put(ProviderContract.SoundEntry.COLUMN_DOWNLOADED, 0);
                mContext.getContentResolver().update(
                        Uri.withAppendedPath(ProviderConstants.SOUND_DOWNLOAD_NOTIFY_URI, soundName), cv, null,
                        null);
            }
        }
    });

    final View.OnClickListener playSound = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String category = mContext.getString(R.string.ana_cat_sound);
            String action = mContext.getString(R.string.ana_act_play);

            Bundle extras = new Bundle();
            extras.putString(SoundFragment.SOUND_TO_PLAY, soundName);
            extras.putBoolean(SoundFragment.LOOP, SoundUtils.isLoopingSet());
            Intent intent = new Intent(mContext, SoundService.class);
            intent.putExtras(extras);

            mContext.startService(intent);
            AnalyticsUtils.sendEvent(category, action, soundName);
        }
    };

    final View.OnClickListener downloadSound = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            card.setOnClickListener(null);
            RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            animation.setInterpolator(new BounceInterpolator());
            animation.setFillAfter(true);
            animation.setFillEnabled(true);
            animation.setDuration(1000);
            animation.setRepeatCount(Animation.INFINITE);
            animation.setRepeatMode(Animation.RESTART);
            downloadFrame.findViewById(R.id.sound_download_icon).startAnimation(animation);

            DownloadService.startActionDownloadSound(mContext, soundName,
                    new SoundUtils.DownloadResultReceiver(new Handler(), downloadFrame, playSound, this));
        }
    };

    if (downloaded) {
        downloadFrame.setVisibility(View.GONE);
        downloadFrame.findViewById(R.id.sound_download_icon).clearAnimation();
        card.setOnClickListener(playSound);
    } else {
        downloadFrame.setAlpha(1);
        downloadFrame.findViewById(R.id.sound_download_icon).setScaleX(1);
        downloadFrame.findViewById(R.id.sound_download_icon).setScaleY(1);
        downloadFrame.setVisibility(View.VISIBLE);
        card.setOnClickListener(downloadSound);
    }

    menu.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final ImageView menuIc = (ImageView) v;
            PopupMenu popup = new PopupMenu(mContext, menuIc);
            Menu menu = popup.getMenu();
            popup.getMenuInflater().inflate(R.menu.sound_menu, menu);

            if (favorite)
                menu.findItem(R.id.action_sound_fav).setTitle("Retirer des favoris");
            if (widget)
                menu.findItem(R.id.action_sound_wid).setTitle("Retirer du widget");

            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch (item.getItemId()) {
                    case R.id.action_sound_fav:
                        SoundUtils.addRemoveFavorite(mContext, soundName);
                        return true;
                    case R.id.action_sound_wid:
                        SoundUtils.addRemoveWidget(mContext, soundName);
                        return true;
                    /*case R.id.action_sound_add:
                       return true;*/
                    case R.id.action_sound_ring:
                        SoundUtils.addRingtone(mContext, soundName, description);
                        return true;
                    case R.id.action_sound_share:
                        AnalyticsUtils.sendEvent(mContext.getString(R.string.ana_cat_soundcontext),
                                mContext.getString(R.string.ana_act_weblink), soundName);
                        ClipboardManager clipboard = (ClipboardManager) mContext
                                .getSystemService(Context.CLIPBOARD_SERVICE);
                        ClipData clip = ClipData.newPlainText("BAD link", "http://bad.shywim.fr/" + soundName);
                        clipboard.setPrimaryClip(clip);
                        Toast.makeText(mContext, R.string.toast_link_copied, Toast.LENGTH_LONG).show();
                        return true;
                    case R.id.action_sound_delete:
                        SoundUtils.delete(mContext, soundName);
                        return true;
                    default:
                        return false;
                    }
                }
            });

            popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
                @Override
                public void onDismiss(PopupMenu menu) {
                    menuIc.setColorFilter(mContext.getResources().getColor(R.color.text_caption_dark));
                }
            });
            menuIc.setColorFilter(mContext.getResources().getColor(R.color.black));

            popup.show();
        }
    });

    tv.setText(description);
    siv.setTag(imgId);

    if (appState.favSounds.contains(soundName)) {
        star.setVisibility(View.VISIBLE);
    } else if (favorite) {
        star.setVisibility(View.VISIBLE);
        appState.favSounds.add(soundName);
    } else {
        star.setVisibility(View.INVISIBLE);
    }

    File file = new File(mContext.getExternalFilesDir(null) + "/img/" + imgId + ".jpg");
    Picasso.with(mContext).load(file).placeholder(R.drawable.noimg).fit().into(siv);
}

From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java

protected void createLocationPanelView(final IGISApplication app) {
    if (null == mGeometry && mFeatureId == NOT_FOUND) {
        mLatView = (TextView) findViewById(R.id.latitude_view);
        mLongView = (TextView) findViewById(R.id.longitude_view);
        mAltView = (TextView) findViewById(R.id.altitude_view);
        mAccView = (TextView) findViewById(R.id.accuracy_view);
        final ImageButton refreshLocation = (ImageButton) findViewById(R.id.refresh);
        mAccurateLocation = (SwitchCompat) findViewById(R.id.accurate_location);
        mAccurateLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override//from   w  w  w  .j a v a 2  s.com
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (mAccurateLocation.getTag() == null) {
                    refreshLocation.performClick();
                    mAccurateLocation.setTag(new Object());
                }
            }
        });
        mAccuracyCE = (AppCompatSpinner) findViewById(R.id.accurate_ce);

        refreshLocation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
                        Animation.RELATIVE_TO_SELF, 0.5f);
                rotateAnimation.setDuration(500);
                rotateAnimation.setRepeatCount(1);
                refreshLocation.startAnimation(rotateAnimation);

                if (mAccurateLocation.isChecked()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(ModifyAttributesActivity.this);
                    View layout = View.inflate(ModifyAttributesActivity.this,
                            R.layout.dialog_progress_accurate_location, null);
                    TextView message = (TextView) layout.findViewById(R.id.message);
                    final ProgressBar progress = (ProgressBar) layout.findViewById(R.id.progress);
                    final TextView progressPercent = (TextView) layout.findViewById(R.id.progress_percent);
                    final TextView progressNumber = (TextView) layout.findViewById(R.id.progress_number);
                    final CheckBox finishBeep = (CheckBox) layout.findViewById(R.id.finish_beep);
                    builder.setView(layout);
                    builder.setTitle(R.string.accurate_location);

                    final AccurateLocationTaker accurateLocation = new AccurateLocationTaker(view.getContext(),
                            100f, mMaxTakeCount, MAX_TAKE_TIME, PROGRESS_DELAY,
                            (String) mAccuracyCE.getSelectedItem());

                    progress.setIndeterminate(true);
                    message.setText(R.string.accurate_taking);
                    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            accurateLocation.cancelTaking();
                        }
                    });
                    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {
                            accurateLocation.cancelTaking();
                        }
                    });
                    builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            ControlHelper.unlockScreenOrientation(ModifyAttributesActivity.this);
                        }
                    });

                    final AlertDialog dialog = builder.create();
                    accurateLocation
                            .setOnProgressUpdateListener(new AccurateLocationTaker.OnProgressUpdateListener() {
                                @SuppressLint("SetTextI18n")
                                @Override
                                public void onProgressUpdate(Long... values) {
                                    int value = values[0].intValue();
                                    if (value == 1) {
                                        progress.setIndeterminate(false);
                                        progress.setMax(mMaxTakeCount);
                                    }

                                    if (value > 0)
                                        progress.setProgress(value);

                                    progressPercent.setText(value * 100 / mMaxTakeCount + " %");
                                    progressNumber.setText(value + " / " + mMaxTakeCount);
                                }
                            });

                    accurateLocation.setOnGetAccurateLocationListener(
                            new AccurateLocationTaker.OnGetAccurateLocationListener() {
                                @Override
                                public void onGetAccurateLocation(Location accurateLocation, Long... values) {
                                    dialog.dismiss();
                                    if (finishBeep.isChecked())
                                        playBeep();

                                    setLocationText(accurateLocation);
                                }
                            });

                    ControlHelper.lockScreenOrientation(ModifyAttributesActivity.this);
                    dialog.setCanceledOnTouchOutside(false);
                    dialog.show();
                    accurateLocation.startTaking();
                } else if (null != app) {
                    GpsEventSource gpsEventSource = app.getGpsEventSource();
                    Location location = gpsEventSource.getLastKnownLocation();
                    setLocationText(location);
                }
            }
        });
    } else {
        //hide location panel
        ViewGroup rootView = (ViewGroup) findViewById(R.id.controls_list);
        rootView.removeView(findViewById(R.id.location_panel));
    }
}

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

public ImageView.OnLayoutChangeListener hourglasslistener() {

    OnLayoutChangeListener olcl = new ImageView.OnLayoutChangeListener() {

        @Override/*from ww w  .  ja v  a 2 s.co  m*/
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {

            RotateAnimation animation = new RotateAnimation(0f, 350f, v.getWidth() / 2, v.getHeight() / 2);
            animation.setInterpolator(new LinearInterpolator());
            animation.setRepeatCount(Animation.INFINITE);
            animation.setDuration(700);

            ((ImageView) v).startAnimation(animation);

        }
    };
    return olcl;

}