Skip to content

Commit

Permalink
Merge pull request #52 from Aspsine/dev
Browse files Browse the repository at this point in the history
v1.0.3 release
  • Loading branch information
Aspsine committed Apr 24, 2016
2 parents b803cec + cbdc1dc commit 52bc487
Show file tree
Hide file tree
Showing 9 changed files with 805 additions and 723 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SwipeToLoadLayout-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2812)
# SwipeToLoadLayout
SwipeToLoadLayout provides a standered to achieve pull-to-refresh and pull-to-loadmore.
SwipeToLoadLayout is a reusable pull-to-refresh and pull-to-load-more widget.

##Supported View
Theoretically support all kinds of views.
Expand Down Expand Up @@ -46,9 +46,12 @@ repositories {
- Step 2. Add the dependency in the form
```
dependencies {
compile 'com.github.Aspsine:SwipeToLoadLayout:v1.0.2'
compile 'com.github.Aspsine:SwipeToLoadLayout:v1.0.3'
}
```
- Step 3.
Look over [Quick Setup](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup) for more details.
You can find more customized header view and footer view in the demo app.

##Thanks
- Google SwipeRefreshLayout
Expand All @@ -58,6 +61,7 @@ dependencies {
##Contact Me
- Github: github.com/aspsine
- Email: littleximail@gmail.com
- WeiBo: [@Aspsine](http://weibo.com/wetze)
- Linkedin: cn.linkedin.com/in/aspsine

##License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,32 @@
import com.aspsine.swipetoloadlayout.demo.R;
import com.aspsine.swipetoloadlayout.demo.view.GoogleCircleProgressView;

public class GoogleHookLoadMoreFooterView extends FrameLayout implements SwipeTrigger, SwipeLoadMoreTrigger {
/**
* Created by aspsine on 16/1/27.
*/
public class GoogleCircleHookLoadMoreFooterView extends FrameLayout implements SwipeTrigger, SwipeLoadMoreTrigger {

private GoogleCircleProgressView progressView;

private int mTriggerOffset;

private int mFinalOffset;

public GoogleHookLoadMoreFooterView(Context context) {
public GoogleCircleHookLoadMoreFooterView(Context context) {
this(context, null);
}

public GoogleHookLoadMoreFooterView(Context context, AttributeSet attrs) {
public GoogleCircleHookLoadMoreFooterView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public GoogleHookLoadMoreFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
public GoogleCircleHookLoadMoreFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.load_more_trigger_offset_google);
mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.load_more_footer_height_google);
mFinalOffset = context.getResources().getDimensionPixelOffset(R.dimen.load_more_final_offset_google);
}


@Override
protected void onFinishInflate() {
super.onFinishInflate();
Expand All @@ -57,22 +62,24 @@ public void onPrepare() {
public void onMove(int y, boolean isComplete, boolean automatic) {
float alpha = -y / (float) mTriggerOffset;
ViewCompat.setAlpha(progressView, alpha);
if (!isComplete){
progressView.setProgressRotation(-y * (1f)/ (float) mFinalOffset);
if (!isComplete) {
progressView.setProgressRotation(-y / (float) mFinalOffset);
}
}

@Override
public void onRelease() {

}

@Override
public void onComplete() {
progressView.stop();
}

@Override
public void onReset() {
progressView.stop();
ViewCompat.setAlpha(progressView, 1f);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.aspsine.swipetoloadlayout.demo.view.header;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.widget.FrameLayout;
Expand Down Expand Up @@ -30,7 +32,7 @@ public GoogleCircleHookRefreshHeaderView(Context context, AttributeSet attrs) {

public GoogleCircleHookRefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_trigger_offset_google);
mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_header_height_google);
mFinalOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_final_offset_google);
}

Expand Down Expand Up @@ -61,22 +63,28 @@ public void onPrepare() {
public void onMove(int y, boolean isComplete, boolean automatic) {
float alpha = y / (float) mTriggerOffset;
ViewCompat.setAlpha(progressView, alpha);
progressView.setProgressRotation(y / (float) mFinalOffset);
if (!isComplete) {
progressView.setProgressRotation(y / (float) mFinalOffset);
}
}

@Override
public void onRelease() {

}

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
@Override
public void onComplete() {
progressView.stop();
progressView.animate().scaleX(0).scaleY(0).setDuration(300);
}

@Override
public void onReset() {
progressView.stop();
ViewCompat.setAlpha(progressView, 1f);
ViewCompat.setScaleX(progressView, 1f);
ViewCompat.setScaleY(progressView, 1f);
}

}
6 changes: 2 additions & 4 deletions app/src/main/res/layout/fragment_google_style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
android:layout_height="match_parent"
android:background="@color/style_window_background"
app:default_to_loading_more_scrolling_duration="500"
app:default_to_refreshing_scrolling_duration="1000"
app:load_more_complete_delay_duration="0"
app:load_more_final_drag_offset="@dimen/load_more_final_offset_google"
app:load_more_trigger_offset="@dimen/load_more_trigger_offset_google"
app:refresh_complete_delay_duration="0"
app:refresh_final_drag_offset="@dimen/refresh_final_offset_google"
app:refresh_trigger_offset="@dimen/refresh_trigger_offset_google"
app:load_more_complete_delay_duration="0"
app:swipe_style="above">

<include
Expand All @@ -27,6 +25,6 @@

<include
android:id="@id/swipe_load_more_footer"
layout="@layout/layout_google_footer" />
layout="@layout/layout_google_hook_footer" />

</com.aspsine.swipetoloadlayout.SwipeToLoadLayout>
20 changes: 10 additions & 10 deletions app/src/main/res/layout/layout_google_hook_footer.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<com.aspsine.swipetoloadlayout.demo.view.footer.GoogleHookLoadMoreFooterView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/load_more_footer_height_google"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/transparent"
android:orientation="vertical">
<com.aspsine.swipetoloadlayout.demo.view.footer.GoogleCircleHookLoadMoreFooterView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/load_more_footer_height_google"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/transparent"
android:orientation="vertical">

<com.aspsine.swipetoloadlayout.demo.view.GoogleCircleProgressView
android:id="@+id/googleProgress"
app:gcp_show_arrow="true"
app:gcp_progress_stoke_width="3dp"
app:gcp_progress_stoke_width="2dp"
app:gcp_arrow_height="6dp"
app:gcp_arrow_width="8dp"
android:layout_width="@dimen/load_more_drawable_size_google"
android:layout_height="@dimen/load_more_drawable_size_google"
android:layout_width="@dimen/refresh_drawable_size_google"
android:layout_height="@dimen/refresh_drawable_size_google"
android:layout_gravity="center" />
</com.aspsine.swipetoloadlayout.demo.view.footer.GoogleHookLoadMoreFooterView>
</com.aspsine.swipetoloadlayout.demo.view.footer.GoogleCircleHookLoadMoreFooterView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/layout_google_hook_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<com.aspsine.swipetoloadlayout.demo.view.GoogleCircleProgressView
android:id="@+id/googleProgress"
app:gcp_show_arrow="true"
app:gcp_progress_stoke_width="3dp"
app:gcp_progress_stoke_width="2dp"
app:gcp_arrow_height="6dp"
app:gcp_arrow_width="8dp"
android:layout_width="@dimen/refresh_drawable_size_google"
Expand Down
Binary file modified art/demo.apk
Binary file not shown.
Loading

0 comments on commit 52bc487

Please sign in to comment.