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.sutromedia.android.core.PhotoActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.image);//from   ww w.j ava 2  s .  co m

    mSwitcher = (ImageViewSwitcher) findViewById(R.image.switcher);
    mSwitcher.setImageId(R.image.photo);
    mSwitcher.setLayouts(R.layout.image_view_outside, R.layout.image_view_inside);

    mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
    mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_out));

    mFlingDetector = new GestureDetector(new MyGestureDetector());
    checkInitialNavigation(savedInstanceState);
}

From source file:com.near.chimerarevo.fragments.FavoritesFragment.java

public void setListShown(boolean shown, boolean animate) {
    if (mListShown == shown)
        return;/*  w  w w .j a va 2 s .  co  m*/

    mListShown = shown;
    if (shown) {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            mListContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        }
        mProgressContainer.setVisibility(View.GONE);
        mListContainer.setVisibility(View.VISIBLE);
    } else {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            mListContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        }
        mProgressContainer.setVisibility(View.VISIBLE);
        mListContainer.setVisibility(View.INVISIBLE);
    }
}

From source file:com.fangzp.daily.widget.ScrollAwareFABBehavior.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) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//w ww .j a  v a2s .  c o  m

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

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

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

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

From source file:com.android.idearse.Result.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.result);//from   w  w  w.  j av  a 2 s . c o m

    getWindow().getAttributes().windowAnimations = R.style.Fade;

    Bundle extras = getIntent().getExtras();
    QR = extras.getString("qr");

    preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    type = preferences.getString("type", "");

    preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sessionid = preferences.getString("sessionid", "");
    session_name = preferences.getString("session_name", "");
    token = preferences.getString("token", "");
    nid = preferences.getString("place_id", "");

    loadima = (ImageView) findViewById(R.id.loading);
    rotation = AnimationUtils.loadAnimation(getApplicationContext(), R.drawable.rotate_loading);
    rotation.setRepeatCount(Animation.INFINITE);
    loadima.startAnimation(rotation);

    ActionBar actionBar = getSupportActionBar();

    setTitle("");
    getSupportActionBar().setIcon(R.drawable.title_logo);

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);

    Button qr_again2 = (Button) findViewById(R.id.detect_again2);
    Button qr_again = (Button) findViewById(R.id.detect_again);
    Button call = (Button) findViewById(R.id.call);

    qr_again2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            if (isCameraAvailable()) {
                Intent intent = new Intent(getApplicationContext(), ZBarScannerActivity.class);
                intent.putExtra(ZBarConstants.SCAN_MODES, new int[] { Symbol.QRCODE });
                startActivityForResult(intent, ZBAR_QR_SCANNER_REQUEST);
            } else {
                Intent goToLogin = new Intent(getApplicationContext(), Login.class);
                startActivity(goToLogin);
            }
        }
    });
    qr_again.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            if (isCameraAvailable()) {
                Intent intent = new Intent(getApplicationContext(), ZBarScannerActivity.class);
                intent.putExtra(ZBarConstants.SCAN_MODES, new int[] { Symbol.QRCODE });
                startActivityForResult(intent, ZBAR_QR_SCANNER_REQUEST);
            } else {
                Intent goToLogin = new Intent(getApplicationContext(), Login.class);
                startActivity(goToLogin);
            }
        }
    });
    call.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent goToCall = new Intent(getApplicationContext(), Call.class);
            startActivity(goToCall);
        }
    });

    if (type.contains("treballador")) {
        new QRquery().execute(
                getString(R.string.URL) + "conectar_mobil/trabajadores.json?nid=" + nid + "&nif=" + QR);
    } else if (type.contains("maquines")) {
        new QRquery().execute(
                getString(R.string.URL) + "conectar_mobil/maquinas.json?nid=" + nid + "&matricula=" + QR);
    }
}

From source file:com.odt.kandani.View.IntroActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_TMessages);/* ww w  . j  a  va  2  s. c  om*/
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_layout);

    icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4 };
    titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title };
    messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message,
            R.string.Page4Message };

    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    topImage1 = (ImageView) findViewById(R.id.icon_image1);
    topImage2 = (ImageView) findViewById(R.id.icon_image2);
    bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
    topImage2.setVisibility(View.GONE);
    viewPager.setAdapter(new IntroAdapter());
    viewPager.setPageMargin(0);
    viewPager.setOffscreenPageLimit(1);
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int i) {

        }

        @Override
        public void onPageScrollStateChanged(int i) {
            if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
                if (lastPage != viewPager.getCurrentItem()) {
                    lastPage = viewPager.getCurrentItem();

                    final ImageView fadeoutImage;
                    final ImageView fadeinImage;
                    if (topImage1.getVisibility() == View.VISIBLE) {
                        fadeoutImage = topImage1;
                        fadeinImage = topImage2;

                    } else {
                        fadeoutImage = topImage2;
                        fadeinImage = topImage1;
                    }

                    fadeinImage.bringToFront();
                    fadeinImage.setImageResource(icons[lastPage]);
                    fadeinImage.clearAnimation();
                    fadeoutImage.clearAnimation();

                    Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_out);
                    outAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            fadeoutImage.setVisibility(View.GONE);
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_in);
                    inAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                            fadeinImage.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    fadeoutImage.startAnimation(outAnimation);
                    fadeinImage.startAnimation(inAnimation);
                }
            }
        }
    });

    startMessagingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(IntroActivity.this, MainActivity.class);
            IntroActivity.this.startActivity(intent);
            overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
            IntroActivity.this.finish();
        }
    });

    justCreated = true;
}

From source file:com.simon.dribbble.widget.navigationbar.behavior.BehaviorScrollZoomFab.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) {
                        BehaviorScrollZoomFab.this.mIsAnimatingOut = true;
                    }//  ww  w . j  a v  a 2 s.co m

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

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

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

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

From source file:com.example.xyzreader.ui.articlelist.ArticleListAdapter.java

@Override
public void onBindViewHolder(final ViewHolder viewHolder, Cursor cursor) {

    // set up the animation per the xml files
    int position = cursor.getPosition();
    Animation animation = AnimationUtils.loadAnimation(mContext,
            (position > mLastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
    viewHolder.itemView.startAnimation(animation);
    mLastPosition = position;//from w w  w.java 2 s .  c  om

    //show the thumb image (with progress spinner) or the "not found" image
    viewHolder.mArticleListImageProgressBar.setVisibility(View.VISIBLE);
    Picasso.with(mContext).load(cursor.getString(ArticleLoader.Query.THUMB_URL))
            .into(viewHolder.mArticleListImageView, new Callback() {
                @Override
                public void onSuccess() {
                    viewHolder.mArticleListImageProgressBar.setVisibility(View.GONE);
                }

                @Override
                public void onError() {
                    viewHolder.mArticleListImageView.setImageResource(R.mipmap.ic_launcher);
                }
            });

    // show the title and byline
    viewHolder.mArticleListItemTitle.setText(cursor.getString(ArticleLoader.Query.TITLE));
    String byLine = DateUtils
            .getRelativeTimeSpanString(cursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
            .toString() + " by " + cursor.getString(ArticleLoader.Query.AUTHOR);
    viewHolder.mArticleListItemByLine.setText(byLine);
}

From source file:com.nononsenseapps.notepad.fragments.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  a  2s.  co  m
        dismiss();
    } else {
        Animation shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
        passwordField.startAnimation(shake);
        Toast.makeText(getActivity(), getText(R.string.password_incorrect), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(TAG, "OnCreate");
    activity = this;

    Bundle extras = getIntent().getExtras();
    if (extras != null) {

        w2faInitRequest = (W2faInitRequest) extras.getSerializable("W2faInitRequest");
        wPayInitRequest = (WPayInitRequest) extras.getSerializable("WPayInitRequest");

        //reset/*from   w  w  w. j  av a2  s  .c o  m*/
        w2faInitResponse = null;
        wPayInitResponse = null;

        if (w2faInitRequest != null || wPayInitRequest != null) {
            qrMsg = "InApp payment";
        } else {
            Log.e(TAG, "W2faInitRequest and wPayInitRequest was null!");
            sendAbort(WibmoSDK.RES_CODE_FAILURE_SYSTEM_ABORT,
                    "sdk init - W2faInitRequest and wPayInitRequest was null!");
            return;
        }
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminateVisibility(false);

    LayoutInflater inflator = getLayoutInflater();
    view = inflator.inflate(R.layout.activity_inapp_init, null, false);
    view.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left));
    setContentView(view);

    TextView text = (TextView) findViewById(R.id.text);
    text.setText(qrMsg);

    mainView = (View) findViewById(R.id.main_view);

    final Activity activity = this;

    Button abortButton = (Button) findViewById(R.id.abort_button);
    abortButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cancelIAP();
            sendAbort();
        }
    });

    if (WibmoSDK.IS_PHONE_STATE_PERMISSION_REQ) {
        if (WibmoSDKPermissionUtil.checkSelfPermission(activity,
                Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            Log.w(TAG, "Permission not granted! READ_PHONE_STATE");

            WibmoSDKPermissionUtil.showRequestPermissionRationalel(activity,
                    getString(R.string.wibmosdk_phone_state_permission_rationale), new Runnable() {
                        @Override
                        public void run() {
                            ActivityCompat.requestPermissions(activity,
                                    new String[] { Manifest.permission.READ_PHONE_STATE },
                                    WibmoSDKPermissionUtil.REQUEST_CODE_ASK_PERMISSION_PHONE_STATE);
                        }
                    }, new Runnable() {
                        @Override
                        public void run() {
                            WibmoSDKPermissionUtil.showPermissionMissingUI(activity,
                                    getString(R.string.wibmosdk_phone_state_permission_missing_msg));
                            sendAbort(WibmoSDK.RES_CODE_FAILURE_SYSTEM_ABORT,
                                    "sdk init - no permission ph state");
                        }
                    });

            return;//we need this so can;t go on
        }
    }

    doIAPStuff();
}

From source file:com.moki.touch.fragments.views.WebContent.java

public WebContent(Context context) {
    super(context);
    fadeOut = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
    fadeOut.setAnimationListener(new Animation.AnimationListener() {

        @Override/*from   www  .j ava  2  s  .co m*/
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {

            progressBar.setVisibility(View.GONE);
        }
    });
    customAlertMessage = SettingsUtil.getCustomAlertMessage();
    userAgent = SettingsUtil.getUserAgent();
}