Android Training - Pull to Refresh

18
Pull To Refresh Training 2014/03/11 John
  • Upload

    -
  • Category

    Science

  • view

    174
  • download

    0

Transcript of Android Training - Pull to Refresh

Pull To Refresh Training2014/03/11 John

Outline

● Introduction● Design● How to implement

○ Touch Event○ Adding view○ On Touching○ Smooth Scrolling○ Window Manager

● Summary● Homework

Introduction

Introduction

There is a patent application for the “pull-to-refresh” feature that Loren Brichter pioneered in Tweetie and is now an extremely popular UI gesture used in a lot of iOS, Mac and Android apps.

ref: http://goo.gl/PjTjMA

Design1. The user pulls down a list.2. A message appears, telling the user

who can pull down the list to refresh.3. The user pulls the list further down.4. A new message appears, telling the

user that the list will refresh when he releases it.

5. A refreshing or loading message appears.

6. The refreshing message disappears and a new list is shown, with the new items at the top of the list.

Design

i.e. LinearLayout

How to implement

Touch event Touch Event

How to implement

Touch eventThe onInterceptTouchEvent() method is called whenever a touch event is detected on the surface of a ViewGroup, including on the surface of its children.The onInterceptTouchEvent() method gives a parent the chance to see any touch event before its children do.

How to implement

Managing Touch events Use ViewConfigurationConstants

ref: http://goo.gl/JJN80z

How to implement

Managing Touch events Extend a Child View's Touchable Area

ref: http://goo.gl/JJN80z

How to implementAdding View

How to implementOn Touching

● Touch event filter.● Setting variable up.

How to implementOn Touching

● Doing actions.

How to implementSmooth scrolling

Ref: http://goo.gl/eb3DQH

SmoothScrollRunnable:● Get next position from

Interpolator.● Set scroll to position.● Post(this).

How to implementWindow Manager● Every display has a

WindowManager.● WindowManager is a

System Manager.

How to implementWindow Manager

Ref: http://goo.gl/sWHpp

Summary

● “Make it a little simpler”● How dose Touch event transit.● How to implement smooth scrolling.

HomeworkSample source code: (You can also fInd it at the video record nearby if this link is invalid.)https://www.dropbox.com/s/9zqt60tf7drppyi/TrainingPullToRefresh.zip

Basic:● Let it be pulled from left.

Advance:● Let it be pulled from both top and bottom.