use of android.view.animation.TranslateAnimation in project android_packages_apps_OmniClock by omnirom.
the class StopwatchFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
ViewGroup v = (ViewGroup) inflater.inflate(org.omnirom.deskclock.R.layout.stopwatch_fragment, container, false);
mTime = (CircleTimerView) v.findViewById(org.omnirom.deskclock.R.id.stopwatch_time);
mTime.setBackgroundResource(Utils.getCircleViewBackgroundResourceId(getActivity()));
mTimeText = (CountingTimerView) v.findViewById(org.omnirom.deskclock.R.id.stopwatch_time_text);
mLapsList = (ListView) v.findViewById(org.omnirom.deskclock.R.id.laps_list);
mLapsList.setDividerHeight(0);
mLapsAdapter = new LapsListAdapter(getActivity());
mLapsList.setAdapter(mLapsAdapter);
View footerView = inflater.inflate(org.omnirom.deskclock.R.layout.blank_footer_view, mLapsList, false);
mLapsList.addFooterView(footerView, null, false);
mTimeText.registerVirtualButtonAction(new Runnable() {
@Override
public void run() {
toggleStopwatchState();
}
});
mCircleLayout = (CircleButtonsLayout) v.findViewById(org.omnirom.deskclock.R.id.stopwatch_circle);
mCircleLayout.setCircleTimerViewIds(org.omnirom.deskclock.R.id.stopwatch_time, 0, /* stopwatchId */
0, /* labelId */
0);
// Animation setup
mLayoutTransition = new LayoutTransition();
mCircleLayoutTransition = new LayoutTransition();
// The CircleButtonsLayout only needs to undertake location changes
mCircleLayoutTransition.enableTransitionType(LayoutTransition.CHANGING);
mCircleLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
mCircleLayoutTransition.disableTransitionType(LayoutTransition.DISAPPEARING);
mCircleLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
mCircleLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
mCircleLayoutTransition.setAnimateParentHierarchy(false);
// These spacers assist in keeping the size of CircleButtonsLayout constant
mStartSpace = v.findViewById(org.omnirom.deskclock.R.id.start_space);
mEndSpace = v.findViewById(org.omnirom.deskclock.R.id.end_space);
mSpacersUsed = mStartSpace != null || mEndSpace != null;
// Listener to invoke extra animation within the laps-list
mLayoutTransition.addTransitionListener(new LayoutTransition.TransitionListener() {
@Override
public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
if (view == mLapsList) {
if (transitionType == LayoutTransition.DISAPPEARING) {
if (DEBUG)
LogUtils.v("StopwatchFragment.start laps-list disappearing");
boolean shiftX = view.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
int first = mLapsList.getFirstVisiblePosition();
int last = mLapsList.getLastVisiblePosition();
// Ensure index range will not cause a divide by zero
if (last < first) {
last = first;
}
long duration = transition.getDuration(LayoutTransition.DISAPPEARING);
long offset = duration / (last - first + 1) / 5;
for (int visibleIndex = first; visibleIndex <= last; visibleIndex++) {
View lapView = mLapsList.getChildAt(visibleIndex - first);
if (lapView != null) {
float toXValue = shiftX ? 1.0f * (visibleIndex - first + 1) : 0;
float toYValue = shiftX ? 0 : 4.0f * (visibleIndex - first + 1);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, toXValue, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, toYValue);
animation.setStartOffset((last - visibleIndex) * offset);
animation.setDuration(duration);
lapView.startAnimation(animation);
}
}
}
}
}
@Override
public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
if (transitionType == LayoutTransition.DISAPPEARING) {
if (DEBUG)
LogUtils.v("StopwatchFragment.end laps-list disappearing");
int last = mLapsList.getLastVisiblePosition();
for (int visibleIndex = mLapsList.getFirstVisiblePosition(); visibleIndex <= last; visibleIndex++) {
View lapView = mLapsList.getChildAt(visibleIndex);
if (lapView != null) {
Animation animation = lapView.getAnimation();
if (animation != null) {
animation.cancel();
}
}
}
}
}
});
return v;
}
use of android.view.animation.TranslateAnimation in project BaseProject by feer921.
the class CanDragScrollView method animation.
public void animation() {
TranslateAnimation ta = new TranslateAnimation(0, 0, inner.getTop(), normal.top);
ta.setDuration(200);
inner.startAnimation(ta);
inner.layout(normal.left, normal.top, normal.right, normal.bottom);
normal.setEmpty();
}
use of android.view.animation.TranslateAnimation in project Signal-Android by signalapp.
the class VerificationPinKeyboard method displayFailure.
public ListenableFuture<Boolean> displayFailure() {
SettableFuture<Boolean> result = new SettableFuture<>();
this.keyboardView.setVisibility(View.INVISIBLE);
this.progressBar.setVisibility(View.GONE);
this.failureView.setVisibility(View.GONE);
this.lockedView.setVisibility(View.GONE);
this.failureView.getBackground().setColorFilter(getResources().getColor(R.color.red_500), PorterDuff.Mode.SRC_IN);
this.failureView.setVisibility(View.VISIBLE);
TranslateAnimation shake = new TranslateAnimation(0, 30, 0, 0);
shake.setDuration(50);
shake.setRepeatCount(7);
shake.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
result.set(true);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
this.failureView.startAnimation(shake);
return result;
}
use of android.view.animation.TranslateAnimation in project Signal-Android by signalapp.
the class AttachmentTypeSelector method animateWindowInTranslate.
private void animateWindowInTranslate(@NonNull View contentView) {
Animation animation = new TranslateAnimation(0, 0, contentView.getHeight(), 0);
animation.setDuration(ANIMATION_DURATION);
getContentView().startAnimation(animation);
}
use of android.view.animation.TranslateAnimation in project Signal-Android by signalapp.
the class AttachmentTypeSelector method animateWindowOutTranslate.
private void animateWindowOutTranslate(@NonNull View contentView) {
Animation animation = new TranslateAnimation(0, 0, 0, contentView.getTop() + contentView.getHeight());
animation.setDuration(ANIMATION_DURATION);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
AttachmentTypeSelector.super.dismiss();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
getContentView().startAnimation(animation);
}
Aggregations