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.github.howeyc.slideshow.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mainLayout = (RelativeLayout) findViewById(R.id.mainLayout);
    mPause = (ImageView) findViewById(R.id.pauseIcon);
    mRemainingTimeLayout = (LinearLayout) findViewById(R.id.remaining_time);
    mFadeInAnim = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    mFadeOutAnim = AnimationUtils.loadAnimation(this, R.anim.fade_out);
    //mConnCheckOC = false;
    //mConnCheckSMB = false;
    rightToLeft = true;//from w  w  w  .ja  va  2s  .c o m
    paused = false;
    enableGestures();
    //deletePreferences();
    //createSettingsIfInexistent();
    if (getSupportActionBar() != null) {
        getSupportActionBar().hide();
    }
    initializeTransitions();
    pager = (CustomViewPager) findViewById(R.id.pager);
    mContext = getApplicationContext();
    loadAdapter();
    setUpSlideShow();

    mOldPath = AppData.getImagePath();
    mOldRecursive = AppData.getRecursiveSearch();

    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            selectTransformer();
        }
    });

    //getlastpage
    currentPage = AppData.getCurrentPage();
    if (pager.getAdapter().getCount() < currentPage) {
        currentPage = 1;
    }

    System.out.println("STARTING PAGE  " + currentPage);

    rightToLeft = AppData.getDirection();

    new AlarmScheduler().scheduleAlarm();
}

From source file:com.tamuhack.bootcamp.MessagesFragment.java

public void showError() {
    Animation slideDown = AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_out_top);
    slideDown.setAnimationListener(new Animation.AnimationListener() {
        @Override// ww  w. j  a  v a2s  . c  o  m
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // need to hide the view when the animation is complete
            mError.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    mError.startAnimation(slideDown);
    mError.setVisibility(View.VISIBLE);
}

From source file:com.aniruddhc.acemusic.player.NowPlayingActivity.NowPlayingActivity.java

@SuppressLint("NewApi")
@Override//  w  w  w .  ja va 2  s . com
protected void onCreate(Bundle savedInstanceState) {
    mContext = getApplicationContext();
    mApp = (Common) getApplicationContext();
    mApp.setNowPlayingActivity(this);
    setNowPlayingActivityListener(mApp.getPlaybackKickstarter());
    mFadeInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.slide_in_from_top);
    mFadeInAnimation.setDuration(700);

    //Set the UI theme.
    setTheme();

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_now_playing);

    //Set the volume stream for this activity.
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    //Drawer layout.
    if (!mApp.isTabletInLandscape()) {
        mDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_drawer_root);
        mDrawerParentLayout = (FrameLayout) findViewById(R.id.now_playing_drawer_frame_root);
        mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
        mDrawerLayout.setDrawerListener(mDrawerListener);
        mDrawerLayout.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    } else {
        mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
    }

    //ViewPager.
    mViewPager = (VelocityViewPager) findViewById(R.id.nowPlayingPlaylistPager);

    //Seekbar indicator.
    mSeekbarIndicatorLayoutParent = (RelativeLayout) findViewById(R.id.seekbarIndicatorParent);
    mSeekbarIndicatorLayout = (RelativeLayout) findViewById(R.id.seekbarIndicator);
    mSeekbarIndicatorText = (TextView) findViewById(R.id.seekbarIndicatorText);

    mSeekbarIndicatorLayoutParent.setVisibility(View.GONE);
    mSeekbarIndicatorLayout.setBackgroundResource(UIElementsHelper.getGridViewCardBackground(mContext));
    mSeekbarIndicatorText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    mSeekbarIndicatorText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));

    //Playback Controls.
    mControlsLayoutHeaderParent = (RelativeLayout) findViewById(R.id.now_playing_controls_header_parent);
    mControlsLayoutHeader = (RelativeLayout) findViewById(R.id.now_playing_controls_header);
    mPlayPauseButtonBackground = (RelativeLayout) findViewById(R.id.playPauseButtonBackground);
    mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
    mNextButton = (ImageButton) findViewById(R.id.nextButton);
    mPreviousButton = (ImageButton) findViewById(R.id.previousButton);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton);
    mRepeatButton = (ImageButton) findViewById(R.id.repeatButton);

    //Song info/seekbar elements.
    mSeekbar = (SeekBar) findViewById(R.id.nowPlayingSeekBar);
    mStreamingProgressBar = (ProgressBar) findViewById(R.id.startingStreamProgressBar);
    mStreamingProgressBar.setVisibility(View.GONE);

    try {
        mSeekbar.setThumb(getResources().getDrawable(R.drawable.transparent_drawable));
    } catch (Exception e) {
        e.printStackTrace();
    }

    mPlayPauseButtonBackground.setBackgroundResource(UIElementsHelper.getShadowedCircle(mContext));
    mPlayPauseButton.setImageResource(R.drawable.pause_light);
    mPlayPauseButton.setId(R.drawable.pause_light);
    mNextButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_next"));
    mPreviousButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_previous"));

    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
        mNextButton.setAlpha(1f);
        mPreviousButton.setAlpha(1f);
    }

    //KitKat specific layout code.
    setKitKatTranslucentBars();

    //Set the control buttons and background.
    setControlButtonsBackground();
    setPlayPauseButton();
    setShuffleButtonIcon();
    setRepeatButtonIcon();

    //Set the click listeners.
    mSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
    mNextButton.setOnClickListener(mOnClickNextListener);
    mPreviousButton.setOnClickListener(mOnClickPreviousListener);
    mPlayPauseButton.setOnClickListener(playPauseClickListener);
    mPlayPauseButtonBackground.setOnClickListener(playPauseClickListener);
    mShuffleButton.setOnClickListener(shuffleButtonClickListener);
    mRepeatButton.setOnClickListener(repeatButtonClickListener);

    //Apply haptic feedback to the play/pause button.
    mPlayPauseButtonBackground.setHapticFeedbackEnabled(true);
    mPlayPauseButton.setHapticFeedbackEnabled(true);

}

From source file:com.lithiumli.fiction.LibraryActivity.java

private void hidePlayerInfo() {
    View bab = findViewById(R.id.bab);
    View bab_hr = findViewById(R.id.bab_hr);
    if (bab.getVisibility() == View.VISIBLE) {
        Animation hideBab = AnimationUtils.loadAnimation(this, R.anim.bab_hide);
        bab.startAnimation(hideBab);/*from   www . jav  a 2s.  c o m*/
        bab_hr.startAnimation(hideBab);
        bab.setVisibility(View.GONE);
    }
}

From source file:com.negaheno.ui.IntroActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_TMessages);//from w ww .j av a 2  s. co m
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (AndroidUtilities.isTablet()) {
        setContentView(R.layout.intro_layout_tablet);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.intro_layout);
    }

    if (LocaleController.isRTL) {
        icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4,
                R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 };
        titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title,
                R.string.Page3Title, R.string.Page2Title, R.string.Page1Title };
        messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message,
                R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message };
    } else {
        icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4,
                R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 };
        titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title,
                R.string.Page5Title, R.string.Page6Title, R.string.Page7Title };
        messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message,
                R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message };
    }
    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    startMessagingButton
            .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase());
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                .setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                .setDuration(200));
        startMessagingButton.setStateListAnimator(animator);
    }
    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) {
            if (startPressed) {
                return;
            }
            startPressed = true;
            Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
            intent2.putExtra("fromIntro", true);
            startActivity(intent2);
            finish();
        }
    });

    justCreated = true;
}

From source file:com.panahit.ui.IntroActivity.java

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

    if (AndroidUtilities.isTablet()) {
        setContentView(R.layout.intro_layout_tablet);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.intro_layout);
    }

    if (LocaleController.isRTL) {
        icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4,
                R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 };
        titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title,
                R.string.Page3Title, R.string.Page2Title, R.string.Page1Title };
        messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message,
                R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message };
    } else {
        icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4,
                R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 };
        titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title,
                R.string.Page5Title, R.string.Page6Title, R.string.Page7Title };
        messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message,
                R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message };
    }
    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    startMessagingButton
            .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase());
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                .setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                .setDuration(200));
        startMessagingButton.setStateListAnimator(animator);
    }
    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.addOnPageChangeListener(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) {
            if (startPressed) {
                return;
            }
            startPressed = true;
            Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
            intent2.putExtra("fromIntro", true);
            startActivity(intent2);
            finish();
        }
    });
    if (BuildVars.DEBUG_VERSION) {
        startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ConnectionsManager.getInstance().switchBackend();
                return true;
            }
        });
    }

    justCreated = true;
}

From source file:com.lightplus.MainActivity.java

/**
 * Click event for all light controllers
 *///from  w w  w .j a  v  a 2s.c om
public void toggleLight(View v) {
    if (on) {
        turnOff();
        if (v.getId() == R.id.button_black) {
            Animation fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in);
            v.startAnimation(fadeIn);
        }
    } else {
        turnOn();
        if (v.getId() == R.id.button_black) {
            Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out);
            v.startAnimation(fadeOut);
        }
    }
}

From source file:com.ae.apps.messagecounter.fragments.SentCountFragment.java

/**
 * This method sets up the data that needs to be displyed if we have to show the content
 *//*from  w  w  w.  j a v a 2 s .c  o m*/
private void showSentCountDetails() {
    // Lets find the cycle start date
    Date cycleStartDate = MessageCounterUtils.getCycleStartDate(mPreferences);

    mCycleDurationText.setText(MessageCounterUtils.getDurationDateString(cycleStartDate));

    // Get the sent count details from the database
    SentCountDataManager dataManager = new SentCountDataManager();
    SentCountDetailsVo detailsVo = dataManager.getSentCountData(mContext);

    // set no of messages sent today and in this cycle
    mSentTodayText.setText(String.valueOf(detailsVo.getSentToday()));
    mHeroSentTodayText.setText(String.valueOf(detailsVo.getSentToday()));
    mHeroSentInCycleText.setText(String.valueOf(detailsVo.getSentCycle()));

    // set the progressbar
    setProgressInfo(detailsVo.getSentCycle(), detailsVo.getCycleLimit(), mProgressBar, mProgressText, 0);

    // Show the previous cycle details
    int lastCycle = detailsVo.getSentLastCycle();
    Date prevCycleStartDate = MessageCounterUtils.getPrevCycleStartDate(cycleStartDate);
    mPrevCycleSentText.setText(String.valueOf(lastCycle));
    mPrevCycleDurationText.setText(MessageCounterUtils.getDurationDateString(prevCycleStartDate));

    // set the progressbar for the last cycle
    setProgressInfo(lastCycle, detailsVo.getCycleLimit(), mPrevCountProgressBar, mPrevCycleSentText, 0);

    // Some basic animations
    Animation fadeInAnimation = AnimationUtils.loadAnimation(mContext, R.animator.fade_in);
    fadeInAnimation.setStartOffset(150);
    mSentCounterLayout.startAnimation(fadeInAnimation);
}

From source file:com.goftagram.telegram.ui.IntroActivity.java

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

    if (AndroidUtilities.isTablet()) {
        setContentView(R.layout.intro_layout_tablet);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.intro_layout);
    }

    if (LocaleController.isRTL) {
        icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4,
                R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 };
        titles = new int[] { R.string.Page7Title, R.string.Page6Title, R.string.Page5Title, R.string.Page4Title,
                R.string.Page3Title, R.string.Page2Title, R.string.Page1Title };
        messages = new int[] { R.string.Page7Message, R.string.Page6Message, R.string.Page5Message,
                R.string.Page4Message, R.string.Page3Message, R.string.Page2Message, R.string.Page1Message };
    } else {
        icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4,
                R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 };
        titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title,
                R.string.Page5Title, R.string.Page6Title, R.string.Page7Title };
        messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message,
                R.string.Page4Message, R.string.Page5Message, R.string.Page6Message, R.string.Page7Message };
    }
    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    startMessagingButton
            .setText(LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase());
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                .setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                .setDuration(200));
        startMessagingButton.setStateListAnimator(animator);
    }
    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.addOnPageChangeListener(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) {
            if (startPressed) {
                return;
            }
            startPressed = true;
            Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
            intent2.putExtra("fromIntro", true);
            startActivity(intent2);
            finish();
        }
    });
    if (BuildConfig.DEBUG) {
        startMessagingButton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ConnectionsManager.getInstance().switchBackend();
                return true;
            }
        });
    }

    justCreated = true;
}

From source file:com.mercandalli.android.apps.files.admin.ServerDataFragment.java

public void updateAdapter() {
    if (this.recyclerView != null && this.list != null && this.isAdded()) {
        this.circularProgressBar.setVisibility(View.GONE);

        this.mAdapter = new AdapterModelInformation(list);
        this.recyclerView.setAdapter(mAdapter);
        this.recyclerView
                .setItemAnimator(/*new SlideInFromLeftItemAnimator(mRecyclerView)*/new DefaultItemAnimator());

        if (circle.getVisibility() == View.GONE) {
            circle.setVisibility(View.VISIBLE);
            Animation animOpen = AnimationUtils.loadAnimation(getContext(), R.anim.circle_button_bottom_open);
            circle.startAnimation(animOpen);
        }/*from  w  w w  . ja v a2  s.c om*/

        circle.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mAdapter.addItem(new ModelInformation("Number", "" + i), 0);
                recyclerView.scrollToPosition(0);
                i++;
            }
        });

        this.mAdapter.setOnItemClickListener(new AdapterModelInformation.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

            }
        });

        this.swipeRefreshLayout.setRefreshing(false);
        i = 0;
    }
}