Example usage for android.view.animation AlphaAnimation AlphaAnimation

List of usage examples for android.view.animation AlphaAnimation AlphaAnimation

Introduction

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

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:com.pdftron.pdf.controls.UserCropDialogFragment.java

private void showSpinner() {
    this.setCancelable(false);
    if (mSpinnerShowing) {
        return;//ww w. j  a v a 2 s  .  c o  m
    }
    mSpinnerShowing = true;

    mProgressBarHost.setVisibility(View.VISIBLE);
    mSpinnerAlphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    mSpinnerAlphaAnimation.setDuration(500);
    mSpinnerAlphaAnimation.setInterpolator(new LinearInterpolator());
    mProgressBarHost.startAnimation(mSpinnerAlphaAnimation);
}

From source file:com.android.hcframe.DraggableGridViewPager.java

private void animateDragged() {
    if (mLastDragged >= 0) {
        final View v = getChildAt(mLastDragged);

        final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        r.inset(-r.width() / 20, -r.height() / 20);
        v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
        v.layout(r.left, r.top, r.right, r.bottom);

        AnimationSet animSet = new AnimationSet(true);
        ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
        scale.setDuration(ANIMATION_DURATION);
        AlphaAnimation alpha = new AlphaAnimation(1, .5f);
        alpha.setDuration(ANIMATION_DURATION);

        animSet.addAnimation(scale);//from w  w  w .jav  a  2  s. c  o m
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

        v.clearAnimation();
        v.startAnimation(animSet);
    }
}

From source file:com.androzic.MapActivity.java

protected void updateNavigationInfo() {
    if (navigationService == null || !navigationService.isNavigating())
        return;/*  www .j  av a2  s  .  c  om*/

    double distance = navigationService.navDistance;
    double bearing = navigationService.navBearing;
    long turn = navigationService.navTurn;
    double vmg = navigationService.navVMG * speedFactor;
    int ete = navigationService.navETE;

    String[] dist = StringFormatter.distanceC(distance, precisionFormat);
    String extra = String.format(precisionFormat, vmg) + " " + speedAbbr + " | " + StringFormatter.timeH(ete);

    String trnsym = "";
    if (turn > 0) {
        trnsym = "R";
    } else if (turn < 0) {
        trnsym = "L";
        turn = -turn;
    }

    bearing = application.fixDeclination(bearing);
    distanceValue.setText(dist[0]);
    distanceUnit.setText(dist[1]);
    bearingValue.setText(String.valueOf(Math.round(bearing)));
    turnValue.setText(String.valueOf(Math.round(turn)) + trnsym);
    waypointExtra.setText(extra);

    if (navigationService.isNavigatingViaRoute()) {
        boolean hasNext = navigationService.hasNextRouteWaypoint();
        if (distance < navigationService.navProximity * 3 && !animationSet) {
            AnimationSet animation = new AnimationSet(true);
            animation.addAnimation(new AlphaAnimation(1.0f, 0.3f));
            animation.addAnimation(new AlphaAnimation(0.3f, 1.0f));
            animation.setDuration(500);
            animation.setRepeatCount(10);
            findViewById(R.id.waypointinfo).startAnimation(animation);
            if (!hasNext) {
                findViewById(R.id.routeinfo).startAnimation(animation);
            }
            animationSet = true;
        } else if (animationSet) {
            findViewById(R.id.waypointinfo).setAnimation(null);
            if (!hasNext) {
                findViewById(R.id.routeinfo).setAnimation(null);
            }
            animationSet = false;
        }

        if (navigationService.navXTK == Double.NEGATIVE_INFINITY) {
            xtkValue.setText("--");
            xtkUnit.setText("--");
        } else {
            String xtksym = navigationService.navXTK == 0 ? "" : navigationService.navXTK > 0 ? "R" : "L";
            String[] xtks = StringFormatter.distanceC(Math.abs(navigationService.navXTK));
            xtkValue.setText(xtks[0] + xtksym);
            xtkUnit.setText(xtks[1]);
        }

        double navDistance = navigationService.navRouteDistanceLeft();
        int eta = navigationService.navRouteETE(navDistance);
        if (eta < Integer.MAX_VALUE)
            eta += navigationService.navETE;
        extra = StringFormatter.distanceH(navDistance + distance, 1000) + " | " + StringFormatter.timeH(eta);
        routeExtra.setText(extra);
    }
}

From source file:com.icloud.listenbook.base.view.DraggableGridViewPager.java

/***
 * ?//from w  w w  .  ja va2s  .  c  om
 * **/
private void animateDragged() {
    if (mLastDragged >= 0) {
        final View v = getChildAt(mLastDragged);

        final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
        r.inset(-r.width() / 20, -r.height() / 20);
        v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
                MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
        v.layout(r.left, r.top, r.right, r.bottom);

        AnimationSet animSet = new AnimationSet(true);
        ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
        scale.setDuration(ANIMATION_DURATION);
        AlphaAnimation alpha = new AlphaAnimation(1, .5f);
        alpha.setDuration(ANIMATION_DURATION);

        animSet.addAnimation(scale);
        animSet.addAnimation(alpha);
        animSet.setFillEnabled(true);
        animSet.setFillAfter(true);

        v.clearAnimation();
        v.startAnimation(animSet);
    }
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*******************************************
 * //from  w  ww . j a  va 2s  .c  o m
 * initializeAnimations
 * 
 *******************************************/
private void initializeAnimations() {
    /*
     * Puts the left panel in perspective
     */
    if (this.display.getOrientation() == 0)
        perspectiveLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                30, 30, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    else
        perspectiveLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                15, 15, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    perspectiveLeft.setDuration(1);
    perspectiveLeft.setFillAfter(true);

    /*
     * Puts the right panel in perspective
     */
    if (this.display.getOrientation() == 0)
        perspectiveRight = new Rotate3dAnimation(0, 0, // X-axis rotation
                -30, -30, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    else
        perspectiveRight = new Rotate3dAnimation(0, 0, // X-axis rotation
                -15, -15, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    perspectiveRight.setDuration(1);
    perspectiveRight.setFillAfter(true);
    //perspectiveLeftAnim.setDuration(500);
    //perspectiveLeftAnim.setInterpolator(new AccelerateInterpolator());

    /*
     * Hides a panel left
     */
    hideLeft = new Rotate3dAnimationY(30, 90, // Y-axis rotation
            100, 100, // rotation center
            0.0f, // Z-depth
            false); //reverse movement
    hideLeft.setDuration(300);
    hideLeft.setFillAfter(true);
    hideLeft.setInterpolator(new DecelerateInterpolator());
    hideLeft.setAnimationListener(this.hideAlbumAnimationListener);

    /*
     * Shows a panel hidden to the left
     */
    showLeft = new Rotate3dAnimationY(270, 390, // Y-axis rotation
            100, 100, // rotation center
            0.0f, // Z-depth
            false); //reverse movement
    showLeft.setDuration(600); // double of the angle
    showLeft.setFillAfter(true);
    showLeft.setInterpolator(new AccelerateInterpolator());
    showLeft.setAnimationListener(this.showAlbumAnimationListener);

    /*
     * Fades an Album out
     */
    /*fadeAlbumOut = new AlphaAnimation((float) 1.0, 0);
    fadeAlbumOut.setDuration(250);
    fadeAlbumOut.setFillAfter(true);
    fadeAlbumOut.setAnimationListener(this.hideAlbumAnimationListener);       
    */
    //      fadeAlbumOut = new TranslateAnimation(-display.getWidth(),-display.getWidth(), 0, 0);
    fadeAlbumOut = new AlphaAnimation(1.0f, 0.0f);
    fadeAlbumOut.setDuration(200);
    fadeAlbumOut.setFillAfter(true);
    //fadeAlbumOut.setInterpolator(new AccelerateInterpolator());
    fadeAlbumOut.setAnimationListener(this.hideAlbumAnimationListener);

    /*
     * Fades an Album in
     */
    /*fadeAlbumIn = new AlphaAnimation(0, 1);
    fadeAlbumIn.setDuration(250);
    fadeAlbumIn.setFillAfter(true);
    fadeAlbumIn.setAnimationListener(this.showAlbumAnimationListener);
    */
    //      fadeAlbumIn = new TranslateAnimation(-display.getWidth(),0, 0, 0);
    fadeAlbumIn = new AlphaAnimation(0.0f, 1.0f);
    fadeAlbumIn.setDuration(200);
    fadeAlbumIn.setFillAfter(true);
    //fadeAlbumIn.setInterpolator(new AccelerateInterpolator());
    fadeAlbumIn.setAnimationListener(this.showAlbumAnimationListener);
}

From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java

private void verifyReward(final String type) {
    verifyView.setVisibility(View.VISIBLE);
    AlphaAnimation animation1 = new AlphaAnimation(0f, 1.0f);
    animation1.setDuration(250);/* w ww  . j  av a2s . com*/
    verifyView.setAlpha(1f);
    verifyView.startAnimation(animation1);

    dotProgress.show();
    final long time = Calendar.getInstance().getTimeInMillis();
    Log.d("VERIFYING", "verifyReward: ");

    PDAPIClient.instance().scanSocialNetwork(mReward.getId(), type, new PDAPICallback<JsonObject>() {
        @Override
        public void success(final JsonObject jsonObject) {

            //                if(type.equalsIgnoreCase("instagram")) {
            //                    PDAPIClient.instance().verifyInstagramPostForReward(mReward.getId(), new PDAPICallback<JsonObject>() {
            //                        @Override
            //                        public void success(final JsonObject jsonObjectVerify) {
            //                            long timediff = Calendar.getInstance().getTimeInMillis()-time;
            //                            if(timediff>3000){
            //                                processValidationReturn(jsonObject);
            //                            }else{
            //                                new Handler().postDelayed(new Runnable() {
            //                                    @Override
            //                                    public void run() {
            //                                        processValidationReturn(jsonObject);
            //                                    }
            //                                }, timediff);
            //                            }
            //                        }
            //
            //                        @Override
            //                        public void failure(int statusCode, Exception e) {
            //                            Log.d("VERIFYING", "verifyReward: failed");
            //                            claiming = false;
            //                            PDLog.d(PDUIWalletFragment.class, "verify failed: code=" + statusCode + ", message=" + e.getMessage());
            //                            mReward.setVerifying(false);
            //
            //                            Realm realm = Realm.getDefaultInstance();
            //                            PDRealmUserDetails userDetails = realm.where(PDRealmUserDetails.class).findFirst();
            //                            realm.close();
            //                            showInstagramFailure(userDetails, mReward.getGlobalHashtag());
            //                            dotProgress.hide(150);
            //                        }
            //                    });
            //                    return;
            //                }
            long timediff = Calendar.getInstance().getTimeInMillis() - time;
            if (timediff > 3000) {
                processValidationReturn(jsonObject);
            } else {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        processValidationReturn(jsonObject);
                    }
                }, timediff);
            }

        }

        @Override
        public void failure(int statusCode, Exception e) {
            Log.d("VERIFYING", "verifyReward: failed");
            claiming = false;
            PDLog.d(PDUIWalletFragment.class,
                    "verify failed: code=" + statusCode + ", message=" + e.getMessage());
            mReward.setVerifying(false);

            Realm realm = Realm.getDefaultInstance();
            PDRealmUserDetails userDetails = realm.where(PDRealmUserDetails.class).findFirst();
            realm.close();
            showInstagramFailure(userDetails, mReward.getGlobalHashtag());
            dotProgress.hide(150);

        }
    });
}

From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java

private void processValidationReturn(JsonObject jsonObject) {
    parseResponse(jsonObject);//from  w w  w.j av  a2 s  . c  om
    PDLog.d(PDUIClaimActivity.class, "verify success: " + jsonObject.toString());
    claiming = false;
    boolean success = false;
    if (jsonObject != null && jsonObject.has("validated")) {
        success = true;
    }
    Realm realm = Realm.getDefaultInstance();
    PDRealmUserDetails userDetails = realm.where(PDRealmUserDetails.class).findFirst();

    if (success) {
        Gson gson = new Gson();
        PDPostScan postScan = gson.fromJson(jsonObject, PDPostScan.class);

        if (postScan != null && postScan.getValidated()) {

            mReward.setInstagramVerified(true);
            Log.d("VERIFYING", "verifyReward: success");

            String headingText = pdVerifyHeadingText.getText().toString();
            if (userDetails.getFirstName() != null && userDetails.getFirstName().length() > 0) {
                headingText = headingText.replace("Richard", userDetails.getFirstName());
            } else {
                headingText = headingText.replace("Hey Richard, w", "W");
            }

            if (postScan != null && postScan.getText() != null && postScan.getText().length() > 0) {
                headingText = headingText.replace("#hashtag", postScan.getText());
            } else {
                headingText = headingText.replace("with #hashtag", "");
            }
            pdVerifyHeadingText.setText(headingText);

            if (postScan != null && postScan.getText() != null && postScan.getText().length() > 0) {
                pdClaimUserHashtagTextView.setText(headingText);
            } else {
                pdClaimUserHashtagTextView.setText("");
            }

            if (postScan != null && postScan.getSocialName() != null && postScan.getSocialName().length() > 0) {
                pdClaimUserNameTextView.setText(postScan.getSocialName());
            } else {
                pdClaimUserNameTextView.setVisibility(View.GONE);
            }
            if (postScan != null && postScan.getSocialName() != null && postScan.getSocialName().length() > 0) {
                pdClaimUserHashtagTextView.setText(postScan.getText());
            } else {
                pdClaimUserHashtagTextView.setVisibility(View.GONE);
            }
            Glide.with(PDUIClaimActivity.this).load(postScan.getMediaUrl()).dontAnimate().into(pdVerifyImage);

            if (postScan != null && postScan.getProfilePictureUrl() != null) {

                String url = postScan.getProfilePictureUrl();
                if (!url.startsWith("http")) {
                    url = "http:" + url;
                }
                Glide.with(PDUIClaimActivity.this).load(url).placeholder(R.drawable.pd_ui_default_user)
                        .error(R.drawable.pd_ui_default_user).dontAnimate().into(pdClaimProfileImageView);
            }

            pdVerifyHeadingText.setVisibility(View.VISIBLE);
            pdVerifyImageCard.setVisibility(View.VISIBLE);
            pdProceedButton.setVisibility(View.VISIBLE);

            int animationTime = 1000;

            AlphaAnimation animation1 = new AlphaAnimation(0f, 1.0f);
            animation1.setDuration(animationTime);
            pdVerifyHeadingText.setAlpha(1f);
            pdVerifyHeadingText.startAnimation(animation1);

            AlphaAnimation animation2 = new AlphaAnimation(0f, 1.0f);
            animation2.setDuration(animationTime);
            animation2.setStartOffset(animationTime);
            pdVerifyImageCard.setAlpha(1f);
            pdVerifyImageCard.startAnimation(animation2);

            AlphaAnimation animation3 = new AlphaAnimation(0f, 1.0f);
            animation3.setDuration(animationTime);
            animation3.setStartOffset(animationTime * 2);
            pdProceedButton.setAlpha(1f);
            pdProceedButton.startAnimation(animation3);
            pdProceedButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (mTwitterSwitch.isChecked() || mFacebookSwitch.isChecked()
                            || mInstagramSwitch.isChecked()) {
                        claimReward();
                        return;
                    }

                    Intent data = new Intent();
                    data.putExtra("id", mReward.getId());
                    data.putExtra("verificationNeeded", false);
                    //                        data.putExtra("verificationNeeded", mInstagramSwitch.isChecked());
                    setResult(RESULT_OK, data);
                    finish();
                }
            });

        } else {
            showInstagramFailure(userDetails, mReward.getGlobalHashtag());
        }

    } else {
        showInstagramFailure(userDetails, mReward.getGlobalHashtag());
    }
    dotProgress.hide(150);
    mReward.setVerifying(false);
    realm.close();
}

From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java

private void alphaAnimation() {
    AlphaAnimation transparency = new AlphaAnimation(1, (float) 0.75);
    transparency.setDuration(200);//from w w w  .j a va2  s. c o m
    transparency.start();
    //view.startAnimation(transparency);
}

From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java

private void showInstagramFailure(PDRealmUserDetails userDetails, String hashtag) {
    pdVerifyHeadingText.setVisibility(View.VISIBLE);
    pdBackButton.setVisibility(View.VISIBLE);

    AlphaAnimation animation1 = new AlphaAnimation(0f, 1.0f);
    animation1.setDuration(250);/*from  www .j  a  v a2s . c om*/
    pdBackButton.setAlpha(1f);
    pdVerifyHeadingText.setAlpha(1f);
    pdBackButton.startAnimation(animation1);
    pdVerifyHeadingText.startAnimation(animation1);

    String headingText = "Whoops! Sorry XXXX, we could not find a post from the last 48 hours with the #hashtag\n\nPlease ensure you've shared from the correct social media account and try again.";
    if (userDetails.getFirstName() != null && userDetails.getFirstName().length() > 0) {
        headingText = headingText.replace("XXXX", userDetails.getFirstName());
    } else {
        headingText = headingText.replace(" XXXX", "");
    }

    if (hashtag != null && hashtag.length() > 0) {
        headingText = headingText.replace("the #hashtag", "" + hashtag);
    }

    pdVerifyHeadingText.setText(headingText);

    pdBackButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });
}

From source file:com.popdeem.sdk.uikit.activity.PDUIClaimActivity.java

@Override
public void onBackPressed() {
    if (!claiming) {
        if (verifyView.getVisibility() == View.VISIBLE) {
            AlphaAnimation animation = new AlphaAnimation(1f, 0.0f);
            animation.setDuration(250);/*from w  ww.j av  a 2  s  .  c o m*/
            animation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                    verifyView.setVisibility(View.GONE);
                    pdVerifyHeadingText.setVisibility(View.GONE);
                    pdVerifyImageCard.setVisibility(View.GONE);
                    pdProceedButton.setVisibility(View.GONE);
                    pdBackButton.setVisibility(View.GONE);
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }
            });
            verifyView.startAnimation(animation);
        } else {
            super.onBackPressed();
        }
    }
}