Example usage for android.animation ObjectAnimator ofInt

List of usage examples for android.animation ObjectAnimator ofInt

Introduction

In this page you can find the example usage for android.animation ObjectAnimator ofInt.

Prototype

public static <T> ObjectAnimator ofInt(T target, Property<T, Integer> xProperty, Property<T, Integer> yProperty,
        Path path) 

Source Link

Document

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

Usage

From source file:Main.java

public static void backgroundToGrey(View view) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", 0xffffffff, 0xffbdbdbd);
    animator.setDuration(1);/*  w w w  .  j  a va2  s  .  com*/
    animator.start();
}

From source file:Main.java

public static void backgroundToWhite(View view) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", 0xffbdbdbd, 0xffffffff);
    animator.setDuration(1);/* w  w w  . ja  v a 2s  .  co  m*/
    animator.start();
}

From source file:Main.java

public static void animateColorChange(View view, int fromColor, int toColor, int duration,
        Animator.AnimatorListener listener) {
    if (view.getWindowToken() == null) {
        return;/*  w  ww  . ja va 2s .c  o m*/
    }
    AnimatorSet animation = new AnimatorSet();
    ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor);
    colorAnimator.setEvaluator(new ArgbEvaluator());
    colorAnimator.setDuration(duration);
    if (listener != null)
        animation.addListener(listener);
    animation.play(colorAnimator);
    animation.start();
}

From source file:Main.java

public static void animateTextViewMaxLinesChange(final TextView textView, final int maxLines,
        final int duration) {
    final int startHeight = textView.getMeasuredHeight();
    textView.setMaxLines(maxLines);/* w  w  w  . j  a  v a 2  s. c  om*/
    textView.measure(View.MeasureSpec.makeMeasureSpec(textView.getWidth(), View.MeasureSpec.EXACTLY),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    final int endHeight = textView.getMeasuredHeight();
    ObjectAnimator animation = ObjectAnimator.ofInt(textView, MAX_HEIGHT_ATTR, startHeight, endHeight);
    animation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (textView.getMaxHeight() == endHeight) {
                textView.setMaxLines(maxLines);
            }
        }
    }

    );
    animation.setDuration(duration).start();
}

From source file:com.actinarium.kinetic.ui.RecordFragment.java

@Override
public void onClick(View v) {
    if (!mIsRecording) {
        // Start recording
        mIsRecording = true;/*from w  w  w .j  a va2 s.  c o  m*/
        mRecordButton.setImageDrawable(getResources().getDrawable(R.drawable.ic_pause));
        mRecorder.startRecording();

        mAnimator = ObjectAnimator.ofInt(mProgress, "level", 0, 10000)
                .setDuration(DataRecorder.DEFAULT_RECORDING_TIME_MILLIS);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.start();
    } else {
        // End animation quickly
        mAnimator.end();

        // Stop recording - the drawable and the boolean will be updated in a callback method
        mRecorder.stop();
    }
}

From source file:com.google.samples.apps.topeka.widget.TextResizeTransition.java

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }/*w  w w.j  a  va 2s  .  com*/

    float initialTextSize = (float) startValues.values.get(PROPERTY_NAME_TEXT_RESIZE);
    float targetTextSize = (float) endValues.values.get(PROPERTY_NAME_TEXT_RESIZE);
    TextView targetView = (TextView) endValues.view;
    targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, initialTextSize);

    int initialPaddingStart = (int) startValues.values.get(PROPERTY_NAME_PADDING_RESIZE);
    int targetPaddingStart = (int) endValues.values.get(PROPERTY_NAME_PADDING_RESIZE);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(targetView, ViewUtils.PROPERTY_TEXT_SIZE, initialTextSize, targetTextSize),
            ObjectAnimator.ofInt(targetView, ViewUtils.PROPERTY_TEXT_PADDING_START, initialPaddingStart,
                    targetPaddingStart));
    return animatorSet;
}

From source file:org.catrobat.paintroid.ui.BottomBar.java

private void delayedAnimateSelectedTool(int startDelay) {
    ImageButton button = getToolButtonByToolType(mCurrentToolType);
    int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated);
    int fadedColor = color & 0x00ffffff;
    ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(500);//from w  w w  . ja  v  a 2 s.  c o  m
    valueAnimator.setRepeatCount(5);
    valueAnimator.setRepeatMode(ValueAnimator.REVERSE);
    valueAnimator.setStartDelay(startDelay);
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (PaintroidApplication.currentTool != null) {
                setActivatedToolButton(PaintroidApplication.currentTool.getToolType());
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    valueAnimator.start();
}

From source file:com.oprisnik.navdrawer.NavDrawerActivity.java

public void animateStatusBarBackgroundColor(int fromColor, int toColor) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
        mStatusBarColorAnimator = null;// w w  w.  j av a2s  . c o  m
    }

    if (mDrawerLayout != null) {
        mStatusBarColorAnimator = ObjectAnimator.ofInt(mDrawerLayout, "statusBarBackgroundColor", fromColor,
                toColor);
        mStatusBarColorAnimator.setDuration(200);
        mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            mStatusBarColorAnimator = ValueAnimator.ofArgb(fromColor, toColor);
            mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @TargetApi(Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    final int val = (Integer) animation.getAnimatedValue();
                    getWindow().setStatusBarColor(val);
                }
            });
        }
    }
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.start();
    }
}

From source file:com.stepstone.stepper.internal.widget.ColorableProgressBar.java

public void setProgressCompat(int progress, boolean animate) {
    if (animate) {
        final ObjectAnimator animator = ObjectAnimator.ofInt(this, PROGRESS_PROPERTY, getProgress(),
                progress * PROGRESS_RANGE_MULTIPLIER);
        animator.setDuration(PROGRESS_ANIM_DURATION);
        animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
        animator.start();//w w w  .  j  a  v a  2  s  .  co m
    } else {
        setProgress(progress * PROGRESS_RANGE_MULTIPLIER);
    }

}

From source file:com.github.dfa.diaspora_android.activity.DiasporaStreamFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    AppLog.d(this, "StreamFragment.onOptionsItemSelected()");
    ShareUtil shu = new ShareUtil(getContext()).setFileProviderAuthority(BuildConfig.APPLICATION_ID);
    PermissionChecker permc = new PermissionChecker(getActivity());
    switch (item.getItemId()) {
    case R.id.action_reload: {
        if (WebHelper.isOnline(getContext())) {
            reloadUrl();/*from   w w w  .  j a v a 2  s.  co  m*/
            return true;
        } else {
            return false;
        }
    }

    case R.id.action_go_to_top: {
        ObjectAnimator anim = ObjectAnimator.ofInt(webView, "scrollY", webView.getScrollY(), 0);
        anim.setDuration(400);
        anim.start();
        return true;
    }

    case R.id.action_share_link: {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, webView.getTitle());
        sharingIntent.putExtra(Intent.EXTRA_TEXT, webView.getUrl());
        startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_dotdotdot)));
        return true;
    }

    case R.id.action_share_pdf: {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            shu.createPdf(webView, "dandelion-" + ShareUtil.SDF_SHORT.format(new Date()));
        }
        return true;
    }

    case R.id.action_share_link_to_clipboard: {
        shu.setClipboard(webView.getUrl());
        Toast.makeText(getContext(), R.string.link_adress_copied, Toast.LENGTH_SHORT).show();
        return true;
    }

    case R.id.action_create_launcher_shortcut: {
        if (webView.getUrl() != null) {
            Intent intent = new Intent(getContext(), MainActivity.class);
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(webView.getUrl()));
            shu.createLauncherDesktopShortcut(intent, R.drawable.ic_launcher, webView.getTitle());
        }
        return true;
    }

    case R.id.action_take_screenshot: {
        if (permc.doIfExtStoragePermissionGranted(getString(R.string.screenshot_permission__appspecific))) {
            File fileSaveDirectory = appSettings.getAppSaveDirectory();
            if (permc.mkdirIfStoragePermissionGranted(fileSaveDirectory)) {
                Bitmap bmp = ShareUtil.getBitmapFromWebView(webView);
                String filename = "dandelion-" + ShareUtil.SDF_SHORT.format(new Date()) + ".jpg";
                _cu.writeImageToFileJpeg(new File(fileSaveDirectory, filename), bmp);
                Snackbar.make(webView, getString(R.string.saving_screenshot_as) + " " + filename,
                        Snackbar.LENGTH_LONG).show();
            }
        }
        return true;
    }

    case R.id.action_share_screenshot: {
        if (permc.doIfExtStoragePermissionGranted(getString(R.string.screenshot_permission__appspecific))) {
            shu.shareImage(ShareUtil.getBitmapFromWebView(webView), Bitmap.CompressFormat.JPEG);
        }
        return true;
    }
    }
    return super.onOptionsItemSelected(item);
}