Example usage for android.view TouchDelegate TouchDelegate

List of usage examples for android.view TouchDelegate TouchDelegate

Introduction

In this page you can find the example usage for android.view TouchDelegate TouchDelegate.

Prototype

public TouchDelegate(Rect bounds, View delegateView) 

Source Link

Document

Constructor

Usage

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.BusStopDetailsFragment.java

/**
 * Using the data in the local fields of this object, populate the various
 * views with data.//  w  w w .j ava  2s  .c  o  m
 */
private void populateView() {
    layoutContent.setVisibility(View.VISIBLE);
    txtEmpty.setVisibility(View.GONE);
    progress.setVisibility(View.GONE);

    layoutDetails.post(new Runnable() {
        @Override
        public void run() {
            final Rect rect = new Rect();
            favouriteBtn.getHitRect(rect);
            // Assume it's a square
            final int adjustBy = (int) ((hitboxSize - (rect.bottom - rect.top)) / 2);

            if (adjustBy > 0) {
                rect.top -= adjustBy;
                rect.bottom += adjustBy;
                rect.left -= adjustBy;
                rect.right += adjustBy;
            }

            layoutDetails.setTouchDelegate(new TouchDelegate(rect, favouriteBtn));
        }
    });

    setMapLocation();

    final String name;

    if (locality != null) {
        name = getString(R.string.busstop_locality_coloured, stopName, locality, stopCode);
    } else {
        name = getString(R.string.busstop_coloured, stopName, stopCode);
    }

    txtName.setText(Html.fromHtml(name));

    // Set the services list text.
    final String services = bsd.getBusServicesForStopAsString(stopCode);
    if (services == null || services.length() == 0) {
        txtServices.setText(R.string.busstopdetails_noservices);
    } else {
        txtServices.setText(BusStopDatabase.getColouredServiceListString(services));
    }

    updateLocation();
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.DisplayStopDataFragment.java

/**
 * Show the bus times. Ensure progress and error layouts are removed and
 * show the top bar and ListView./* ww w  .  j a  va  2  s  . c  om*/
 */
private void showTimes() {
    progressBig.setVisibility(View.GONE);
    txtError.setVisibility(View.GONE);
    progressSmall.setVisibility(View.INVISIBLE);

    layoutTopBar.setVisibility(View.VISIBLE);
    listView.setVisibility(View.VISIBLE);

    getActivity().supportInvalidateOptionsMenu();

    layoutTopBar.post(new Runnable() {
        @Override
        public void run() {
            final Rect rect = new Rect();
            imgbtnFavourite.getHitRect(rect);
            // Assume it's a square
            final int adjustBy = (int) ((hitboxSize - (rect.bottom - rect.top)) / 2);

            if (adjustBy > 0) {
                rect.top -= adjustBy;
                rect.bottom += adjustBy;
                rect.left -= adjustBy;
                rect.right += adjustBy;
            }

            layoutTopBar.setTouchDelegate(new TouchDelegate(rect, imgbtnFavourite));
        }
    });
}