SwipeToRefresh

A simple swipe to refresh helper library to replicate the swipe to refresh pattern first seen in GMail

License

License

Categories

Categories

Net
GroupId

GroupId

net.callumtaylor
ArtifactId

ArtifactId

swipetorefresh
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

aar
Description

Description

SwipeToRefresh
A simple swipe to refresh helper library to replicate the swipe to refresh pattern first seen in GMail
Project URL

Project URL

https://github.com/scruffyfox/SwipeToRefresh
Source Code Management

Source Code Management

https://github.com/scruffyfox/SwipeToRefresh

Download swipetorefresh

How to add to project

<!-- https://jarcasting.com/artifacts/net.callumtaylor/swipetorefresh/ -->
<dependency>
    <groupId>net.callumtaylor</groupId>
    <artifactId>swipetorefresh</artifactId>
    <version>1.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/net.callumtaylor/swipetorefresh/
implementation 'net.callumtaylor:swipetorefresh:1.1'
// https://jarcasting.com/artifacts/net.callumtaylor/swipetorefresh/
implementation ("net.callumtaylor:swipetorefresh:1.1")
'net.callumtaylor:swipetorefresh:aar:1.1'
<dependency org="net.callumtaylor" name="swipetorefresh" rev="1.1">
  <artifact name="swipetorefresh" type="aar" />
</dependency>
@Grapes(
@Grab(group='net.callumtaylor', module='swipetorefresh', version='1.1')
)
libraryDependencies += "net.callumtaylor" % "swipetorefresh" % "1.1"
[net.callumtaylor/swipetorefresh "1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

#README

##Usage

Simply import the gradle file into Android Studio and reference the dependancy in your settings.gradle and project's build.gradle

Alternatively you can add the maven dependancy net.callumtaylor:swipetorefresh:1.1

###To use the library

In your XML, include the RefreshableListView

<net.callumtaylor.swipetorefresh.view.RefreshableListView
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:id="@android:id/list"
	android:divider="?attr/storm_list_view_divider_color"
	android:scrollbarStyle="outsideOverlay"
/>

Implement OnRefreshListener in your fragment

And in your fragment, in onActivityCreated add

refreshHelper = RefreshHelper.wrapRefreshable(getActivity(), (RefreshableListView)getListView(), this);

Now, when the list is refreshed, onRefresh() will be called.

You can then call ListView.onRefreshComplete(); to stop the inderterminate refreshable.

There is also a time where you would use a single fragment which gets replaced, you may end up with multiple zombie pull to refresh views in your action bar. To fix this, in your base activity simple call RefreshHelper.reset(getActivity());

##Style

You can customise the style of the PTR by overriding ptr_text_style, ptr_progress_style, and ptr_progress_inderteminate_style in your theme.

###Example styles

@style/ptr_text_style

<style name="RefreshProgressText">
	<item name="android:textColor">#ffffffff</item>
</style>

@style/ptr_progress_style

<style name="RefreshProgressInderterminateThemeLight">
	<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_holo_light</item>
	<item name="android:minHeight">3dip</item>
	<item name="android:maxHeight">3dip</item>
	<item name="android:indeterminateOnly">true</item>
</style>

@style/ptr_progress_inderteminate_style

<style name="RefreshProgressInderterminateThemeLight" parent="android:Widget.ProgressBar.Horizontal">
	<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_holo_light</item>
	<item name="android:minHeight">4dip</item>
	<item name="android:maxHeight">4dip</item>
	<item name="android:indeterminateOnly">true</item>
</style>

#LICENSE

Copyright 2013 Callum Taylor

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
1.1