Example usage for android.view.animation TranslateAnimation setRepeatCount

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

Introduction

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

Prototype

public void setRepeatCount(int repeatCount) 

Source Link

Document

Sets how many times the animation should be repeated.

Usage

From source file:com.chiemy.zxing.activity.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Window window = getWindow();// w ww. j av  a2s.c o m
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(getLayoutId());

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    //inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    getWindow().getDecorView().post(new Runnable() {
        @Override
        public void run() {
            TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
                    Animation.RELATIVE_TO_PARENT, 0.9f);
            animation.setDuration(4500);
            animation.setRepeatCount(-1);
            animation.setRepeatMode(Animation.RESTART);
            scanLine.startAnimation(animation);
        }
    });

    redecodeHandler = new Handler();
    redecodeRunnable = new RedecodeRunnable(this);
}

From source file:com.kuaichumen.whistle.admin.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Window window = getWindow();/* w w w  .j av a 2  s . co  m*/
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);
    getSupportActionBar().hide();
    CameraManager.init(getApplication());
    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);
    title = (TextView) findViewById(R.id.title);
    flashLight = (LinearLayout) findViewById(R.id.flash_light);
    ll_back = (LinearLayout) findViewById(R.id.ll_back);
    flash = (ImageView) findViewById(R.id.flash);
    flashLight.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            light();
        }
    });
    ll_back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
    EventBus.getDefault().register(this);
    InitData();
}

From source file:com.dtr.zxing.activity.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();/*from   ww  w. j a v  a2s.  c  o m*/
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_qr_scan);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);
    mFlash = (ImageView) findViewById(R.id.capture_flash);
    mFlash.setOnClickListener(this);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}

From source file:com.zoffcc.applications.zanavi.Navit.java

static void animate_bottom_bar_down() {
    final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide);

    // System.out.println("FRAG:animate_bottom_bar_down:014");

    // set bottom end positon correctly??
    bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px
            - Navit.bottom_bar_slider_shadow_px;

    final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch);
    TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); //  new TranslateAnimation(xFrom,xTo, yFrom,yTo)
    animation.setDuration(bottom_bar_snap_duration); // animation duration
    animation.setFillAfter(true);/*www .  jav a 2s. c o m*/
    animation.setFillEnabled(true);
    animation.setRepeatCount(0); // animation repeat count
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // set bottom end positon correctly??
            bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px
                    - Navit.bottom_bar_slider_shadow_px;

            cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch;
            RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
            relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
            a.setLayoutParams(relativeParams);
            a.requestLayout();

            TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
            anim.setFillAfter(true);
            anim.setFillEnabled(true);
            anim.setDuration(1);
            a.startAnimation(anim);

            // remove roadbook fragment -----------
            try {
                if (road_book != null) {
                    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                    // System.out.println("FRAG:dettach:002");
                    fragmentTransaction.detach(road_book);
                    fragmentTransaction.remove(road_book).commit();
                    road_book = null;
                }
            } catch (Exception ef) {
            }
            // remove roadbook fragment -----------

        }
    });
    a.startAnimation(animation);
}

From source file:com.zoffcc.applications.zanavi.Navit.java

void animate_bottom_bar_up() {
    final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide);
    TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch);
    animation.setDuration(bottom_bar_snap_duration); // animation duration
    animation.setFillAfter(true);/*  w  w w. ja  va 2s .  co  m*/
    animation.setFillEnabled(true);
    animation.setRepeatCount(0); // animation repeat count
    animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            cur_y_margin_bottom_bar_touch = 0;
            RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams();
            relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom
            a.setLayoutParams(relativeParams);
            a.requestLayout();

            TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0);
            anim.setFillAfter(true);
            anim.setFillEnabled(true);
            anim.setDuration(1);
            a.startAnimation(anim);
        }
    });
    a.startAnimation(animation);
}