Swipe-to-Dismiss Google Now Style

TL;DR The Code

Super BART 1.2, adds My Trips which lets you save trips for later reference. I wanted users to be able to manage their trips by swiping cards away Google Now style. The schedule view was already using the excellent ListViewAnimations library for the Google Now style slide-in animations. Luckily the library’s Google Now sample code  contained code for dismissing cards as well. I decided to implement this in the new My Trips view.

I quickly ran into two problems. The swipe to dismiss functionality would sometimes behave erratically. Cards would sometimes go flying away with just a tap. It was far too sensitive. The SwipeDismissAdapter included in the library really just adds the SwipeDismissListViewTouchListener to the ListView. I created a copy and changed a few lines in the onTouch method.

<br />
if (Math.abs(deltaX) &gt; mViewWidth / 2) {<br />
    dismiss = true;<br />
    dismissRight = deltaX &gt; 0;<br />
} else if (mMinFlingVelocity &lt;= velocityX &amp;&amp; velocityX &lt;= mMaxFlingVelocity<br />
        &amp;&amp; velocityY &lt; velocityX) {<br />
    dismiss = true;<br />
    dismissRight = mVelocityTracker.getXVelocity() &gt; 0;<br />
}<br />

This code lies within the MotionEvent.ACTION_UP case of onTouch and determines if the ListView item should be dismissed. Here is the modified version.

<br />
if (Math.abs(deltaX) &gt; mViewWidth / 2) {<br />
    dismiss = true;<br />
    dismissRight = deltaX &gt; 0;<br />
} else if (Math.abs(deltaX) &gt; mViewWidth / 4 &amp;&amp; mMinFlingVelocity &lt;= velocityX<br />
        &amp;&amp; velocityX &lt;= mMaxFlingVelocity &amp;&amp; velocityY &lt; velocityX / 2) {<br />
    dismiss = true;<br />
    dismissRight = mVelocityTracker.getXVelocity() &gt; 0;<br />
}<br />

The else if statement has two small but significant changes. First, I require that all swipes must travel at least 1/4 of the screen width to eliminate the tap to dismiss behavior I was initially seeing. Finally, I require that the Y velocity be less than half of the X velocity to eliminate false positives when scrolling the list.Watch All Girls Weekend (2016) Full Movie Online Streaming Online and Download

Another problem arose with the section headers in My Trips that organize trips by day.

4 my_trips

The base SwipeDismissListViewTouchListener does not support a mix of views of varying dismiss-ability. I added support for this behavior in SelectiveSwipeDismissListViewTouchListener.java. It contains an interface called SelectiveSwipeDismissAdapter with one method:

<br />
public boolean canDismissItem(int position);<br />

Now, instead of wrapping your base adapter in another adapter, you can add the touch listener to your list view like so:

<br />
SelectiveSwipeDismissListViewTouchListener dismissTouchListener =<br />
	new SelectiveSwipeDismissListViewTouchListener(mListView, mAdapter, mDismissCallback);<br />
mListView.setOnTouchListener(dismissTouchListener);<br />

 

Super BART 1.2 is available for free on the Play Store.

how to score in rugbyDeveloping an offensive game plan and seeing it work on game day is one of the most rewarding experiences you will get in coaching football. There really is nothing quite like pouring over hours of film to find your opponents weakness then finding creative ways to put your players in Cheap china Jerseys position to exploit those weaknesses. There is always a sense of confidence when you know you have done your homework and you have a great plan. But what makes a great plan ? Where do you start http://www.cheapraybans2013.com ? What should it look like ? How do you implement it ? By showing you the answers to those questions this book can serve as a tool for you and your coaching staff to use as you put together your offensive game plans this season and beyond.You have nostalgia for the days when blacks kept quiet, gays were in the closet, immigrants were invisible and http://www.cheapjerseys-nfl.com women stayed in the kitchen, Sen. Jefferson Beauregard Sessions is your man, Rep. Luis Gutierrez (D Ill.) said in a statement. senator has fought harder against the hopes and aspirations of Latinos, immigrants, and people of color than Sen. Sessions.’It’s been a rollercoaster year,’ Wilf says, ‘but we remain very confident about our team and our coaching staff and our players. We’ve had some adversity but they fight and they play hard. Fortunately we were on the winning side last week and we’re just doing it one game at a time.So, from our sale of radio stations to our investment in interactive businesses, clearly show that we are moving in the right direction for growth. In http://www.mycheapnfljerseys.com addition to shifting our asset mix, we took key steps, during the quarter to reduce our expense base across the board to offset the advertising slowdown, we are seeing in local markets. We’ve been doing that throughout this year with particular focus on our TV and radio stations and Outdoor. We continue to look at every one of our businesses to make sure we have both the appropriate cost structure and the growth focus to outperform as the marketplace improves. Fred Wholesale NFL Jerseys will go into this a bit more, later.Tape the lens periphery of a pair of goggles or glasses and wear the eyewear for several plays. Note how you need to make exaggerated head movements and concentrate harder to make your moves. Remove the eyewear to gain a greater appreciation of how peripheral vision allows you to be aware of NFL Jerseys Cheap crucial developments around you in the running back position.Under the principles of natural justice, it is an expectation within our society and our legal system that a person has the right to a fair trial, free from wholesale Jerseys bias. A person is therefore presumed innocent until proven guilty, and information regarding prior convictions for past offences cannot be used to suggest guilt for the present case.

Leave a Reply

Your email address will not be published.