List of usage examples for android.view.animation TranslateAnimation TranslateAnimation
public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
From source file:com.google.android.apps.santatracker.games.gumball.TiltGameFragment.java
/** * Start an animation to move the outlet to the x position in pixels. *///from w w w. j av a 2 s.c om private void moveOutlet(float xPos) { float scale = mRootView.getWidth() / 10.0f; mAnimationOutlet = new TranslateAnimation(mOutletPreviousXPos, (scale * xPos) - mOutletOffset, 0, 0); mAnimationOutlet.setDuration(700); mAnimationOutlet.setFillAfter(true); mAnimationOutlet.setStartOffset(400); mAnimationOutlet.setAnimationListener(this); mGameOutlet.startAnimation(mAnimationOutlet); mOutletPreviousXPos = (scale * xPos) - mOutletOffset; }
From source file:com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.java
private void translateHeader(float of) { float ofCalculated = of * SCROLL_MULTIPLIER; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //Logs.d("ofCalculated " + ofCalculated+" "+mHeader.getHeight()); mHeader.setTranslationY(ofCalculated); } else {/*from ww w .j av a2s. c o m*/ TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated); anim.setFillAfter(true); anim.setDuration(0); mHeader.startAnimation(anim); } mHeader.setClipY(Math.round(ofCalculated)); if (mParallaxScroll != null) { float left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * SCROLL_MULTIPLIER))); mParallaxScroll.onParallaxScroll(left, of, mHeader); } }
From source file:org.androfarsh.widget.DragGridLayout.java
@Override public boolean onTouchEvent(MotionEvent ev) { final float x = ev.getX(); final float y = ev.getY(); if (mGestureDetector.onTouchEvent(ev)) { mPrevX = x;/*from w w w . j av a2 s. c o m*/ mPrevY = y; return true; } switch (ev.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: if (mEditMode) { final View child = findIntersectChild(x, y); if (child != null) { if ((mDragNode != null) && (mDragNode.view != child)) { return true; } mPrevX = x; mPrevY = y; stopAnimation(mDragNode != null ? mDragNode.view : null); mDragNode = new Node(child, requestPreferredRect(mTmpRect, child)); Node.scale(mDragNode.currentRect, mScaleFactor); requestFreeCellRegion(child); requestHoveredCells(mDragNode); if (mDragListener != null) { mDragListener.onDrag(mDragNode.view, this); } final Animation animation = new ScaleAnimation((1f - mScaleFactor) + 1f, 1f, (1f - mScaleFactor) + 1f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(DURATION); animation.setAnimationListener(new AbstractAnimationListener() { @Override public void onAnimationEnd(Animation animation) { mTmpRect.set(mDragNode.startRect); child.setAnimation(null); child.requestLayout(); invalidate(mTmpRect); } }); requestLayout(); child.startAnimation(animation); return true; } final Cell cell = findCellUnder(x, y); if (cell != null) { mPressedCell = cell; invalidate(); return true; } mEditModeSwitchOff = true; return true; } break; case MotionEvent.ACTION_MOVE: if (mPressedCell != null) { final Cell cell = findCellUnder(x, y); if (mPressedCell != cell) { mPressedCell = null; invalidate(); return true; } } else if (mDragNode != null) { mDragNode.currentRect.offset((int) (x - mPrevX), (int) (y - mPrevY)); if (mDebugMode) { Log.w(VIEW_LOG_TAG, "ACTION_MOVE: x=" + x + " y=" + y + " prevX=" + mPrevX + " prevY=" + mPrevY + " dX=" + (x - mPrevX) + " dY=" + (y - mPrevY)); } requestHoveredCells(mDragNode); boolean dragged = (Math.abs(x - mPrevX) < DELTA) && (Math.abs(y - mPrevY) < DELTA); if (dragged) { requestReorderRevert(); } if (!mHoveredCells.isEmpty() && dragged) { if (!mLoongHoveredRequested) { mLoongHoveredRequested = true; mHandler.sendEmptyMessageDelayed(LONGHOVER_MESSAGE, LONGPRESS_TIMEOUT + TAP_TIMEOUT); } } else if (mLoongHoveredRequested) { mLoongHoveredRequested = false; mHandler.removeMessages(LONGHOVER_MESSAGE); } mPrevX = x; mPrevY = y; requestLayout(); invalidate(); return true; } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: mLoongHoveredRequested = false; mHandler.removeMessages(LONGHOVER_MESSAGE); if (mPressedCell != null) { if (mCellClickListener != null) { mCellClickListener.onClick(new Point(mPressedCell.rect.left, mPressedCell.rect.top), this); } mPressedCell = null; invalidate(); return true; } else if (mDragNode != null) { mDragNode.currentRect.offset((int) (x - mPrevX), (int) (y - mPrevY)); requestHoveredCells(mDragNode); requestReorderRevert(); requestDrop(mDragNode); mPrevX = x; mPrevY = y; mTmpRect.set(mDragNode.currentRect); mTmpRect.union(mDragNode.startRect); final View child = mDragNode.view; final LayoutParams lp = (LayoutParams) child.getLayoutParams(); lp.mX = mDragNode.startRect.left; lp.mY = mDragNode.startRect.top; mNodes.clear(); mDragNode.startRect.offset(lp.leftMargin, lp.topMargin); final AnimationSet animation = new AnimationSet(true); animation.addAnimation(new TranslateAnimation(mDragNode.currentRect.left - mDragNode.startRect.left, 0, mDragNode.currentRect.top - mDragNode.startRect.top, 0)); animation.addAnimation(new ScaleAnimation(mScaleFactor, 1f, mScaleFactor, 1f)); animation.setDuration(DURATION); animation.setAnimationListener(new AbstractAnimationListener() { @Override public void onAnimationEnd(final Animation a) { mDragNode.dispose(); mDragNode = null; child.setAnimation(null); requestLayout(); invalidate(); } }); if (mDragListener != null) { mDragListener.onDrop(mDragNode.view, this); } mDragNode.currentRect.set(mDragNode.startRect); child.requestLayout(); child.startAnimation(animation); invalidate(mTmpRect); return true; } else if (mEditModeSwitchOff) { setEditMode(false); mEditModeSwitchOff = false; return true; } break; } return super.onTouchEvent(ev); }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlidePowerLayout() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float height = metrics.heightPixels; float width = metrics.widthPixels; int left500 = (int) ((width / 100) * 39); int top200 = (int) ((width / 100) * 15.7); final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog powerdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); powerdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); powerdialog.setContentView(R.layout.powerdialoglayout); powerdialog.getWindow().getAttributes().windowAnimations = R.style.PowerDialogAnimation; powerdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = powerdialog.getWindow().getAttributes(); lp.dimAmount = 0f;/*from w ww. j av a 2 s .c o m*/ final CheckBox chkpower_headLight = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_headLight); final CheckBox chkpower_dim = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_dim); final CheckBox chkpower_highBeam = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_highBeam); final CheckBox chkpower_dashBoardLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_dashBoardLight); final CheckBox chkpower_cabinSeatLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_cabinSeatLight); final CheckBox chkpower_sideDoorLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_sideDoorLight); final CheckBox chkpower_turnSignal = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_turnSignal); final CheckBox chkpower_air = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_air); final CheckBox chkpower_thermometer = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_thermometer); final CheckBox chkpower_horn = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_horn); final CheckBox chkpower_wipe = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_wipe); final CheckBox chkpower_rainSensor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_rainSensor); final CheckBox chkpower_thirdBrakeLight = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_thirdBrakeLight); final CheckBox chkpower_antiFoggyBack = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_antiFoggyBack); final CheckBox chkpower_antiFoggySide = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_antiFoggySide); final CheckBox chkpower_steeringWheelTest = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_steeringWheelTest); final CheckBox chkpower_steeringWheelSet = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_steeringWheelSet); final CheckBox chkpower_carStereo = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_carStereo); final CheckBox chkpower_electronicWindow = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_electronicWindow); final CheckBox chkpower_sideMirror = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_sideMirror); final CheckBox chkpower_warnDoor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_warnDoor); final CheckBox chkpower_warnSeatBelt = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_warnSeatBelt); final CheckBox chkpower_warnHandBrake = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_warnHandBrake); final CheckBox chkpower_clock = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_clock); final CheckBox chkpower_remoteKey = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_remoteKey); final CheckBox chkpower_centralLock = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_centralLock); final CheckBox chkpower_transmissionPosition = (CheckBox) powerdialog.getWindow() .findViewById(R.id.power_transmissionPosition); // change font chkpower_headLight.setTypeface(type); chkpower_dim.setTypeface(type); chkpower_highBeam.setTypeface(type); chkpower_dashBoardLight.setTypeface(type); chkpower_cabinSeatLight.setTypeface(type); chkpower_sideDoorLight.setTypeface(type); chkpower_turnSignal.setTypeface(type); chkpower_air.setTypeface(type); chkpower_thermometer.setTypeface(type); chkpower_horn.setTypeface(type); chkpower_wipe.setTypeface(type); chkpower_rainSensor.setTypeface(type); chkpower_thirdBrakeLight.setTypeface(type); chkpower_antiFoggyBack.setTypeface(type); chkpower_antiFoggySide.setTypeface(type); chkpower_steeringWheelTest.setTypeface(type); chkpower_steeringWheelSet.setTypeface(type); chkpower_carStereo.setTypeface(type); chkpower_electronicWindow.setTypeface(type); chkpower_sideMirror.setTypeface(type); chkpower_warnDoor.setTypeface(type); chkpower_warnSeatBelt.setTypeface(type); chkpower_warnHandBrake.setTypeface(type); chkpower_clock.setTypeface(type); chkpower_remoteKey.setTypeface(type); chkpower_centralLock.setTypeface(type); chkpower_transmissionPosition.setTypeface(type); powerdialog.setCanceledOnTouchOutside(true); powerdialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headpower.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800); slideoutheadpower.setDuration(500); slideoutheadpower.setFillAfter(true); headpower.startAnimation(slideoutheadpower); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("power_headLight", chkpower_headLight.isChecked()); mp.put("power_dim", chkpower_dim.isChecked()); mp.put("power_highBeam", chkpower_highBeam.isChecked()); mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked()); mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked()); mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked()); mp.put("power_turnSignal", chkpower_turnSignal.isChecked()); mp.put("power_air", chkpower_air.isChecked()); mp.put("power_thermometer", chkpower_thermometer.isChecked()); mp.put("power_horn", chkpower_horn.isChecked()); mp.put("power_wipe", chkpower_wipe.isChecked()); mp.put("power_rainSensor", chkpower_rainSensor.isChecked()); mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked()); mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked()); mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked()); mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked()); mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked()); mp.put("power_carStereo", chkpower_carStereo.isChecked()); mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked()); mp.put("power_sideMirror", chkpower_sideMirror.isChecked()); mp.put("power_warnDoor", chkpower_warnDoor.isChecked()); mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked()); mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked()); mp.put("power_clock", chkpower_clock.isChecked()); mp.put("power_remoteKey", chkpower_remoteKey.isChecked()); mp.put("power_centralLock", chkpower_centralLock.isChecked()); mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked()); filterStore("power", mp); save(mp); } }); TextView power = (TextView) powerdialog.getWindow().findViewById(R.id.Power); power.setTypeface(type); Button powerback = (Button) powerdialog.getWindow().findViewById(R.id.Powerback); powerback.setTypeface(type); powerback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { powerdialog.dismiss(); headpower.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800); slideoutheadpower.setDuration(500); slideoutheadpower.setFillAfter(true); headpower.startAnimation(slideoutheadpower); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("power_headLight", chkpower_headLight.isChecked()); mp.put("power_dim", chkpower_dim.isChecked()); mp.put("power_highBeam", chkpower_highBeam.isChecked()); mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked()); mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked()); mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked()); mp.put("power_turnSignal", chkpower_turnSignal.isChecked()); mp.put("power_air", chkpower_air.isChecked()); mp.put("power_thermometer", chkpower_thermometer.isChecked()); mp.put("power_horn", chkpower_horn.isChecked()); mp.put("power_wipe", chkpower_wipe.isChecked()); mp.put("power_rainSensor", chkpower_rainSensor.isChecked()); mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked()); mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked()); mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked()); mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked()); mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked()); mp.put("power_carStereo", chkpower_carStereo.isChecked()); mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked()); mp.put("power_sideMirror", chkpower_sideMirror.isChecked()); mp.put("power_warnDoor", chkpower_warnDoor.isChecked()); mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked()); mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked()); mp.put("power_clock", chkpower_clock.isChecked()); mp.put("power_remoteKey", chkpower_remoteKey.isChecked()); mp.put("power_centralLock", chkpower_centralLock.isChecked()); mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked()); filterStore("power", mp); save(mp); } }); chkpower_headLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_dim.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_highBeam.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_dashBoardLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_cabinSeatLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_sideDoorLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_turnSignal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_air.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_thermometer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_horn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_wipe.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_rainSensor.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_thirdBrakeLight.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_antiFoggyBack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_antiFoggySide.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_steeringWheelTest.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_steeringWheelSet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_carStereo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_electronicWindow.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_sideMirror.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_warnDoor.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_warnSeatBelt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_warnHandBrake.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_clock.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_remoteKey.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_centralLock.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkpower_transmissionPosition.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalPower(increment); } else { increment = false; getTotalPower(increment); } PowerProgress.setProgress(PercenPower); percenpower.setText("" + PercenPower + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headpower.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadpower = new TranslateAnimation(0, 0, 800, 200); slideheadpower.setDuration(300); slideheadpower.setFillAfter(true); headpower.startAnimation(slideheadpower); powerdialog.show(); WindowManager.LayoutParams params = powerdialog.getWindow().getAttributes(); params.y = top200; params.x = left500; params.gravity = Gravity.TOP | Gravity.LEFT; powerdialog.getWindow().setAttributes(params); isSaveCheckBox(); chkpower_headLight.setChecked(load("power_headLight")); chkpower_dim.setChecked(load("power_dim")); chkpower_highBeam.setChecked(load("power_highBeam")); chkpower_dashBoardLight.setChecked(load("power_dashBoardLight")); chkpower_cabinSeatLight.setChecked(load("power_cabinSeatLight")); chkpower_sideDoorLight.setChecked(load("power_sideDoorLight")); chkpower_turnSignal.setChecked(load("power_turnSignal")); chkpower_air.setChecked(load("power_air")); chkpower_thermometer.setChecked(load("power_thermometer")); chkpower_horn.setChecked(load("power_horn")); chkpower_wipe.setChecked(load("power_wipe")); chkpower_rainSensor.setChecked(load("power_rainSensor")); chkpower_thirdBrakeLight.setChecked(load("power_thirdBrakeLight")); chkpower_antiFoggyBack.setChecked(load("power_antiFoggyBack")); chkpower_antiFoggySide.setChecked(load("power_antiFoggySide")); chkpower_steeringWheelTest.setChecked(load("power_steeringWheelTest")); chkpower_steeringWheelSet.setChecked(load("power_steeringWheelSet")); chkpower_carStereo.setChecked(load("power_carStereo")); chkpower_electronicWindow.setChecked(load("power_electronicWindow")); chkpower_sideMirror.setChecked(load("power_sideMirror")); chkpower_warnDoor.setChecked(load("power_warnDoor")); chkpower_warnSeatBelt.setChecked(load("power_warnSeatBelt")); chkpower_warnHandBrake.setChecked(load("power_warnHandBrake")); chkpower_clock.setChecked(load("power_clock")); chkpower_remoteKey.setChecked(load("power_remoteKey")); chkpower_centralLock.setChecked(load("power_centralLock")); chkpower_transmissionPosition.setChecked(load("power_transmissionPosition")); }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
void clearGroupListAnimation(boolean exceptAddedRoutes) { int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); if (exceptAddedRoutes && mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { continue; }/*from w w w. j av a2s. c o m*/ LinearLayout container = (LinearLayout) view.findViewById(R.id.volume_item_container); container.setVisibility(View.VISIBLE); AnimationSet animSet = new AnimationSet(true); Animation alphaAnim = new AlphaAnimation(1.0f, 1.0f); alphaAnim.setDuration(0); animSet.addAnimation(alphaAnim); Animation translationAnim = new TranslateAnimation(0, 0, 0, 0); translationAnim.setDuration(0); animSet.setFillAfter(true); animSet.setFillEnabled(true); view.clearAnimation(); view.startAnimation(animSet); } mVolumeGroupList.stopAnimationAll(); if (!exceptAddedRoutes) { finishAnimation(false); } }
From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java
private void highlightCurDot(int oldIndex, int newIndex) { Log.i("jim", "oldIndex = " + oldIndex + ">>>>newIndex = " + newIndex); if (mTopTextView == null || mTopFocusLine == null || newIndex < 0 || newIndex > mPageCount - 1 || oldIndex == newIndex) {/*from w w w.j av a 2s .c o m*/ return; } mTopTextView[oldIndex].setTextColor(this.getResources().getColor(R.color.grey)); mTopTextView[newIndex].setTextColor(this.getResources().getColor(R.color.blue)); int moveDistance = mTopTextView[newIndex].getLeft() - mTopTextView[oldIndex].getLeft(); TranslateAnimation animation = new TranslateAnimation(startLeft, startLeft + moveDistance, 0, 0); startLeft += moveDistance; animation.setDuration(300); animation.setFillAfter(true); mTopFocusLine.startAnimation(animation); }
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationActivity.java
void translate(float deltaX, final boolean finalAnim) { // mapFragment.mapView.setEnabled(false); float newX = posX + deltaX; if (slidden) { if (newX < -maxSlide) newX = -maxSlide;//from w w w . j av a2 s .c o m else if (newX > 0) newX = 0; } else { if (newX < 0) newX = 0; else if (newX > maxSlide) newX = maxSlide; } if (((int) newX) <= 0) { mapDisabledView.setVisibility(View.GONE); } final boolean newSlidden = slidden ? newX > -SLIDE_THRESHOLD : newX > SLIDE_THRESHOLD; if (finalAnim) { newX = (slidden == newSlidden) ? 0 : (slidden ? -maxSlide : maxSlide); } if (animation != null && animation.isInitialized()) { animation.cancel(); parentContainer.clearAnimation(); leftContainer.invalidate(); } animation = new TranslateAnimation(posX, newX, 0, 0); animation.setDuration(finalAnim ? 100 : 0); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (!finalAnim) { animation.setFillEnabled(true); animation.setFillAfter(true); } else { parentContainer.clearAnimation(); if (slidden == newSlidden) { if (!slidden) { leftContainer.setVisibility(View.GONE); mapDisabledView.setVisibility(View.GONE); // mapFragment.mapView.setEnabled(true); // mapFragment.mapView.invalidate(); leftContainer.invalidate(); } else { leftContainer.setVisibility(View.VISIBLE); mapDisabledView.setVisibility(View.VISIBLE); leftContainer.invalidate(); } return; } slidden = newSlidden; int leftmargin = slidden ? maxSlide : 0; int rightMargin = slidden ? 0 : maxSlide; RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) parentContainer .getLayoutParams(); lp.setMargins(leftmargin, lp.topMargin, rightMargin, lp.bottomMargin); parentContainer.setLayoutParams(lp); if (leftmargin == 0) { leftContainer.setVisibility(View.GONE); mapDisabledView.setVisibility(View.GONE); // mapFragment.mapView.setEnabled(true); // mapFragment.mapView.invalidate(); leftContainer.invalidate(); } posX = 0; } } }); posX = newX; parentContainer.startAnimation(animation); }
From source file:com.coco.draggablegridviewpager.DraggableGridViewPager.java
private void animateGap(int target) { for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i);/* w w w. j a v a2s.c o m*/ if (i == mLastDragged) { continue; } int newPos = i; if (mLastDragged < target && i >= mLastDragged + 1 && i <= target) { newPos--; } else if (target < mLastDragged && i >= target && i < mLastDragged) { newPos++; } int oldPos = i; if (newPositions.get(i) != -1) { oldPos = newPositions.get(i); } if (oldPos == newPos) { continue; } // animate DEBUG_LOG("animateGap from=" + oldPos + ", to=" + newPos); final Rect oldRect = getRectByPosition(oldPos); final Rect newRect = getRectByPosition(newPos); oldRect.offset(-v.getLeft(), -v.getTop()); newRect.offset(-v.getLeft(), -v.getTop()); TranslateAnimation translate = new TranslateAnimation(oldRect.left, newRect.left, oldRect.top, newRect.top); translate.setDuration(ANIMATION_DURATION); translate.setFillEnabled(true); translate.setFillAfter(true); v.clearAnimation(); v.startAnimation(translate); newPositions.set(i, newPos); } }
From source file:com.android.hcframe.DraggableGridViewPager.java
private void animateGap(int target) { for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i);/*from w w w . jav a 2 s .c o m*/ if (i == mLastDragged) { continue; } int newPos = i; if (mLastDragged < target && i >= mLastDragged + 1 && i <= target) { newPos--; } else if (target < mLastDragged && i >= target && i < mLastDragged) { newPos++; } int oldPos = i; if (newPositions.get(i) != -1) { oldPos = newPositions.get(i); } if (oldPos == newPos) { continue; } // animate HcLog.D("animateGap from=" + oldPos + ", to=" + newPos); final Rect oldRect = getRectByPosition(oldPos); final Rect newRect = getRectByPosition(newPos); oldRect.offset(-v.getLeft(), -v.getTop()); newRect.offset(-v.getLeft(), -v.getTop()); TranslateAnimation translate = new TranslateAnimation(oldRect.left, newRect.left, oldRect.top, newRect.top); translate.setDuration(ANIMATION_DURATION); translate.setFillEnabled(true); translate.setFillAfter(true); v.clearAnimation(); v.startAnimation(translate); newPositions.set(i, newPos); } }
From source file:org.androfarsh.widget.DragGridLayout.java
private void requestReorder() { if (mDragNode == null) { return;/*w w w . j a va 2 s.co m*/ } Set<Node> nodes = findNodesUnder(mDragNode, mHoveredCells); for (final Node childNode : nodes) { requestFreeCellRegion(childNode.view, mDragNode.view); mFreeCellsRegion.op(mDragNode.currentRect, Op.DIFFERENCE); final LayoutParams lp = (LayoutParams) childNode.view.getLayoutParams(); final LayoutParams newLp = validateLayoutParams(generateLayoutParams(lp), mFreeCellsRegion); if ((lp.mX == newLp.mX) && (lp.mY == newLp.mY)) { continue; } childNode.view.setLayoutParams(newLp); requestPreferredRect(childNode.currentRect, childNode.view); final AnimationSet animation = new AnimationSet(true); animation.addAnimation(new TranslateAnimation(childNode.startRect.left - childNode.currentRect.left, 0, childNode.startRect.top - childNode.currentRect.top, 0)); animation.setDuration(DURATION / 2); animation.setAnimationListener(new AbstractAnimationListener() { @Override public void onAnimationEnd(final Animation a) { childNode.view.setAnimation(null); requestLayout(); invalidate(); } }); childNode.view.setAnimation(animation); mNodes.add(childNode); } if (!nodes.isEmpty()) { requestFreeCellRegion(); requestLayout(); invalidate(); } }