List of usage examples for android.animation ValueAnimator INFINITE
int INFINITE
To view the source code for android.animation ValueAnimator INFINITE.
Click Source Link
From source file:com.xixicm.de.presentation.view.fragment.SentenceDetailFragment.java
private void initAnimatiorIfNeed() { if (mAudioFabAnimator == null) { mAudioFabAnimator = ObjectAnimator.ofInt(mAudioFab, "imageLevel", 0, 10000); mAudioFabAnimator.setDuration(1000); mAudioFabAnimator.setRepeatCount(ValueAnimator.INFINITE); }/*from ww w . ja v a2s. c om*/ }
From source file:me.lizheng.deckview.views.DeckChildViewHeader.java
/** * Notifies the associated TaskView has been focused. *///from www .j a v a 2 s . co m void onTaskViewFocusChanged(boolean focused, boolean animateFocusedState) { // If we are not animating the visible state, just return if (!animateFocusedState) return; boolean isRunning = false; if (mFocusAnimator != null) { isRunning = mFocusAnimator.isRunning(); DVUtils.cancelAnimationWithoutCallbacks(mFocusAnimator); } if (focused) { // Pulse the background color int currentColor = mBackgroundColor; int lightPrimaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark); ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor, lightPrimaryColor); backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); mBackgroundColorDrawable.setColor(color); mBackgroundColor = color; } }); backgroundColor.setRepeatCount(ValueAnimator.INFINITE); backgroundColor.setRepeatMode(ValueAnimator.REVERSE); // Pulse the translation ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 15f); translation.setRepeatCount(ValueAnimator.INFINITE); translation.setRepeatMode(ValueAnimator.REVERSE); mFocusAnimator = new AnimatorSet(); mFocusAnimator.playTogether(backgroundColor, translation); mFocusAnimator.setStartDelay(750); mFocusAnimator.setDuration(750); mFocusAnimator.start(); } else if (isRunning) { // Restore the background color int currentColor = mBackgroundColor; ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor, mCurrentPrimaryColor); backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); mBackgroundColorDrawable.setColor(color); mBackgroundColor = color; } }); // Restore the translation ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 0f); mFocusAnimator = new AnimatorSet(); mFocusAnimator.playTogether(backgroundColor, translation); mFocusAnimator.setDuration(150); mFocusAnimator.start(); } }
From source file:com.stasbar.knowyourself.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();/*from www. j a v a 2 s . co m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock); mCurrentHourColor = UiDataModel.getUiDataModel().getWindowBackgroundColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LogUtils.e(LOGTAG, "Error displaying alarm for intent: %s", getIntent()); finish();/* w ww. ja va 2s . c o m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LogUtils.i(LOGTAG, "Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // In order to allow tablets to freely rotate and phones to stick // with "nosensor" (use default device orientation) we have to have // the manifest start with an orientation of unspecified" and only limit // to "nosensor" for phones. Otherwise we get behavior like in b/8728671 // where tablets start off in their default orientation and then are // able to freely rotate. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(this, digitalClock); mCurrentHourColor = Utils.getCurrentHourColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LogUtils.e(LOGTAG, "Error displaying alarm for intent: %s", getIntent()); finish();// w w w. ja v a 2 s . c o m return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LogUtils.i(LOGTAG, "Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LogUtils.i(LOGTAG, "Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = PreferenceManager.getDefaultSharedPreferences(this) .getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // In order to allow tablets to freely rotate and phones to stick // with "nosensor" (use default device orientation) we have to have // the manifest start with an orientation of unspecified" and only limit // to "nosensor" for phones. Otherwise we get behavior like in b/8728671 // where tablets start off in their default orientation and then are // able to freely rotate. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); // final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final TextTime digitalClock = (TextTime) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(this, digitalClock); mCurrentHourColor = Utils.getCurrentHourColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.androidinspain.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_ALARM); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();//from www . ja va 2s . c o m return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = DataModel.getDataModel().getAlarmVolumeButtonBehavior(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(com.androidinspain.deskclock.R.bool.rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(com.androidinspain.deskclock.R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(com.androidinspain.deskclock.R.id.alert_info); mContentView = (ViewGroup) findViewById(com.androidinspain.deskclock.R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(com.androidinspain.deskclock.R.id.dismiss); mHintView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(com.androidinspain.deskclock.R.id.title); final TextClock digitalClock = (TextClock) mContentView .findViewById(com.androidinspain.deskclock.R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView .findViewById(com.androidinspain.deskclock.R.id.pulse); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock, false); mCurrentHourColor = ThemeUtils.resolveColor(this, android.R.attr.windowBackground); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); }
From source file:com.wizardsofm.deskclock.alarms.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final long instanceId = AlarmInstance.getId(getIntent().getData()); mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId); if (mAlarmInstance == null) { // The alarm was deleted before the activity got created, so just finish() LOGGER.e("Error displaying alarm for intent: %s", getIntent()); finish();/*from w ww. j a v a2 s . c o m*/ return; } else if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) { LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance); finish(); return; } LOGGER.i("Displaying alarm for instance: %s", mAlarmInstance); // Get the volume/camera button behavior setting mVolumeBehavior = Utils.getDefaultSharedPreferences(this).getString(SettingsActivity.KEY_VOLUME_BUTTONS, SettingsActivity.DEFAULT_VOLUME_BEHAVIOR); getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD | FLAG_KEEP_SCREEN_ON | FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON); // Hide navigation bar to minimize accidental tap on Home key hideNavigationBar(); // Close dialogs and window shade, so this is fully visible sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); // Honor rotation on tablets; fix the orientation on phones. if (!getResources().getBoolean(R.bool.config_rotateAlarmAlert)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE); setContentView(R.layout.alarm_activity); mAlertView = (ViewGroup) findViewById(R.id.alert); mAlertTitleView = (TextView) mAlertView.findViewById(R.id.alert_title); mAlertInfoView = (TextView) mAlertView.findViewById(R.id.alert_info); mContentView = (ViewGroup) findViewById(R.id.content); mAlarmButton = (ImageView) mContentView.findViewById(R.id.alarm); mSnoozeButton = (ImageView) mContentView.findViewById(R.id.snooze); mDismissButton = (ImageView) mContentView.findViewById(R.id.dismiss); mHintView = (TextView) mContentView.findViewById(R.id.hint); final TextView titleView = (TextView) mContentView.findViewById(R.id.title); final TextClock digitalClock = (TextClock) mContentView.findViewById(R.id.digital_clock); final CircleView pulseView = (CircleView) mContentView.findViewById(R.id.pulse); // PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); // PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); // wakeLock.acquire(); // // // // KeyguardManager keyguardManager = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); // KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG"); // keyguardLock.disableKeyguard(); titleView.setText(mAlarmInstance.getLabelOrDefault(this)); Utils.setTimeFormat(digitalClock); mCurrentHourColor = UiDataModel.getUiDataModel().getWindowBackgroundColor(); getWindow().setBackgroundDrawable(new ColorDrawable(mCurrentHourColor)); mAlarmButton.setOnTouchListener(this); mSnoozeButton.setOnClickListener(this); mDismissButton.setOnClickListener(this); mAlarmAnimator = AnimatorUtils.getScaleAnimator(mAlarmButton, 1.0f, 0.0f); mSnoozeAnimator = getButtonAnimator(mSnoozeButton, Color.WHITE); mDismissAnimator = getButtonAnimator(mDismissButton, mCurrentHourColor); mPulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(CircleView.RADIUS, 0.0f, pulseView.getRadius()), PropertyValuesHolder.ofObject(CircleView.FILL_COLOR, AnimatorUtils.ARGB_EVALUATOR, ColorUtils.setAlphaComponent(pulseView.getFillColor(), 0))); mPulseAnimator.setDuration(PULSE_DURATION_MILLIS); mPulseAnimator.setInterpolator(PULSE_INTERPOLATOR); mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); mPulseAnimator.start(); if (DataModel.getDataModel().getSnoozeByVoice()) { startListening(); } // if (DataModel.getDataModel().getSnoozeByVoice()) { // thisContext = this; // Thread t1 = new Thread(new Runnable() { // public void run() { // mSpeechRecognizerManager = SpeechRecognizerManager.getInstance(thisContext); //new SpeechRecognizerManager(thisContext); // } // }); // t1.start(); // // } }
From source file:com.microsoft.mimickeralarm.ringing.AlarmRingingFragment.java
private void initializeClockAnimation(View view) { // Show a growing clock and then shrinking again repeatedly PropertyValuesHolder scaleXAnimation = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 1.2f, 1f); PropertyValuesHolder scaleYAnimation = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 1.2f, 1f); mClockAnimation = ObjectAnimator.ofPropertyValuesHolder(mAlarmRingingClock, scaleXAnimation, scaleYAnimation);// w w w .j ava 2 s .co m mClockAnimation.setDuration(CLOCK_ANIMATION_DURATION); mClockAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); mClockAnimation.setRepeatCount(ValueAnimator.INFINITE); mLeftArrowImage = (ImageView) view.findViewById(R.id.alarm_ringing_left_arrow); mLeftArrowImage.setBackgroundResource(R.drawable.ringing_left_arrow_animation); mRightArrowImage = (ImageView) view.findViewById(R.id.alarm_ringing_right_arrow); mRightArrowImage.setBackgroundResource(R.drawable.ringing_right_arrow_animation); mLeftArrowAnimation = (AnimationDrawable) mLeftArrowImage.getBackground(); mRightArrowAnimation = (AnimationDrawable) mRightArrowImage.getBackground(); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override public boolean onTouch(View view, MotionEvent motionEvent) { if (mAlarmHandled) { LogUtils.v(LOGTAG, "onTouch ignored: %s", motionEvent); return false; }/*from www . j a v a 2 s . co m*/ final int[] contentLocation = { 0, 0 }; mContentView.getLocationOnScreen(contentLocation); final float x = motionEvent.getRawX() - contentLocation[0]; final float y = motionEvent.getRawY() - contentLocation[1]; final int alarmLeft = mAlarmButton.getLeft() + mAlarmButton.getPaddingLeft(); final int alarmRight = mAlarmButton.getRight() - mAlarmButton.getPaddingRight(); final float snoozeFraction, dismissFraction; if (mContentView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); } setAnimatedFractions(snoozeFraction, dismissFraction); switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: LogUtils.v(LOGTAG, "onTouch started: %s", motionEvent); // Stop the pulse, allowing the last pulse to finish. mPulseAnimator.setRepeatCount(0); break; case MotionEvent.ACTION_UP: LogUtils.v(LOGTAG, "onTouch ended: %s", motionEvent); if (snoozeFraction == 1.0f) { snooze(); } else if (dismissFraction == 1.0f) { dismiss(); } else { if (snoozeFraction > 0.0f || dismissFraction > 0.0f) { // Animate back to the initial state. AnimatorUtils.reverse(mAlarmAnimator, mSnoozeAnimator, mDismissAnimator); } else if (mAlarmButton.getTop() <= y && y <= mAlarmButton.getBottom()) { // User touched the alarm button, hint the dismiss action hintDismiss(); } // Restart the pulse. mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); if (!mPulseAnimator.isStarted()) { mPulseAnimator.start(); } } break; case MotionEvent.ACTION_CANCEL: resetAnimations(); break; default: break; } return true; }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
@Override public boolean onTouch(View view, MotionEvent motionEvent) { if (mAlarmHandled) { LogUtils.v(LOGTAG, "onTouch ignored: %s", motionEvent); return false; }// w ww . j a v a 2 s. co m final int[] contentLocation = { 0, 0 }; mContentView.getLocationOnScreen(contentLocation); final float x = motionEvent.getRawX() - contentLocation[0]; final float y = motionEvent.getRawY() - contentLocation[1]; final int alarmLeft = mAlarmButton.getLeft() + mAlarmButton.getPaddingLeft(); final int alarmRight = mAlarmButton.getRight() - mAlarmButton.getPaddingRight(); final float snoozeFraction, dismissFraction; if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); } // API >= 17 /*if (mContentView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); }*/ setAnimatedFractions(snoozeFraction, dismissFraction); switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: LogUtils.v(LOGTAG, "onTouch started: %s", motionEvent); // Stop the pulse, allowing the last pulse to finish. mPulseAnimator.setRepeatCount(0); break; case MotionEvent.ACTION_UP: LogUtils.v(LOGTAG, "onTouch ended: %s", motionEvent); if (snoozeFraction == 1.0f) { snooze(); } else if (dismissFraction == 1.0f) { dismiss(); } else { if (snoozeFraction > 0.0f || dismissFraction > 0.0f) { // Animate back to the initial state. AnimatorUtils.reverse(mAlarmAnimator, mSnoozeAnimator, mDismissAnimator); } else if (mAlarmButton.getTop() <= y && y <= mAlarmButton.getBottom()) { // User touched the alarm button, hint the dismiss action hintDismiss(); } // Restart the pulse. mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); if (!mPulseAnimator.isStarted()) { mPulseAnimator.start(); } } break; case MotionEvent.ACTION_CANCEL: resetAnimations(); break; default: break; } return true; }