List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Property Animation/* www . j a v a 2 s.c o m*/ * Animation for timer text slide to center */ public void animSlideClockToCenter() { timerClockView.animate().setDuration(animTimerDuration); if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { timerClockView.animate().y(yCenterValue); } else { ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1.5f); ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1.5f); scaleUpY.setDuration(animTimerDuration); scaleUpX.setDuration(animTimerDuration); AnimatorSet scaleUp = new AnimatorSet(); scaleUp.play(scaleUpX).with(scaleUpY); timerClockView.animate().y(yCenterValue); scaleUp.start(); } }
From source file:com.android.deskclock.alarms.AlarmActivity.java
private Animator getAlertAnimator(final View source, final int titleResId, final String infoText, final String accessibilityText, final int revealColor, final int backgroundColor) { final ViewGroup containerView = (ViewGroup) findViewById(android.R.id.content); final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth()); containerView.offsetDescendantRectToMyCoords(source, sourceBounds); final int centerX = sourceBounds.centerX(); final int centerY = sourceBounds.centerY(); final int xMax = Math.max(centerX, containerView.getWidth() - centerX); final int yMax = Math.max(centerY, containerView.getHeight() - centerY); final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f; final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax); final CircleView revealView = new CircleView(this).setCenterX(centerX).setCenterY(centerY) .setFillColor(revealColor);// w w w .ja v a2s .com containerView.addView(revealView); // TODO: Fade out source icon over the reveal (like LOLLIPOP version). final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius, endRadius); revealAnimator.setDuration(ALERT_REVEAL_DURATION_MILLIS); revealAnimator.setInterpolator(REVEAL_INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mAlertView.setVisibility(View.VISIBLE); mAlertTitleView.setText(titleResId); if (infoText != null) { mAlertInfoView.setText(infoText); mAlertInfoView.setVisibility(View.VISIBLE); } mContentView.setVisibility(View.GONE); getWindow().setBackgroundDrawable(new ColorDrawable(backgroundColor)); } }); final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); fadeAnimator.setDuration(ALERT_FADE_DURATION_MILLIS); fadeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { containerView.removeView(revealView); } }); final AnimatorSet alertAnimator = new AnimatorSet(); alertAnimator.play(revealAnimator).before(fadeAnimator); alertAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mAlertView.announceForAccessibility(accessibilityText); mHandler.postDelayed(new Runnable() { @Override public void run() { finish(); } }, ALERT_DISMISS_DELAY_MILLIS); } }); return alertAnimator; }
From source file:com.fa.imaged.activity.DetailActivityV2.java
private static void animatePhotoLike() { detailvBgLike.setVisibility(View.VISIBLE); detailivLike.setVisibility(View.VISIBLE); detailvBgLike.setScaleY(0.1f);/* ww w .ja v a 2 s .co m*/ detailvBgLike.setScaleX(0.1f); detailvBgLike.setAlpha(1f); detailivLike.setScaleY(0.1f); detailivLike.setScaleX(0.1f); AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleY", 0.1f, 1f); bgScaleYAnim.setDuration(200); bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleX", 0.1f, 1f); bgScaleXAnim.setDuration(200); bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(detailvBgLike, "alpha", 1f, 0f); bgAlphaAnim.setDuration(200); bgAlphaAnim.setStartDelay(150); bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 0.1f, 1f); imgScaleUpYAnim.setDuration(300); imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 0.1f, 1f); imgScaleUpXAnim.setDuration(300); imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 1f, 0f); imgScaleDownYAnim.setDuration(300); imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 1f, 0f); imgScaleDownXAnim.setDuration(300); imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR); animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim); animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim); animatorSet.start(); }
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private AnimatorSet newCloseNavAnimator() { ObjectAnimator ncTransX = ObjectAnimator.ofFloat(navContainer, "translationX", 0, -leftWidth); AnimatorSet as = new AnimatorSet(); as.setDuration(durationMs).play(ncTransX); as.addListener(new AnimatorListenerAdapter() { @Override/*from www . j a v a 2s . com*/ public void onAnimationStart(Animator animation) { navContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); navContainer.setVisibility(View.VISIBLE); thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); thingContainer.setVisibility(View.GONE); thingContainer.setTranslationX(0); } @Override public void onAnimationEnd(Animator animation) { navContainer.setLayerType(View.LAYER_TYPE_NONE, null); navContainer.setVisibility(View.GONE); thingContainer.setLayerType(View.LAYER_TYPE_NONE, null); thingContainer.setVisibility(View.VISIBLE); } }); return as; }
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Property Animation//from w w w .j a v a2s . co m * Animation for timer clock slide up to original position */ public void animSlideClockUp() { timerClockView.animate().setDuration(animTimerDuration); if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { timerClockView.animate().y(yOriginalValue); } else { ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1f); ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1f); scaleDownY.setDuration(animTimerDuration); scaleDownX.setDuration(animTimerDuration); AnimatorSet scaleDown = new AnimatorSet(); scaleDown.play(scaleDownX).with(scaleDownY); timerClockView.animate().y(yOriginalValue); scaleDown.start(); } }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
private Animator getAlertAnimator(final View source, final int titleResId, final String infoText, final String accessibilityText, final int revealColor, final int backgroundColor) { final ViewGroup containerView = (ViewGroup) findViewById(android.R.id.content); final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth()); containerView.offsetDescendantRectToMyCoords(source, sourceBounds); final int centerX = sourceBounds.centerX(); final int centerY = sourceBounds.centerY(); final int xMax = Math.max(centerX, containerView.getWidth() - centerX); final int yMax = Math.max(centerY, containerView.getHeight() - centerY); final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f; final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax); final CircleView revealView = new CircleView(this).setCenterX(centerX).setCenterY(centerY) .setFillColor(revealColor);// ww w . j a va 2s .co m containerView.addView(revealView); // TODO: Fade out source icon over the reveal (like LOLLIPOP version). final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius, endRadius); revealAnimator.setDuration(ALERT_REVEAL_DURATION_MILLIS); revealAnimator.setInterpolator(REVEAL_INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mAlertView.setVisibility(View.VISIBLE); mAlertTitleView.setText(titleResId); if (infoText != null) { mAlertInfoView.setText(infoText); mAlertInfoView.setVisibility(View.VISIBLE); } mContentView.setVisibility(View.GONE); getWindow().setBackgroundDrawable(new ColorDrawable(backgroundColor)); } }); final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); fadeAnimator.setDuration(ALERT_FADE_DURATION_MILLIS); fadeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { containerView.removeView(revealView); } }); final AnimatorSet alertAnimator = new AnimatorSet(); alertAnimator.play(revealAnimator).before(fadeAnimator); alertAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (Build.VERSION.SDK_INT >= 16) { mAlertView.announceForAccessibility(accessibilityText); } mHandler.postDelayed(new Runnable() { @Override public void run() { finish(); } }, ALERT_DISMISS_DELAY_MILLIS); } }); return alertAnimator; }
From source file:com.androidinspain.deskclock.timer.TimerFragment.java
/** * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView} * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer * should be removed/*from w ww .jav a2s . com*/ * @param animateDown {@code true} if the views should animate upwards, otherwise downwards */ private void animateToView(final View toView, final Timer timerToRemove, final boolean animateDown) { if (mCurrentView == toView) { return; } final boolean toTimers = toView == mTimersView; if (toTimers) { mTimersView.setVisibility(VISIBLE); } else { mCreateTimerView.setVisibility(VISIBLE); } // Avoid double-taps by enabling/disabling the set of buttons active on the new view. updateFab(BUTTONS_DISABLE); final long animationDuration = UiDataModel.getUiDataModel().getLongAnimationDuration(); final ViewTreeObserver viewTreeObserver = toView.getViewTreeObserver(); viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { if (viewTreeObserver.isAlive()) { viewTreeObserver.removeOnPreDrawListener(this); } final View view = mTimersView.findViewById(com.androidinspain.deskclock.R.id.timer_time); final float distanceY = view != null ? view.getHeight() + view.getY() : 0; final float translationDistance = animateDown ? distanceY : -distanceY; toView.setTranslationY(-translationDistance); mCurrentView.setTranslationY(0f); toView.setAlpha(0f); mCurrentView.setAlpha(1f); final Animator translateCurrent = ObjectAnimator.ofFloat(mCurrentView, TRANSLATION_Y, translationDistance); final Animator translateNew = ObjectAnimator.ofFloat(toView, TRANSLATION_Y, 0f); final AnimatorSet translationAnimatorSet = new AnimatorSet(); translationAnimatorSet.playTogether(translateCurrent, translateNew); translationAnimatorSet.setDuration(animationDuration); translationAnimatorSet.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); final Animator fadeOutAnimator = ObjectAnimator.ofFloat(mCurrentView, ALPHA, 0f); fadeOutAnimator.setDuration(animationDuration / 2); fadeOutAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); // The fade-out animation and fab-shrinking animation should run together. updateFab(FAB_AND_BUTTONS_SHRINK); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (toTimers) { showTimersView(FAB_AND_BUTTONS_EXPAND); // Reset the state of the create view. mCreateTimerView.reset(); } else { showCreateTimerView(FAB_AND_BUTTONS_EXPAND); } if (timerToRemove != null) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_delete, com.androidinspain.deskclock.R.string.label_deskclock); } // Update the fab and button states now that the correct view is visible and // before the animation to expand the fab and buttons starts. updateFab(FAB_AND_BUTTONS_IMMEDIATE); } }); final Animator fadeInAnimator = ObjectAnimator.ofFloat(toView, ALPHA, 1f); fadeInAnimator.setDuration(animationDuration / 2); fadeInAnimator.setStartDelay(animationDuration / 2); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(fadeOutAnimator, fadeInAnimator, translationAnimatorSet); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mTimersView.setTranslationY(0f); mCreateTimerView.setTranslationY(0f); mTimersView.setAlpha(1f); mCreateTimerView.setAlpha(1f); } }); animatorSet.start(); return true; } }); }
From source file:org.pouyadr.ui.LocationActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); }/*from w ww . java 2s . com*/ actionBar.setAddToContainer(messageObject != null); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == map_list_menu_map) { if (googleMap != null) { googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); } } else if (id == map_list_menu_satellite) { if (googleMap != null) { googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); } } else if (id == map_list_menu_hybrid) { if (googleMap != null) { googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); } } else if (id == share) { try { double lat = messageObject.messageOwner.media.geo.lat; double lon = messageObject.messageOwner.media.geo._long; getParentActivity().startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + lat + "," + lon + "?q=" + lat + "," + lon))); } catch (Exception e) { FileLog.e("tmessages", e); } } } }); ActionBarMenu menu = actionBar.createMenu(); if (messageObject != null) { if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) { actionBar.setTitle(messageObject.messageOwner.media.title); if (messageObject.messageOwner.media.address != null && messageObject.messageOwner.media.address.length() > 0) { actionBar.setSubtitle(messageObject.messageOwner.media.address); } } else { actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation)); } menu.addItem(share, R.drawable.share); } else { actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation)); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true) .setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; listView.setVisibility(View.GONE); mapViewClip.setVisibility(View.GONE); searchListView.setVisibility(View.VISIBLE); searchListView.setEmptyView(emptyTextLayout); } @Override public void onSearchCollapse() { searching = false; searchWas = false; searchListView.setEmptyView(null); listView.setVisibility(View.VISIBLE); mapViewClip.setVisibility(View.VISIBLE); searchListView.setVisibility(View.GONE); emptyTextLayout.setVisibility(View.GONE); searchAdapter.searchDelayed(null, null); } @Override public void onTextChanged(EditText editText) { if (searchAdapter == null) { return; } String text = editText.getText().toString(); if (text.length() != 0) { searchWas = true; } searchAdapter.searchDelayed(text, userLocation); } }); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); } ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0); item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0); item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0); fragmentView = new FrameLayout(context) { private boolean first = true; @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (changed) { fixLayoutInternal(first); first = false; } } }; FrameLayout frameLayout = (FrameLayout) fragmentView; locationButton = new ImageView(context); locationButton.setBackgroundResource(R.drawable.floating_user_states); locationButton.setImageResource(R.drawable.myloc_on); locationButton.setScaleType(ImageView.ScaleType.CENTER); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(locationButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(locationButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); locationButton.setStateListAnimator(animator); locationButton.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56)); } }); } if (messageObject != null) { mapView = new MapView(context); frameLayout.setBackgroundDrawable(new MapPlaceholderDrawable()); mapView.onCreate(null); try { MapsInitializer.initialize(context); // googleMap = mapView.getMap(); } catch (Exception e) { FileLog.e("tmessages", e); } FrameLayout bottomView = new FrameLayout(context); bottomView.setBackgroundResource(R.drawable.location_panel); frameLayout.addView(bottomView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 60, Gravity.LEFT | Gravity.BOTTOM)); bottomView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (userLocation != null) { LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); if (googleMap != null) { CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 4); googleMap.animateCamera(position); } } } }); avatarImageView = new BackupImageView(context); avatarImageView.setRoundRadius(AndroidUtilities.dp(20)); bottomView.addView(avatarImageView, LayoutHelper.createFrame(40, 40, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 12, 12, LocaleController.isRTL ? 12 : 0, 0)); nameTextView = new TextView(context); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); nameTextView.setTextColor(0xff212121); nameTextView.setMaxLines(1); nameTextView.setTypeface(AndroidUtilities.getTypeface(org.pouyadr.finalsoft.Fonts.CurrentFont())); nameTextView.setEllipsize(TextUtils.TruncateAt.END); nameTextView.setSingleLine(true); nameTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); bottomView.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 12 : 72, 10, LocaleController.isRTL ? 72 : 12, 0)); distanceTextView = new TextView(context); distanceTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); distanceTextView.setTextColor(0xff2f8cc9); distanceTextView.setMaxLines(1); distanceTextView.setEllipsize(TextUtils.TruncateAt.END); distanceTextView.setSingleLine(true); distanceTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); bottomView.addView(distanceTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 12 : 72, 33, LocaleController.isRTL ? 72 : 12, 0)); userLocation = new Location("network"); userLocation.setLatitude(messageObject.messageOwner.media.geo.lat); userLocation.setLongitude(messageObject.messageOwner.media.geo._long); if (googleMap != null) { LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); try { googleMap.addMarker(new MarkerOptions().position(latLng) .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin))); } catch (Exception e) { FileLog.e("tmessages", e); } CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 4); googleMap.moveCamera(position); } ImageView routeButton = new ImageView(context); routeButton.setBackgroundResource(R.drawable.floating_states); routeButton.setImageResource(R.drawable.navigate); routeButton.setScaleType(ImageView.ScaleType.CENTER); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator .ofFloat(routeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)) .setDuration(200)); animator.addState(new int[] {}, ObjectAnimator .ofFloat(routeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)) .setDuration(200)); routeButton.setStateListAnimator(animator); routeButton.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56)); } }); } frameLayout.addView(routeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 28)); routeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { if (activity.checkSelfPermission( Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { showPermissionAlert(true); return; } } } if (myLocation != null) { try { Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", myLocation.getLatitude(), myLocation.getLongitude(), messageObject.messageOwner.media.geo.lat, messageObject.messageOwner.media.geo._long))); getParentActivity().startActivity(intent); } catch (Exception e) { FileLog.e("tmessages", e); } } } }); frameLayout.addView(locationButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 100)); locationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { if (activity.checkSelfPermission( Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { showPermissionAlert(true); return; } } } if (myLocation != null && googleMap != null) { googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom( new LatLng(myLocation.getLatitude(), myLocation.getLongitude()), googleMap.getMaxZoomLevel() - 4)); } } }); } else { searchWas = false; searching = false; mapViewClip = new FrameLayout(context); mapViewClip.setBackgroundDrawable(new MapPlaceholderDrawable()); if (adapter != null) { adapter.destroy(); } if (searchAdapter != null) { searchAdapter.destroy(); } listView = new ListView(context); listView.setAdapter(adapter = new LocationActivityAdapter(context)); listView.setVerticalScrollBarEnabled(false); listView.setDividerHeight(0); listView.setDivider(null); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (totalItemCount == 0) { return; } updateClipView(firstVisibleItem); } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == 1) { if (delegate != null && userLocation != null) { TLRPC.TL_messageMediaGeo location = new TLRPC.TL_messageMediaGeo(); location.geo = new TLRPC.TL_geoPoint(); location.geo.lat = userLocation.getLatitude(); location.geo._long = userLocation.getLongitude(); delegate.didSelectLocation(location); } finishFragment(); } else { TLRPC.TL_messageMediaVenue object = adapter.getItem(position); if (object != null && delegate != null) { delegate.didSelectLocation(object); } finishFragment(); } } }); adapter.setDelegate(new BaseLocationAdapter.BaseLocationAdapterDelegate() { @Override public void didLoadedSearchResult(ArrayList<TLRPC.TL_messageMediaVenue> places) { if (!wasResults && !places.isEmpty()) { wasResults = true; } } }); adapter.setOverScrollHeight(overScrollHeight); frameLayout.addView(mapViewClip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); mapView = new MapView(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (Build.VERSION.SDK_INT >= 11) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { if (animatorSet != null) { animatorSet.cancel(); } animatorSet = new AnimatorSet(); animatorSet.setDuration(200); animatorSet.playTogether( ObjectAnimator.ofFloat(markerImageView, "translationY", markerTop + -AndroidUtilities.dp(10)), ObjectAnimator.ofFloat(markerXImageView, "alpha", 1.0f)); animatorSet.start(); } else if (ev.getAction() == MotionEvent.ACTION_UP) { if (animatorSet != null) { animatorSet.cancel(); } animatorSet = new AnimatorSet(); animatorSet.setDuration(200); animatorSet.playTogether( ObjectAnimator.ofFloat(markerImageView, "translationY", markerTop), ObjectAnimator.ofFloat(markerXImageView, "alpha", 0.0f)); animatorSet.start(); } } if (ev.getAction() == MotionEvent.ACTION_MOVE) { if (!userLocationMoved) { if (Build.VERSION.SDK_INT >= 11) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(200); animatorSet.play(ObjectAnimator.ofFloat(locationButton, "alpha", 1.0f)); animatorSet.start(); } else { locationButton.setVisibility(VISIBLE); } userLocationMoved = true; } if (googleMap != null && userLocation != null) { userLocation.setLatitude(googleMap.getCameraPosition().target.latitude); userLocation.setLongitude(googleMap.getCameraPosition().target.longitude); } adapter.setCustomLocation(userLocation); } return super.onInterceptTouchEvent(ev); } }; try { mapView.onCreate(null); } catch (Exception e) { FileLog.e("tmessages", e); } try { MapsInitializer.initialize(context); // googleMap = mapView.getMap(); } catch (Exception e) { FileLog.e("tmessages", e); } View shadow = new View(context); shadow.setBackgroundResource(R.drawable.header_shadow_reverse); mapViewClip.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.LEFT | Gravity.BOTTOM)); markerImageView = new ImageView(context); markerImageView.setImageResource(R.drawable.map_pin); mapViewClip.addView(markerImageView, LayoutHelper.createFrame(24, 42, Gravity.TOP | Gravity.CENTER_HORIZONTAL)); if (Build.VERSION.SDK_INT >= 11) { markerXImageView = new ImageView(context); markerXImageView.setAlpha(0.0f); markerXImageView.setImageResource(R.drawable.place_x); mapViewClip.addView(markerXImageView, LayoutHelper.createFrame(14, 14, Gravity.TOP | Gravity.CENTER_HORIZONTAL)); } mapViewClip.addView(locationButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14)); locationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { if (activity.checkSelfPermission( Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { showPermissionAlert(false); return; } } } if (myLocation != null && googleMap != null) { if (Build.VERSION.SDK_INT >= 11) { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(200); animatorSet.play(ObjectAnimator.ofFloat(locationButton, "alpha", 0.0f)); animatorSet.start(); } else { locationButton.setVisibility(View.INVISIBLE); } adapter.setCustomLocation(null); userLocationMoved = false; googleMap.animateCamera(CameraUpdateFactory .newLatLng(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()))); } } }); if (Build.VERSION.SDK_INT >= 11) { locationButton.setAlpha(0.0f); } else { locationButton.setVisibility(View.INVISIBLE); } emptyTextLayout = new LinearLayout(context); emptyTextLayout.setVisibility(View.GONE); emptyTextLayout.setOrientation(LinearLayout.VERTICAL); frameLayout.addView(emptyTextLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 100, 0, 0)); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TextView emptyTextView = new TextView(context); emptyTextView.setTextColor(0xff808080); emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); emptyTextLayout.addView(emptyTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f)); FrameLayout frameLayoutEmpty = new FrameLayout(context); emptyTextLayout.addView(frameLayoutEmpty, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f)); searchListView = new ListView(context); searchListView.setVisibility(View.GONE); searchListView.setDividerHeight(0); searchListView.setDivider(null); searchListView.setAdapter(searchAdapter = new LocationActivitySearchAdapter(context)); frameLayout.addView(searchListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP)); searchListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) { AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); searchListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TLRPC.TL_messageMediaVenue object = searchAdapter.getItem(position); if (object != null && delegate != null) { delegate.didSelectLocation(object); } finishFragment(); } }); if (googleMap != null) { userLocation = new Location("network"); userLocation.setLatitude(20.659322); userLocation.setLongitude(-11.406250); } frameLayout.addView(actionBar); } if (googleMap != null) { try { googleMap.setMyLocationEnabled(true); } catch (Exception e) { FileLog.e("tmessages", e); } googleMap.getUiSettings().setMyLocationButtonEnabled(false); googleMap.getUiSettings().setZoomControlsEnabled(false); googleMap.getUiSettings().setCompassEnabled(false); googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() { @Override public void onMyLocationChange(Location location) { positionMarker(location); } }); positionMarker(myLocation = getLastLocation()); } return fragmentView; }
From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java
private void animateSelector(int toPosition, String property, boolean hasAnimation, boolean enableDeselection) { int value1 = 0, value2 = 1; if (animationType == ANIM_TRANSLATE_Y) { value1 = selectorSize;/*w w w .ja v a2s.c om*/ value2 = 0; } if (enableDeselection && toPosition == lastPosition && !buttons.get(toPosition).isChecked()) { int temp = value1; value1 = value2; value2 = temp; } AnimatorSet set = new AnimatorSet(); ObjectAnimator to = createAnimator(v_selectors.get(toPosition), property, value2, false, hasAnimation); if (lastPosition > -1) { ObjectAnimator from = createAnimator(v_selectors.get(lastPosition), property, value1, true, hasAnimation); set.playTogether(to, from); } else set.play(to); set.start(); }
From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java
private void animateToProfile(DrawerProfile profile) { Log.d(TAG, "animateToProfile(*" + profile.getId() + ")"); if (mProfileAdapter.getCount() > 1) { List<Animator> animators = new ArrayList<>(); List<Animator.AnimatorListener> listeners = new ArrayList<>(); final DrawerProfile oldProfile = mProfileAdapter.getItem(0); final DrawerProfile newProfile = profile; /* Background animation */ AlphaSatColorMatrixEvaluator evaluator = new AlphaSatColorMatrixEvaluator(); final AnimatableColorMatrixColorFilter filter = new AnimatableColorMatrixColorFilter( evaluator.getColorMatrix()); ObjectAnimator backgroundAnimator = ObjectAnimator.ofObject(filter, "colorMatrix", evaluator, evaluator.getColorMatrix()); backgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w w w .ja va 2 s. co m*/ public void onAnimationUpdate(ValueAnimator animation) { imageViewProfileBackgroundOverlay.setColorFilter(filter.getColorFilter()); } }); animators.add(backgroundAnimator); listeners.add(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { imageViewProfileBackground.setImageDrawable(oldProfile.getBackground()); imageViewProfileBackgroundOverlay.setImageDrawable(newProfile.getBackground()); imageViewProfileBackgroundOverlay.setColorFilter(filter.getColorFilter()); imageViewProfileBackgroundOverlay.setVisibility(VISIBLE); imageViewProfileAvatarSecondary.setClickable(false); } @Override public void onAnimationEnd(Animator animation) { imageViewProfileBackground.setImageDrawable(newProfile.getBackground()); if (newProfile.getBackground() instanceof BitmapDrawable) { new Palette.Builder(((BitmapDrawable) newProfile.getBackground()).getBitmap()) .resizeBitmapSize(500).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { Palette.Swatch vibrantSwatch = palette.getVibrantSwatch(); if (vibrantSwatch != null) { textViewProfileAvatarCount .setTextColor(vibrantSwatch.getTitleTextColor()); textViewProfileAvatarCount.getBackground() .setColorFilter(vibrantSwatch.getRgb(), PorterDuff.Mode.SRC_IN); } } }); } imageViewProfileBackgroundOverlay.setVisibility(GONE); if (hasOnProfileSwitchListener()) { onProfileSwitchListener.onSwitch(oldProfile, oldProfile.getId(), newProfile, newProfile.getId()); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); /* Text animation */ AnimatorSet textSet = new AnimatorSet(); AnimatorSet textOutSet = new AnimatorSet(); textOutSet.playTogether(ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "alpha", 1, 0), ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "translationX", 0, getWidth() / 4)); textOutSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { updateProfileTheme(); if (newProfile.hasName()) { textViewProfileName.setText(newProfile.getName()); textViewProfileName.setVisibility(VISIBLE); } else { textViewProfileName.setVisibility(GONE); } if (newProfile.hasDescription()) { textViewProfileDescription.setText(newProfile.getDescription()); textViewProfileDescription.setVisibility(VISIBLE); } else { textViewProfileDescription.setVisibility(GONE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet textInSet = new AnimatorSet(); textInSet.playTogether(ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "alpha", 0, 1), ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "translationX", -getWidth() / 4, 0)); textSet.playSequentially(textOutSet, textInSet); animators.add(textSet); AnimatorSet profileSet = new AnimatorSet(); if (mProfileAdapter.getCount() == 2) { /* Avatar animation */ int translation = imageViewProfileAvatarSecondary.getLeft() - getResources().getDimensionPixelSize(R.dimen.md_baseline); float scale = getResources().getDimension(R.dimen.md_avatar_size) / getResources().getDimension(R.dimen.md_big_avatar_size); float translationCorrect = (getResources().getDimension(R.dimen.md_avatar_size) - getResources().getDimension(R.dimen.md_big_avatar_size)) / 2; listeners.add(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { imageViewProfileAvatarSecondary.setPivotX(0); imageViewProfileAvatarSecondary.setPivotY(0); } @Override public void onAnimationEnd(Animator animation) { imageViewProfileAvatar.setTranslationX(0); imageViewProfileAvatar.setTranslationY(0); imageViewProfileAvatar.setScaleX(1); imageViewProfileAvatar.setScaleY(1); imageViewProfileAvatarSecondary.setTranslationX(0); imageViewProfileAvatarSecondary.setScaleX(1); imageViewProfileAvatarSecondary.setScaleY(1); if (oldProfile.hasAvatar()) { imageViewProfileAvatarSecondary.setImageDrawable(oldProfile.getAvatar()); imageViewProfileAvatarSecondary.setVisibility(VISIBLE); } else { imageViewProfileAvatarSecondary.setVisibility(INVISIBLE); } if (newProfile.hasAvatar()) { imageViewProfileAvatar.setImageDrawable(newProfile.getAvatar()); imageViewProfileAvatar.setVisibility(VISIBLE); imageViewProfileAvatarSecondary.setClickable(true); } else { imageViewProfileAvatar.setVisibility(INVISIBLE); imageViewProfileAvatarSecondary.setClickable(false); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); if (oldProfile.hasAvatar()) { ObjectAnimator stepTranslateXAnimator = ObjectAnimator.ofFloat(imageViewProfileAvatar, "translationX", 0, translation + translationCorrect); stepTranslateXAnimator.setInterpolator(new StepInterpolator()); animators.add(stepTranslateXAnimator); ObjectAnimator stepTranslateYAnimator = ObjectAnimator.ofFloat(imageViewProfileAvatar, "translationY", 0, translationCorrect); stepTranslateYAnimator.setInterpolator(new StepInterpolator()); animators.add(stepTranslateYAnimator); animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatar, "alpha", 1, 0, 1)); animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleX", 1, 0.5f, scale)); animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleY", 1, 0.5f, scale)); } if (newProfile.hasAvatar()) { animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatarSecondary, "translationX", 0, -translation)); animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatarSecondary, "scaleX", 1, 1 / scale)); animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatarSecondary, "scaleY", 1, 1 / scale)); } } else { AnimatorSet profileOutSet = new AnimatorSet(); profileOutSet.playTogether(ObjectAnimator.ofFloat(imageViewProfileAvatar, "alpha", 1, 0), ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleX", 1, 0.5f), ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleY", 1, 0.5f)); profileOutSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { linearListViewProfileList.setOnItemClickListener(new LinearListView.OnItemClickListener() { @Override public void onItemClick(LinearListView parent, View view, int position, long id) { } }); } @Override public void onAnimationEnd(Animator animation) { imageViewProfileAvatar.setImageDrawable(newProfile.getAvatar()); linearListViewProfileList.setOnItemClickListener(new LinearListView.OnItemClickListener() { @Override public void onItemClick(LinearListView parent, View view, int position, long id) { if (position != 0) { selectProfile(mProfileAdapter.getItem(position)); } } }); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet profileInSet = new AnimatorSet(); profileInSet.playTogether(ObjectAnimator.ofFloat(imageViewProfileAvatar, "alpha", 0, 1), ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleX", 0.5f, 1), ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleY", 0.5f, 1)); profileSet.playSequentially(profileOutSet, profileInSet); animators.add(profileSet); } if (animators.size() > 0) { /* Play animation */ AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.setDuration(getResources().getInteger(R.integer.md_profile_switching_anim_time)); textSet.setDuration(getResources().getInteger(R.integer.md_profile_switching_anim_time) / 2); profileSet.setDuration(getResources().getInteger(R.integer.md_profile_switching_anim_time) / 2); for (Animator.AnimatorListener listener : listeners) { set.addListener(listener); } set.start(); } } }