Example usage for android.view.animation AlphaAnimation setDuration

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

Introduction

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

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.umeng.comm.ui.fragments.BaseFeedsFragment.java

/**
 * /*from  w  ww. ja va2s  .co m*/
 */
private void hidePostButtonWithAnim() {
    AlphaAnimation animation = new AlphaAnimation(1.0f, 0f);
    animation.setDuration(500);

    mPostBtn.setVisibility(View.GONE);
    mPostBtn.startAnimation(animation);
}

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

/***
 * ?//from www .java2 s. 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:org.numixproject.hermes.activity.ConversationActivity.java

private void showConversationLayout() {
    // get the final radius for the clipping circle
    int finalRadius = Math.max(roomsLayout.getWidth(), roomsLayout.getHeight());
    final FrameLayout colorLayout = (FrameLayout) findViewById(R.id.colorLayout);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // create the animator for this view (the start radius is zero)
        Animator colorAnim;//from  w w  w.  jav  a 2  s.  c o m
        colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) roomsLayout.getLeft(),
                (int) roomsLayout.getTop(), 0, finalRadius);
        final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f);
        fadeAnim.setDuration(250);
        fadeAnim.setInterpolator(new AccelerateInterpolator());
        fadeAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                conversationLayout.setVisibility(View.VISIBLE);
            }

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

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        colorAnim.setInterpolator(new AccelerateInterpolator());
        colorAnim.addListener(new android.animation.Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationRepeat(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationEnd(android.animation.Animator animation) {
                colorLayout.startAnimation(fadeAnim);
            }

            @Override
            public void onAnimationCancel(android.animation.Animator animation) {
            }
        });

        colorLayout.setVisibility(View.VISIBLE);
        colorAnim.start();

    } else {
        conversationLayout.setVisibility(View.VISIBLE);
        conversationLayout.setAlpha(0.f);
        conversationLayout.setScaleX(0.f);
        conversationLayout.setScaleY(0.f);
        conversationLayout.animate().alpha(1.f).scaleX(1.f).scaleY(1.f).setDuration(300).start();
    }
}

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);
    pdBackButton.setAlpha(1f);/*  w w w  .  ja v  a2s. c  o  m*/
    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);
            animation.setAnimationListener(new Animation.AnimationListener() {
                @Override/*  w w  w .  j a va 2s .c om*/
                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();
        }
    }
}

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

private void alphaAnimation() {
    AlphaAnimation transparency = new AlphaAnimation(1, (float) 0.75);
    transparency.setDuration(200);
    transparency.start();//from ww w.ja  va  2 s .  com
    //view.startAnimation(transparency);
}

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);
    verifyView.setAlpha(1f);// www .  java2 s  . co  m
    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);// ww w . j  av a2  s .  c o m
    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:com.irccloud.android.fragment.MessageViewFragment.java

public void showSpinner(boolean show) {
    if (show) {/*from  w  w  w  .ja va2s  . com*/
        if (Build.VERSION.SDK_INT < 16) {
            AlphaAnimation anim = new AlphaAnimation(0, 1);
            anim.setDuration(150);
            anim.setFillAfter(true);
            spinner.setAnimation(anim);
        } else {
            spinner.setAlpha(0);
            spinner.animate().alpha(1);
        }
        spinner.setVisibility(View.VISIBLE);
    } else {
        if (Build.VERSION.SDK_INT < 16) {
            AlphaAnimation anim = new AlphaAnimation(1, 0);
            anim.setDuration(150);
            anim.setFillAfter(true);
            anim.setAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

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

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            spinner.setAnimation(anim);
        } else {
            spinner.animate().alpha(0).withEndAction(new Runnable() {
                @Override
                public void run() {
                    spinner.setVisibility(View.GONE);
                }
            });
        }
    }
}

From source file:com.irccloud.android.activity.MainActivity.java

@Override
public void onMessageViewReady() {
    if (shouldFadeIn) {
        Crashlytics.log(Log.DEBUG, "IRCCloud", "Fade In");
        MessageViewFragment mvf = (MessageViewFragment) getSupportFragmentManager()
                .findFragmentById(R.id.messageViewFragment);
        UsersListFragment ulf = (UsersListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.usersListFragment);

        if (Build.VERSION.SDK_INT < 16) {
            AlphaAnimation anim = new AlphaAnimation(0, 1);
            anim.setDuration(150);
            anim.setFillAfter(true);/*w  w w  .ja v a2 s.c  o  m*/
            if (mvf != null && mvf.getListView() != null)
                mvf.getListView().startAnimation(anim);
            if (ulf != null && ulf.getListView() != null)
                ulf.getListView().startAnimation(anim);
        } else {
            if (mvf != null && mvf.getListView() != null)
                mvf.getListView().animate().alpha(1);
            if (ulf != null && ulf.getListView() != null)
                ulf.getListView().animate().alpha(1);
        }
        if (mvf != null && mvf.getListView() != null) {
            if (mvf.buffer != buffer && buffer != null
                    && BuffersDataSource.getInstance().getBuffer(buffer.bid) != null) {
                Bundle b = new Bundle();
                b.putInt("cid", buffer.cid);
                b.putInt("bid", buffer.bid);
                b.putBoolean("fade", false);
                mvf.setArguments(b);
            }
            mvf.showSpinner(false);
        }
        shouldFadeIn = false;
    }
}