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.todoroo.astrid.helper.ProgressBarSyncResultCallback.java

@Override
public void started() {
    if (providers.incrementAndGet() == 1) {
        activity.runOnUiThread(new Runnable() {
            @Override//from  ww  w  .j  av a 2s . c o m
            public void run() {
                progressBar.setVisibility(View.VISIBLE);
                AlphaAnimation animation = new AlphaAnimation(0, 1);
                animation.setFillAfter(true);
                animation.setDuration(1000L);
                progressBar.startAnimation(animation);
            }
        });
    }
}

From source file:com.nikola.despotoski.drawerlayouttoggles.FadingDrawerToggle.java

@SuppressLint("NewApi")
@Override//w w  w  .ja  v a2s. co m
public void onDrawerSlide(View drawerView, float slideOffset) {
    if (!mEnabled)
        return;
    float currentViewAlpha = slideOffset * MAX_VIEW_ALPHA;
    float currentDrawableAlpha = slideOffset * MAX_DRAWABLE_ALPHA;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        drawerView.setAlpha(currentViewAlpha);
    } else {
        AlphaAnimation alphaAnimation = new AlphaAnimation(mPreviousViewAlpha, currentViewAlpha);
        alphaAnimation.setFillAfter(true);
        alphaAnimation.setDuration(0);
        drawerView.startAnimation(alphaAnimation);
        mPreviousViewAlpha = currentViewAlpha;
    }
    drawerView.getBackground().setAlpha((int) currentDrawableAlpha);

}

From source file:com.todoroo.astrid.helper.ProgressBarSyncResultCallback.java

@Override
public void finished() {
    if (providers.decrementAndGet() == 0) {
        activity.runOnUiThread(new Runnable() {
            @Override//from   www  . j a  va 2 s.c o  m
            public void run() {
                try {
                    progressBar.setMax(100);
                    progressBar.setProgress(100);
                    AlphaAnimation animation = new AlphaAnimation(1, 0);
                    animation.setFillAfter(true);
                    animation.setDuration(1000L);
                    progressBar.startAnimation(animation);

                    onFinished.run();
                } catch (Exception e) {
                    // ignore, view could have been destroyed
                }
            }
        });
        new Thread() {
            @Override
            public void run() {
                AndroidUtilities.sleepDeep(1000);
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressBar.setVisibility(View.GONE);
                        } catch (Exception e) {
                            // ignore
                        }
                    }
                });
            }
        }.start();
    }
}

From source file:org.akvo.caddisfly.sensor.colorimetry.strip.camera.CameraSharedFragmentBase.java

private void hideProgressBar() {
    AlphaAnimation animation = new AlphaAnimation(1f, 0);
    animation.setDuration(PROGRESS_FADE_DURATION_MILLIS);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override// www  .j a v a 2 s  . c o m
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            clearProgress();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    progressBar.startAnimation(animation);
}

From source file:com.hookedonplay.decoviewsample.SamplePeopleFragment.java

private void showAvatar(boolean show, View view) {
    AlphaAnimation animation = new AlphaAnimation(show ? 0.0f : 1.0f, show ? 1.0f : 0.0f);
    animation.setDuration(1000);
    animation.setFillAfter(true);//from  w ww  . java  2s . c o m
    view.startAnimation(animation);
}

From source file:com.charbgr.BlurNavigationDrawer.v4.BlurActionBarDrawerToggle.java

private void setAlpha(View view, float alpha, long durationMillis) {
    if (Build.VERSION.SDK_INT < 11) {
        final AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
        animation.setDuration(durationMillis);
        animation.setFillAfter(true);//from  w  ww .  j  a  v a 2s  . c  o m
        view.startAnimation(animation);
    } else {
        view.setAlpha(alpha);
    }
}

From source file:org.ohmage.prompts.SurveyItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.prompt_basic, container, false);
    ((TextView) view.findViewById(R.id.text)).setText(getPromptText());
    mButtons = view.findViewById(R.id.buttons);
    skipButton = (TextView) view.findViewById(R.id.skip);
    okButton = (TextView) view.findViewById(R.id.ok);

    okButton.setOnClickListener(new OnClickListener() {
        @Override/*  w w w  . j  a  v a 2 s.  com*/
        public void onClick(View v) {
            mAnswered = true;
            onOkPressed();
        }
    });
    skipButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAnswered = true;
            onSkipPressed();
        }
    });

    if (isSkippable()) {
        skipButton.setVisibility(View.VISIBLE);
    } else {
        skipButton.setVisibility(View.GONE);
    }

    if (isAnswered()) {
        mButtons.setVisibility(View.GONE);
    } else {
        updateCanContinue();
    }

    onCreatePromptView(inflater, (ViewGroup) view.findViewById(R.id.content), savedInstanceState);

    // Fade the prompt in
    if (!isAnswered()) {
        AlphaAnimation aa = new AlphaAnimation(0f, 1f);
        aa.setFillAfter(true);
        aa.setDuration(200);
        view.startAnimation(aa);
    }

    return view;
}

From source file:com.justwayward.reader.view.recyclerview.adapter.BaseViewHolder.java

public BaseViewHolder setAlpha(int viewId, float value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getView(viewId).setAlpha(value);
    } else {//from w w  w.ja va 2 s  .com
        AlphaAnimation alpha = new AlphaAnimation(value, value);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        getView(viewId).startAnimation(alpha);
    }
    return this;
}

From source file:org.digitalcampus.oppia.fragments.CourseScorecardFragment.java

public void onParseComplete(CompleteCourse parsed) {

    ArrayList<Activity> baseline = parsed.getBaselineActivities();

    DbHelper db = DbHelper.getInstance(super.getActivity());
    long userId = db.getUserId(SessionManager.getUsername(getActivity()));
    ArrayList<Activity> quizActs = db.getCourseQuizzes(course.getCourseId());
    ArrayList<QuizStats> quizzes = new ArrayList<>();
    for (Activity a : quizActs) {
        // get the max score for the quiz for the user
        QuizStats qs = db.getQuizAttempt(a.getDigest(), userId);
        quizzes.add(qs);//  w w  w  .  ja v  a2 s .c o  m
    }

    int quizzesAttempted = 0, quizzesPassed = 0;

    for (QuizStats qs : quizzes) {
        if (qs.isAttempted()) {
            quizzesAttempted++;
        }
        if (qs.isPassed()) {
            quizzesPassed++;
        }
    }

    int pretestScore = -1;
    for (Activity baselineAct : baseline) {
        if (!baselineAct.getActType().equals("quiz"))
            continue;
        QuizStats pretest = db.getQuizAttempt(baselineAct.getDigest(), userId);
        pretestScore = pretest.getPercent();
    }

    quizStats.clear();
    quizStats.addAll(quizzes);
    if (quizStats.size() == 0) {
        quizzesContainer.setVisibility(View.GONE);
        return;
    }

    highlightPretest.setText(pretestScore >= 0 ? (pretestScore + "%") : "-");
    highlightAttempted.setText("" + quizzesAttempted);
    highlightPassed.setText("" + quizzesPassed);
    quizzesAdapter.notifyDataSetChanged();

    AlphaAnimation fadeInAnimation = new AlphaAnimation(0f, 1f);
    fadeInAnimation.setDuration(700);
    fadeInAnimation.setFillAfter(true);

    quizzesProgressBar.setProgress(0);
    quizzesProgressBar.setSecondaryProgress(0);

    quizzesView.setVisibility(View.VISIBLE);
    quizzesView.startAnimation(fadeInAnimation);

    quizzesProgressBar.setMax(quizStats.size());
    ProgressBarAnimator animator = new ProgressBarAnimator(quizzesProgressBar);
    animator.setStartDelay(500);
    animator.animateBoth(quizzesPassed, quizzesAttempted);
}

From source file:com.carver.paul.truesight.Ui.CounterPicker.CounterPickerFragment.java

/**
 * Shows the loading text and pulses it. Ensures everything else is hidden
 *///w  w w.j a  va 2 s.co m
protected void startLoadingAnimation() {
    mLoadingText.setVisibility(View.VISIBLE);
    mLoadingText.setAlpha(1f);

    AlphaAnimation pulseAlphaAnimation = new AlphaAnimation(0.2f, 1f);
    pulseAlphaAnimation.setDuration(300);
    pulseAlphaAnimation.setRepeatCount(Animation.INFINITE);
    pulseAlphaAnimation.setRepeatMode(Animation.REVERSE);
    mLoadingText.startAnimation(pulseAlphaAnimation);
}