public void OnActionDown(RecordButton recordBtn, MotionEvent motionEvent) { try { RecordListener?.OnStartRecord(); AnimationHelper.SetStartRecorded(true); AnimationHelper.ResetBasketAnimation(); AnimationHelper.ResetSmallMic(); recordBtn.StartScale(); SlideToCancelLayout.StartShimmerAnimation(); InitialX = recordBtn.GetX(); BasketInitialY = BasketImg.GetY() + 90; PlaySound(RecordStart); ShowViews(); AnimationHelper.AnimateSmallMicAlpha(); CounterTime.Base = SystemClock.ElapsedRealtime(); StartTime = Methods.Time.CurrentTimeMillis(); CounterTime.Start(); IsSwiped = false; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public void MoveRecordButtonAndSlideToCancelBack(RecordButton recordBtn, FrameLayout slideToCancelLayout, float initialX, float difX) { try { ValueAnimator positionAnimator = ValueAnimator.OfFloat(recordBtn.GetX(), initialX); if (positionAnimator != null) { positionAnimator.SetInterpolator(new AccelerateDecelerateInterpolator()); positionAnimator.Update += (sender, args) => { try { float x = (float)args.Animation?.AnimatedValue; recordBtn.SetX(x); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }; recordBtn.StopScale(); positionAnimator.SetDuration(0); positionAnimator.Start(); } // if the move event was not called ,then the difX will still 0 and there is no need to move it back if (difX != 0) { float x = initialX - difX; slideToCancelLayout.Animate() ?.X(x) ?.SetDuration(0) ?.Start(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }