Java Code Examples for android.view.animation.AnimationUtils#loadAnimation()

The following examples show how to use android.view.animation.AnimationUtils#loadAnimation() . 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: StartActivity.java    From FriendBook with GNU General Public License v3.0 6 votes vote down vote up
private void initDisPlay() {
    tvSkip = findViewById(R.id.tv_skip);
    tvSkip.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            skip();
        }
    });
    View contentView = findViewById(R.id.content_view);
    if (DisplayUtil.hasVirtualNavigationBar(this)) {
        contentView.setPadding(0, 0, 0, DisplayUtil.getNavigationBarHeight(this));
    }
    TextView tvVersionName = findViewById(R.id.tv_version_name);
    tvVersionName.setText(BuildConfig.VERSION_NAME);
    LinearLayout llWelcome = (LinearLayout) findViewById(R.id.ll_welcome);
    TextView tvDate = findViewById(R.id.tv_date);
    SimpleDateFormat format2 = new SimpleDateFormat("yyyy年MM月dd日,EEEE");
    tvDate.setText(format2.format(new Date()));
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha_in);
    llWelcome.startAnimation(animation);
}
 
Example 2
Source File: ToDayStateFragment.java    From ToDay with MIT License 6 votes vote down vote up
/**
 * Produces animation, sets text to finish
 */
@Override
public void onFinish() {
    if (activityStateFlag.equals(AppConstants.FS_NOTIFICATION_ACTIVE)) {
        mNotifyMgr.notify(
                AppConstants.FLOW_STATE_NOTIFICATION_ID,
                mNotify
                        .setContentText(
                                getString(R.string.fs_task_finish_msg)
                        )
                        .setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
                        .build()
        );
    }
    progressBar.setProgress(0);
    Animation fadeInAnimation = AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in);
    timeDisplay.setText(getString(R.string.fs_task_finish_msg));
    timeDisplay.setAnimation(fadeInAnimation);

    TextView notFinished = (TextView) getView().findViewById(R.id.fragment_fe_not_finished);
    notFinished.setVisibility(View.VISIBLE);
    notFinished.startAnimation(fadeInAnimation);
}
 
Example 3
Source File: SwipeBackFragment.java    From SwipeBackFragment with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        boolean isSupportHidden = savedInstanceState.getBoolean(SWIPEBACKFRAGMENT_STATE_SAVE_IS_HIDDEN);

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        if (isSupportHidden) {
            ft.hide(this);
        } else {
            ft.show(this);
        }
        ft.commit();
    }

    mNoAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.no_anim);
    onFragmentCreate();
}
 
Example 4
Source File: ReceiveActivity.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 5
Source File: MainActivity.java    From android-fab-animations with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    fab = (FloatingActionButton)findViewById(R.id.fab);
    fab1 = (FloatingActionButton)findViewById(R.id.fab1);
    fab2 = (FloatingActionButton)findViewById(R.id.fab2);
    fab_open = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_open);
    fab_close = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fab_close);
    rotate_forward = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_forward);
    rotate_backward = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_backward);
    fab.setOnClickListener(this);
    fab1.setOnClickListener(this);
    fab2.setOnClickListener(this);
}
 
Example 6
Source File: AlertList.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alert_list);
    mContext = getApplicationContext();
    listViewLow = (ListView) findViewById(R.id.listView_low);
    listViewHigh = (ListView) findViewById(R.id.listView_high);
    prefs =  PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);

    addListenerOnButton();
    FillLists();
    anim = AnimationUtils.loadAnimation(this, R.anim.fade_anim);
    listViewLow.setOnItemLongClickListener(new AlertsOnItemLongClickListener());
    listViewHigh.setOnItemLongClickListener(new AlertsOnItemLongClickListener());
}
 
Example 7
Source File: EntryHolder.java    From Aegis with GNU General Public License v3.0 5 votes vote down vote up
public EntryHolder(final View view) {
    super(view);

    _view = view.findViewById(R.id.rlCardEntry);

    _profileName = view.findViewById(R.id.profile_account_name);
    _profileCode = view.findViewById(R.id.profile_code);
    _profileIssuer = view.findViewById(R.id.profile_issuer);
    _profileCopied = view.findViewById(R.id.profile_copied);
    _description = view.findViewById(R.id.description);
    _profileDrawable = view.findViewById(R.id.ivTextDrawable);
    _buttonRefresh = view.findViewById(R.id.buttonRefresh);
    _selected = view.findViewById(R.id.ivSelected);
    _selectedHandler = new Handler();
    _animationHandler = new Handler();

    _progressBar = view.findViewById(R.id.progressBar);
    int primaryColorId = view.getContext().getResources().getColor(R.color.colorPrimary);
    _progressBar.getProgressDrawable().setColorFilter(primaryColorId, PorterDuff.Mode.SRC_IN);
    _view.setBackground(_view.getContext().getResources().getDrawable(R.color.card_background));

    _scaleIn = AnimationUtils.loadAnimation(view.getContext(), R.anim.item_scale_in);
    _scaleOut = AnimationUtils.loadAnimation(view.getContext(), R.anim.item_scale_out);

    _refresher = new UiRefresher(new UiRefresher.Listener() {
        @Override
        public void onRefresh() {
            if (!_hidden) {
                refreshCode();
            }
        }

        @Override
        public long getMillisTillNextRefresh() {
            return ((TotpInfo) _entry.getInfo()).getMillisTillNextRotation();
        }
    });
}
 
Example 8
Source File: JokeAdapter.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
protected void setAnimation(View viewToAnimate, int position) {
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(viewToAnimate.getContext(), R
                .anim.item_bottom_in);
        viewToAnimate.startAnimation(animation);
        lastPosition = position;
    }
}
 
Example 9
Source File: AnimationViewBehavior.java    From simple-view-behavior with MIT License 5 votes vote down vote up
public AnimationViewBehavior(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewBehavior);
    int animationId = a.getResourceId(R.styleable.ViewBehavior_behavior_animation, 0);
    a.recycle();

    if (animationId != 0) {
        mAnimation = AnimationUtils.loadAnimation(context, animationId);
    }
}
 
Example 10
Source File: SimpleBookListDetailActivity.java    From a with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void bindView() {


    //设置为垂直的样式
    recycler_view_list.setLayoutManager(new LinearLayoutManager(this));
    //使用的是系统默认的分割线
    //recycler_view_list.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
    //设置适配器
    recycler_view_list.setAdapter(adapter=new SimpleBookListDetailAdapter(this));
    recycler_view_list.setNestedScrollingEnabled(false);
    //设置默认动画
    recycler_view_list.setItemAnimator(new DefaultItemAnimator());

    final Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
    adapter.setOnItemClickListener(new SimpleBookListDetailAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            view.startAnimation(animation);
            // Toast.makeText(mContext, position + " click",
            //        Toast.LENGTH_SHORT).show();

            RecommendBookBean recommendBookBean = adapter.getDataList().get(position);
            Intent intent = new Intent(getContext(), MyMainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            String key = String.valueOf(System.currentTimeMillis());
            intent.putExtra("recommendBook", recommendBookBean.getTitle());

            startActivityByAnim(intent, android.R.anim.fade_in, android.R.anim.fade_out);

        }
    });
}
 
Example 11
Source File: TransactionAdapter.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private void setAnimation(View viewToAnimate, int position) {
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(context, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_bottom);
        viewToAnimate.startAnimation(animation);
        lastPosition = position;
    }
}
 
Example 12
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 13
Source File: SongsListAdapter.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
private void setAnimation(View viewToAnimate, int position) {
    // If the bound view wasn't previously displayed on screen, it's animated
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.abc_slide_in_bottom);
        viewToAnimate.startAnimation(animation);
        lastPosition = position;
    }
}
 
Example 14
Source File: AnimUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
     * 开始动画
     *
     * @param context
     * @param resId
     * @param resAnimId
     */
    public static void startAnim(Context context, int resId, int resAnimId) {
//		Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
//		findViewById(R.id.xxx).startAnimation(shake);

        Animation shake = AnimationUtils.loadAnimation(context, resAnimId);
        ((Activity) context).findViewById(resId).startAnimation(shake);
    }
 
Example 15
Source File: TestSmallFragment.java    From Alligator with MIT License 5 votes vote down vote up
@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
	if (getParentFragment() != null && (getParentFragment().isDetached() || getParentFragment().isRemoving())) {
		return AnimationUtils.loadAnimation(getContext(), R.anim.stay);
	}
	return super.onCreateAnimation(transit, enter, nextAnim);
}
 
Example 16
Source File: AnimatingToggle.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public AnimatingToggle(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);
  this.outAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.animation_toggle_out);
  this.inAnimation  = AnimationUtils.loadAnimation(getContext(), R.anim.animation_toggle_in);
  this.outAnimation.setInterpolator(new FastOutSlowInInterpolator());
  this.inAnimation.setInterpolator(new FastOutSlowInInterpolator());
}
 
Example 17
Source File: ShowHideOnScroll.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
private void animate(int anim) {
    if(anim != 0) {
        Animation a = AnimationUtils.loadAnimation(this.view.getContext(), anim);
        a.setAnimationListener(this);
        this.view.startAnimation(a);
        this.setIgnore(true);
    }

}
 
Example 18
Source File: BaseDialogActivity.java    From q-municate-android with Apache License 2.0 4 votes vote down vote up
private void animateCanceling() {
    Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
    bucketView.startAnimation(shake);
}
 
Example 19
Source File: PullToRefreshAttacher.java    From endpoints-codelab-android with GNU General Public License v3.0 4 votes vote down vote up
protected PullToRefreshAttacher(Activity activity, Options options) {
	if (options == null) {
		Log.i(LOG_TAG, "Given null options so using default options.");
		options = new Options();
	}

	mRefreshableViews = new WeakHashMap<View, ViewParams>();

	// Copy necessary values from options
	mRefreshScrollDistance = options.refreshScrollDistance;
	mRefreshOnUp = options.refreshOnUp;
	mRefreshMinimizeDelay = options.refreshMinimizeDelay;
	mRefreshMinimize = options.refreshMinimize;

	// EnvironmentDelegate
	mEnvironmentDelegate = options.environmentDelegate != null ? options.environmentDelegate
			: createDefaultEnvironmentDelegate();

	// Header Transformer
	mHeaderTransformer = options.headerTransformer != null ? options.headerTransformer
			: createDefaultHeaderTransformer();

	// Create animations for use later
	mHeaderInAnimation = AnimationUtils.loadAnimation(activity,
			options.headerInAnimation);
	mHeaderOutAnimation = AnimationUtils.loadAnimation(activity,
			options.headerOutAnimation);
	if (mHeaderOutAnimation != null || mHeaderInAnimation != null) {
		final AnimationCallback callback = new AnimationCallback();
		if (mHeaderInAnimation != null)
			mHeaderInAnimation.setAnimationListener(callback);
		if (mHeaderOutAnimation != null)
			mHeaderOutAnimation.setAnimationListener(callback);
	}

	// Get touch slop for use later
	mTouchSlop = ViewConfiguration.get(activity).getScaledTouchSlop();

	// Get Window Decor View
	final ViewGroup decorView = (ViewGroup) activity.getWindow()
			.getDecorView();

	// Check to see if there is already a Attacher view installed
	if (decorView.getChildCount() == 1
			&& decorView.getChildAt(0) instanceof DecorChildLayout) {
		throw new IllegalStateException(
				"View already installed to DecorView. This shouldn't happen.");
	}

	// Create Header view and then add to Decor View
	mHeaderView = LayoutInflater.from(
			mEnvironmentDelegate.getContextForInflater(activity)).inflate(
			options.headerLayout, decorView, false);
	if (mHeaderView == null) {
		throw new IllegalArgumentException(
				"Must supply valid layout id for header.");
	}
	mHeaderView.setVisibility(View.GONE);

	// Create DecorChildLayout which will move all of the system's decor
	// view's children + the
	// Header View to itself. See DecorChildLayout for more info.
	DecorChildLayout decorContents = new DecorChildLayout(activity,
			decorView, mHeaderView);

	// Now add the DecorChildLayout to the decor view
	decorView.addView(decorContents, ViewGroup.LayoutParams.MATCH_PARENT,
			ViewGroup.LayoutParams.MATCH_PARENT);

	// Notify transformer
       mHeaderTransformer.onViewCreated(activity, mHeaderView);
       // TODO Remove the follow deprecated method call before v1.0
	mHeaderTransformer.onViewCreated(mHeaderView);
}
 
Example 20
Source File: StandOutWindow.java    From LogcatViewer with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Return the animation to play when the window corresponding to the id is
 * shown.
 * 
 * @param id
 *            The id of the window.
 * @return The animation to play or null.
 */
public Animation getShowAnimation(int id) {
	return AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
}