Example usage for android.view.animation LinearInterpolator LinearInterpolator

List of usage examples for android.view.animation LinearInterpolator LinearInterpolator

Introduction

In this page you can find the example usage for android.view.animation LinearInterpolator LinearInterpolator.

Prototype

public LinearInterpolator() 

Source Link

Usage

From source file:com.example.waitou.rxjava.LoadingView.java

/**
 * set the animator's interpolator/*w  w  w  .j av a 2  s. com*/
 *
 * @param style
 */
public void setProgressStyle(int style) {
    switch (style) {
    case PROGRESS_STYLE_MATERIAL:
        interpolator = new FastOutSlowInInterpolator();
        break;
    case PROGRESS_STYLE_LINEAR:
        interpolator = new LinearInterpolator();
        break;
    }
}

From source file:com.cloverstudio.spika.SpikaApp.java

@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;
    mPreferences = new Preferences(this);
    mPreferences.clearFlagsForTutorialEachBoot(getApplicationContext().getPackageName());
    gOpenFromBackground = true;//from  w w w  .  ja va 2 s .com
    mFileDir = new FileDir(this);

    ImageLoader.initImageLoaderInstance(this);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create typefaces
    mTfMyriadPro = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    mTfMyriadProBold = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf");

    setTransportBasedOnScreenDensity(42);

    // Example interpolator; could use linear or accelerate interpolator
    // instead
    final AccelerateDecelerateInterpolator accDecInterpolator = new AccelerateDecelerateInterpolator();
    final LinearInterpolator linearInterpolator = new LinearInterpolator();
    final int slidingDuration = getResources().getInteger(R.integer.sliding_duration);

    // Set up animations
    mSlideInLeft = new TranslateAnimation(-mTransport, 0, 0, 0);
    mSlideInLeft.setDuration(slidingDuration);
    // mSlideInLeft.setFillAfter(true); // hmm not sure
    mSlideInLeft.setFillEnabled(false);
    mSlideInLeft.setInterpolator(linearInterpolator);

    mSlideOutRight = new TranslateAnimation(0, mTransport, 0, 0);
    mSlideOutRight.setDuration(slidingDuration);
    mSlideOutRight.setFillAfter(true);
    mSlideOutRight.setFillEnabled(true);
    mSlideOutRight.setInterpolator(linearInterpolator);

    mSlideOutLeft = new TranslateAnimation(0, -mTransport, 0, 0);
    mSlideOutLeft.setDuration(slidingDuration);
    mSlideOutLeft.setInterpolator(linearInterpolator);

    mSlideInRight = new TranslateAnimation(mTransport, 0, 0, 0);
    mSlideInRight.setDuration(slidingDuration);
    mSlideInRight.setFillAfter(true);
    mSlideInRight.setFillEnabled(true);
    mSlideInRight.setInterpolator(linearInterpolator);

    mSlideFromTop.setFillAfter(true);
    mSlideFromTop.setFillEnabled(true);
    mSlideFromTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideFromTop.setInterpolator(linearInterpolator);

    mSlideOutTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideOutTop.setInterpolator(linearInterpolator);

    String strUUID = UUID.randomUUID().toString();
    Logger.debug("uuid", strUUID);

    mBaseUrl = mPreferences.getUserServerURL();
}

From source file:com.changhong.mscreensynergy.mainui.fragment.ViewPageFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //mInflater = inflater;
    View mView = inflater.inflate(R.layout.view_pager, null);
    showLeft = (Button) mView.findViewById(R.id.showLeft);
    mPager = (ViewPager) mView.findViewById(R.id.pager);
    PageFragment1 page1 = new PageFragment1();
    PageFragment2 page2 = new PageFragment2();
    PageFragment3 page3 = new PageFragment3();
    //      PageFragment4 page4 = new PageFragment4();
    //      PageFragment5 page5 = new PageFragment5();
    pagerItemList.add(page1);// ww w.jav a 2  s  .c o  m
    pagerItemList.add(page2);
    pagerItemList.add(page3);
    //      pagerItemList.add(page4);
    //      pagerItemList.add(page5);
    mAdapter = new MyAdapter(getFragmentManager());
    mPager.setAdapter(mAdapter);
    mPager.setOffscreenPageLimit(3); //3
    mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {

            if (myPageChangeListener != null)
                myPageChangeListener.onPageSelected(position);

            if (rg_nav_content != null && rg_nav_content.getChildCount() > position) {
                ((RadioButton) rg_nav_content.getChildAt(position)).performClick();
            }

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int position) {

        }
    });

    /*
     * ?
     */
    rl_nav = (RelativeLayout) mView.findViewById(R.id.rl_nav);

    mHsv = (SyncHorizontalScrollView) mView.findViewById(R.id.mHsv);

    rg_nav_content = (RadioGroup) mView.findViewById(R.id.rg_nav_content);

    rg_nav_content.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            if (rg_nav_content.getChildAt(checkedId) != null) {

                TranslateAnimation animation = new TranslateAnimation(currentIndicatorLeft,
                        ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft(), 0f, 0f);
                animation.setInterpolator(new LinearInterpolator());
                animation.setDuration(100);
                animation.setFillAfter(true);

                //?
                iv_nav_indicator.startAnimation(animation);

                mPager.setCurrentItem(checkedId); //ViewPager ? ?

                //? ? ?
                currentIndicatorLeft = ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft();

                mHsv.smoothScrollTo(
                        (checkedId > 1 ? ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft() : 0)
                                - ((RadioButton) rg_nav_content.getChildAt(2)).getLeft(),
                        0);
            }
        }
    });

    iv_nav_indicator = (ImageView) mView.findViewById(R.id.iv_nav_indicator);
    iv_nav_left = (ImageView) mView.findViewById(R.id.iv_nav_left);
    iv_nav_right = (ImageView) mView.findViewById(R.id.iv_nav_right);

    LayoutParams cursor_Params = iv_nav_indicator.getLayoutParams();
    cursor_Params.width = indicatorWidth;// ?
    iv_nav_indicator.setLayoutParams(cursor_Params);

    mHsv.setSomeParam(rl_nav, iv_nav_left, iv_nav_right, SlidingActivity.scontext);

    mInflater = (LayoutInflater) SlidingActivity.scontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    indicatorWidth = SlidingMenu.screenWidth / 4;

    initNavigationHSV();

    return mView;
}

From source file:com.ape.emoji.keyboard.emoji.EmojiKeyboard.java

void animateView(View view) {
    view.animate().setInterpolator(new LinearInterpolator()).alpha(150).setDuration(300).start();
}

From source file:pl.rmakowiecki.simplemusicplayer.ui.widget.MusicCoverView.java

public MusicCoverView(Context context, AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    // Canvas.clipPath works wrong when running with hardware acceleration on Android N
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }/*  ww  w .  j  av  a 2  s .co  m*/

    final float density = getResources().getDisplayMetrics().density;
    mTrackSize = TRACK_SIZE * density;
    mTrackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTrackPaint.setStyle(Paint.Style.STROKE);
    mTrackPaint.setStrokeWidth(TRACK_WIDTH * density);

    mStartRotateAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, FULL_ANGLE);
    mStartRotateAnimator.setInterpolator(new LinearInterpolator());
    mStartRotateAnimator.setRepeatCount(Animation.INFINITE);
    mStartRotateAnimator.setDuration(DURATION);
    mStartRotateAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            float current = getRotation();
            float target = current > HALF_ANGLE ? FULL_ANGLE : 0; // Choose the shortest distance to 0 rotation
            float diff = target > 0 ? FULL_ANGLE - current : current;
            mEndRotateAnimator.setFloatValues(current, target);
            mEndRotateAnimator.setDuration((int) (DURATION_PER_DEGREES * diff));
            mEndRotateAnimator.start();
        }
    });

    mEndRotateAnimator = ObjectAnimator.ofFloat(MusicCoverView.this, View.ROTATION, 0);
    mEndRotateAnimator.setInterpolator(new LinearInterpolator());
    mEndRotateAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setRotation(0);
            // isRunning method return true if it's called form here.
            // So we need call from post method to get the right returning.
            post(new Runnable() {
                @Override
                public void run() {
                    if (mCallbacks != null) {
                        mCallbacks.onRotateEnd(MusicCoverView.this);
                    }
                }
            });
        }
    });

    mRectToCircleTransition = new MorphTransition(SHAPE_RECTANGLE);
    mRectToCircleTransition.addTarget(this);
    mRectToCircleTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_CIRCLE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });

    mCircleToRectTransition = new MorphTransition(SHAPE_CIRCLE);
    mCircleToRectTransition.addTarget(this);
    mCircleToRectTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_RECTANGLE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MusicCoverView);
    @Shape
    int shape = a.getInt(R.styleable.MusicCoverView_cover_shape, SHAPE_RECTANGLE);
    @ColorInt
    int trackColor = a.getColor(R.styleable.MusicCoverView_trackColor, TRACK_COLOR);
    a.recycle();

    setShape(shape);
    setTrackColor(trackColor);
    setScaleType();
}

From source file:de.grobox.liberario.ui.LocationInputGPSView.java

public void activateGPS() {
    if (isSearching())
        return;/*from  w  w w.j  a v  a  2  s .c  om*/

    // check permissions
    if (ContextCompat.checkSelfPermission(context,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // we don't have a permission, so store the information that we are requesting it
        request_permission = true;

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(context,
                Manifest.permission.ACCESS_FINE_LOCATION)) {
            Toast.makeText(context, R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
        } else {
            // No explanation needed, we can request the permission
            ActivityCompat.requestPermissions(context,
                    new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller);
        }

        return;
    }

    // we arrive here only once we have got the permission and are not longer requesting it
    request_permission = false;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {

        locationManager.removeUpdates(this);
        Toast.makeText(context, context.getResources().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        return;
    }

    // clear input
    //noinspection deprecation
    setLocation(null, context.getResources().getDrawable(R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.setAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    searching = true;
}

From source file:com.cloverstudio.spikademo.SpikaApp.java

@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;
    mPreferences = new Preferences(this);
    mPreferences.clearFlagsForTutorialEachBoot(getApplicationContext().getPackageName());
    gOpenFromBackground = true;//  ww w .  ja v a  2 s .co m
    mFileDir = new FileDir(this);

    ImageLoader.initImageLoaderInstance(this);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create typefaces
    mTfMyriadPro = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    mTfMyriadProBold = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf");

    setTransportBasedOnScreenDensity(42);

    // Example interpolator; could use linear or accelerate interpolator
    // instead
    final AccelerateDecelerateInterpolator accDecInterpolator = new AccelerateDecelerateInterpolator();
    final LinearInterpolator linearInterpolator = new LinearInterpolator();
    final int slidingDuration = getResources().getInteger(R.integer.sliding_duration);

    // Set up animations
    mSlideInLeft = new TranslateAnimation(-mTransport, 0, 0, 0);
    mSlideInLeft.setDuration(slidingDuration);
    // mSlideInLeft.setFillAfter(true); // hmm not sure
    mSlideInLeft.setFillEnabled(false);
    mSlideInLeft.setInterpolator(linearInterpolator);

    mSlideOutRight = new TranslateAnimation(0, mTransport, 0, 0);
    mSlideOutRight.setDuration(slidingDuration);
    mSlideOutRight.setFillAfter(true);
    mSlideOutRight.setFillEnabled(true);
    mSlideOutRight.setInterpolator(linearInterpolator);

    mSlideOutLeft = new TranslateAnimation(0, -mTransport, 0, 0);
    mSlideOutLeft.setDuration(slidingDuration);
    mSlideOutLeft.setInterpolator(linearInterpolator);

    mSlideInRight = new TranslateAnimation(mTransport, 0, 0, 0);
    mSlideInRight.setDuration(slidingDuration);
    mSlideInRight.setFillAfter(true);
    mSlideInRight.setFillEnabled(true);
    mSlideInRight.setInterpolator(linearInterpolator);

    mSlideFromTop.setFillAfter(true);
    mSlideFromTop.setFillEnabled(true);
    mSlideFromTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideFromTop.setInterpolator(linearInterpolator);

    mSlideOutTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideOutTop.setInterpolator(linearInterpolator);

    String strUUID = UUID.randomUUID().toString();
    Logger.debug("uuid", strUUID);
}

From source file:com.gigigo.vuforiaimplementation.VuforiaActivity.java

private void startBoringAnimation() {
    scanLine.setVisibility(View.VISIBLE);
    // Create animators for y axe
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        int yMax = 0;
        yMax = getResources().getDisplayMetrics().heightPixels; //mVuforiaView.getDisplay().getHeight();
        yMax = (int) (yMax * 0.9);// 174;

        ObjectAnimator oay = ObjectAnimator.ofFloat(scanLine, "translationY", 0, yMax);
        oay.setRepeatCount(Animation.INFINITE);
        oay.setDuration(ANIM_DURATION);//  ww w. j  a v  a2s  . com
        oay.setRepeatMode(Animation.REVERSE);

        oay.setInterpolator(new LinearInterpolator());
        oay.start();

        //for draw points near scanline
        markFakeFeaturePoint.setObjectAnimator(oay);
    }

    //scanAnimation.

}

From source file:org.centum.android.play.PlayCardView.java

private void init() {
    titleTextView = (TextView) findViewById(R.id.title_textView);
    detailsTextView = (TextView) findViewById(R.id.details_textView);
    imageView = (ImageView) findViewById(R.id.imageView);
    correctBtn = (ImageButton) findViewById(R.id.correct_imageButton);
    wrongBtn = (ImageButton) findViewById(R.id.wrong_imageButton);
    playRelativeLayout = (RelativeLayout) findViewById(R.id.play_relativelayout);
    detailsScrollView = (ScrollView) findViewById(R.id.details_scrollView);

    int titleTextSize = 30;
    int detailsTextSize = 22;
    try {/*  w  w  w  .  j av  a2 s.c o  m*/
        titleTextSize = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getContext())
                .getString(SettingsActivity.KEY_PREF_PLAY_TITLE_SIZE, "30"));
    } catch (Exception e) {
        PreferenceManager.getDefaultSharedPreferences(getContext()).edit()
                .putString(SettingsActivity.KEY_PREF_PLAY_TITLE_SIZE, "30").commit();
    }
    try {
        detailsTextSize = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getContext())
                .getString(SettingsActivity.KEY_PREF_PLAY_DETAILS_SIZE, "22"));
    } catch (Exception e) {
        PreferenceManager.getDefaultSharedPreferences(getContext()).edit()
                .putString(SettingsActivity.KEY_PREF_PLAY_DETAILS_SIZE, "22").commit();
    }

    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, titleTextSize);
    detailsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, detailsTextSize);

    autoAdvance = PreferenceManager.getDefaultSharedPreferences(getContext())
            .getBoolean(SettingsActivity.KEY_PREF_PLAY_AUTO_ADVANCE, false);

    detailsAnimator = new ObjectAnimator();
    detailsAnimator.setTarget(detailsTextView);
    detailsAnimator.setPropertyName("alpha");
    detailsAnimator.setDuration(100);
    detailsAnimator.setInterpolator(new LinearInterpolator());

    correctAnimator = new ObjectAnimator();
    correctAnimator.setTarget(correctBtn);
    correctAnimator.setPropertyName("alpha");
    correctAnimator.setDuration(100);
    correctAnimator.setInterpolator(new LinearInterpolator());

    wrongAnimator = new ObjectAnimator();
    wrongAnimator.setTarget(wrongBtn);
    wrongAnimator.setPropertyName("alpha");
    wrongAnimator.setDuration(100);
    wrongAnimator.setInterpolator(new LinearInterpolator());

    setThemeParams();

    detailsScrollView.setOnClickListener(this);
    detailsTextView.setOnClickListener(this);
    playRelativeLayout.setOnClickListener(this);
    correctBtn.setOnClickListener(this);
    wrongBtn.setOnClickListener(this);
    imageView.setOnClickListener(this);
    setOnClickListener(this);
}

From source file:com.snappy.SpikaApp.java

@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;
    /*For test purposes, we change this method*/
    mPreferences = new Preferences(this);

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    /*end of new method*/

    gOpenFromBackground = true;/*from w ww .  j a  v  a2 s  .  co  m*/
    mFileDir = new FileDir(this);

    ImageLoader.initImageLoaderInstance(this);

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    // Create typefaces
    mTfMyriadPro = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    mTfMyriadProBold = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf");

    setTransportBasedOnScreenDensity(42);

    // Example interpolator; could use linear or accelerate interpolator
    // instead
    final AccelerateDecelerateInterpolator accDecInterpolator = new AccelerateDecelerateInterpolator();
    final LinearInterpolator linearInterpolator = new LinearInterpolator();
    final int slidingDuration = getResources().getInteger(R.integer.sliding_duration);

    // Set up animations
    mSlideInLeft = new TranslateAnimation(-mTransport, 0, 0, 0);
    mSlideInLeft.setDuration(slidingDuration);
    // mSlideInLeft.setFillAfter(true); // hmm not sure
    mSlideInLeft.setFillEnabled(false);
    mSlideInLeft.setInterpolator(linearInterpolator);

    mSlideOutRight = new TranslateAnimation(0, mTransport, 0, 0);
    mSlideOutRight.setDuration(slidingDuration);
    mSlideOutRight.setFillAfter(true);
    mSlideOutRight.setFillEnabled(true);
    mSlideOutRight.setInterpolator(linearInterpolator);

    mSlideOutLeft = new TranslateAnimation(0, -mTransport, 0, 0);
    mSlideOutLeft.setDuration(slidingDuration);
    mSlideOutLeft.setInterpolator(linearInterpolator);

    mSlideInRight = new TranslateAnimation(mTransport, 0, 0, 0);
    mSlideInRight.setDuration(slidingDuration);
    mSlideInRight.setFillAfter(true);
    mSlideInRight.setFillEnabled(true);
    mSlideInRight.setInterpolator(linearInterpolator);

    mSlideFromTop.setFillAfter(true);
    mSlideFromTop.setFillEnabled(true);
    mSlideFromTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideFromTop.setInterpolator(linearInterpolator);

    mSlideOutTop.setDuration(this.getResources().getInteger(android.R.integer.config_mediumAnimTime));
    mSlideOutTop.setInterpolator(linearInterpolator);

    String strUUID = UUID.randomUUID().toString();
    Logger.debug("uuid", strUUID);

    mBaseUrl = mPreferences.getUserServerURL();

    sContext = getApplicationContext();
}