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.xfzbd.cqi.widget.srl.ShyaringanSwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*  ww  w . ja v  a 2  s. co  m*/
 * @param attrs
 */
public ShyaringanSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mLinearInterpolator = new LinearInterpolator();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density);
    mTotalDragDistance = mSpinnerOffsetEnd;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);

    mOriginalOffsetTop = mCurrentTargetOffsetTop = -mCircleDiameter;
    moveToStart(1.0f);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}

From source file:com.taobao.weex.dom.action.AnimationAction.java

private @Nullable Interpolator createTimeInterpolator() {
    String interpolator = mAnimationBean.timingFunction;
    if (!TextUtils.isEmpty(interpolator)) {
        switch (interpolator) {
        case WXAnimationBean.EASE_IN:
            return new AccelerateInterpolator();
        case WXAnimationBean.EASE_OUT:
            return new DecelerateInterpolator();
        case WXAnimationBean.EASE_IN_OUT:
            return new AccelerateDecelerateInterpolator();
        case WXAnimationBean.LINEAR:
            return new LinearInterpolator();
        default:/*  ww w .j  a  v  a  2s  .  c o m*/
            //Parse cubic-bezier
            try {
                SingleFunctionParser<Float> parser = new SingleFunctionParser<>(mAnimationBean.timingFunction,
                        new SingleFunctionParser.FlatMapper<Float>() {
                            @Override
                            public Float map(String raw) {
                                return Float.parseFloat(raw);
                            }
                        });
                List<Float> params = parser.parse(WXAnimationBean.CUBIC_BEZIER);
                if (params != null && params.size() == WXAnimationBean.NUM_CUBIC_PARAM) {
                    return PathInterpolatorCompat.create(params.get(0), params.get(1), params.get(2),
                            params.get(3));
                } else {
                    return null;
                }
            } catch (RuntimeException e) {
                return null;
            }
        }
    }
    return null;
}

From source file:com.wii.sean.wiimmfiitus.adapters.CustomWiiCyclerViewAdapter.java

private Animation getBlinkAnimation() {
    Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);//from w  ww.j  av  a 2  s.  c  om
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);

    return animation;
}

From source file:com.example.volunteerhandbook.MainActivity.java

void loopNewBox(LinearLayout iBox) {
    if (lastone <= 1) {
        show_what_I_thought();//  w  w  w  .j  a v a 2  s.  c o m
        return;
    }
    if (iTh > 3 * thoughts.length + 2) {
        lastone--;
        return;
    }
    float bH = (int) (1.2 * iBox.getHeight());
    iBox.removeAllViews();
    for (int i = 0; i < thoughts.length / 4; i++) {
        iBox.addView(toMove[iTh++ % thoughts.length]);
    }
    //toMove.setTranslationY(600);
    //container.addView(textBox);
    iBox.setX(20);
    iBox.setY(2 * bH);
    //hBox += iBox.getHeight();
    float startY = iBox.getY();
    endY = (-1) * bH;
    int duration = 20000;
    ValueAnimator bounceAnim = ObjectAnimator.ofFloat(iBox, "y", startY, endY);
    bounceAnim.setDuration(duration);
    bounceAnim.setInterpolator(new LinearInterpolator());
    final LinearLayout fBox = iBox;
    bounceAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            loopNewBox(fBox);
        }
    });
    bounceAnim.start();
}

From source file:me.lizheng.deckview.views.DeckChildView.java

/**
 * Animates the deletion of this task view
 *///w  w  w .  ja va 2s .  c  o  m
void startDeleteTaskAnimation(final Runnable r) {
    // Disabling clipping with the stack while the view is animating away
    setClipViewInStack(false);
    ValueAnimator anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, getSize());
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(100);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setClipViewInStack(true);

            setTouchEnabled(true);
            r.run();
        }
    });
    anim.start();
}

From source file:com.gigamole.library.NavigationTabBar.java

public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB// w  ww . j  a v a  2 s.c  om

    // Always draw
    setWillNotDraw(false);
    // More speed!
    setLayerType(LAYER_TYPE_HARDWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));
        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX));
        setBadgePosition(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, RIGHT_INDEX));
        setBadgeGravity(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, TOP_INDEX));
        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0f));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null)
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);

                for (String previewColor : previewColors)
                    mModels.add(new Model(null, Color.parseColor(previewColor)));
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:talex.zsw.baselibrary.widget.NavigationTabBar.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public NavigationTabBar(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init NTB//from ww w.j av  a 2 s  . c o m

    // Always draw
    setWillNotDraw(false);
    // More speed!
    setLayerType(LAYER_TYPE_HARDWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NavigationTabBar);
    try {
        setIsScaled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_scaled, false));
        setIsTitled(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_titled, false));
        setIsBadged(typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badged, false));
        setIsBadgeUseTypeface(
                typedArray.getBoolean(R.styleable.NavigationTabBar_ntb_badge_use_typeface, false));
        setTitleMode(typedArray.getInt(R.styleable.NavigationTabBar_ntb_title_mode, ALL_INDEX));
        setBadgePosition(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_position, RIGHT_INDEX));
        setBadgeGravity(typedArray.getInt(R.styleable.NavigationTabBar_ntb_badge_gravity, TOP_INDEX));
        setTypeface(typedArray.getString(R.styleable.NavigationTabBar_ntb_typeface));
        setInactiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_inactive_color, DEFAULT_INACTIVE_COLOR));
        setActiveColor(
                typedArray.getColor(R.styleable.NavigationTabBar_ntb_active_color, DEFAULT_ACTIVE_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.NavigationTabBar_ntb_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setCornersRadius(typedArray.getDimension(R.styleable.NavigationTabBar_ntb_corners_radius, 0.0f));

        // Init animator
        mAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
        mAnimator.setInterpolator(new LinearInterpolator());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(final ValueAnimator animation) {
                updateIndicatorPosition((Float) animation.getAnimatedValue());
            }
        });

        // Set preview models
        if (isInEditMode()) {
            // Get preview colors
            String[] previewColors = null;
            try {
                final int previewColorsId = typedArray
                        .getResourceId(R.styleable.NavigationTabBar_ntb_preview_colors, 0);
                previewColors = previewColorsId == 0 ? null
                        : typedArray.getResources().getStringArray(previewColorsId);
            } catch (Exception exception) {
                previewColors = null;
                exception.printStackTrace();
            } finally {
                if (previewColors == null) {
                    previewColors = typedArray.getResources().getStringArray(R.array.default_preview);
                }

                for (String previewColor : previewColors) {
                    mModels.add(new Model(null, Color.parseColor(previewColor)));
                }
                requestLayout();
            }
        }
    } finally {
        typedArray.recycle();
    }
}

From source file:ca.zadrox.dota2esportticker.ui.LiveContentView.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_live_stats);

    mMaxHeaderElevation = getResources().getDimensionPixelSize(R.dimen.session_detail_max_header_elevation);

    mScrollView = (ObservableScrollView) findViewById(R.id.game_scroll_view);
    mScrollView.addCallbacks(this);
    ViewTreeObserver vto = mScrollView.getViewTreeObserver();
    if (vto.isAlive()) {
        vto.addOnGlobalLayoutListener(mGlobalLayoutListener);
    }//from   w w  w  . ja  va  2 s  . c o m

    mScrollViewChild = findViewById(R.id.game_scroll_view_child);

    mDetailsContainer = findViewById(R.id.game_details_container);

    mDetailsContainer.setAlpha(0);
    mDetailsContainer.setY(1200);

    mHeaderBox = findViewById(R.id.header_game);
    mGameViewContainer = findViewById(R.id.game_photo_container);

    mGameImageView = (ImageView) findViewById(R.id.game_photo);
    mGameTimeView = (TextView) findViewById(R.id.game_time_view);
    mGameScoreViewLeft = (TextView) findViewById(R.id.game_score_view_left);
    mGameScoreViewRight = (TextView) findViewById(R.id.game_score_view_right);
    tickerLayout = (LinearLayout) findViewById(R.id.sidedrawer);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mTitle = (TextView) findViewById(R.id.header_title);
    mSubtitle = (TextView) findViewById(R.id.header_subtitle);
    mUpdateProgressBar = (ProgressBar) findViewById(R.id.header_progressbar);

    mapView = (ImageView) findViewById(R.id.game_map_view);
    mHasPhoto = true;
    mGameImageView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY);

    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();

    Picasso.with(this).load(R.drawable.drawable_dota_bg_dire_ancient).config(Bitmap.Config.ARGB_8888)
            .resize(Math.round(displayMetrics.widthPixels * PHOTO_ASPECT_RATIO * 2 / 3),
                    displayMetrics.widthPixels * 2 / 3)
            .transform(new CropImageTransform(displayMetrics.heightPixels, displayMetrics.widthPixels))
            .into(mGameImageView);

    setBundleContents();
    initMapView();

    mPresenter = new LiveStatsPresenter(this);
    mLiveTickerAdapter = new LiveTickerAdapter(this, R.layout.sidedrawer_list_item);

    if (savedInstanceState != null) {
        mLiveTickerAdapter.onRestoreInstanceState(savedInstanceState);
        gameCompleted = savedInstanceState.getBoolean(KEY_GAME_COMPLETE, false);
    }

    mDrawerListView = (ListView) findViewById(R.id.sidedrawer_items_list);
    mDrawerListView.setAdapter(mLiveTickerAdapter);

    mUpdateProgressAnim = new ProgressBarAnimation(mUpdateProgressBar, 2000, 0);
    mUpdateProgressAnim.setDuration(GAME_UPDATE_INTERVAL);
    mUpdateProgressAnim.setInterpolator(new LinearInterpolator());

    if (!PrefUtils.hasLiveDrawerBeenShown(this)) {
        mDrawerLayout.openDrawer(Gravity.END);
        Toast.makeText(this, "Match events are shown in the right drawer", Toast.LENGTH_SHORT).show();
        PrefUtils.setLiveDrawerShown(this);
    }
}

From source file:com.gitstudy.rili.liarbry.CalendarView.java

/**
 * /*from  w  ww.j  av  a 2  s  .  c o m*/
 *  showYearSelectLayout(final int year) ?
 *
 * @param year 
 */
private void showSelectLayout(final int year) {
    if (mParentLayout != null && mParentLayout.mContentView != null) {
        if (!mParentLayout.isExpand()) {
            mParentLayout.expand();
            return;
        }
    }
    mWeekPager.setVisibility(GONE);
    mDelegate.isShowYearSelectedLayout = true;
    if (mParentLayout != null) {
        mParentLayout.hideContentView();
    }
    mWeekBar.animate().translationY(-mWeekBar.getHeight()).setInterpolator(new LinearInterpolator())
            .setDuration(260).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mWeekBar.setVisibility(GONE);
                    mSelectLayout.setVisibility(VISIBLE);
                    mSelectLayout.scrollToYear(year, false);
                    if (mParentLayout != null && mParentLayout.mContentView != null) {
                        mParentLayout.expand();
                    }
                }
            });

    mMonthPager.animate().scaleX(0).scaleY(0).setDuration(260).setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                }
            });
}

From source file:org.bart452.runningshoesensor.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    requestPermission();/*www  .  ja v a  2  s  .c om*/
    context = getApplicationContext();

    mHeaderImageView = (ImageView) findViewById(R.id.appBarIv);
    Picasso.with(context).load(R.drawable.sunset_road_landscape).into(mHeaderImageView);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.toolBar);
    setSupportActionBar(mToolbar);
    mCollapsingTb = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
    mCollapsingTb.setTitle("Shoe sensor");
    mCollapsingTb.setExpandedTitleGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);

    // Bluetooth
    final BluetoothManager mBleMan = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBleAdapter = mBleMan.getAdapter();
    mBleScanner = mBleAdapter.getBluetoothLeScanner();
    mCharList = new ArrayList<>();
    mBleSem = new Semaphore(1);
    mBleThread = new BleThread(mBleSem);
    mBleThread.start();

    mBleReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
                if (mBleAdapter.getState() == BluetoothAdapter.STATE_ON) {
                    Log.d(LOG_TAG, "BT ON");
                    mScanFab.setEnabled(true);
                    if (mSnackBar != null) {
                        if (mSnackBar.isShown())
                            mSnackBar.dismiss();
                    }
                } else {
                    mScanFab.setEnabled(false);
                    bleEnable();
                }
            }
        }
    };

    // Text
    mDevNameTv = (TextView) findViewById(R.id.devNameTv);
    mDevNameTv.setText(getString(R.string.device_name) + " No device found");
    mRssiTv = (TextView) findViewById(R.id.rssiTv);
    mAddrTv = (TextView) findViewById(R.id.devAddrTv);

    // Buttons and switches
    mScanFab = (FloatingActionButton) findViewById(R.id.scanFab);
    mScanFab.setOnClickListener(this);
    mConnSwitch = (Switch) findViewById(R.id.connSwitch);
    mConnSwitch.setOnClickListener(this);

    //Graph
    mDataGraph = (GraphView) findViewById(R.id.dataGraph);
    mDataXSeries = new LineGraphSeries<>();
    mDataYSeries = new LineGraphSeries<>();
    mDataYSeries.setBackgroundColor(Color.RED);
    mDataGraph.addSeries(mDataXSeries);
    mDataGraph.addSeries(mDataYSeries);
    mDataGraph.getViewport().setXAxisBoundsManual(true);
    mDataGraph.getViewport().setMinX(0);
    mDataGraph.getViewport().setMaxX(20);

    // Animation
    mRotateAnim = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    mRotateAnim.setDuration(SCAN_PERIOD);
    mRotateAnim.setInterpolator(new LinearInterpolator());
    bleEnable();
}