Example usage for android.view.animation Animation INFINITE

List of usage examples for android.view.animation Animation INFINITE

Introduction

In this page you can find the example usage for android.view.animation Animation INFINITE.

Prototype

int INFINITE

To view the source code for android.view.animation Animation INFINITE.

Click Source Link

Document

Repeat the animation indefinitely.

Usage

From source file:com.kobi.metalsexchange.app.ExchangeRatesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMetalId = getArguments().getString(METAL_ID);
    // Add this line in order for this fragment to handle menu events.
    setHasOptionsMenu(true);// w ww.  j a  va2  s.co m
    /* Attach a rotating ImageView to the refresh item as an ActionView */
    inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    refreshImageView = (ImageView) inflater.inflate(R.layout.refresh_action_view, null);
    rotation = AnimationUtils.loadAnimation(getActivity(), R.anim.clockwise_refresh);
    rotation.setRepeatCount(Animation.INFINITE);
}

From source file:heartware.com.heartware_master.ProfileFragment.java

/**
 * start the animation on the graph//from   w  w w . ja va2 s . c om
 */
private void triggerAnimation() {
    // set up animation
    Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.animated_view);
    animation.setRepeatMode(Animation.REVERSE);
    animation.setRepeatCount(Animation.INFINITE);
    mGraph.startAnimation(animation);
}

From source file:eu.andlabs.studiolounge.lobby.LobbyFragment.java

private void animateHostMode() {
    pulseBeacon.setVisibility(View.VISIBLE);
    staticBeacon.setVisibility(View.INVISIBLE);

    Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.pulse);
    hyperspaceJumpAnimation.setRepeatMode(Animation.INFINITE);
    hyperspaceJumpAnimation.setRepeatCount(1000);
    pulseBeacon.startAnimation(hyperspaceJumpAnimation);

    // final ObjectAnimator alphaAnimation =
    // ObjectAnimator.ofFloat(pulseBeacon, "alpha", 0);
    ///*  w  ww .ja  v  a  2 s.  c o m*/
    // final ObjectAnimator scaleXAnimation =
    // ObjectAnimator.ofFloat(pulseBeacon, "scaleX", 1);
    //
    // final ObjectAnimator scaleYAnimation =
    // ObjectAnimator.ofFloat(pulseBeacon, "scaleY", 1);
    //
    // long duration= 300;
    // alphaAnimation.setDuration(duration);
    //
    // scaleXAnimation.setDuration(duration);
    //
    // scaleYAnimation.setDuration(duration);
    //
    // scaleYAnimation.setRepeatMode(ObjectAnimator.INFINITE);
    // scaleXAnimation.setRepeatMode(ObjectAnimator.INFINITE);
    // alphaAnimation.setRepeatMode(ObjectAnimator.INFINITE);
    //
    // scaleDown = new AnimatorSet();
    //
    //
    // scaleDown.play(alphaAnimation).with(scaleXAnimation).with(scaleYAnimation);
    // scaleDown.start();
}

From source file:com.carver.paul.truesight.Ui.CounterPicker.CounterPickerFragment.java

/**
 * Shows the loading text and pulses it. Ensures everything else is hidden
 *///from  w  w  w  . ja v  a2  s  .  co m
protected void startLoadingAnimation() {
    mLoadingText.setVisibility(View.VISIBLE);
    mLoadingText.setAlpha(1f);

    AlphaAnimation pulseAlphaAnimation = new AlphaAnimation(0.2f, 1f);
    pulseAlphaAnimation.setDuration(300);
    pulseAlphaAnimation.setRepeatCount(Animation.INFINITE);
    pulseAlphaAnimation.setRepeatMode(Animation.REVERSE);
    mLoadingText.startAnimation(pulseAlphaAnimation);
}

From source file:de.grobox.liberario.ui.LocationGpsView.java

public void activateGPS() {
    if (searching)
        return;/*  www  .ja v a2  s  .  com*/

    // check permissions
    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
                Manifest.permission.ACCESS_FINE_LOCATION)) {
            Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
        } else {
            // No explanation needed, we can request the permission
            ActivityCompat.requestPermissions(activity,
                    new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller);
        }

        return;
    }

    searching = true;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {
        locationManager.removeUpdates(this);
        Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        return;
    }

    // clear input
    setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.startAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    if (gpsListener != null)
        gpsListener.activateGPS();
}

From source file:io.github.runassudo.ptoffline.ui.LocationGpsView.java

public void activateGPS() {
    if (searching)
        return;//from ww w  .  j  a va2 s .co  m

    // check permissions
    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
                Manifest.permission.ACCESS_FINE_LOCATION)) {
            Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
        } else {
            // No explanation needed, we can request the permission
            ActivityCompat.requestPermissions(activity,
                    new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller);
        }

        return;
    }

    searching = true;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {
        locationManager.removeUpdates(this);
        Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        // Set the flag that there is currently no active search. Otherwise the App won't
        // allow new searches even after GPS has been reenabled, because the app "hangs" in
        // a semistate where searching = true but now real search is active.
        searching = false;
        return;
    }

    // clear input
    setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.startAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    if (gpsListener != null)
        gpsListener.activateGPS();
}

From source file:de.grobox.liberario.locations.LocationGpsView.java

public void activateGPS() {
    if (searching)
        return;/*  w ww.j a va  2 s  . c  o  m*/

    // check permissions
    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        /*         if(ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION)) {
                    Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
                 } else {
                    // No explanation needed, we can request the permission
                    ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, caller);
                 }
        */
        return;
    }

    searching = true;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {
        locationManager.removeUpdates(this);
        Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        // Set the flag that there is currently no active search. Otherwise the App won't
        // allow new searches even after GPS has been reenabled, because the app "hangs" in
        // a semistate where searching = true but now real search is active.
        searching = false;
        return;
    }

    // clear input
    setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.startAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    if (gpsListener != null)
        gpsListener.activateGPS();
}

From source file:com.andremion.music.MusicCoverView.java

public MusicCoverView(Context context, AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MusicCoverView);
    @Shape/* w ww  .j a v  a 2 s.co m*/
    int shape = a.getInt(R.styleable.MusicCoverView_shape, SHAPE_SQUARE);
    @ColorInt
    int trackColor = a.getColor(R.styleable.MusicCoverView_trackColor, TRACK_COLOR);
    a.recycle();

    // TODO: Canvas.clipPath works wrong when running with hardware acceleration on Android N
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }

    final float density = getResources().getDisplayMetrics().density;
    mTrackSize = TRACK_SIZE * density;
    mTrackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTrackPaint.setStyle(Paint.Style.STROKE);
    mTrackPaint.setStrokeWidth(TRACK_WIDTH * density);

    mDiscPaintCenterDecor = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDiscPaintCenterDecor.setStyle(Paint.Style.FILL);
    mDiscPaintCenter = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDiscPaintCenter.setStyle(Paint.Style.FILL);

    setShape(shape);
    setTrackColor(trackColor);
    if (getDrawable() != null && ((BitmapDrawable) getDrawable()).getBitmap() != null) {
        setCenterColor(DISC_CENTER_COLOR, Palette.generate(((BitmapDrawable) getDrawable()).getBitmap(), 32)
                .getLightVibrantColor(DISC_CENTER_DECOR_COLOR));
    } else {
        setCenterColor(DISC_CENTER_COLOR, DISC_CENTER_DECOR_COLOR);
    }
    setScaleType();

    mStartRotateAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, FULL_ANGLE);
    mStartRotateAnimator.setInterpolator(new LinearInterpolator());
    if (SHAPE_SQUARE == mShape) {
        mStartRotateAnimator.setDuration(DURATION_SQUARE);
    } else {
        mStartRotateAnimator.setDuration(DURATION);
        mStartRotateAnimator.setRepeatCount(Animation.INFINITE);
    }

    mStartRotateAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            float current = getRotation();
            float target = current > HALF_ANGLE ? FULL_ANGLE : 0; // Choose the shortest distance to 0 rotation
            float diff = target > 0 ? FULL_ANGLE - current : current;
            mEndRotateAnimator.setFloatValues(current, target);
            if (SHAPE_SQUARE == mShape) {
                mEndRotateAnimator.setDuration((int) (DURATION_SQUARE_PER_DEGREES * diff));
            } else {
                mEndRotateAnimator.setDuration((int) (DURATION_PER_DEGREES * diff));
            }

            mEndRotateAnimator.start();
        }
    });

    mEndRotateAnimator = ObjectAnimator.ofFloat(MusicCoverView.this, View.ROTATION, 0);
    mEndRotateAnimator.setInterpolator(new LinearInterpolator());
    mEndRotateAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setRotation(0);
            // isRunning method return true if it's called form here.
            // So we need call from post method to get the right returning.
            post(new Runnable() {
                @Override
                public void run() {
                    if (mCallbacks != null) {
                        mCallbacks.onRotateEnd(MusicCoverView.this);
                    }
                }
            });
        }
    });

    mRectToCircleTransition = new MorphTransition(SHAPE_RECTANGLE);
    mRectToCircleTransition.addTarget(this);
    mRectToCircleTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_CIRCLE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });

    mCircleToRectTransition = new MorphTransition(SHAPE_CIRCLE);
    mCircleToRectTransition.addTarget(this);
    mCircleToRectTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_RECTANGLE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });

    mSquareToSquareTransition = new MorphTransition(SHAPE_SQUARE);
    mSquareToSquareTransition.addTarget(this);
    mSquareToSquareTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_SQUARE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });
}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java

/**
 * On click image view to start stop recording 
 * /*  w w  w  .  j ava2  s. c  o  m*/
 * Records time SYNCHRONOUSLY
 * 
 * @param v
 */
public void onClickSwitchAction(View v) {

    Drawable drwStart = getResources().getDrawable(R.drawable.play);
    Drawable drwStop = getResources().getDrawable(R.drawable.stop);

    LinearLayout lllFrag = (LinearLayout) v.getParent();
    LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker);
    LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus);
    TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording);
    ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording);

    Animation anim = new AlphaAnimation(0.0f, 1.0f);

    Log.d(CLASSNAME,
            "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString());

    ImageView iv = (ImageView) v;
    int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus();

    if (currentStatus == ActivitySession.STATUS_STOPPED) {
        Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED");
        iv.setImageDrawable(drwStop);
        llTimePicker.setVisibility(View.INVISIBLE);

        anim.setDuration(500);
        anim.setStartOffset(20);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);

        Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn();

    } else {
        Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED");
        iv.setImageDrawable(drwStart);
        llTimePicker.setVisibility(View.VISIBLE);
        anim.setRepeatCount(0);

        ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem());

        String sSubjectId = as.getId_subject();
        double dLat = as.getLocation_latitude();
        double dLong = as.getLocation_longitude();
        long lCheckOut = new Date().getTime();
        long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut();

        // Save data into both databases
        DateUtils du = new DateUtils();
        Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / "
                + du.duration(lCheckIn, lCheckOut));

        // TODO make some control here to make this transactional
        // Save in backend
        recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong,
                ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS);
        // Save in local database
        recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong);

        TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration);
        tvDuration.setText(
                du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId)));

        Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut),
                Toast.LENGTH_SHORT).show();

        //
        // Update history layout
        //

        LayoutInflater inflater = LayoutInflater.from(this);
        LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null);
        LinearLayout liContent = (LinearLayout) llParent.getChildAt(0);

        //           ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart);
        //           ivParent.setImageResource(R.drawable.rec_50x);

        //TextView tvTimeStamp = (TextView) liContent.getChildAt(1);    
        TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp);
        tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn));
        tvTimeStamp.setTag(Long.valueOf(lCheckIn));

        TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration);
        tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]");
        // Passing subject id as parameter        
        tvDurRecord.setTag(sSubjectId);

        LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory);
        // Set index number so that the record can be removed
        int iTag = (llHistory.getChildCount() - 1) / 2;
        llParent.setTag(iTag);

        llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1);
        llHistory.addView(llParent, 2);

    }
    tvRecording.startAnimation(anim);
    ivRecording.startAnimation(anim);

    Log.d(CLASSNAME,
            "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString());

}

From source file:com.nextgis.firereporter.MainActivity.java

public void refresh() {
    if (refreshItem == null || mbRefreshing)
        return;/*from w  w  w.  jav  a  2s  .  c  o  m*/

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ImageView iv = (ImageView) inflater.inflate(R.layout.refresh_action_view, null);

    Animation rotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_refresh);
    rotation.setRepeatCount(Animation.INFINITE);
    iv.startAnimation(rotation);

    refreshItem.setActionView(iv);

    mbRefreshing = true;
}