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.mdlive.sav.MDLiveProviderDetails.java

private void clickForVideoOrPhoneTapReqFutureAction() {
    findViewById(R.id.dateTxtLayout).setVisibility(View.VISIBLE);
    tapSeetheDoctorTxtLayout.setVisibility(View.GONE);
    reqfutureapptBtnLayout.setVisibility(View.GONE);
    videophoneparentLl.setVisibility(View.VISIBLE);
    horizontalscrollview.setVisibility(View.GONE);
    //This condition is only for PHS Users

    final UserBasicInfo userBasicInfo = UserBasicInfo.readFromSharedPreference(getBaseContext());
    //PHS user/*from   w w  w  .  j  a va 2s .  co  m*/
    if (userBasicInfo.getPersonalInfo().getConsultMethod().equalsIgnoreCase("video")) {
        byphoneBtnLayout.setVisibility(View.INVISIBLE);
        byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
        byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
        byphoneBtnLayout.setClickable(false);

        saveAppmtType("video");
        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        byvideoBtn.setTextColor(Color.GRAY);
        byvideoBtn.setTextColor(Color.GRAY);
        byvideoBtnLayout.setVisibility(View.VISIBLE);
        byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                    byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                    byvideoBtn.setTextColor(Color.WHITE);
                    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                    ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
                    byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                    byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                    byphoneBtnLayout.setVisibility(View.INVISIBLE);
                    byphoneBtnLayout.setClickable(false);

                    horizontalscrollview.setVisibility(View.VISIBLE);
                    final LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                    if (layout.getChildCount() > 0) {
                        layout.removeAllViews();
                    }

                    for (TextView tv : videoList) {
                        layout.addView(tv);
                    }
                    saveConsultationType("Video", MDLiveProviderDetails.this);
                    //Enable Request Appointment Button
                    enableReqAppmtBtn();
                    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                    //horizontalscrollview.smoothScrollTo(0,0);

                    horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                    horizontalscrollview.postDelayed(new Runnable() {
                        public void run() {
                            horizontalscrollview.fullScroll(HorizontalScrollView.FOCUS_LEFT);
                        }
                    }, 100L);
                    //horizontalscrollview.fullScroll(HorizontalScrollView.FOCUS_LEFT);
                    selectedTimeslot = false;
                    enableReqAppmtBtn();
                    clearTimeSlotViews();
                    horizontalscrollview.startAnimation(AnimationUtils.loadAnimation(MDLiveProviderDetails.this,
                            R.anim.mdlive_trans_left_in));

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else if (userBasicInfo.getPersonalInfo().getConsultMethod().equalsIgnoreCase("phone")) {
        phsOnlyForPhone();
    }
    //Only For idaho
    else if (longLocation.equalsIgnoreCase("idaho")) {
        onlyForIdaho();
    }
    //Only For Texas
    else if (longLocation.equalsIgnoreCase("texas")) {
        phsOnlyForPhone();
    }
    //Vido or Phone Button on Click listener for Blue color
    else {
        //Disabling the Video or Phone Based on the Phone list and video list
        //if the phone list is empty we should not shown the Phone Layout
        //if the video list is empty then we should not show the Video Layout.
        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon);
        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);
        byvideoBtn.setTextColor(Color.GRAY);
        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        byphoneBtn.setTextColor(Color.GRAY);

        if (videoList.size() == 0) {
            saveAppmtType("phone");
            byvideoBtnLayout.setVisibility(View.VISIBLE);
            byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
            byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
            ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
            byvideoBtnLayout.setClickable(false);
        } else {
            byvideoBtnLayout.setVisibility(View.VISIBLE);
            byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                        byvideoBtn.setTextColor(Color.WHITE);
                        ((ImageView) findViewById(R.id.videoicon))
                                .setImageResource(R.drawable.video_icon_white);
                        byphoneBtnLayout.setVisibility(View.VISIBLE);
                        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
                        byphoneBtn.setTextColor(Color.GRAY);
                        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);

                        horizontalscrollview.setVisibility(View.VISIBLE);
                        LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                        if (layout.getChildCount() > 0) {
                            layout.removeAllViews();
                        }

                        for (TextView tv : videoList) {
                            layout.addView(tv);
                        }
                        saveConsultationType("Video", MDLiveProviderDetails.this);
                        //Enable Request Appointment Button

                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        ((ImageView) findViewById(R.id.videoicon))
                                .setImageResource(R.drawable.video_icon_white);
                        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);
                        selectedTimeslot = false;
                        enableReqAppmtBtn();
                        clearTimeSlotViews();
                        horizontalscrollview.startAnimation(AnimationUtils
                                .loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        if (phoneList.size() == 0) {
            saveAppmtType("video");
            byphoneBtnLayout.setVisibility(View.VISIBLE);
            byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
            byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
            ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
            byphoneBtnLayout.setClickable(false);
        } else {
            byphoneBtnLayout.setVisibility(View.VISIBLE);
            byphoneBtnLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                        byphoneBtn.setTextColor(Color.WHITE);
                        ((ImageView) findViewById(R.id.phoneicon))
                                .setImageResource(R.drawable.phone_icon_white);

                        byvideoBtnLayout.setVisibility(View.VISIBLE);
                        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
                        byvideoBtn.setTextColor(Color.GRAY);
                        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
                        horizontalscrollview.setVisibility(View.VISIBLE);
                        LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                        if (layout.getChildCount() > 0) {
                            layout.removeAllViews();
                        }
                        for (TextView tv : phoneList) {
                            layout.addView(tv);
                        }
                        saveConsultationType("Phone", MDLiveProviderDetails.this);
                        //Enable Request Appointment Button

                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        ((ImageView) findViewById(R.id.phoneicon))
                                .setImageResource(R.drawable.phone_icon_white);
                        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon);
                        selectedTimeslot = false;
                        enableReqAppmtBtn();
                        clearTimeSlotViews();
                        horizontalscrollview.startAnimation(AnimationUtils
                                .loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

    }

}

From source file:com.androidquery.AQuery.java

/**
 * Starts an animation on the view./*from   w  ww .  ja va 2s  . c  o  m*/
 * 
 * <br>
 * contributed by: marcosbeirigo
 * 
 * @param animId Id of the desired animation.
 * @param listener The listener to recieve notifications from the animation on its events.
 * @return self
 * 
 * 
 */
public AQuery animate(int animId, AnimationListener listener) {
    Animation anim = AnimationUtils.loadAnimation(getContext(), animId);
    anim.setAnimationListener(listener);
    return animate(anim);
}

From source file:com.androidquery.AbstractAQuery.java

/**
 * Starts an animation on the view./*from   w  w  w  .j a  v a2s.  co m*/
 * 
 * <br>
 * contributed by: marcosbeirigo
 * 
 * @param animId Id of the desired animation.
 * @param listener The listener to recieve notifications from the animation on its events.
 * @return self
 * 
 * 
 */
public T animate(int animId, AnimationListener listener) {
    Animation anim = AnimationUtils.loadAnimation(getContext(), animId);
    anim.setAnimationListener(listener);
    return animate(anim);
}

From source file:com.haomee.chat.activity.ChatActivity.java

private void startQuestionAnim() {

    if (is_anim_started) {
        return;/*www .j  av  a2s . c o m*/
    }

    MySoundPlayer.getInstance(this).play_background(R.raw.sound_question, false);

    if (q1 == null) {
        q1 = questionContainer.findViewById(R.id.q1);
        q2 = questionContainer.findViewById(R.id.q2);
        q3 = questionContainer.findViewById(R.id.q3);
        q4 = questionContainer.findViewById(R.id.q4);
        anim_liulian = (AnimationDrawable) bt_liulian_question.getDrawable();
        anim_arrow = (AnimationDrawable) ((ImageView) questionContainer.findViewById(R.id.icon_arrow))
                .getDrawable();

        q1.setVisibility(View.INVISIBLE);
        q2.setVisibility(View.INVISIBLE);
        q3.setVisibility(View.INVISIBLE);
        q4.setVisibility(View.INVISIBLE);

        anim_q1 = AnimationUtils.loadAnimation(this, R.anim.fade_in_fade_out);
        anim_q2 = AnimationUtils.loadAnimation(this, R.anim.fade_in_fade_out);
        anim_q3 = AnimationUtils.loadAnimation(this, R.anim.fade_in_fade_out);
        anim_q4 = AnimationUtils.loadAnimation(this, R.anim.fade_in_fade_out);

        anim_q4.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                is_anim_started = true;
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                sendRandomQuestion();
                is_anim_started = false;

                if (anim_liulian != null) {
                    anim_liulian.stop();
                }

            }
        });

        anim_q2.setStartOffset(500);
        anim_q3.setStartOffset(1000);
        anim_q4.setStartOffset(1500);
    }

    q1.startAnimation(anim_q1);
    q2.startAnimation(anim_q2);
    q3.startAnimation(anim_q3);
    q4.startAnimation(anim_q4);

    anim_liulian.start();
    anim_arrow.start();

}

From source file:com.httrack.android.HTTrackActivity.java

protected void displayFinishedPanel(final String displayMessage, final long errorsCount) {
    handlerUI.post(new Runnable() {
        @Override/*ww  w  .j a  v  a 2  s.com*/
        public void run() {
            // Final pane
            setPane(LAYOUT_FINISHED);

            // Fancy result message
            if (displayMessage != null) {
                final View view = findViewById(R.id.fieldDisplay);
                if (view != null) {
                    TextView.class.cast(view).setText(Html.fromHtml(displayMessage));
                }
            }
            if (errorsCount != 0) {
                final View view = findViewById(R.id.buttonLogs);
                if (view != null) {
                    final Animation shake = AnimationUtils.loadAnimation(HTTrackActivity.this, R.anim.scale);
                    view.startAnimation(shake);
                }
            }
            /* If not visible, send a notification. */
            if (!started) {
                final String name = mapper.getProjectName();
                final String finished = getString(R.string.mirror_finished);
                /* FIXME TODO check intent */
                final Intent current = getCurrentIntentReference();
                sendSystemNotification(current, finished + ": " + name, Html.fromHtml(displayMessage));
            }
        }
    });
}

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

private void pressAnimation() {
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.keypress);
    //view.startAnimation(anim);
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void onlyForIdaho() {
    byphoneBtnLayout.setVisibility(View.VISIBLE);
    byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
    byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
    ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
    byphoneBtnLayout.setClickable(false);
    saveAppmtType("video");
    byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
    byvideoBtn.setTextColor(Color.GRAY);
    byvideoBtn.setTextColor(Color.GRAY);
    byvideoBtnLayout.setVisibility(View.VISIBLE);
    byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
        @Override/*  w  w  w.j  a va  2  s.  c  om*/
        public void onClick(View v) {
            try {
                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                byvideoBtn.setTextColor(Color.WHITE);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
                byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                byphoneBtnLayout.setVisibility(View.VISIBLE);
                byphoneBtnLayout.setClickable(false);

                horizontalscrollview.setVisibility(View.VISIBLE);
                LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                if (layout.getChildCount() > 0) {
                    layout.removeAllViews();
                }

                for (TextView tv : videoList) {
                    layout.addView(tv);
                }
                saveConsultationType("Video", MDLiveProviderDetails.this);
                //Enable Request Appointment Button

                horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                selectedTimeslot = false;
                enableReqAppmtBtn();
                clearTimeSlotViews();
                horizontalscrollview.startAnimation(
                        AnimationUtils.loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

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

private void slideAnimation() {
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.slider);
    kv.startAnimation(anim);
}

From source file:com.kll.collect.android.activities.FormEntryActivity.java

/**
 * Displays the View specified by the parameter 'next', animating both the
 * current view and next appropriately given the AnimationType. Also updates
 * the progress bar.//  w w  w.  j  a  v a 2  s.  com
 */
public void showView(View next, AnimationType from) {

    // disable notifications...
    if (mInAnimation != null) {
        mInAnimation.setAnimationListener(null);
    }
    if (mOutAnimation != null) {
        mOutAnimation.setAnimationListener(null);

    }

    // logging of the view being shown is already done, as this was handled
    // by createView()
    switch (from) {
    case RIGHT:
        mInAnimation = AnimationUtils.loadAnimation(this, R.anim.push_left_in);
        mOutAnimation = AnimationUtils.loadAnimation(this, R.anim.push_left_out);
        break;
    case LEFT:
        mInAnimation = AnimationUtils.loadAnimation(this, R.anim.push_right_in);
        mOutAnimation = AnimationUtils.loadAnimation(this, R.anim.push_right_out);
        break;
    case FADE:
        mInAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
        mOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
        break;
    }

    // complete setup for animations...
    mInAnimation.setAnimationListener(this);
    mOutAnimation.setAnimationListener(this);

    // drop keyboard before transition...
    if (mCurrentView != null) {
        InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.hideSoftInputFromWindow(mCurrentView.getWindowToken(), 0);
    }

    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);

    // adjust which view is in the layout container...
    mStaleView = mCurrentView;
    mCurrentView = next;
    mQuestionHolder.addView(mCurrentView, lp);
    mAnimationCompletionSet = 0;

    if (mStaleView != null) {
        // start OutAnimation for transition...
        mStaleView.startAnimation(mOutAnimation);
        // and remove the old view (MUST occur after start of animation!!!)
        mQuestionHolder.removeView(mStaleView);
    } else {
        mAnimationCompletionSet = 2;
    }
    // start InAnimation for transition...
    mCurrentView.startAnimation(mInAnimation);

    String logString = "";
    switch (from) {
    case RIGHT:
        logString = "next";
        break;
    case LEFT:
        logString = "previous";
        break;
    case FADE:
        logString = "refresh";
        break;
    }

    Collect.getInstance().getActivityLogger().logInstanceAction(this, "showView", logString);
}

From source file:com.httrack.android.HTTrackActivity.java

/**
 * Validate the current pane with visual effects on error. Thanks to Sushant
 * for the idea./*w  w  w.  j a v a2  s. c  om*/
 * 
 * @return true if the current pane is valid
 */
protected boolean validatePaneWithEffects(final boolean next) {
    final boolean validated = validatePane();
    if (!validated) {
        final Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
        findViewById(next ? R.id.buttonNext : R.id.buttonPrevious).startAnimation(shake);
    }
    return validated;
}