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.initiativaromania.hartabanilorpublici.IRUserInterface.activities.MainActivity.java

private void initTransparentView() {

    /* Avoid displaying infographic if the home button has been pushed */
    Intent intent = getIntent();/*from  w  ww .ja  va 2  s. c o  m*/
    displayInfographic = intent.getBooleanExtra(EXTRA_DISPLAY_INFOGRAPHIC, true);
    System.out.println("Display info " + displayInfographic);
    if (!displayInfographic) {
        LinearLayout linear = (LinearLayout) findViewById(R.id.transparentLayer);
        linear.setVisibility(View.INVISIBLE);
        return;
    }

    /* Setup the OK button */
    Button okButton = (Button) findViewById(R.id.okButton);
    if (okButton != null) {
        okButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                System.out.println("OK button pushed");

                Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_down);
                LinearLayout linear = (LinearLayout) findViewById(R.id.transparentLayer);
                linear.startAnimation(animation);
                linear.setVisibility(View.INVISIBLE);

                Toast toast = Toast.makeText(getBaseContext(), "Apasa pe simbolurile  din jurul tau",
                        Toast.LENGTH_LONG);
                toast.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL, 0, 0);
                toast.show();

                /* Display initial seek bar value */
                Rect thumbRect = seekBar.getThumb().getBounds();
                seekBarValue.setX(thumbRect.exactCenterX());
                DecimalFormat dm = new DecimalFormat("###,###.###");
                seekBarValue.setText(" " + String.valueOf(dm.format(CommManager.aroundTotalSum)) + " EURO ");
                seekBarValue.setVisibility(View.VISIBLE);
                seekBarValue.startAnimation(animationFadeIn);
            }
        });
    }

    /* Send request to get the init data */
    CommManager.requestInitData(new ICommManagerResponse() {
        @Override
        public void processResponse(JSONObject response) {
            MainActivity.this.receiveInitData(response);
        }

        @Override
        public void onErrorOccurred(String errorMsg) {
            Toast.makeText(MainActivity.this, "Eroare conectare la server", Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.awt.supark.MainActivity.java

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

    cont = this;//www.  ja v  a  2  s.  co  m

    // Animations
    anim_zoom_in = AnimationUtils.loadAnimation(this, R.anim.zoom_in);
    anim_zoom_out = AnimationUtils.loadAnimation(this, R.anim.zoom_out);
    anim_fade_in = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    anim_fade_out = AnimationUtils.loadAnimation(this, R.anim.fade_out);
    anim_slide_up_fade_in = AnimationUtils.loadAnimation(this, R.anim.slide_up_fade_in);
    anim_slide_down_fade_out = AnimationUtils.loadAnimation(this, R.anim.slide_down_fade_out);
    anim_center_open_up = AnimationUtils.loadAnimation(this, R.anim.center_open_up);
    anim_anticipate_rotate_zoom_out = AnimationUtils.loadAnimation(this, R.anim.anticipate_rotate_zoom_out);
    anim_anticipate_rotate_zoom_in = AnimationUtils.loadAnimation(this, R.anim.anticipate_rotate_zoom_in);
    anim_blink = AnimationUtils.loadAnimation(this, R.anim.blink);
    anim_car_enter = AnimationUtils.loadAnimation(this, R.anim.car_enter);
    anim_car_leave = AnimationUtils.loadAnimation(this, R.anim.car_leave);

    // UI elements
    btnPark = (ImageButton) findViewById(R.id.buttonPark);
    btnZone1 = (ImageButton) findViewById(R.id.buttonZone1);
    btnZone2 = (ImageButton) findViewById(R.id.buttonZone2);
    btnZone3 = (ImageButton) findViewById(R.id.buttonZone3);
    btnZone4 = (ImageButton) findViewById(R.id.buttonZone4);
    locationInfo = (TextView) findViewById(R.id.textViewLocationInfo);
    imageLocation = (ImageView) findViewById(R.id.imageLocation);
    imageCar = (ImageView) findViewById(R.id.imageCar);
    textParkingScreen = (TextView) findViewById(R.id.textParkingScreen);
    btnCars = (FloatingActionButton) findViewById(R.id.buttonCars);
    btnStatistics = (FloatingActionButton) findViewById(R.id.buttonStatistics);
    btnEtc = (FloatingActionButton) findViewById(R.id.buttonEtc);
    btnMap = (FloatingActionButton) findViewById(R.id.buttonMap);
    zonePrice = (TextView) findViewById(R.id.textViewZonePrice);
    licensePlate = (LinearLayout) findViewById(R.id.licensePlate);
    licenseCity = (TextView) findViewById(R.id.city);
    licenseNum = (TextView) findViewById(R.id.num);
    tapHereText = (LinearLayout) findViewById(R.id.tapHereText);
    tapHereText1 = (TextView) findViewById(R.id.tapHereText1);

    // Layouts
    backDimmer = (RelativeLayout) findViewById(R.id.back_dimmer);
    contentLinear = (LinearLayout) findViewById(R.id.contentLinear);
    tableRowTopHalf = (TableRow) findViewById(R.id.tableRowTopHalf);
    otherContent = (FrameLayout) findViewById(R.id.otherContent);
    parkingBackground = (LinearLayout) findViewById(R.id.parkingBackground);
    wrapper = (RelativeLayout) findViewById(R.id.wrapper);

    sharedprefs = PreferenceManager.getDefaultSharedPreferences(cont);
    autoLoc = sharedprefs.getBoolean("autoloc", true);
    lastLicense = sharedprefs.getBoolean("lastlicenseremember", true);
    showTicket = sharedprefs.getBoolean("showTicket", true);
    debugNumbers = sharedprefs.getBoolean("debugNumbers", true);
    debugsendsms = sharedprefs.getBoolean("debugsendsms", true);
    setLanguage(sharedprefs.getString("lang", "auto"));
    tapHereText1.setText(getString(R.string.tap_here2));
    if (lastLicense)
        currentLicense = sharedprefs.getString("lastlicense", "");

    fragmentManager = getSupportFragmentManager();

    // Setting up the handlers
    parkHandler = new ParkingDataHandler(this);
    parkHandler.checkForUpdate(); // Checks that the local database is up to date
    parkHandler.throwHandler(mHandler); // Initializes the message handler

    smsHandler = new ParkingSmsSender(this);
    smsHandler.throwHandler(smsResponse); // Initializes the message handler

    layoutHandler = new LayoutHandler(this);
    CarHandler = new carHandler(this);
    zoneHandler = new ZoneHandler(this);

    btnPark.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == android.view.MotionEvent.ACTION_DOWN) {
                view.startAnimation(anim_zoom_out);
                anim_zoom_out.setFillAfter(true);
            } else if (motionEvent.getAction() == android.view.MotionEvent.ACTION_UP) {
                view.startAnimation(anim_zoom_in);
                anim_zoom_in.setFillAfter(true);
            }

            return false;
        }
    });

    // Setting up a listener to track the click events for the parking button
    btnPark.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!pullUpStarted) {
                pullUpStarted = true;
                parkingInit("start");
            }
        }
    });

    // Turning off zone button highlight
    layoutHandler.activeZoneButton(0, act);

    // If the auto locate setting was enabled starts locating
    if (autoLoc) {
        getGPSzone(null);
    } else {
        currentZone = 0;
        layoutHandler.updateLocationTextButton(act);
    }

    CarHandler.updateLicense(act);
    setDebugNumbers();

    // Starting the background service
    mServiceIntent = new Intent(act, ParkingTimerService.class);
    Log.i("Main", "OnCreate");
    startTimerService(0);
}

From source file:com.amaze.filemanager.adapters.ZipAdapter.java

void animate(ZipAdapter.ViewHolder holder) {
    holder.rl.clearAnimation();/*  w  w w  .ja va  2 s  .c  om*/
    localAnimation = AnimationUtils.loadAnimation(zipViewer.getActivity(), R.anim.fade_in_top);
    localAnimation.setStartOffset(this.offset);
    holder.rl.startAnimation(localAnimation);
    this.offset = (30 + this.offset);
}

From source file:com.cssweb.android.trade.stock.StockTrading.java

@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    sc = new ServiceControl(this);//??
    ////from   www .ja  va2 s.co m
    HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD");
    mHandlerThread.start();
    priceHandler = new PriceDataHandler(mHandlerThread.getLooper());

    setContentView(com.cssweb.android.main.R.layout.zr_trade_stock_trade);
    Bundle bundle = getIntent().getExtras();
    type = bundle.getInt("type");
    bsname = bundle.getString("bsname");
    String stockCode = bundle.getString("stkcode");

    initTitle(R.drawable.njzq_title_left_back, 0, bsname);

    LinearLayout localLinearLayout = (LinearLayout) findViewById(R.id.zrtradelayout);
    localLinearLayout.setOnFocusChangeListener(setOnEditFocusListener);
    this.m_vklayout = localLinearLayout;
    View localView1 = this.m_vklayout;
    localView1.setOnFocusChangeListener(setOnEditFocusListener);
    View localView2 = this.m_vklayout;
    localView2.setOnClickListener(setOnEditClickListener);

    viewFlipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper01);
    preView = (ImageView) findViewById(R.id.previous_screen);

    leftIn = AnimationUtils.loadAnimation(this, R.anim.push_left_in_layout);
    leftOut = AnimationUtils.loadAnimation(this, R.anim.push_left_out_layout);
    rightIn = AnimationUtils.loadAnimation(this, R.anim.push_right_in_layout);
    rightOut = AnimationUtils.loadAnimation(this, R.anim.push_right_out_layout);

    priceView = (PriceMini) findViewById(R.id.zrviewprice);
    trendView = (TrendView) findViewById(R.id.zrviewtrend);
    trendView.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });
    klineView = (KlineMini) findViewById(R.id.zrviewkline);
    klineView.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });
    financeView = (FinanceMini) findViewById(R.id.zrviewfinance);

    stockHolder = (Spinner) findViewById(R.id.zrtxtaccount);
    queryMethod = (Spinner) findViewById(R.id.zrtxtbsflag);
    //      availableNum = (SeekBar) findViewById(R.id.zrcanbs);
    //      lblMaxNumber = (TextView)findViewById(R.id.txtMaxNumber);
    stkcode = (EditText) findViewById(R.id.zredtstockcode);
    stkname = (TextView) findViewById(R.id.zrtxtstockname);
    price = (EditText) findViewById(R.id.zredtprice);
    number = (EditText) findViewById(R.id.zredtcount);
    lblNumberUnit = (TextView) findViewById(R.id.lblNumberUnit);
    btn0 = (ShadowButton) findViewById(R.id.zr_surebutton);
    btn0.setOnClickListener(myShowProgreeBar);

    layoutprice0 = (LinearLayout) findViewById(R.id.LinearLayout03);
    layoutprice = (LinearLayout) findViewById(R.id.LinearLayout11);
    //layoutAvaiNumber = (LinearLayout)findViewById(R.id.LinearLayout04);
    //layoutAvaiAsset = (LinearLayout)findViewById(R.id.LinearLayout06);
    lblAvaiAsset = (TextView) findViewById(R.id.lblAvaiAsset);
    AvaiAsset = (TextView) findViewById(R.id.AvaiAsset);
    lblPrice = (TextView) findViewById(R.id.lblPrice);
    lblPrice1 = (TextView) findViewById(R.id.lblPrice1);
    lblNumber = (TextView) findViewById(R.id.lblNumber);
    avaiAsset = (TextView) findViewById(R.id.AvaiAsset);
    lblNumberUnit = (TextView) findViewById(R.id.lblNumberUnit);

    setDynamic();

    adjustDownPrice = (ImageView) findViewById(R.id.AdjustDownPrice);
    adjustDownPrice.setTag(0);
    adjustDownPrice.setOnClickListener(adjustIconListener);

    adjustUpPrice = (ImageView) findViewById(R.id.AdjustUpPrice);
    adjustUpPrice.setTag(1);
    adjustUpPrice.setOnClickListener(adjustIconListener);

    adjustDownNumber = (ImageView) findViewById(R.id.AdjustDownNumber);
    adjustDownNumber.setTag(2);
    adjustDownNumber.setOnClickListener(adjustIconListener);

    adjustUpNumber = (ImageView) findViewById(R.id.AdjustUpNumber);
    adjustUpNumber.setTag(3);
    adjustUpNumber.setOnClickListener(adjustIconListener);

    stkcode.setText(stockCode);
    if (stkcode.getText().length() == 6) {
        showProgress();
    }

    stkcode.setInputType(InputType.TYPE_NULL);
    stkcode.setFocusable(true);
    stkcode.setTag("STOCK");
    stkcode.setOnClickListener(setOnEditClickListener);
    stkcode.setOnFocusChangeListener(setOnEditFocusListener);

    price.setInputType(InputType.TYPE_NULL);
    price.setFocusable(true);
    price.setTag("NUMDOT");
    price.setOnClickListener(setOnEditClickListener);
    price.setOnFocusChangeListener(setOnEditFocusListener);

    number.setInputType(InputType.TYPE_NULL);
    number.setFocusable(true);
    number.setTag("");
    number.setOnClickListener(setOnEditClickListener);
    number.setOnFocusChangeListener(setOnEditFocusListener);

    stkcode.addTextChangedListener(new TextWatcher() {

        public void afterTextChanged(Editable arg0) {
            //queryStock(queryCode.getText());
            OnTextChanged(arg0);
        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

    });

    holder = TradeUser.getInstance().getHolder();

    stockHolderAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
            (String[]) holder.toArray(new String[holder.size()]));
    stockHolderAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    stockHolder.setAdapter(stockHolderAdapter);

    String[] arrayOfString = getResources().getStringArray(R.array.other_market_bs_methods);
    for (int i = 0; i < arrayOfString.length; i++) {
        Log.e("arrayOfString", arrayOfString[i]);
    }

    queryMethodAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arrayOfString);
    queryMethodAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    queryMethod.setAdapter(queryMethodAdapter);
    queryMethod.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position != 0) {
                layoutprice0.setVisibility(View.GONE);
                layoutprice.setVisibility(View.VISIBLE);
            } else {
                layoutprice0.setVisibility(View.VISIBLE);
                layoutprice.setVisibility(View.GONE);
            }
        }

        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });

    int h = R.drawable.forminput;
    Resources localResources = getResources();
    Drawable localDrawable = null;
    localDrawable = localResources.getDrawable(h);
    int spinnerheight = localDrawable.getIntrinsicHeight() - 4;
    //      Log.e("<<<<<<<<<<<<<<<<<<<eeeeeeeeeeeeeeeeeeeeeeeeeee>>>>>>>>>>>>>>", String.valueOf(spinnerheight));
    LinearLayout.LayoutParams linearParams1 = (LinearLayout.LayoutParams) stockHolder.getLayoutParams();//?stockHolder?
    linearParams1.height = spinnerheight;//??
    stockHolder.setLayoutParams(linearParams1);

    LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) queryMethod.getLayoutParams();//?queryMethod?
    linearParams.height = spinnerheight;//??
    queryMethod.setLayoutParams(linearParams);
}

From source file:net.mEmoZz.PopMovies.frags.MoviesFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    helper = new DBHelper(getActivity());
    if (isNetworkAvailable()) {
        handler.postDelayed(refreshing, 100);
        new CountDownTimer(400, 1000) {
            @Override// w w w  .  j  a v  a 2s  .c o m
            public void onTick(long millisUntilFinished) {
            }

            @Override
            public void onFinish() {
                if (conf.smallestScreenWidthDp >= 600) {
                    cornStamp.setVisibility(VISIBLE);
                    cornStamp.startAnimation(anim);
                }
            }
        }.start();
    } else {
        noConn.setVisibility(VISIBLE);
        noConnTxt.setVisibility(VISIBLE);
    }

    anim = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
    anim.setDuration(200);

    mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (isNetworkAvailable()) {
                movies.clear();
                SharedPreferences prefs = getActivity().getSharedPreferences(SORT, 0);
                String state = prefs.getString(SORT_SATE, "No pop!");
                if (state.equals("popChecked")) {
                    fullTask("popularity.desc");
                    adapter.notifyDataSetChanged();
                } else if (state.equals("highChecked")) {
                    fullTask("vote_average.desc");
                    adapter.notifyDataSetChanged();
                } else if (state.equals("favChecked")) {
                    dbTask();
                }
                new CountDownTimer(400, 1000) {
                    @Override
                    public void onTick(long millisUntilFinished) {
                    }

                    @Override
                    public void onFinish() {
                        if (conf.smallestScreenWidthDp >= 600) {
                            cornStamp.setVisibility(VISIBLE);
                            cornStamp.startAnimation(anim);
                        }
                    }
                }.start();
            } else {
                gridView.setVisibility(GONE);
                noConn.setVisibility(VISIBLE);
                noConnTxt.setVisibility(VISIBLE);
                mRefreshLayout.setRefreshing(false);
                if (conf.smallestScreenWidthDp >= 600) {
                    cornStamp.setVisibility(VISIBLE);
                    cornStamp.startAnimation(anim);
                }
            }
        }
    });
}

From source file:com.hang.exoplayer.PlayActivity.java

public void updatePlayView(boolean isPlaying) {
    if (isPlaying) {
        mPlayControlView.setImageResource(R.drawable.sel_radio_play);
        mPlayAnimView.setVisibility(View.VISIBLE);
        mPlayAnimView.startAnimation(AnimationUtils.loadAnimation(PlayActivity.this, R.anim.ri_live_rotate));
    } else {/*from  w w w . j a  v  a2s .  c o m*/
        mPlayControlView.setImageResource(R.drawable.sel_radio_pause);
        mPlayAnimView.clearAnimation();
        mPlayAnimView.setVisibility(View.INVISIBLE);
    }
}

From source file:com.king.base.BaseDialogFragment.java

public void startShake(View view) {
    view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.shake));
}

From source file:com.rowland.movies.ui.fragments.DetailFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Let the fragment handle its menu items
    setHasOptionsMenu(true);//w  w  w  . j a v a 2s. c  om
    // Don't destroy fragment across orientation change
    setRetainInstance(true);
    // Check if we have any arguments
    if (getArguments() != null) {
        // Acquire the selected movie identifier
        id = getArguments().getLong(DetailFragment.MOVIE_KEY);
        // Acquire movie instance
        mMovie = new MovieRepository().getWhereId(id);
        // Checek for null
        if (mMovie != null) {
            // Is movie Favourite
            isFavourite = mMovie.getIsFavourite();
            // Start services
            startReviewIntentService();
            startTrailerIntentService();
            // Initialize the review list
            mReviewList = new ArrayList<>();
            // Initialize the trailer list
            mTrailerList = new ArrayList<>();
            // Create an Animation
            simpleGrowAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.grow_bigger);
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_MessengerProj);
    super.onCreate(savedInstanceState);
    Theme.loadRecources(this);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (AndroidUtilities.isTablet()) {
        setContentView(R.layout.intro_layout_tablet);
    } else {//from  ww w . j ava2s. c o  m
        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.Intro7Headline, R.string.Intro6Headline, R.string.Intro5Headline,
                R.string.Intro4Headline, R.string.Intro3Headline, R.string.Intro2Headline,
                R.string.Intro1Headline };
        messages = new int[] { R.string.Intro7Message, R.string.Intro6Message, R.string.Intro5Message,
                R.string.Intro4Message, R.string.Intro3Message, R.string.Intro2Message,
                R.string.Intro1Message };
    } 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.Intro1Headline, R.string.Intro2Headline, R.string.Intro3Headline,
                R.string.Intro4Headline, R.string.Intro5Headline, R.string.Intro6Headline,
                R.string.Intro7Headline };
        messages = new int[] { R.string.Intro1Message, R.string.Intro2Message, R.string.Intro3Message,
                R.string.Intro4Message, R.string.Intro5Message, R.string.Intro6Message,
                R.string.Intro7Message };
    }
    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    startMessagingButton.setText(ApplicationLoader.applicationContext.getString(R.string.IntroStartMessaging)
            .toUpperCase(Locale.getDefault()));
    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();
        }
    });

    justCreated = true;
}

From source file:com.near.chimerarevo.fragments.CommentsFragment.java

public void setListShown(boolean shown, boolean animate) {
    if (mListShown == shown)
        return;//from   ww w . ja  v  a  2s . co  m

    mListShown = shown;
    if (shown) {
        if (animate) {
            try {
                mProgressContainer
                        .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
                mListContainer
                        .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        mProgressContainer.setVisibility(View.GONE);
        mListContainer.setVisibility(View.VISIBLE);
    } else {
        if (animate) {
            try {
                mProgressContainer
                        .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
                mListContainer
                        .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        mProgressContainer.setVisibility(View.VISIBLE);
        mListContainer.setVisibility(View.INVISIBLE);
    }
}