Example usage for android.view.animation Animation RELATIVE_TO_SELF

List of usage examples for android.view.animation Animation RELATIVE_TO_SELF

Introduction

In this page you can find the example usage for android.view.animation Animation RELATIVE_TO_SELF.

Prototype

int RELATIVE_TO_SELF

To view the source code for android.view.animation Animation RELATIVE_TO_SELF.

Click Source Link

Document

The specified dimension holds a float and should be multiplied by the height or width of the object being animated.

Usage

From source file:ly.kite.journey.selection.ProductOverviewFragment.java

/*****************************************************
 *
 * Returns the content view for this fragment
 *
 *****************************************************/
@Override//from   w ww  . jav  a2s.  c  o m
public View onCreateView(LayoutInflater layoutInflator, ViewGroup container, Bundle savedInstanceState) {
    boolean slidingDrawerIsExpanded = false;

    // Get any saved instance state

    if (savedInstanceState != null) {
        slidingDrawerIsExpanded = savedInstanceState.getBoolean(BUNDLE_KEY_SLIDING_DRAWER_IS_EXPANDED, false);
    } else {
        Analytics.getInstance(mKiteActivity).trackProductOverviewScreenViewed(mProduct);
    }

    // Set up the screen. Note that the SDK allows for different layouts to be used in place of the standard
    // one, so some of these views are optional and may not actually exist in the current layout.

    View view = layoutInflator.inflate(R.layout.screen_product_overview, container, false);

    mProductImageViewPager = (ViewPager) view.findViewById(R.id.view_pager);
    mOverlaidComponents = view.findViewById(R.id.overlaid_components);
    mPagingDots = (PagingDots) view.findViewById(R.id.paging_dots);
    mOverlaidStartButton = (Button) view.findViewById(R.id.overlaid_start_button);
    mSlidingOverlayFrame = (SlidingOverlayFrame) view.findViewById(R.id.sliding_overlay_frame);
    mDrawerControlLayout = view.findViewById(R.id.drawer_control_layout);
    mOpenCloseDrawerIconImageView = (ImageView) view.findViewById(R.id.open_close_drawer_icon_image_view);
    mProceedOverlayButton = (Button) view.findViewById(R.id.proceed_overlay_button);
    TextView priceTextView = (TextView) view.findViewById(R.id.price_text_view);
    TextView summaryDescriptionTextView = (TextView) view.findViewById(R.id.summary_description_text_view);
    TextView summaryShippingTextView = (TextView) view.findViewById(R.id.summary_shipping_text_view);
    View descriptionLayout = view.findViewById(R.id.description_layout);
    TextView descriptionTextView = (TextView) view.findViewById(R.id.description_text_view);
    View sizeLayout = view.findViewById(R.id.size_layout);
    TextView sizeTextView = (TextView) view.findViewById(R.id.size_text_view);
    View quantityLayout = view.findViewById(R.id.quantity_layout);
    TextView quantityTextView = (TextView) view.findViewById(R.id.quantity_text_view);
    TextView shippingTextView = (TextView) view.findViewById(R.id.shipping_text_view);

    // Paging dots

    Animation pagingDotOutAlphaAnimation = new AlphaAnimation(PAGING_DOT_ANIMATION_OPAQUE,
            PAGING_DOT_ANIMATION_TRANSLUCENT);
    pagingDotOutAlphaAnimation.setFillAfter(true);
    pagingDotOutAlphaAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);

    Animation pagingDotOutScaleAnimation = new ScaleAnimation(0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, 0f,
            PAGING_DOT_ANIMATION_NORMAL_SCALE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);

    pagingDotOutScaleAnimation.setFillAfter(true);
    pagingDotOutScaleAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);
    pagingDotOutScaleAnimation.setInterpolator(new BellInterpolator(1.0f, 0.8f, true));

    AnimationSet pagingDotOutAnimation = new AnimationSet(false);
    pagingDotOutAnimation.addAnimation(pagingDotOutAlphaAnimation);
    pagingDotOutAnimation.addAnimation(pagingDotOutScaleAnimation);
    pagingDotOutAnimation.setFillAfter(true);

    Animation pagingDotInAlphaAnimation = new AlphaAnimation(PAGING_DOT_ANIMATION_TRANSLUCENT,
            PAGING_DOT_ANIMATION_OPAQUE);
    pagingDotInAlphaAnimation.setFillAfter(true);
    pagingDotInAlphaAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);

    Animation pagingDotInScaleAnimation = new ScaleAnimation(0f, PAGING_DOT_ANIMATION_NORMAL_SCALE, 0f,
            PAGING_DOT_ANIMATION_NORMAL_SCALE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);

    pagingDotInScaleAnimation.setFillAfter(true);
    pagingDotInScaleAnimation.setDuration(PAGING_DOT_ANIMATION_DURATION_MILLIS);
    pagingDotInScaleAnimation.setInterpolator(new BellInterpolator(1.0f, 1.2f));

    AnimationSet pagingDotInAnimation = new AnimationSet(false);
    pagingDotInAnimation.addAnimation(pagingDotInAlphaAnimation);
    pagingDotInAnimation.addAnimation(pagingDotInScaleAnimation);
    pagingDotInAnimation.setFillAfter(true);

    mPagingDots.setProperties(mProduct.getImageURLList().size(), R.drawable.paging_dot_unselected,
            R.drawable.paging_dot_selected);
    mPagingDots.setOutAnimation(pagingDotOutAlphaAnimation);
    mPagingDots.setInAnimation(pagingDotInAnimation);

    mProductImageViewPager.setOnPageChangeListener(mPagingDots);

    mOverlaidComponents.setAlpha(slidingDrawerIsExpanded ? 0f : 1f); // If the drawer starts open, these components need to be invisible

    if (mSlidingOverlayFrame != null) {
        mSlidingOverlayFrame.snapToExpandedState(slidingDrawerIsExpanded);
        mSlidingOverlayFrame.setSlideAnimationDuration(SLIDE_ANIMATION_DURATION_MILLIS);
        mOpenCloseDrawerIconImageView.setRotation(
                slidingDrawerIsExpanded ? OPEN_CLOSE_ICON_ROTATION_DOWN : OPEN_CLOSE_ICON_ROTATION_UP);
    }

    SingleUnitSize size = mProduct.getSizeWithFallback(UnitOfLength.CENTIMETERS);
    boolean formatAsInt = size.getWidth() == (int) size.getWidth()
            && size.getHeight() == (int) size.getHeight();
    String sizeFormatString = getString(
            formatAsInt ? R.string.product_size_format_string_int : R.string.product_size_format_string_float);
    String sizeString = String.format(sizeFormatString, size.getWidth(), size.getHeight(),
            size.getUnit().shortString(mKiteActivity));

    int quantityPerSheet = mProduct.getQuantityPerSheet();
    MultipleDestinationShippingCosts shippingCosts = mProduct.getShippingCosts();

    Locale locale = Locale.getDefault();
    Country country = Country.getInstance(locale);

    SingleCurrencyAmount singleCurrencyCost;

    // Price

    if (isVisible(priceTextView)) {
        singleCurrencyCost = mProduct.getCostWithFallback(locale);

        if (singleCurrencyCost != null)
            priceTextView.setText(singleCurrencyCost.getDisplayAmountForLocale(locale));
    }

    // Summary description. This is a short description - not to be confused with the (full) description.

    if (isVisible(summaryDescriptionTextView)) {
        String summaryDescription = String.valueOf(quantityPerSheet) + " " + mProduct.getName()
                + (Product.isSensibleSize(size) ? " (" + sizeString + ")" : "");

        summaryDescriptionTextView.setText(summaryDescription);
    }

    // (Full) description

    String description = mProduct.getDescription();

    boolean haveDescription = (description != null && (!description.trim().equals("")));

    if (haveDescription && descriptionLayout != null && descriptionTextView != null) {
        descriptionLayout.setVisibility(View.VISIBLE);
        descriptionTextView.setVisibility(View.VISIBLE);

        descriptionTextView.setText(description);
    } else {
        if (descriptionLayout != null)
            descriptionLayout.setVisibility(View.GONE);
        if (descriptionTextView != null)
            descriptionTextView.setVisibility(View.GONE);
    }

    // Size

    if (isVisible(sizeTextView)) {
        if (Product.isSensibleSize(size)) {
            sizeTextView.setText(String.format(sizeFormatString, size.getWidth(), size.getHeight(),
                    size.getUnit().shortString(mKiteActivity)));
        } else {
            sizeLayout.setVisibility(View.GONE);
        }
    }

    // Quantity

    if (isVisible(quantityTextView)) {
        if (quantityPerSheet > 1) {
            quantityLayout.setVisibility(View.VISIBLE);

            quantityTextView.setText(getString(R.string.product_quantity_format_string, quantityPerSheet));
        } else {
            quantityLayout.setVisibility(View.GONE);
        }
    }

    // Shipping description

    if (isVisible(summaryShippingTextView)) {
        // Currently we just check that shipping is free everywhere. If it isn't - we don't display
        // anything.

        boolean freeShippingEverywhere = true;

        MultipleDestinationShippingCosts multipleDestinationShippingCosts = shippingCosts;

        for (SingleDestinationShippingCost singleDestinationShippingCosts : multipleDestinationShippingCosts
                .asList()) {
            MultipleCurrencyAmount multipleCurrencyShippingCost = singleDestinationShippingCosts.getCost();

            for (SingleCurrencyAmount singleCurrencyShippingCost : multipleCurrencyShippingCost
                    .asCollection()) {
                if (singleCurrencyShippingCost.isNonZero()) {
                    freeShippingEverywhere = false;
                }
            }
        }

        if (freeShippingEverywhere) {
            summaryShippingTextView.setText(R.string.product_free_worldwide_shipping);
        } else {
            summaryShippingTextView.setText(getString(R.string.product_shipping_summary_format_string,
                    shippingCosts.getDisplayCost(locale)));
        }
    }

    // Shipping (postage)

    if (isVisible(shippingTextView)) {
        List<SingleDestinationShippingCost> sortedShippingCostList = mProduct.getSortedShippingCosts(country);

        StringBuilder shippingCostsStringBuilder = new StringBuilder();

        String newlineString = "";

        for (SingleDestinationShippingCost singleDestinationShippingCost : sortedShippingCostList) {
            // We want to prepend a new line for every shipping destination except the first

            shippingCostsStringBuilder.append(newlineString);

            newlineString = "\n";

            // Get the cost in the default currency for the locale, and format the amount.

            singleCurrencyCost = singleDestinationShippingCost.getCost().getDefaultAmountWithFallback();

            if (singleCurrencyCost != null) {
                String formatString = getString(R.string.product_shipping_format_string);

                String costString = (singleCurrencyCost.isNonZero()
                        ? singleCurrencyCost.getDisplayAmountForLocale(locale)
                        : getString(R.string.product_free_shipping));

                shippingCostsStringBuilder.append(String.format(formatString,
                        singleDestinationShippingCost.getDestinationDescription(mKiteActivity), costString));
            }

            shippingTextView.setText(shippingCostsStringBuilder.toString());
        }
    }

    if (mProceedOverlayButton != null) {
        mProceedOverlayButton.setText(R.string.product_overview_start_button_text);

        mProceedOverlayButton.setOnClickListener(this);
    }

    mProductImageViewPager.setOnClickListener(this);

    if (mDrawerControlLayout != null)
        mDrawerControlLayout.setOnClickListener(this);

    mOverlaidStartButton.setOnClickListener(this);

    return (view);
}

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

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Bundle bundle = this.getArguments();
    helper = new DBHelper(getActivity());
    Configuration conf = getActivity().getResources().getConfiguration();
    if (conf.smallestScreenWidthDp >= 600) {
        if (bundle != null) {
            movie = bundle.getParcelable("movie");
            position = bundle.getInt("pos");
            if (movie != null) {
                posterEndPoint = movie.getPoster();
                backdropEndPoint = movie.getBackdrop();
                overviewEndPoint = movie.getOverview();
                dateEndPoint = movie.getDate();
                voteEndPoint = movie.getVoteAvr();
                titleEndPoint = movie.getTitle();
                idEndpoint = movie.getId();
                if (dateEndPoint.equals("")) {
                    year = "Unknown";
                } else {
                    year = dateEndPoint.substring(0, 4);
                }//ww w.  ja  va 2  s .co m
                if (titleEndPoint.equals("")) {
                    titleEndPoint = "Not available.";
                } else {
                    titleEndPoint = movie.getTitle();
                }
                if (overviewEndPoint.equals("")) {
                    overviewEndPoint = "No overview found.";
                } else {
                    overviewEndPoint = movie.getOverview();
                }
            }
        }
    } else {
        posterEndPoint = getActivity().getIntent().getExtras().getString("poster");
        backdropEndPoint = getActivity().getIntent().getExtras().getString("backdrop");
        overviewEndPoint = getActivity().getIntent().getExtras().getString("overview");
        dateEndPoint = getActivity().getIntent().getExtras().getString("date");
        voteEndPoint = getActivity().getIntent().getExtras().getString("vote");
        titleEndPoint = getActivity().getIntent().getExtras().getString("title");
        idEndpoint = getActivity().getIntent().getExtras().getString("id");
        position = getActivity().getIntent().getExtras().getInt("position");
    }
    boolean ifExist = helper.ifExist(idEndpoint);
    if (ifExist) {
        detailUnFav.setVisibility(VISIBLE);
        detailFav.setVisibility(GONE);
    } else {
        detailUnFav.setVisibility(GONE);
        detailFav.setVisibility(VISIBLE);
    }
    String posterUrl = Url.POSTERS_URL + "w342" + posterEndPoint;

    DisplayImageOptions mOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(false)
            .displayer(new FadeInBitmapDisplayer(1500)).showImageOnFail(R.drawable.no_poster)
            .showImageForEmptyUri(R.drawable.no_poster).build();

    ImageLoader.getInstance().displayImage(posterUrl, detailPoster, mOptions, new SimpleImageLoadingListener() {
        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            Palette p = Palette.from(loadedImage).generate();
            detailCard.setCardBackgroundColor(p.getVibrantColor(0));
            if (p.getVibrantColor(0) == Color.TRANSPARENT) {
                detailCard.setCardBackgroundColor(p.getMutedColor(0));
            }
        }
    });

    String backdropUrl = Url.POSTERS_URL + "w780" + backdropEndPoint;
    if (conf.smallestScreenWidthDp >= 600) {
        ImageLoader.getInstance().displayImage(backdropUrl, tabBackdrop, mOptions,
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                        Palette p = Palette.from(loadedImage).generate();
                        tabBackdrop.setBackgroundColor(p.getVibrantColor(0));
                        if (p.getVibrantColor(0) == Color.TRANSPARENT) {
                            tabBackdrop.setBackgroundColor(p.getMutedColor(0));
                        }
                    }
                });
        detailDate.setText(year);
        detailTitle.setText(titleEndPoint);
    } else {
        detailDate.setText(dateEndPoint);
    }
    detailVoteAvr.setText(voteEndPoint);
    detailOverview.setText(overviewEndPoint);

    final ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(165);

    detailFav.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            adapter.notifyDataSetChanged();
            detailFav.setVisibility(GONE);
            detailUnFav.startAnimation(animation);
            detailUnFav.setVisibility(VISIBLE);
            helper.insertRow(posterEndPoint, backdropEndPoint, idEndpoint, titleEndPoint, dateEndPoint,
                    voteEndPoint, overviewEndPoint);
        }
    });

    detailUnFav.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            adapter.notifyDataSetChanged();
            detailUnFav.setVisibility(GONE);
            detailFav.startAnimation(animation);
            detailFav.setVisibility(VISIBLE);
            helper.deleteRow(idEndpoint);
            if (fav.isChecked()) {
                CoreAdapter.movies.remove(position);
                adapter.notifyItemRemoved(position);
                adapter.notifyDataSetChanged();
            }
        }
    });
    new DurationTask().execute();

    trailsAdapter = new TrailersAdapter(trailers, getActivity());
    new TrailersTask().execute();

    revsAdapter = new ReviewsAdapter(reviews, getActivity());
    new ReviewsTask().execute();
}

From source file:com.ottd.libs.ui.SwipeRefreshLayout.java

private void addDefaultHeadView(Context context) {
    mHeadView = LayoutInflater.from(context).inflate(R.layout.com_bihe0832_common_swipe_refresh, null);
    mRefreshImageview = (ImageView) mHeadView.findViewById(R.id.pull_to_refresh_image);
    mRefreshTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_text);
    mRefreshSubTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_sub_text);
    mRefreshProgress = (ProgressBar) mHeadView.findViewById(R.id.pull_to_refresh_progress);
    addView(mHeadView, 0);//from  www .  jav a 2 s. c om

    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setDuration(150);
    mRotateAnimation.setFillAfter(true);

    mIsDefaultHeadView = true;
}

From source file:com.example.harris.onionweather.ui.swipe.SwipeRefreshLayout.java

private void addDefaultHeadView(Context context) {
    mHeadView = LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, null);
    mRefreshImageview = (ImageView) mHeadView.findViewById(R.id.pull_to_refresh_image);
    mRefreshTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_text);
    mRefreshSubTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_sub_text);
    mRefreshProgress = (ProgressBar) mHeadView.findViewById(R.id.pull_to_refresh_progress);
    addView(mHeadView, 0);// w  w w .j a va2  s. com

    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setDuration(150);
    mRotateAnimation.setFillAfter(true);

    mIsDefaultHeadView = true;
}

From source file:com.cmad.swipe.SwipeRefreshLayout.java

private void addDefaultHeadView(Context context) {
    //   R.layout
    mHeadView = LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header_vertical, null);
    mRefreshImageview = (ImageView) mHeadView.findViewById(R.id.pull_to_refresh_image);
    mRefreshTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_text);
    mRefreshSubTitle = (TextView) mHeadView.findViewById(R.id.pull_to_refresh_sub_text);
    mRefreshProgress = (ProgressBar) mHeadView.findViewById(R.id.pull_to_refresh_progress);
    addView(mHeadView, 0);//w w w .  j  ava2 s .  c o m

    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setDuration(150);
    mRotateAnimation.setFillAfter(true);

    mIsDefaultHeadView = true;
}

From source file:com.appassit.common.Utils.java

/**
 * ??//w  ww .j  a  v  a2s  .c o  m
 * 
 * @return
 */
public static LayoutAnimationController getLayoutAnimation() {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(50);
    set.addAnimation(animation);

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(100);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    return controller;
}

From source file:net.willwebberley.gowertides.ui.DayFragment.java

private void setWeatherInfo() {
    Weather weather = day.getWeather();//w  ww  . j av  a2  s.  com
    String weather_description = weather.description;
    String unitType = prefs.getString("unitFormat", "true");
    Boolean metric = false;
    if (unitType.equals("true")) {
        metric = true;
    }

    int max_temp = weather.getMaxTemp(metric);
    int min_temp = weather.getMinTemp(metric);
    int wind_speed = weather.getWindSpeed(metric);
    Double prep = weather.precipitation;
    String direction = weather.wind_direction;
    Spanned temp = null, wind = null;
    if (metric) {
        temp = Html.fromHtml("<b>" + min_temp + "&deg;C - " + max_temp + "&deg;C</b>");
        wind = Html.fromHtml("<b>" + wind_speed + "km/h</b> from <b>" + direction + "</b>");

    } else {
        temp = Html.fromHtml("<b>" + min_temp + "&deg;F - " + max_temp + "&deg;F</b>");
        wind = Html.fromHtml("<b>" + wind_speed + "mph</b> from <b>" + direction + "</b>");
    }
    Spanned precipitation = Html.fromHtml("<b>" + prep + "mm</b>");

    ((TextView) layoutView.findViewById(R.id.weather_description)).setText(weather_description);
    ((TextView) layoutView.findViewById(R.id.weatherTemp)).setText(temp);
    ((TextView) layoutView.findViewById(R.id.weatherTemp)).setTextColor(Color.rgb(100, 100, 100));
    ((TextView) layoutView.findViewById(R.id.weatherWind)).setText(wind);
    ((TextView) layoutView.findViewById(R.id.weatherWind)).setTextColor(Color.rgb(100, 100, 100));
    ((TextView) layoutView.findViewById(R.id.weatherPrecipitation)).setText(precipitation);
    ((TextView) layoutView.findViewById(R.id.weatherPrecipitation)).setTextColor(Color.rgb(100, 100, 100));
    String icon = weather.getWeatherIcon();
    try {
        InputStream ims = getActivity().getAssets().open("icons/" + icon);
        Drawable d = Drawable.createFromStream(ims, null);
        ((ImageView) layoutView.findViewById(R.id.weatherIcon)).setImageDrawable(d);
        InputStream ims2 = getActivity().getAssets().open("icons/arrow.png");
        Drawable d2 = Drawable.createFromStream(ims2, null);
        ((ImageView) layoutView.findViewById(R.id.weatherWindIcon)).setImageDrawable(d2);

        RotateAnimation rAnim = new RotateAnimation(0, weather.wind_degree, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        rAnim.setDuration(500);
        rAnim.setFillEnabled(true);
        rAnim.setFillAfter(true);
        ((ImageView) layoutView.findViewById(R.id.weatherWindIcon)).startAnimation(rAnim);
    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:com.smp.musicspeed.MainActivity.java

private void animateLinkOn() {

    TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -1.0f);/*from w w  w  . j  ava  2  s  . c o  m*/
    anim.setDuration(TRANS_ANIMATION_TIME);
    anim.setInterpolator(new AnticipateOvershootInterpolator());
    anim.setAnimationListener(new AnimationListenerAdaptor() {
        @Override
        public void onAnimationEnd(Animation animation) {
            rateText.setAlpha(0f);
            linkOn();

            rateText.animate().alpha(1f).setDuration(TRANS_ANIMATION_TIME)
                    .setListener(new AnimatorListenerAdapter() {
                    });
        }
    });
    tempoCard.startAnimation(anim);
    tempoText.animate().alpha(0f).setDuration(TEXT_ANIMATION_TIME).setListener(new AnimatorListenerAdapter() {
    });
}

From source file:org.bart452.runningshoesensor.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    requestPermission();//from   w  w  w.  ja v a  2  s. c  o m
    context = getApplicationContext();

    mHeaderImageView = (ImageView) findViewById(R.id.appBarIv);
    Picasso.with(context).load(R.drawable.sunset_road_landscape).into(mHeaderImageView);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.toolBar);
    setSupportActionBar(mToolbar);
    mCollapsingTb = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
    mCollapsingTb.setTitle("Shoe sensor");
    mCollapsingTb.setExpandedTitleGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);

    // Bluetooth
    final BluetoothManager mBleMan = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBleAdapter = mBleMan.getAdapter();
    mBleScanner = mBleAdapter.getBluetoothLeScanner();
    mCharList = new ArrayList<>();
    mBleSem = new Semaphore(1);
    mBleThread = new BleThread(mBleSem);
    mBleThread.start();

    mBleReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(intent.getAction())) {
                if (mBleAdapter.getState() == BluetoothAdapter.STATE_ON) {
                    Log.d(LOG_TAG, "BT ON");
                    mScanFab.setEnabled(true);
                    if (mSnackBar != null) {
                        if (mSnackBar.isShown())
                            mSnackBar.dismiss();
                    }
                } else {
                    mScanFab.setEnabled(false);
                    bleEnable();
                }
            }
        }
    };

    // Text
    mDevNameTv = (TextView) findViewById(R.id.devNameTv);
    mDevNameTv.setText(getString(R.string.device_name) + " No device found");
    mRssiTv = (TextView) findViewById(R.id.rssiTv);
    mAddrTv = (TextView) findViewById(R.id.devAddrTv);

    // Buttons and switches
    mScanFab = (FloatingActionButton) findViewById(R.id.scanFab);
    mScanFab.setOnClickListener(this);
    mConnSwitch = (Switch) findViewById(R.id.connSwitch);
    mConnSwitch.setOnClickListener(this);

    //Graph
    mDataGraph = (GraphView) findViewById(R.id.dataGraph);
    mDataXSeries = new LineGraphSeries<>();
    mDataYSeries = new LineGraphSeries<>();
    mDataYSeries.setBackgroundColor(Color.RED);
    mDataGraph.addSeries(mDataXSeries);
    mDataGraph.addSeries(mDataYSeries);
    mDataGraph.getViewport().setXAxisBoundsManual(true);
    mDataGraph.getViewport().setMinX(0);
    mDataGraph.getViewport().setMaxX(20);

    // Animation
    mRotateAnim = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    mRotateAnim.setDuration(SCAN_PERIOD);
    mRotateAnim.setInterpolator(new LinearInterpolator());
    bleEnable();
}

From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.passitem.MountainPassItemActivity.java

private void startRefreshAnimation() {
    MenuItem item = mToolbar.getMenu().findItem(MENU_ITEM_REFRESH);
    if (item == null) {
        Log.e(TAG, "null");
        return;/*from www  . j a  v  a 2  s. co m*/
    }
    // define the animation for rotation
    Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(1000);

    animation.setRepeatCount(Animation.INFINITE);

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setActionView(null);
            mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setIcon(R.drawable.ic_menu_refresh);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    ImageView imageView = new ImageView(this, null, android.R.style.Widget_Material_ActionButton);
    imageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu_refresh));

    imageView.setPadding(31, imageView.getPaddingTop(), 32, imageView.getPaddingBottom());

    imageView.startAnimation(animation);
    item.setActionView(imageView);

}