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:jp.mixi.android.sdk.MixiDialog.java

private void showLoading(String message) {
    ((TextView) findViewById(R.id.progressLabel)).setText(message);

    View progress = findViewById(R.id.progress);
    progress.setVisibility(View.VISIBLE);
    progress.startAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in));

    View webView = findViewById(R.id.webview);
    webView.setVisibility(View.GONE);
    webView.startAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out));
}

From source file:com.nononsenseapps.notepad.fragments.DialogPassword.java

private void setPassword(final String pass1, final String pass2) {
    if (pass1 != null && !pass1.isEmpty() && pass1.equals(pass2)) {
        PreferenceManager.getDefaultSharedPreferences(getActivity()).edit()
                .putString(PasswordPrefs.KEY_PASSWORD, pass1).commit();
        if (listener != null) {
            listener.onPasswordConfirmed();
        }/*from   w ww.j a v a  2 s.c  om*/
        dismiss();
    } else {
        Animation shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
        passwordVerificationField.startAnimation(shake);
        Toast.makeText(getActivity(), getText(R.string.passwords_dont_match), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.osama.cryptofm.startup.PreStartActivity.java

private void animateButtonAndShow() {
    ImageButton button = (ImageButton) findViewById(R.id.pre_start_skip_button);
    button.setVisibility(View.VISIBLE);
    //animate//  w  w  w  .  j  a v  a 2s. c o  m
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.done_button_anim);
    button.startAnimation(animation);
}

From source file:com.chromium.fontinstaller.util.ViewUtils.java

public static void animShrinkToCenter(View view, Context context) {
    if (context == null || view == null)
        return;//from ww  w  .j a v a2s .  co m
    view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.shrink_to_center));
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.common.DialogPassword.java

private void checkPassword(final String enteredPassword, final String currentPassword) {
    if (currentPassword.equals(enteredPassword)) {
        if (listener != null) {
            listener.onPasswordConfirmed();
        }//from w  w  w. j  a v a2 s.  co  m
        dismiss();
    } else {
        Animation shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
        binding.passwordField.startAnimation(shake);
        Toast.makeText(getActivity(), getText(R.string.password_incorrect), Toast.LENGTH_SHORT).show();
    }
}

From source file:net.olejon.mdapp.ClinicalTrialsCardsAdapter.java

private void animateView(View view, int position) {
    if (position > mLastPosition) {
        mLastPosition = position;// ww  w .  j av  a 2s. c o m

        Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.card);
        view.startAnimation(animation);
    }
}

From source file:com.sir_m2x.messenger.activities.ChatWindowPager.java

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

    this.rootLayout = (RelativeLayout) findViewById(R.id.chatPagerParent);
    this.buzzAnimation = AnimationUtils.loadAnimation(this, R.anim.shake);

    this.mViewPager = (ViewPager) findViewById(R.id.chatPager);
    this.mAdapter = new ChatFragmentAdapter(getSupportFragmentManager());
    this.mViewPager.setAdapter(this.mAdapter);

    this.drawer = (SlidingDrawer) findViewById(R.id.drawer);
    this.btnClose = (Button) findViewById(R.id.btnClose);
    this.btnSmiley = (Button) findViewById(R.id.btnSmiley);
    GridView gv = (GridView) this.drawer.findViewById(R.id.content);
    gv.setAdapter(new SmileyAdapter());
    gv.setOnItemClickListener(new OnItemClickListener() {

        @Override/*from  www .j a va2s.c  o m*/
        public void onItemClick(final AdapterView<?> arg0, final View arg1, final int arg2, final long arg3) {
            String smiley = arg1.getTag().toString();
            Intent intent = new Intent();
            intent.setAction(MessengerService.INTENT_INSERT_SMILEY)
                    .putExtra(Utils.qualify("from"), ChatWindowPager.currentFriendId)
                    .putExtra(Utils.qualify("symbol"), smiley);

            sendBroadcast(intent);
            ChatWindowPager.this.drawer.animateClose();
        }
    });

    if (getIntent().hasExtra(Utils.qualify("friendId"))) {
        currentFriendId = getIntent().getExtras().getString(Utils.qualify("friendId"));
        if (!MessengerService.getFriendsInChat().keySet().contains(currentFriendId))
            MessengerService.getFriendIMs(this, currentFriendId);
    } else if (currentFriendId == "" || !MessengerService.getFriendsInChat().keySet().contains(currentFriendId))
        currentFriendId = MessengerService.getFriendsInChat().keySet().toArray()[0].toString();

    for (int i = 0; i < MessengerService.getFriendsInChat().size(); i++)
        if (MessengerService.getFriendsInChat().keySet().toArray()[i].toString().equals(currentFriendId)) {
            currentItem = i;
            break;
        }

    this.mTabPageIndicator = (TabPageIndicator) findViewById(R.id.chatIndicator);
    this.mTabPageIndicator.setViewPager(this.mViewPager, currentItem);
    this.mTabPageIndicator.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(final int arg0) {
        }

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

        @Override
        public void onPageSelected(final int arg0) {
            buzzWaitElapsed.set(true);
            ChatWindowPager.this.buzzAllower.cancel();
            ChatWindowPager.currentFriendId = ChatWindowPager.this.mAdapter.getId(arg0);
            currentItem = arg0;

            synchronized (MessengerService.getUnreadIMs()) {
                MessengerService.getUnreadIMs().remove(ChatWindowPager.this.mAdapter.getId(arg0));
                ChatWindowPager.this.mTabPageIndicator.notifyDataSetChanged();
            }
        }
    });

    this.btnClose.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            Utils.saveConversationHistory(ChatWindowPager.this, currentFriendId);
            MessengerService.getFriendsInChat().remove(currentFriendId);
            currentItem--;
            if (currentItem < 0)
                if (MessengerService.getFriendsInChat().size() == 0) {
                    finish();
                    return;
                } else
                    currentItem++;

            currentFriendId = MessengerService.getFriendsInChat().keySet().toArray()[currentItem].toString();

            Intent intent = getIntent();
            overridePendingTransition(0, 0);
            intent.putExtra(Utils.qualify("friendId"), currentFriendId);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            finish();
            overridePendingTransition(0, 0);
            startActivity(intent);
        }
    });
    this.btnSmiley.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            ChatWindowPager.this.drawer.animateOpen();
        }
    });

    MessengerService.getUnreadIMs().remove(currentFriendId);
    this.mViewPager.setCurrentItem(currentItem);
    this.mTabPageIndicator.notifyDataSetChanged();

    // reshow the default notification
    MessengerService.getNotificationHelper().showDefaultNotification(false, false);
}

From source file:com.jins_meme.bridge.CameraMenuFragment.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation anim = super.onCreateAnimation(transit, enter, nextAnim);
    if (anim == null) {
        if (enter) {
            anim = AnimationUtils.loadAnimation(getContext(), R.anim.config_in);
        } else {//ww  w.j  av a2s. c om
            anim = AnimationUtils.loadAnimation(getContext(), R.anim.config_out);
        }
    }
    if (enter && anim != null) {
        anim.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (checkIfAllRequiedPermissionGranted()) {
                    mCamera.reopenCamera();
                } else {
                    isPermissionRequested = true;
                    requestPermissions(getPermissionsNotGrantedYet(),
                            getResources().getInteger(R.integer.PERMISSION_REQUEST_CODE_CAMERA));
                }
            }
        });
    }
    return anim;
}

From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameHomeFragment.java

private void initWhisplyPicture(View v) {
    mIsWhisplyAnimationRunning = false;/*from www .j av  a 2 s .c o m*/
    mWhisplyAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.whisply_picture_animation);
    if (mWhisplyAnimation == null)
        return;
    mWhisplyAnimation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            mIsWhisplyAnimationRunning = true;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mIsWhisplyAnimationRunning = false;
        }

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

From source file:com.gubo.vosh.ScrollAwareFABBehavior.java

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 {//from  ww w .  j  a v  a  2  s.  co  m
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.R.anim.fade_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}