android.view.animation.AnimationUtils Java Examples

The following examples show how to use android.view.animation.AnimationUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainNavigationActivity.java    From beaconloc with Apache License 2.0 6 votes vote down vote up
public void hideFab() {
    fab.clearAnimation();
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.hide_fab);
    fab.startAnimation(animation);

    CoordinatorLayout.LayoutParams params =
            (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
    FloatingActionButton.Behavior behavior =
            (FloatingActionButton.Behavior) params.getBehavior();

    if (behavior != null) {
        behavior.setAutoHideEnabled(false);
    }

    fab.hide();
}
 
Example #2
Source File: ImagePreviewActivity.java    From ImagePicker with Apache License 2.0 6 votes vote down vote up
/**
     * 单击时,隐藏头和尾
     */
    @Override
    public void onImageSingleTap() {
        if (topBar.getVisibility() == View.VISIBLE) {
            topBar.setAnimation(AnimationUtils.loadAnimation(this, R.anim.top_out));
            bottomBar.setAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));
            topBar.setVisibility(View.GONE);
            bottomBar.setVisibility(View.GONE);
            tintManager.setStatusBarTintResource(Color.TRANSPARENT);//通知栏所需颜色
            //给最外层布局加上这个属性表示,Activity全屏显示,且状态栏被隐藏覆盖掉。
//            if (Build.VERSION.SDK_INT >= 16) content.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        } else {
            topBar.setAnimation(AnimationUtils.loadAnimation(this, R.anim.top_in));
            bottomBar.setAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
            topBar.setVisibility(View.VISIBLE);
            bottomBar.setVisibility(View.VISIBLE);
            tintManager.setStatusBarTintResource(R.color.ip_color_primary_dark);//通知栏所需颜色
            //Activity全屏显示,但状态栏不会被隐藏覆盖,状态栏依然可见,Activity顶端布局部分会被状态遮住
//            if (Build.VERSION.SDK_INT >= 16) content.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    }
 
Example #3
Source File: BrowserActivity.java    From EFRConnect-android with Apache License 2.0 6 votes vote down vote up
public void showConnectingAnimation() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            scanningGradientContainer.setVisibility(View.GONE);

            Animation connectingGradientAnimation = AnimationUtils.loadAnimation(BrowserActivity.this,
                    R.anim.connection_translate_right);
            connectingContainer.setVisibility(View.VISIBLE);
            connectingGradientContainer.startAnimation(connectingGradientAnimation);
            Animation connectingBarFlyIn = AnimationUtils.loadAnimation(BrowserActivity.this,
                    R.anim.scanning_bar_fly_in);
            connectingBarContainer.startAnimation(connectingBarFlyIn);
        }
    });
}
 
Example #4
Source File: AnimatedButtonView.java    From braintree-android-drop-in with MIT License 6 votes vote down vote up
private void init(AttributeSet attrs) {
    if (isInEditMode()) {
        return;
    }

    LayoutInflater.from(getContext()).inflate(R.layout.bt_animated_button_view, this);

    mViewAnimator = findViewById(R.id.bt_view_animator);
    mButton = findViewById(R.id.bt_button);
    mButton.setOnClickListener(this);

    mViewAnimator.setInAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in));
    mViewAnimator.setOutAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out));

    TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.bt_AnimatedButtonAttributes);
    mButton.setText(attributes.getString(R.styleable.bt_AnimatedButtonAttributes_bt_buttonText));
    attributes.recycle();

    setFocusable(true);
    setFocusableInTouchMode(true);
}
 
Example #5
Source File: MainGameActivity.java    From Trivia-Knowledge with Apache License 2.0 6 votes vote down vote up
public void incorrectAnimation() {
    incorrect.setVisibility(View.VISIBLE);
    //Animation
    final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);
    //Use bounce interpolator with amplitude 0.2 and frequency 20
    MyBounceInterpolator interpolator = new MyBounceInterpolator(0.1, 60);
    myAnim.setInterpolator(interpolator);
    incorrect.startAnimation(myAnim);
    final Handler handler = new Handler();
    Runnable runnable = new Runnable() {
        public void run() {
            incorrect.setVisibility(View.INVISIBLE);  //for interval...
        }
    };
    handler.postDelayed(runnable, 100); //for initial delay..*/
}
 
Example #6
Source File: DictionarySettingsFragment.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
void stopLoadingAnimation() {
    final View preferenceView = getView();
    final Activity activity = getActivity();
    if (null == activity) return;
    final View loadingView = mLoadingView;
    final MenuItem updateNowMenu = mUpdateNowMenu;
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            loadingView.setVisibility(View.GONE);
            preferenceView.setVisibility(View.VISIBLE);
            loadingView.startAnimation(AnimationUtils.loadAnimation(
                    activity, android.R.anim.fade_out));
            preferenceView.startAnimation(AnimationUtils.loadAnimation(
                    activity, android.R.anim.fade_in));
            // The menu is created by the framework asynchronously after the activity,
            // which means it's possible to have the activity running but the menu not
            // created yet - hence the necessity for a null check here.
            if (null != updateNowMenu) {
                updateNowMenu.setTitle(R.string.check_for_updates_now);
            }
        }
    });
}
 
Example #7
Source File: SendScreen.java    From smartcoins-wallet with MIT License 6 votes vote down vote up
private void updateBlockNumberHead() {
    final Handler handler = new Handler();

    final Activity myActivity = this;

    final Runnable updateTask = new Runnable() {
        @Override
        public void run() {
            if (Application.isConnected()) {
                ivSocketConnected.setImageResource(R.drawable.icon_connecting);
                tvBlockNumberHead.setText(Application.blockHead);
                ivSocketConnected.clearAnimation();
            } else {
                ivSocketConnected.setImageResource(R.drawable.icon_disconnecting);
                Animation myFadeInAnimation = AnimationUtils.loadAnimation(myActivity.getApplicationContext(), R.anim.flash);
                ivSocketConnected.startAnimation(myFadeInAnimation);
            }
            handler.postDelayed(this, 1000);
        }
    };
    handler.postDelayed(updateTask, 1000);
}
 
Example #8
Source File: LocaleAwareFragment.java    From focus-android with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation animation = super.onCreateAnimation(transit, enter, nextAnim);
    if (animation == null && nextAnim != 0) {
        try {
            animation = AnimationUtils.loadAnimation(getActivity(), nextAnim);
        } catch (Resources.NotFoundException e) {
            return null;
        }
    }

    if (animation != null) {
        final AnimationSet animSet = new AnimationSet(true);
        animSet.addAnimation(animation);
        this.animationSet = animSet;
        return animSet;
    } else {
        return null;
    }
}
 
Example #9
Source File: SummaryView.java    From px-android with MIT License 6 votes vote down vote up
public void animateExit(final int duration) {
    final Animation fadeOut = AnimationUtils.loadAnimation(getContext(), R.anim.px_fade_out);
    fadeOut.setDuration(duration);

    if (showingBigLogo) {
        bigHeaderDescriptor.startAnimation(fadeOut);
    } else {
        toolbarElementDescriptor.startAnimation(
            AnimationUtils.loadAnimation(getContext(), R.anim.px_summary_slide_up_out));
    }

    detailRecyclerView.startAnimation(fadeOut);

    findViewById(R.id.separator).startAnimation(fadeOut);

    startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.px_summary_translate_out));

    totalAmountDescriptor.startAnimation(fadeOut);
}
 
Example #10
Source File: VelocityScroller.java    From Muzesto with GNU General Public License v3.0 6 votes vote down vote up
public void notifyFinalPositionExtended(int position) {
    mOver = 0;
    mFinished = false;
    mDuration = mDuration - (int) (mStartTime - AnimationUtils.currentAnimationTimeMillis());

    if (mDuration < 50) {
        mDuration = 50;
    }

    mSplineDuration = mDuration;

    mStartTime = AnimationUtils.currentAnimationTimeMillis();
    mStart = mCurrentPosition;
    mFinal = position;

    mState = SPLINE;

    mSplineDistance = mFinal - mStart;
}
 
Example #11
Source File: ImagePreviewDelActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
/** 单击时,隐藏头和尾 */
    @Override
    public void onImageSingleTap() {
        if (topBar.getVisibility() == View.VISIBLE) {
            topBar.setAnimation(AnimationUtils.loadAnimation(this, R.anim.atom_ui_top_out));
            topBar.setVisibility(View.GONE);
            tintManager.setStatusBarTintResource(Color.TRANSPARENT);//通知栏所需颜色
            //给最外层布局加上这个属性表示,Activity全屏显示,且状态栏被隐藏覆盖掉。
//            if (Build.VERSION.SDK_INT >= 16) content.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        } else {
            topBar.setAnimation(AnimationUtils.loadAnimation(this, R.anim.atom_ui_top_in));
            topBar.setVisibility(View.VISIBLE);
            tintManager.setStatusBarTintResource(R.color.ip_color_primary_dark);//通知栏所需颜色
            //Activity全屏显示,但状态栏不会被隐藏覆盖,状态栏依然可见,Activity顶端布局部分会被状态遮住
//            if (Build.VERSION.SDK_INT >= 16) content.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    }
 
Example #12
Source File: ScrollAwareFABBehavior.java    From MaoWanAndoidClient with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);

    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();

    }
    else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);

    }
}
 
Example #13
Source File: LoadingBananaPeelView.java    From AndroidReusableUI with MIT License 6 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    hadAttrs = (attrs != null);
    if (attrs != null) {
        TypedArray styledAttributes = getContext().getApplicationContext().obtainStyledAttributes(attrs, R.styleable.LoadingBananaPeelView);

        // Load the resource IDs for each property from the styled attributes set
        bananaPeelContentViewLayoutResourceId = styledAttributes.getResourceId(R.styleable.LoadingBananaPeelView_bananaPeelContentViewLayoutResource, 0);
        bananaPeelViewResourceId = styledAttributes.getResourceId(R.styleable.LoadingBananaPeelView_bananaPeelViewResource, 0);
        bananaPeelDefaultMessageResourceId = styledAttributes.getResourceId(R.styleable.LoadingBananaPeelView_bananaPeelDefaultMessageStringResource, 0);
        bananaPeelDefaultImageResourceId = styledAttributes.getResourceId(R.styleable.LoadingBananaPeelView_bananaPeelDefaultImageResource, 0);

        // Set the default animations for changing between View Flipper children
        this.setAnimateFirstView(false);
        this.setInAnimation(AnimationUtils.loadAnimation(context, R.anim.abc_fade_in));
        this.setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.abc_fade_out));

        styledAttributes.recycle();
    }
}
 
Example #14
Source File: MainActivity.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
public void animationsAndTransitions(View view) {
    switch (view.getId()) {
        case R.id.image_circle:
            Intent intent = new Intent(this, MainActivity.class);
            Explode explode = new Explode();
            explode.setDuration(400);
            getWindow().setExitTransition(explode);
            intent.putExtra(ANIMATION, EXPLODE_ANIMATION);
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this);
            startActivity(intent, options.toBundle());
            break;

        case R.id.image_line:
            Intent intent2 = new Intent(this, MainActivity.class);
            intent2.putExtra(ANIMATION, FADE_TRANSITION);
            Fade fade = new Fade();
            fade.setDuration(400);
            getWindow().setExitTransition(fade);
            startActivity(intent2,
                    ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
            break;

        case R.id.image_square:
            Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_rotate);
            mYellowSquare.startAnimation(rotateAnimation);
            break;

        case R.id.image_android:
            Intent intent3 = new Intent(MainActivity.this, SecondActivity.class);
            ActivityOptions options2 = ActivityOptions.makeSceneTransitionAnimation(this,
                    Pair.create((View) mGreenAndroid, "swap_shared_transition_android_icon"),
                    Pair.create((View) mYellowSquare, "swap_shared_transition_square")
            );
            startActivity(intent3, options2.toBundle());
            break;

        default:
            break;
    }
}
 
Example #15
Source File: AutoHomeListView.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
private void init(Context context) {
	setOverScrollMode(View.OVER_SCROLL_NEVER);
	setOnScrollListener(this);

	this.mHeaderView = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.imitateautohome_header, null, false);
	this.mAutoHome = ViewFinder.findViewById(mHeaderView, R.id.sdi_autohome);
	this.mPullToRefreshTV = ViewFinder.findViewById(mHeaderView, R.id.sdi_pulltorefresh_tv);
	mAnimContainer = ViewFinder.findViewById(mHeaderView, R.id.sdi_animcontainer_fl);
	mAutoHomeAnim = ViewFinder.findViewById(mHeaderView, R.id.sdi_animpointer_iv);

	mAnimation = AnimationUtils.loadAnimation(context, R.anim.sda_autohome_pointer_rotate);

	measureView(mHeaderView);
	addHeaderView(mHeaderView);
	mHeaderViewHeight = mHeaderView.getMeasuredHeight();
	mHeaderView.setPadding(0, -mHeaderViewHeight, 0, 0);

	mState = DONE;
	mIsEnd = true;
	mIsRefreable = false;
}
 
Example #16
Source File: UnderlabelValidatorTest.java    From AwesomeValidation with MIT License 6 votes vote down vote up
public void testReplaceView() throws Exception {
    EditText mockEditText = mock(EditText.class);
    ViewGroup mockViewGroup = mock(ViewGroup.class);
    LinearLayout mockNewContainer = mock(LinearLayout.class);
    int mockInt = PowerMockito.mock(Integer.class);
    TextView mockTextView = mock(TextView.class);
    PowerMockito.mockStatic(AnimationUtils.class);
    when(mMockValidationHolder.getEditText()).thenReturn(mockEditText);
    when(mMockValidationHolder.getErrMsg()).thenReturn(PowerMockito.mock(String.class));
    when(mockEditText.getParent()).thenReturn(mockViewGroup);
    when(mockViewGroup.indexOfChild(mockEditText)).thenReturn(mockInt);
    when(mockEditText.getPaddingLeft()).thenReturn(PowerMockito.mock(Integer.class));
    when(mockEditText.getPaddingRight()).thenReturn(PowerMockito.mock(Integer.class));
    PowerMockito.whenNew(LinearLayout.class).withArguments(mMockContext).thenReturn(mockNewContainer);
    PowerMockito.whenNew(TextView.class).withArguments(mMockContext).thenReturn(mockTextView);
    PowerMockito.when(AnimationUtils.loadAnimation(any(Context.class), anyInt())).thenReturn(mock(Animation.class));
    assertEquals(mockTextView, Whitebox.invokeMethod(mSpiedUnderlabelValidator, "replaceView", mMockValidationHolder));
    verify(mockViewGroup).addView(mockNewContainer, mockInt);
}
 
Example #17
Source File: ContactSelectActivity.java    From weMessage with GNU Affero General Public License v3.0 6 votes vote down vote up
private void invalidateField(final EditText editText){
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), getResources().getColor(R.color.colorHeader), getResources().getColor(R.color.brightRed));
    colorAnimation.setDuration(200);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            editText.setTextColor((int) animation.getAnimatedValue());
        }
    });

    Animation invalidShake = AnimationUtils.loadAnimation(this, R.anim.invalid_shake);
    invalidShake.setInterpolator(new CycleInterpolator(7F));

    colorAnimation.start();
    editText.startAnimation(invalidShake);
}
 
Example #18
Source File: LoginFragment.java    From mosby with Apache License 2.0 6 votes vote down vote up
@Override public void showError() {

    viewState.setShowError();

    setFormEnabled(true);
    loginButton.setProgress(0);

    if (!isRestoringViewState()) {
      // Enable animations only if not restoring view state
      loginForm.clearAnimation();
      Animation shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
      loginForm.startAnimation(shake);
    }

    errorView.setVisibility(View.VISIBLE);
  }
 
Example #19
Source File: AnimUtils.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
public static Interpolator getFastOutSlowInInterpolator(Context context) {
    if (fastOutSlowIn == null) {
        fastOutSlowIn = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_slow_in);
    }
    return fastOutSlowIn;
}
 
Example #20
Source File: FileExplorerFragment.java    From rcloneExplorer with MIT License 5 votes vote down vote up
private void hideBottomBar() {
    View bottomBar = ((FragmentActivity) context).findViewById(R.id.bottom_bar);
    if (bottomBar.getVisibility() != View.VISIBLE) {
        return;
    }
    Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.fade_out_animation);
    bottomBar.setAnimation(animation);
    bottomBar.setVisibility(View.GONE);
}
 
Example #21
Source File: ParallaxHeader.java    From LiveSourceCode with Apache License 2.0 5 votes vote down vote up
private void initialize() {
    LayoutInflater.from(getContext()).inflate(R.layout.refresh_parallax, this);
    setBackgroundColor(ContextCompat.getColor(getContext(), R.color.refresh_background));

    mIvBack1 = (ImageView) findViewById(R.id.iv_background_1);
    mIvBack2 = (ImageView) findViewById(R.id.iv_background_2);
    mIvIcon = (ImageView) findViewById(R.id.iv_refresh_icon);

    mAnimationDrawable = (AnimationDrawable) mIvIcon.getDrawable();
    mBackAnim1 = AnimationUtils.loadAnimation(getContext(), R.anim.refresh_down_background_1);
    mBackAnim2 = AnimationUtils.loadAnimation(getContext(), R.anim.refresh_down_background_2);
}
 
Example #22
Source File: LogOnActivity.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
void registerEvent()
{
    if (mTencent == null) {
        mTencent = Tencent.createInstance(SharePanelView.QQ_API_ID, this);
    }
    mLogOnButton.setOnClickListener(this);
    mRegisterButton.setOnClickListener(this);
    tv_find_password.setOnClickListener(this);
    tv_quick_log_on.setOnClickListener(this);
    final Animation arrowRight2Down = AnimationUtils.loadAnimation(this,R.anim.rotate_arrow_right_to_down);
    final Animation arrowDown2Right = AnimationUtils.loadAnimation(this,R.anim.rotate_arrow_down_to_right);
    mLogOnButton.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mLogOnButton.setAnimation(arrowRight2Down);
            arrowRight2Down.startNow();
            arrowRight2Down.setFillAfter(true);
        }
    });
    passwordEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if(hasFocus){
                arrowRight2Down.cancel();
                mLogOnButton.clearAnimation();
                mLogOnButton.setAnimation(arrowDown2Right);
                arrowDown2Right.startNow();
                arrowDown2Right.setFillAfter(true);
            }
        }
    });
}
 
Example #23
Source File: CustomSwipeBaseAdapter.java    From custom-swipelistview with Apache License 2.0 5 votes vote down vote up
/**
 * set the animation {@link anim} to the specified view by
 * {@link #mHasDeletedPosition} when the specified view exectuing the undo
 * action.
 *
 * @param itemView
 * @param undoPosition
 */
private void setItemUndoActionAnimation(View itemView, int undoPosition) {
    if (undoPosition == mHasDeletedPosition && undoAnimationEnable) {
        itemView.startAnimation(AnimationUtils.loadAnimation(mContext,
                R.anim.undodialog_push_right_in));
        clearDeletedObject();
    } else {
        itemView.clearAnimation();
    }
}
 
Example #24
Source File: TimeAnimator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void setCurrentPlayTime(long playTime) {
    long currentTime = AnimationUtils.currentAnimationTimeMillis();
    mStartTime = Math.max(mStartTime, currentTime - playTime);
    mStartTimeCommitted = true; // do not allow start time to be compensated for jank
    animateBasedOnTime(currentTime);
}
 
Example #25
Source File: ChooseModeActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAnimationEnd(Animator animation) {
    Animation anim = AnimationUtils.loadAnimation(ChooseModeActivity.this,
            R.anim.choose_mode_grow);
    anim.setDuration(AnimGrowDuration);
    anim.setAnimationListener(new ModeGrowAnimatorListener(BitherjSettings.AppMode.COLD));
    vCold.startAnimation(anim);
}
 
Example #26
Source File: Binder.java    From Android-Shortify with Apache License 2.0 5 votes vote down vote up
public static Animation bindAnimation(int resId){
    Resources res = sActivity.getResources();
    String resourceName = res.getResourceTypeName(resId);
    if(resourceName.equalsIgnoreCase("anim")) {
        return AnimationUtils.loadAnimation(sActivity, resId);
    }else{
        return null;
    }
}
 
Example #27
Source File: MainListAdapter.java    From Passbook with Apache License 2.0 5 votes vote down vote up
void markAll(ListView listView) {
    int firstVisible = listView.getFirstVisiblePosition();
    int lastVisible = listView.getLastVisiblePosition();
    int pos;
    for(pos = 0; pos < firstVisible; ++pos) {
        mChecked.set(pos, true);
    }
    for(pos = lastVisible + 1; pos < mChecked.size(); ++pos) {
        mChecked.set(pos, true);
    }
    mCheckCount += (mChecked.size() - lastVisible - 1);
    for(pos = firstVisible; pos <= lastVisible; ++pos) {
        View v = listView.getChildAt(pos);
        if(v!=null) {
            ViewHolder holder = (ViewHolder) v.getTag();
            Animation anim1 = AnimationUtils.loadAnimation(mContext, R.anim.shrink_to_middle);
            Animation anim2 = AnimationUtils.loadAnimation(mContext, R.anim.expand_from_middle);
            holder.mIconView.clearAnimation();
            holder.mIconView.setAnimation(anim1);
            holder.mIconView.startAnimation(anim1);

            AnimationListener listener = getAnimListener(v, holder.mIconView, pos, anim1, anim2);
            anim1.setAnimationListener(listener);
            anim2.setAnimationListener(listener);
        }
    }
}
 
Example #28
Source File: SmoothOverScroller.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
/**
 * Call this when you want to know the new location. If it returns true, the
 * animation is not yet finished.
 */
public boolean computeScrollOffset(Interpolator interpolator) {
    if (mFinished) {
        return false;
    }

    switch (mMode) {
        case SCROLL_MODE:
            long time = AnimationUtils.currentAnimationTimeMillis();
            // Any scroller can be used for time, since they were started
            // together in scroll mode. We use X here.
            final long elapsedTime = time - mStartTime;

            final int duration = mDuration;
            if (elapsedTime < duration) {
                final float q = interpolator.getInterpolation(elapsedTime / (float) duration);
                updateScroll(q);
            } else {
                finish();
            }
            break;

        case FLING_MODE:
            if (!update()) {
                if (!continueWhenFinished()) {
                    finish();
                }
            }

            break;
    }

    return true;
}
 
Example #29
Source File: AppAdapter.java    From Android-PreferencesManager with Apache License 2.0 5 votes vote down vote up
private void updateEmptyView() {
    if (isEmpty()) {
        if (emptyView.getVisibility() == View.GONE) {
            Animation animation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);
            if (animation != null) {
                emptyView.startAnimation(animation);
            }
        }
        emptyView.setVisibility(View.VISIBLE);
    } else {
        emptyView.setVisibility(View.GONE);
    }
}
 
Example #30
Source File: AppsFragment.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public void toggleChecked(boolean checked, AppInfo packageInfo) {
	Log.d(TAG, "toggleChecked " + checked + packageInfo);
	if (checked) {
		selectedInList1.add(packageInfo);
	} else {
		selectedInList1.remove(packageInfo);
	}
	notifyDataSetChanged();
	selectionStatusTV.setText(selectedInList1.size() + "/" + appList.size() + "/" + tempOriDataSourceL1.size());
	boolean all = selectedInList1.size() == appList.size();
	allCbx.setSelected(all);
	if (all) {
		allCbx.setImageResource(R.drawable.ic_accept);
	} else if (selectedInList1.size() > 0) {
		allCbx.setImageResource(R.drawable.ready);
	} else {
		allCbx.setImageResource(R.drawable.dot);
	}
	if (selectedInList1.size() > 0) {
		if (commands.getVisibility() == View.GONE) {
			commands.setAnimation(AnimationUtils.loadAnimation(activity, R.anim.grow_from_bottom));
			commands.setVisibility(View.VISIBLE);
			horizontalDivider6.setVisibility(View.VISIBLE);
		}
	} else if (commands.getVisibility() == View.VISIBLE) {
		horizontalDivider6.setVisibility(View.GONE);
		commands.setAnimation(AnimationUtils.loadAnimation(activity, R.anim.shrink_from_top));
		commands.setVisibility(View.GONE);
	}
}