Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

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

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:com.megaphone.skoozi.FloatingActionButtonScrollBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = true;
                    }//from www.j a  v a2s  .  co  m

                    public void onAnimationCancel(View view) {
                        FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.evandroid.musica.utils.RefreshButtonBehavior.java

public void animateIn(FloatingActionButton button) {
    if (!button.isEnabled())
        return;/*from  www . j  a v  a 2s  .c om*/
    button.setVisibility(View.VISIBLE);
    visible = true;
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).translationY(0).setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.refresh_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}

From source file:com.megaphone.skoozi.FloatingActionButtonScrollMorphBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = true;
                    }/*  w w  w  .j  ava2s  .  co m*/

                    public void onAnimationCancel(View view) {
                        FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.grarak.kerneladiutor.elements.SplashView.java

public void finish() {
    if (Utils.DARKTHEME)
        mPaintCircle.setColor(ContextCompat.getColor(getContext(), R.color.navigationdrawer_background_dark));
    new Thread(new Runnable() {
        @Override//w  w w  . j a  v  a2 s  .  co  m
        public void run() {
            try {
                for (int i = 1; i <= getHeight() / 2; i += 15) {
                    radius = i;
                    ((Activity) getContext()).runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            invalidate();
                        }
                    });
                    Thread.sleep(17);
                }
                ((Activity) getContext()).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        setVisibility(GONE);
                        finished = true;
                        startAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out));
                    }
                });
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }).start();
}

From source file:com.byteshaft.licenseservice.fragments.QuestionsFragment.java

public void showCurrentQuestion() {
    Animation RightSwipe = AnimationUtils.loadAnimation(getActivity().getApplicationContext(),
            R.anim.slide_in_right);/* w  ww  .  ja  v  a 2s  . c o m*/
    mRelativeLayout.startAnimation(RightSwipe);
}

From source file:com.chatwing.whitelabel.fragments.BaseExpandableListFragment.java

public void setContentShown(boolean shown) {
    if (isShowingContent() == shown) {
        return;// w  w  w. j  av  a2  s  .  c o  m
    }
    if (shown) {
        mProgressView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        mContentView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        mProgressView.setVisibility(View.GONE);
        mContentView.setVisibility(View.VISIBLE);
    } else {
        mProgressView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        mContentView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        mProgressView.setVisibility(View.VISIBLE);
        mContentView.setVisibility(View.GONE);
    }
}

From source file:ca.rmen.android.scrumchatter.meeting.list.MeetingsCursorAdapter.java

/**
 * Fill the view holder's fields with data from the given meeting.
 *//*  ww  w. j  a  v a  2  s.co m*/
@Override
public void onBindViewHolder(final MeetingViewHolder holder, int position) {
    getCursor().moveToPosition(position);
    Context context = holder.binding.getRoot().getContext();
    // Get the data from the cursor
    MeetingCursorWrapper cursorWrapper = new MeetingCursorWrapper(getCursor());
    final Meeting meeting = Meeting.read(context, cursorWrapper);
    String dateString = TextUtils.formatDateTime(context, meeting.getStartDate());
    String duration = DateUtils.formatElapsedTime(meeting.getDuration());

    String stateName = mMeetingStateNames[meeting.getState().ordinal()];

    final MeetingListItemBinding binding = holder.binding;
    // Find the views we need to set up.
    binding.setMeeting(meeting);

    // Fill the date view.
    binding.tvMeetingDate.setText(dateString);

    // Fill the duration view. We will only show the duration if
    // the meeting is finished. For not-started or in-progress
    // meetings, we show the state.
    if (meeting.getState() == State.FINISHED)
        binding.tvMeetingDuration.setText(duration);
    else
        binding.tvMeetingDuration.setText(stateName);
    if (meeting.getState() == State.IN_PROGRESS) {
        Animation animBlink = AnimationUtils.loadAnimation(context, R.anim.blink);
        binding.tvMeetingDuration.startAnimation(animBlink);
        binding.tvMeetingDuration.setTextColor(mColorStateInProgress);
    } else {
        Animation anim = binding.tvMeetingDuration.getAnimation();
        if (anim != null) {
            anim.cancel();
            // Need to make sure the animation doesn't stay faded out.
            anim = AnimationUtils.loadAnimation(context, R.anim.show);
            binding.tvMeetingDuration.startAnimation(anim);
        }
        binding.tvMeetingDuration.setTextColor(mColorStateDefault);
    }
    if (binding.getRoot().getContext().getResources().getBoolean(R.bool.is_tablet)
            && Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        binding.getRoot().setActivated(mSelectedPosition == position);
    }
    binding.btnDeleteMeeting.setOnClickListener(v -> mMeetingListener.onMeetingDelete(meeting));
    binding.getRoot().setOnClickListener(v -> {
        mSelectedPosition = holder.getAdapterPosition();
        mMeetingListener.onMeetingOpen(meeting);
        notifyDataSetChanged();
    });
}

From source file:com.alchemiasoft.book.fragment.base.RecyclerViewFragment.java

private void setContentShown(boolean shown, boolean animate) {
    if (mContentShown == shown) {
        mEmptyTextView/*from   w  w w.j  av  a 2  s .c om*/
                .setVisibility(mAdapter == null || mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
        return;
    }
    mContentShown = shown;
    if (shown) {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            mContentContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        } else {
            mProgressContainer.clearAnimation();
            mContentContainer.clearAnimation();
        }
        mProgressContainer.setVisibility(View.GONE);
        mContentContainer.setVisibility(View.VISIBLE);
        boolean noContent = mAdapter == null || mAdapter.getItemCount() == 0;
        mEmptyTextView.setVisibility(noContent ? View.VISIBLE : View.GONE);
    } else {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            mContentContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        } else {
            mProgressContainer.clearAnimation();
            mContentContainer.clearAnimation();
        }
        mProgressContainer.setVisibility(View.VISIBLE);
        mContentContainer.setVisibility(View.GONE);
    }
}

From source file:com.cnm.cnmrc.fragment.search.SearchVodFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation anim;/*  ww w  .  ja va2s.  c  o m*/

    if (enter)
        anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_entering);
    else
        anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_exit);

    anim.setAnimationListener(new AnimationListener() {
        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            ((MainActivity) getActivity()).getMyProgressBar().show();
            showSearchVod();
        }

        public void onAnimationRepeat(Animation animation) {
        }
    });

    return anim;
}

From source file:ansteph.com.beecabfordrivers.view.CabResponder.JobsBoard.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_jobs_board);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  w w w.  j  av  a2s . co  m*/

    sessionManager = new SessionManager(getApplicationContext());
    mGlobalRetainer = (GlobalRetainer) getApplicationContext();

    HashMap<String, String> user = sessionManager.getUserDetails();
    // String id, String name, String companyname, String email, String mobile, String licence, String year, String apikey, int companyid

    mGlobalRetainer.set_grDriver(new Driver(user.get(SessionManager.KEY_ID), user.get(SessionManager.KEY_NAME),
            user.get(SessionManager.KEY_COMNAME), user.get(SessionManager.KEY_EMAIL),
            user.get(SessionManager.KEY_MOBILE), user.get(SessionManager.KEY_LICENSE),
            user.get(SessionManager.KEY_YEAR), user.get(SessionManager.KEY_APIKEY),
            Integer.parseInt(user.get(SessionManager.KEY_COMPANY_ID))));

    //Try to register the firebase messaging token
    FirebaseMessaging.getInstance().subscribeToTopic("BeeCab");
    String token = FirebaseInstanceId.getInstance().getToken();

    /* if(!token.isEmpty())
     {
            
    FirebaseServerRegistration fbRegistration = new FirebaseServerRegistration
            (getApplicationContext(), mGlobalRetainer.get_grDriver(),token);
            
    fbRegistration.registerFBToken();
            
     }*/

    viewPager = (ViewPager) findViewById(R.id.view_pager);
    adapterViewPager = new JobCatAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapterViewPager);

    tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);

    final ViewAnimator viewAnimator = (ViewAnimator) findViewById(R.id.viewAnimator);

    final Animation inAmin = AnimationUtils.loadAnimation(getApplication(), android.R.anim.slide_in_left);
    final Animation outAmin = AnimationUtils.loadAnimation(getApplication(), android.R.anim.slide_out_right);

    viewAnimator.setInAnimation(inAmin);
    viewAnimator.setOutAnimation(outAmin);

    viewAnimator.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            viewAnimator.showNext();
        }
    });

    try {

        Glide.with(getApplication()).load(R.drawable.denys).into((ImageView) findViewById(R.id.imgadvplace2));
        Glide.with(getApplication()).load(R.drawable.auto).into((ImageView) findViewById(R.id.imgadvplace3));
    } catch (Exception e) {
        e.printStackTrace();
    }

    Button btnCaller = (Button) findViewById(R.id.btnCaller);
    btnCaller.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplication(), JoRPickupBoard.class);
            startActivity(i);
        }
    });

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            //Checking for the type of intent filter
            if (intent.getAction().equals(Config.REGISTRATION_COMPLETE)) {
                //gcm successful reg
                //now subscribe to the topic beecab topic to receive app wide notifications
                FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
            } else if (intent.getAction().equals(Config.PUSH_NOTIFICATION)) {
                String message = intent.getStringExtra("message");

                Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
            }

        }
    };
    updateRegIDonServer();
}