Example usage for android.view.animation AnimationSet setDuration

List of usage examples for android.view.animation AnimationSet setDuration

Introduction

In this page you can find the example usage for android.view.animation AnimationSet setDuration.

Prototype

@Override
public void setDuration(long durationMillis) 

Source Link

Document

Sets the duration of every child animation.

Usage

From source file:com.androzic.vnspeech.MapFragment.java

private void onUpdateNavigationStatus() {
    if (!application.isNavigating())
        return;/*from   w w w .  j  av  a  2s . c om*/

    if (!map.isFollowing())
        map.refreshMap();

    long now = System.currentTimeMillis();

    double distance = application.navigationService.navDistance;
    double bearing = application.navigationService.navBearing;
    long turn = application.navigationService.navTurn;
    double vmg = application.navigationService.navVMG;
    int ete = application.navigationService.navETE;

    String[] dist = StringFormatter.distanceC(distance, StringFormatter.precisionFormat);
    String eteString = (ete == Integer.MAX_VALUE) ? getString(R.string.never)
            : (String) DateUtils.getRelativeTimeSpanString(now + (ete + 1) * 60000, now,
                    DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE);
    String extra = StringFormatter.speedH(vmg) + " | " + eteString;

    String trnsym = "";
    if (turn > 0) {
        trnsym = "R";
    } else if (turn < 0) {
        trnsym = "L";
        turn = -turn;
    }

    bearing = application.fixDeclination(bearing);
    distanceValue.setText(dist[0]);
    distanceUnit.setText(dist[1]);
    bearingValue.setText(StringFormatter.angleC(bearing));
    turnValue.setText(StringFormatter.angleC(turn) + trnsym);
    waypointExtra.setText(extra);

    if (application.navigationService.isNavigatingViaRoute()) {
        View rootView = getView();
        boolean hasNext = application.navigationService.hasNextRouteWaypoint();
        if (distance < application.navigationService.navProximity * 3 && !animationSet) {
            AnimationSet animation = new AnimationSet(true);
            animation.addAnimation(new AlphaAnimation(1.0f, 0.3f));
            animation.addAnimation(new AlphaAnimation(0.3f, 1.0f));
            animation.setDuration(500);
            animation.setRepeatCount(10);
            rootView.findViewById(R.id.waypointinfo).startAnimation(animation);
            if (!hasNext) {
                rootView.findViewById(R.id.routeinfo).startAnimation(animation);
            }
            animationSet = true;
        } else if (animationSet) {
            rootView.findViewById(R.id.waypointinfo).setAnimation(null);
            if (!hasNext) {
                rootView.findViewById(R.id.routeinfo).setAnimation(null);
            }
            animationSet = false;
        }

        if (application.navigationService.navXTK == Double.NEGATIVE_INFINITY) {
            xtkValue.setText("--");
            xtkUnit.setText("--");
        } else {
            String xtksym = application.navigationService.navXTK == 0 ? ""
                    : application.navigationService.navXTK > 0 ? "R" : "L";
            String[] xtks = StringFormatter.distanceC(Math.abs(application.navigationService.navXTK));
            xtkValue.setText(xtks[0] + xtksym);
            xtkUnit.setText(xtks[1]);
        }

        double navDistance = application.navigationService.navRouteDistanceLeft();
        int eta = application.navigationService.navRouteETE(navDistance);
        if (eta < Integer.MAX_VALUE)
            eta += application.navigationService.navETE;
        String etaString = (eta == Integer.MAX_VALUE) ? getString(R.string.never)
                : (String) DateUtils.getRelativeTimeSpanString(now + (eta + 1) * 60000, now,
                        DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE);
        extra = StringFormatter.distanceH(navDistance + distance, 1000) + " | " + etaString;
        routeExtra.setText(extra);
    }
}

From source file:com.androzic.MapActivity.java

protected void updateNavigationInfo() {
    if (navigationService == null || !navigationService.isNavigating())
        return;//from w  w w .  j a  v  a 2  s. co m

    double distance = navigationService.navDistance;
    double bearing = navigationService.navBearing;
    long turn = navigationService.navTurn;
    double vmg = navigationService.navVMG * speedFactor;
    int ete = navigationService.navETE;

    String[] dist = StringFormatter.distanceC(distance, precisionFormat);
    String extra = String.format(precisionFormat, vmg) + " " + speedAbbr + " | " + StringFormatter.timeH(ete);

    String trnsym = "";
    if (turn > 0) {
        trnsym = "R";
    } else if (turn < 0) {
        trnsym = "L";
        turn = -turn;
    }

    bearing = application.fixDeclination(bearing);
    distanceValue.setText(dist[0]);
    distanceUnit.setText(dist[1]);
    bearingValue.setText(String.valueOf(Math.round(bearing)));
    turnValue.setText(String.valueOf(Math.round(turn)) + trnsym);
    waypointExtra.setText(extra);

    if (navigationService.isNavigatingViaRoute()) {
        boolean hasNext = navigationService.hasNextRouteWaypoint();
        if (distance < navigationService.navProximity * 3 && !animationSet) {
            AnimationSet animation = new AnimationSet(true);
            animation.addAnimation(new AlphaAnimation(1.0f, 0.3f));
            animation.addAnimation(new AlphaAnimation(0.3f, 1.0f));
            animation.setDuration(500);
            animation.setRepeatCount(10);
            findViewById(R.id.waypointinfo).startAnimation(animation);
            if (!hasNext) {
                findViewById(R.id.routeinfo).startAnimation(animation);
            }
            animationSet = true;
        } else if (animationSet) {
            findViewById(R.id.waypointinfo).setAnimation(null);
            if (!hasNext) {
                findViewById(R.id.routeinfo).setAnimation(null);
            }
            animationSet = false;
        }

        if (navigationService.navXTK == Double.NEGATIVE_INFINITY) {
            xtkValue.setText("--");
            xtkUnit.setText("--");
        } else {
            String xtksym = navigationService.navXTK == 0 ? "" : navigationService.navXTK > 0 ? "R" : "L";
            String[] xtks = StringFormatter.distanceC(Math.abs(navigationService.navXTK));
            xtkValue.setText(xtks[0] + xtksym);
            xtkUnit.setText(xtks[1]);
        }

        double navDistance = navigationService.navRouteDistanceLeft();
        int eta = navigationService.navRouteETE(navDistance);
        if (eta < Integer.MAX_VALUE)
            eta += navigationService.navETE;
        extra = StringFormatter.distanceH(navDistance + distance, 1000) + " | " + StringFormatter.timeH(eta);
        routeExtra.setText(extra);
    }
}