├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_menu.png
│ │ │ │ ├── jd_speed.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── jd_people_0.png
│ │ │ │ ├── jd_people_1.png
│ │ │ │ ├── jd_people_2.png
│ │ │ │ ├── jd_people_3.png
│ │ │ │ ├── yalantis_icon_1.png
│ │ │ │ ├── yalantis_icon_2.png
│ │ │ │ ├── yalantis_icon_3.png
│ │ │ │ ├── twitter_pull_arrow.png
│ │ │ │ ├── yalantis_phoenix_sky.png
│ │ │ │ ├── yalantis_phoenix_sun.png
│ │ │ │ ├── twitter_pull_arrow_white.png
│ │ │ │ └── yalantis_phoenix_buildings.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_menu.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── yalantis_icon_1.png
│ │ │ │ ├── yalantis_icon_2.png
│ │ │ │ ├── yalantis_icon_3.png
│ │ │ │ ├── twitter_pull_arrow.png
│ │ │ │ ├── yalantis_phoenix_sky.png
│ │ │ │ ├── yalantis_phoenix_sun.png
│ │ │ │ ├── twitter_pull_arrow_white.png
│ │ │ │ └── yalantis_phoenix_buildings.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_menu.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── yalantis_icon_1.png
│ │ │ │ ├── yalantis_icon_2.png
│ │ │ │ ├── yalantis_icon_3.png
│ │ │ │ ├── qq_refresh_success.png
│ │ │ │ ├── twitter_pull_arrow.png
│ │ │ │ ├── yalantis_phoenix_sky.png
│ │ │ │ ├── yalantis_phoenix_sun.png
│ │ │ │ ├── twitter_pull_arrow_white.png
│ │ │ │ └── yalantis_phoenix_buildings.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_menu.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── bg_viewpager.jpg
│ │ │ │ ├── yalantis_icon_1.png
│ │ │ │ ├── yalantis_icon_2.png
│ │ │ │ ├── yalantis_icon_3.png
│ │ │ │ ├── twitter_pull_arrow.png
│ │ │ │ ├── yalantis_phoenix_sky.png
│ │ │ │ ├── yalantis_phoenix_sun.png
│ │ │ │ ├── twitter_pull_arrow_white.png
│ │ │ │ └── yalantis_phoenix_buildings.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_done.png
│ │ │ │ ├── ic_menu.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── yalantis_icon_1.png
│ │ │ │ ├── yalantis_icon_2.png
│ │ │ │ ├── yalantis_icon_3.png
│ │ │ │ ├── yalantis_phoenix_sky.png
│ │ │ │ ├── yalantis_phoenix_sun.png
│ │ │ │ └── yalantis_phoenix_buildings.png
│ │ │ ├── anim
│ │ │ │ ├── cycle_interpolator.xml
│ │ │ │ ├── twinkle.xml
│ │ │ │ ├── rotate_up.xml
│ │ │ │ └── rotate_down.xml
│ │ │ ├── drawable
│ │ │ │ ├── shape_rectangle.xml
│ │ │ │ ├── selector_item_hero.xml
│ │ │ │ ├── animation_list_refresh_jd.xml
│ │ │ │ └── selector_indicator.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_config.xml
│ │ │ │ ├── menu_main.xml
│ │ │ │ └── menu_drawer.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── layout
│ │ │ │ ├── item_yalantis.xml
│ │ │ │ ├── layout_toolbar.xml
│ │ │ │ ├── layout_yalantis_header.xml
│ │ │ │ ├── layout_google_header.xml
│ │ │ │ ├── layout_google_footer.xml
│ │ │ │ ├── layout_navigation_header.xml
│ │ │ │ ├── layout_viewpager.xml
│ │ │ │ ├── layout_viewpager_grid.xml
│ │ │ │ ├── fragment_twitter_other_imageview.xml
│ │ │ │ ├── item_viewpager.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── item_hero_grid.xml
│ │ │ │ ├── fragment_twitter_other_textview.xml
│ │ │ │ ├── item_header.xml
│ │ │ │ ├── item_hero.xml
│ │ │ │ ├── layout_google_hook_header.xml
│ │ │ │ ├── layout_google_hook_footer.xml
│ │ │ │ ├── fragment_twitter_web_view.xml
│ │ │ │ ├── layout_jd_header.xml
│ │ │ │ ├── fragment_twitter_grid_view.xml
│ │ │ │ ├── fragment_nav_java_code.xml
│ │ │ │ ├── fragment_twitter_recycler.xml
│ │ │ │ ├── fragment_twitter_listview.xml
│ │ │ │ ├── fragment_twitter_other_linearlayout.xml
│ │ │ │ ├── fragment_twitter_other_framelayout.xml
│ │ │ │ ├── fragment_twitter_other_relativelayout.xml
│ │ │ │ ├── fragment_google_style.xml
│ │ │ │ ├── fragment_google_style_custom.xml
│ │ │ │ ├── fragment_nav_jd.xml
│ │ │ │ ├── fragment_nav_yalantis.xml
│ │ │ │ ├── layout_classic_footer.xml
│ │ │ │ ├── activity_about.xml
│ │ │ │ ├── layout_twitter_header.xml
│ │ │ │ ├── fragment_base_nav_pager.xml
│ │ │ │ ├── fragment_nav_twitter.xml
│ │ │ │ ├── fragment_twitter_scroll_view.xml
│ │ │ │ └── layout_dialog_config.xml
│ │ │ └── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ └── dimens.xml
│ │ ├── ic_launcher-web.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ ├── aspsine
│ │ │ │ └── swipetoloadlayout
│ │ │ │ │ └── demo
│ │ │ │ │ ├── fragment
│ │ │ │ │ ├── BaseFragment.java
│ │ │ │ │ ├── BaseNavigationFragment.java
│ │ │ │ │ ├── NavGoogleFragment.java
│ │ │ │ │ ├── BaseToolbarFragment.java
│ │ │ │ │ ├── NavJDFragment.java
│ │ │ │ │ ├── BaseNavPagerFragment.java
│ │ │ │ │ ├── NavTwitterFragment.java
│ │ │ │ │ ├── TwitterWebViewFragment.java
│ │ │ │ │ ├── TwitterOtherViewFragment.java
│ │ │ │ │ └── NavYalantisFragment.java
│ │ │ │ │ ├── adapter
│ │ │ │ │ ├── OnGroupItemClickListener.java
│ │ │ │ │ ├── OnGroupItemLongClickListener.java
│ │ │ │ │ ├── OnChildItemClickListener.java
│ │ │ │ │ ├── OnChildItemLongClickListener.java
│ │ │ │ │ ├── BaseArrayAdapter.java
│ │ │ │ │ ├── CharacterAdapter.java
│ │ │ │ │ ├── LoopViewPagerAdapter.java
│ │ │ │ │ ├── SectionAdapter.java
│ │ │ │ │ └── BaseGroupAdapter.java
│ │ │ │ │ ├── Constants.java
│ │ │ │ │ ├── model
│ │ │ │ │ ├── Section.java
│ │ │ │ │ ├── SectionCharacters.java
│ │ │ │ │ └── Character.java
│ │ │ │ │ ├── view
│ │ │ │ │ ├── drawable
│ │ │ │ │ │ ├── google
│ │ │ │ │ │ │ ├── MaterialHookDrawable.java
│ │ │ │ │ │ │ ├── ProgressDrawable.java
│ │ │ │ │ │ │ └── RingProgressDrawable.java
│ │ │ │ │ │ └── yalantis
│ │ │ │ │ │ │ └── BaseRefreshDrawable.java
│ │ │ │ │ ├── footer
│ │ │ │ │ │ ├── ClassicLoadMoreFooterView.java
│ │ │ │ │ │ ├── GoogleLoadMoreFooterView.java
│ │ │ │ │ │ └── GoogleCircleHookLoadMoreFooterView.java
│ │ │ │ │ └── header
│ │ │ │ │ │ ├── GoogleRefreshHeaderView.java
│ │ │ │ │ │ ├── YalantisPhoenixRefreshHeaderView.java
│ │ │ │ │ │ ├── JdRefreshHeaderView.java
│ │ │ │ │ │ ├── GoogleCircleHookRefreshHeaderView.java
│ │ │ │ │ │ └── TwitterRefreshHeaderView.java
│ │ │ │ │ ├── util
│ │ │ │ │ ├── DensityUtil.java
│ │ │ │ │ └── AssetUtils.java
│ │ │ │ │ ├── App.java
│ │ │ │ │ ├── MainFragmentAdapter.java
│ │ │ │ │ ├── AboutActivity.java
│ │ │ │ │ └── MainActivity.java
│ │ │ │ ├── android
│ │ │ │ └── volley
│ │ │ │ │ └── toolbox
│ │ │ │ │ └── GsonRequest.java
│ │ │ │ └── squareup
│ │ │ │ └── picasso
│ │ │ │ └── CircleTransformation.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── aspsine
│ │ │ └── swipetoloadlayout
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── aspsine
│ │ └── swipetoloadlayout
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── library
├── .gitignore
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── aspsine
│ │ │ │ └── swipetoloadlayout
│ │ │ │ ├── OnRefreshListener.java
│ │ │ │ ├── SwipeLoadMoreTrigger.java
│ │ │ │ ├── OnLoadMoreListener.java
│ │ │ │ ├── SwipeRefreshTrigger.java
│ │ │ │ ├── SwipeTrigger.java
│ │ │ │ ├── SwipeRefreshHeaderLayout.java
│ │ │ │ └── SwipeLoadMoreFooterLayout.java
│ │ └── res
│ │ │ └── values
│ │ │ ├── ids.xml
│ │ │ └── attrs.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── aspsine
│ │ │ └── swipetoloadlayout
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── aspsine
│ │ └── swipetoloadlayout
│ │ └── ApplicationTest.java
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── art
└── demo.apk
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README_CN.md
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------
/art/demo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/art/demo.apk
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/jd_speed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/jd_speed.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/jd_people_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/jd_people_0.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/jd_people_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/jd_people_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/jd_people_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/jd_people_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/jd_people_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/jd_people_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/yalantis_icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/yalantis_icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/yalantis_icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/yalantis_icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/yalantis_icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/yalantis_icon_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/yalantis_icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/yalantis_icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/yalantis_icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/yalantis_icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/yalantis_icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/yalantis_icon_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/bg_viewpager.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/bg_viewpager.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/twitter_pull_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/twitter_pull_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/twitter_pull_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/twitter_pull_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/yalantis_icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/yalantis_icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/yalantis_icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/yalantis_icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/yalantis_icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/yalantis_icon_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/yalantis_icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/yalantis_icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/yalantis_icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/yalantis_icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/yalantis_icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/yalantis_icon_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/yalantis_icon_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/yalantis_icon_1.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/yalantis_icon_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/yalantis_icon_2.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/yalantis_icon_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/yalantis_icon_3.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/yalantis_phoenix_sky.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/yalantis_phoenix_sky.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/yalantis_phoenix_sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/yalantis_phoenix_sun.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/yalantis_phoenix_sky.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/yalantis_phoenix_sky.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/yalantis_phoenix_sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/yalantis_phoenix_sun.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/qq_refresh_success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/qq_refresh_success.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/twitter_pull_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/twitter_pull_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/twitter_pull_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/twitter_pull_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/yalantis_phoenix_sky.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/yalantis_phoenix_sky.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/yalantis_phoenix_sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/yalantis_phoenix_sun.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/yalantis_phoenix_sky.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/yalantis_phoenix_sky.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/yalantis_phoenix_sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/yalantis_phoenix_sun.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/yalantis_phoenix_sky.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/yalantis_phoenix_sky.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/yalantis_phoenix_sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/yalantis_phoenix_sun.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/twitter_pull_arrow_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/twitter_pull_arrow_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/twitter_pull_arrow_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/twitter_pull_arrow_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/twitter_pull_arrow_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/twitter_pull_arrow_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/yalantis_phoenix_buildings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-hdpi/yalantis_phoenix_buildings.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/yalantis_phoenix_buildings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-mdpi/yalantis_phoenix_buildings.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/yalantis_phoenix_buildings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xhdpi/yalantis_phoenix_buildings.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/twitter_pull_arrow_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/twitter_pull_arrow_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/yalantis_phoenix_buildings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxhdpi/yalantis_phoenix_buildings.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/yalantis_phoenix_buildings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/HEAD/app/src/main/res/mipmap-xxxhdpi/yalantis_phoenix_buildings.png
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/OnRefreshListener.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | /**
4 | * Created by Aspsine on 2015/8/13.
5 | */
6 | public interface OnRefreshListener {
7 | public void onRefresh();
8 | }
9 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeLoadMoreTrigger.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | /**
4 | * Created by Aspsine on 2015/8/17.
5 | */
6 | public interface SwipeLoadMoreTrigger {
7 | void onLoadMore();
8 | }
9 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/OnLoadMoreListener.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | /**
4 | * Created by Aspsine on 2015/8/13.
5 | */
6 | public interface OnLoadMoreListener {
7 | public void onLoadMore();
8 | }
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeRefreshTrigger.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | /**
4 | * Created by Aspsine on 2015/8/13.
5 | */
6 | public interface SwipeRefreshTrigger {
7 |
8 | void onRefresh();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jan 04 00:31:07 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/cycle_interpolator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | /**
6 | * Created by aspsine on 15/9/8.
7 | */
8 | public class BaseFragment extends Fragment {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_rectangle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/twinkle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/OnGroupItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by aspsine on 16/8/9.
7 | */
8 |
9 | public interface OnGroupItemClickListener {
10 | void onGroupItemClick(int groupPosition, G g, View view);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/OnGroupItemLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by aspsine on 16/8/9.
7 | */
8 |
9 | public interface OnGroupItemLongClickListener {
10 | boolean onGroupLongClick(int groupPosition, G g, View view);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/OnChildItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by aspsine on 16/8/9.
7 | */
8 |
9 | public interface OnChildItemClickListener {
10 | void onChildItemClick(int groupPosition, int childPosition, C c, View view);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/OnChildItemLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by aspsine on 16/8/9.
7 | */
8 |
9 | public interface OnChildItemLongClickListener {
10 | boolean onClickItemLongClick(int groupPosition, int childPosition, C c, View view);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/rotate_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_item_hero.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeTrigger.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | /**
4 | * Created by Aspsine on 2015/8/17.
5 | */
6 | public interface SwipeTrigger {
7 | void onPrepare();
8 |
9 | void onMove(int y, boolean isComplete, boolean automatic);
10 |
11 | void onRelease();
12 |
13 | void onComplete();
14 |
15 | void onReset();
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/rotate_down.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/aspsine/swipetoloadlayout/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/library/src/test/java/com/aspsine/swipetoloadlayout/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/aspsine/swipetoloadlayout/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/aspsine/swipetoloadlayout/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_yalantis.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/Constants.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo;
2 |
3 | /**
4 | * Created by Aspsine on 2015/9/6.
5 | */
6 | public class Constants {
7 |
8 | public static final class API {
9 | public static final String CHARACTERS = "https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/dev/app/src/main/assets/characters.json";
10 | public static final String ALL_CHARACTERS = "https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/master/app/src/main/assets/all_characters.json";
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/animation_list_refresh_jd.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
10 |
13 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_yalantis_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SwipeToLoadLayout Demo
3 |
4 | Hello world!
5 | Config
6 |
7 |
8 | Hello blank fragment
9 | Aspsine
10 | SwipeToLoadLayout provides a standered to achieve pull-to-refresh and pull-to-loadmore.
11 | http://github.com/Aspsine/SwipeToLoadLayout
12 |
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Android template
2 | # Built application files
3 | *.apk
4 | *.ap_
5 |
6 | # Files for the Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | /.gitignore
33 | .gradle
34 | /local.properties
35 | /.idea/workspace.xml
36 | /.idea/libraries
37 | .DS_Store
38 | /build
39 | /captures
40 | /.idea
41 | *.iml
42 | .idea
43 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '25.0.2'
6 |
7 | defaultConfig {
8 | minSdkVersion 9
9 | targetSdkVersion 25
10 | versionCode 4
11 | versionName "1.0.4"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(include: ['*.jar'], dir: 'libs')
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:support-compat:25.1.0'
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/model/Section.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by aspsine on 15/9/4.
7 | */
8 | public class Section {
9 | private String name;
10 | private List characters;
11 |
12 | public String getName() {
13 | return name;
14 | }
15 |
16 | public void setName(String name) {
17 | this.name = name;
18 | }
19 |
20 | public List getCharacters() {
21 | return characters;
22 | }
23 |
24 | public void setCharacters(List characters) {
25 | this.characters = characters;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_google_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_google_footer.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_navigation_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/model/SectionCharacters.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by aspsine on 15/9/4.
7 | */
8 | public class SectionCharacters {
9 |
10 | private List characters;
11 |
12 | private List sections;
13 |
14 | public List getCharacters() {
15 | return characters;
16 | }
17 |
18 | public void setCharacters(List characters) {
19 | this.characters = characters;
20 | }
21 |
22 | public List getSections() {
23 | return sections;
24 | }
25 |
26 | public void setSections(List sections) {
27 | this.sections = sections;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/drawable/google/MaterialHookDrawable.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.drawable.google;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.ColorFilter;
5 | import android.graphics.drawable.Drawable;
6 |
7 | /**
8 | * Created by aspsine on 15/9/10.
9 | */
10 | public class MaterialHookDrawable extends Drawable {
11 |
12 | @Override
13 | public void draw(Canvas canvas) {
14 |
15 | }
16 |
17 | @Override
18 | public void setAlpha(int alpha) {
19 |
20 | }
21 |
22 | @Override
23 | public void setColorFilter(ColorFilter colorFilter) {
24 |
25 | }
26 |
27 | @Override
28 | public int getOpacity() {
29 | return 0;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/model/Character.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.model;
2 |
3 | /**
4 | * Created by Aspsine on 2015/9/2.
5 | */
6 | public class Character {
7 | private String name;
8 | private String avatar;
9 |
10 | public Character() {
11 | }
12 |
13 | public Character(String name, String avatar) {
14 | this.name = name;
15 | this.avatar = avatar;
16 | }
17 |
18 | public String getName() {
19 | return name;
20 | }
21 |
22 | public void setName(String name) {
23 | this.name = name;
24 | }
25 |
26 | public String getAvatar() {
27 | return avatar;
28 | }
29 |
30 | public void setAvatar(String avatar) {
31 | this.avatar = avatar;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/util/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.util;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.util.DisplayMetrics;
6 |
7 | /**
8 | * Created by Aspsine on 2015/11/5.
9 | */
10 | public class DensityUtil {
11 | public static int getScreenWidth(Context context) {
12 | DisplayMetrics dm = new DisplayMetrics();
13 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
14 | return dm.widthPixels;
15 | }
16 |
17 | public static int getScreenHeight(Context context) {
18 | DisplayMetrics dm = new DisplayMetrics();
19 | ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
20 | return dm.heightPixels;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_viewpager_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/BaseNavigationFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * Created by Aspsine on 2015/9/8.
13 | */
14 | public class BaseNavigationFragment extends BaseToolbarFragment {
15 |
16 | public static final String NAVIGATION_FRAGMENT_TITLE = "navigation_fragment_title";
17 |
18 | @Nullable
19 | @Override
20 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
21 | TextView tv = new TextView(getActivity());
22 | tv.setText("Not developed yet. Support latter...");
23 | tv.setGravity(Gravity.CENTER);
24 | return tv;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #d32f2f
4 | #b71c1c
5 | #FFCDD2
6 | #d32f2f
7 | #212121
8 | #ffffff
9 |
10 | #ffffff
11 | #000000
12 | #ff0000
13 |
14 | #4285F4
15 | #EA4335
16 | #34A853
17 | #FBBC05
18 |
19 | #F4B63E
20 | #663D4E
21 | #EB6460
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_indicator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 | -
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_other_imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_hero_grid.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_other_textview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
20 |
21 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_hero.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_google_hook_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_google_hook_footer.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_web_view.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
14 |
15 |
16 |
20 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/BaseArrayAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.widget.BaseAdapter;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by aspsine on 15/9/4.
10 | */
11 | public abstract class BaseArrayAdapter extends BaseAdapter {
12 | private List mList;
13 |
14 |
15 | public BaseArrayAdapter() {
16 | this.mList = new ArrayList<>();
17 | }
18 |
19 | public void setList(List list) {
20 | this.mList.clear();
21 | append(list);
22 | }
23 |
24 | public void append(List list) {
25 | this.mList.addAll(list);
26 | notifyDataSetChanged();
27 | }
28 |
29 | @Override
30 | public int getCount() {
31 | return mList.size();
32 | }
33 |
34 | @Override
35 | public T getItem(int position) {
36 | return mList.get(position);
37 | }
38 |
39 | @Override
40 | public long getItemId(int position) {
41 | return position;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_jd_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_grid_view.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
14 |
15 |
20 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_nav_java_code.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
10 |
11 |
17 |
18 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_recycler.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
14 |
15 |
20 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_listview.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
14 |
15 |
21 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/NavGoogleFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.view.View;
8 |
9 | /**
10 | * A simple {@link Fragment} subclass.
11 | */
12 | public class NavGoogleFragment extends BaseNavPagerFragment {
13 |
14 | public static BaseNavigationFragment newInstance() {
15 | BaseNavigationFragment fragment = new NavGoogleFragment();
16 | return fragment;
17 | }
18 |
19 | public NavGoogleFragment() {
20 | // Required empty public constructor
21 | }
22 |
23 | @Override
24 | protected String[] getTitles() {
25 | return new String[]{"Google", "Custom"};
26 | }
27 |
28 | @Override
29 | protected Fragment getFragment(int i) {
30 | return GoogleStyleFragment.newInstance(i);
31 | }
32 |
33 | @Override
34 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
35 | super.onViewCreated(view, savedInstanceState);
36 | setTitle("Google Style");
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/App.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.os.StrictMode;
7 |
8 | import com.android.volley.RequestQueue;
9 | import com.android.volley.toolbox.Volley;
10 | import com.aspsine.swipetoloadlayout.BuildConfig;
11 |
12 | /**
13 | * Created by Aspsine on 2015/9/2.
14 | */
15 | public class App extends Application {
16 |
17 | private static RequestQueue sRequestQueue;
18 |
19 | private static Context sContext;
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | setStrictMode();
25 | sContext = getApplicationContext();
26 | }
27 |
28 | private void setStrictMode() {
29 | if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
30 | StrictMode.enableDefaults();
31 | }
32 | }
33 |
34 | public static RequestQueue getRequestQueue() {
35 | if (sRequestQueue == null) {
36 | sRequestQueue = Volley.newRequestQueue(sContext);
37 | }
38 | return sRequestQueue;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/util/AssetUtils.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.util;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 |
11 | /**
12 | * Created by Aspsine on 2015/4/15.
13 | */
14 | public class AssetUtils {
15 |
16 | public static String getStringFromAsset(Context context, String filePath){
17 | AssetManager assetManager = context.getAssets();
18 | try {
19 | InputStream inputStream = assetManager.open(filePath);
20 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
21 | String inputLine;
22 | StringBuilder response = new StringBuilder();
23 | while ((inputLine = reader.readLine()) != null) {
24 | response.append(inputLine);
25 | }
26 | reader.close();
27 | return response.toString();
28 | } catch (IOException e) {
29 | e.printStackTrace();
30 | }
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_other_linearlayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
19 |
20 |
25 |
26 |
27 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_other_framelayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
18 |
19 |
25 |
26 |
27 |
30 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '25.0.2'
6 |
7 | defaultConfig {
8 | applicationId "com.aspsine.swipetoloadlayout"
9 | minSdkVersion 10
10 | targetSdkVersion 25
11 | versionCode 4
12 | versionName "1.0.4"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | repositories {
22 | maven { url "https://jitpack.io" }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(include: ['*.jar'], dir: 'libs')
28 | testCompile 'junit:junit:4.12'
29 | compile project(':library')
30 | compile 'com.android.support:appcompat-v7:25.1.0'
31 | compile 'com.android.support:recyclerview-v7:25.1.0'
32 | compile 'com.android.support:design:25.1.0'
33 | compile 'com.google.code.gson:gson:2.4'
34 | compile 'com.mcxiaoke.volley:library-aar:1.0.1'
35 | compile 'com.squareup.picasso:picasso:2.5.2'
36 | compile 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
37 | compile 'com.github.Aspsine:FragmentNavigator:1.0.2'
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_other_relativelayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
18 |
19 |
25 |
26 |
27 |
30 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeRefreshHeaderLayout.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.FrameLayout;
6 |
7 | /**
8 | * Created by Aspsine on 2015/8/13.
9 | */
10 | public class SwipeRefreshHeaderLayout extends FrameLayout implements SwipeRefreshTrigger, SwipeTrigger {
11 |
12 | public SwipeRefreshHeaderLayout(Context context) {
13 | this(context, null);
14 | }
15 |
16 | public SwipeRefreshHeaderLayout(Context context, AttributeSet attrs) {
17 | this(context, attrs, 0);
18 | }
19 |
20 | public SwipeRefreshHeaderLayout(Context context, AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | }
23 |
24 | @Override
25 | public void onRefresh() {
26 | }
27 |
28 | @Override
29 | public void onPrepare() {
30 | }
31 |
32 | @Override
33 | public void onMove(int y, boolean isComplete, boolean automatic) {
34 | }
35 |
36 | @Override
37 | public void onRelease() {
38 |
39 | }
40 |
41 | @Override
42 | public void onComplete() {
43 |
44 | }
45 |
46 | @Override
47 | public void onReset() {
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeLoadMoreFooterLayout.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.FrameLayout;
6 |
7 | /**
8 | * Created by Aspsine on 2015/8/13.
9 | */
10 | public class SwipeLoadMoreFooterLayout extends FrameLayout implements SwipeLoadMoreTrigger, SwipeTrigger {
11 |
12 | public SwipeLoadMoreFooterLayout(Context context) {
13 | this(context, null);
14 | }
15 |
16 | public SwipeLoadMoreFooterLayout(Context context, AttributeSet attrs) {
17 | this(context, attrs, 0);
18 | }
19 |
20 | public SwipeLoadMoreFooterLayout(Context context, AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | }
23 |
24 | @Override
25 | public void onLoadMore() {
26 | }
27 |
28 | @Override
29 | public void onPrepare() {
30 | }
31 |
32 | @Override
33 | public void onMove(int y, boolean isComplete, boolean automatic) {
34 | }
35 |
36 | @Override
37 | public void onRelease() {
38 |
39 | }
40 |
41 | @Override
42 | public void onComplete() {
43 |
44 | }
45 |
46 | @Override
47 | public void onReset() {
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_google_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
19 |
20 |
25 |
26 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 |
7 | 120dp
8 | 3dp
9 | 240dp
10 | 6dp
11 | 6dp
12 |
13 | 60dp
14 |
15 | 80dp
16 | 60dp
17 |
18 |
19 | 100dp
20 | 100dp
21 | 150dp
22 | 40dp
23 |
24 | 72dp
25 | 88dp
26 | 120dp
27 | 36dp
28 |
29 |
30 | 136dp
31 |
32 |
33 | 100dp
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_google_style_custom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
22 |
27 |
28 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_nav_jd.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
11 |
12 |
17 |
18 |
26 |
27 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/MainFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | import com.aspsine.fragmentnavigator.FragmentNavigatorAdapter;
6 | import com.aspsine.swipetoloadlayout.demo.fragment.NavGoogleFragment;
7 | import com.aspsine.swipetoloadlayout.demo.fragment.NavJDFragment;
8 | import com.aspsine.swipetoloadlayout.demo.fragment.NavJavaCodeFragment;
9 | import com.aspsine.swipetoloadlayout.demo.fragment.NavTwitterFragment;
10 | import com.aspsine.swipetoloadlayout.demo.fragment.NavYalantisFragment;
11 |
12 | /**
13 | * Created by aspsine on 16/4/28.
14 | */
15 | public class MainFragmentAdapter implements FragmentNavigatorAdapter {
16 |
17 | @Override
18 | public Fragment onCreateFragment(int position) {
19 | switch (position) {
20 | case 0:
21 | return NavTwitterFragment.newInstance();
22 |
23 | case 1:
24 | return NavGoogleFragment.newInstance();
25 |
26 | case 2:
27 | return NavYalantisFragment.newInstance();
28 |
29 | case 3:
30 | return NavJDFragment.newInstance();
31 |
32 | case 4:
33 | return NavJavaCodeFragment.newInstance();
34 | }
35 | return null;
36 | }
37 |
38 | @Override
39 | public String getTag(int position) {
40 | return String.valueOf(position);
41 | }
42 |
43 | @Override
44 | public int getCount() {
45 | return 5;
46 | }
47 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_nav_yalantis.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
11 |
12 |
24 |
25 |
28 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_classic_footer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
10 |
11 |
19 |
20 |
28 |
29 |
37 |
38 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo;
2 |
3 | import android.content.pm.PackageInfo;
4 | import android.content.pm.PackageManager;
5 | import android.os.Bundle;
6 | import android.support.v7.app.ActionBar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.MenuItem;
10 | import android.widget.TextView;
11 |
12 |
13 | public class AboutActivity extends AppCompatActivity {
14 |
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_about);
20 |
21 | final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
22 |
23 | setSupportActionBar(toolbar);
24 | ActionBar actionBar = getSupportActionBar();
25 | if (actionBar != null) {
26 | actionBar.setDisplayHomeAsUpEnabled(true);
27 | }
28 |
29 | TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
30 | tvVersion.setText("V " + getVersion());
31 | }
32 |
33 | private String getVersion() {
34 | String version = null;
35 | try {
36 | PackageManager packageManager = getPackageManager();
37 | PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(), 0);
38 | version = packInfo.versionName;
39 | } catch (Exception e) {
40 | e.printStackTrace();
41 | }
42 | return version;
43 | }
44 |
45 | @Override
46 | public boolean onOptionsItemSelected(MenuItem item) {
47 | int id = item.getItemId();
48 | switch (id) {
49 | case android.R.id.home:
50 | onBackPressed();
51 | return true;
52 | }
53 | return super.onOptionsItemSelected(item);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
21 |
22 |
28 |
29 |
36 |
37 |
44 |
45 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/volley/toolbox/GsonRequest.java:
--------------------------------------------------------------------------------
1 | package com.android.volley.toolbox;
2 |
3 | import com.android.volley.NetworkResponse;
4 | import com.android.volley.Request;
5 | import com.android.volley.Response;
6 | import com.google.gson.Gson;
7 |
8 | import java.io.UnsupportedEncodingException;
9 |
10 | /**
11 | * Created by Aspsine on 2015/9/7.
12 | */
13 | public class GsonRequest extends Request {
14 | private Response.Listener mListener;
15 | private Class mClazz;
16 | private Gson mGson;
17 |
18 | public GsonRequest(String url, Class clazz, Response.Listener listener, Response.ErrorListener errorListener) {
19 | this(Method.GET, url, clazz, listener, errorListener);
20 | }
21 |
22 | public GsonRequest(int method, String url, Class clazz, Response.Listener listener, Response.ErrorListener errorListener) {
23 | super(method, url, errorListener);
24 | this.mListener = listener;
25 | this.mClazz = clazz;
26 | this.mGson = new Gson();
27 | }
28 |
29 | public GsonRequest(int method, String url, Response.ErrorListener listener) {
30 | super(method, url, listener);
31 | }
32 |
33 | @Override
34 | protected Response parseNetworkResponse(NetworkResponse response) {
35 | String parsed;
36 | try {
37 | parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
38 | } catch (UnsupportedEncodingException e) {
39 | parsed = new String(response.data);
40 | }
41 | T t = mGson.fromJson(parsed, mClazz);
42 | //TODO
43 | try {
44 | Thread.sleep(2000);
45 | } catch (InterruptedException e) {
46 | e.printStackTrace();
47 | }
48 | return Response.success(t, HttpHeaderParser.parseCacheHeaders(response));
49 | }
50 |
51 | @Override
52 | protected void deliverResponse(T t) {
53 | mListener.onResponse(t);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/BaseToolbarFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.ActionBar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 |
12 | import com.aspsine.swipetoloadlayout.demo.R;
13 |
14 | /**
15 | * Created by aspsine on 15/9/8.
16 | */
17 | public class BaseToolbarFragment extends BaseFragment {
18 |
19 | public interface ToggleDrawerCallBack {
20 | void openDrawer();
21 | }
22 |
23 | @Override
24 | public void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setHasOptionsMenu(true);
27 | }
28 |
29 | @Override
30 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
31 | super.onViewCreated(view, savedInstanceState);
32 | Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
33 | if (toolbar != null) {
34 | ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
35 | final ActionBar actionbar = getSupportActionBar();
36 | actionbar.setHomeAsUpIndicator(R.mipmap.ic_menu);
37 | actionbar.setDisplayHomeAsUpEnabled(true);
38 | }
39 | }
40 |
41 | @Override
42 | public boolean onOptionsItemSelected(MenuItem item) {
43 | switch (item.getItemId()) {
44 | case android.R.id.home:
45 | ((ToggleDrawerCallBack) getActivity()).openDrawer();
46 | return true;
47 | }
48 | return super.onOptionsItemSelected(item);
49 | }
50 |
51 | public ActionBar getSupportActionBar() {
52 | return ((AppCompatActivity) getActivity()).getSupportActionBar();
53 | }
54 |
55 | protected void setTitle(CharSequence title) {
56 | getSupportActionBar().setTitle(title);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_twitter_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
19 |
20 |
28 |
29 |
37 |
38 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_base_nav_pager.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
23 |
24 |
25 |
26 |
31 |
32 |
33 |
38 |
39 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_nav_twitter.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
22 |
23 |
24 |
25 |
26 |
32 |
33 |
34 |
39 |
40 |
41 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/CharacterAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.content.res.Resources;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 | import android.widget.Toast;
10 |
11 | import com.aspsine.swipetoloadlayout.demo.R;
12 | import com.aspsine.swipetoloadlayout.demo.model.*;
13 | import com.aspsine.swipetoloadlayout.demo.model.Character;
14 | import com.squareup.picasso.CircleTransformation;
15 | import com.squareup.picasso.Picasso;
16 |
17 |
18 |
19 | /**
20 | * Created by aspsine on 15/9/11.
21 | */
22 | public class CharacterAdapter extends BaseArrayAdapter {
23 |
24 | @Override
25 | public View getView(int position, View convertView, ViewGroup parent) {
26 | ViewHolder holder = null;
27 | if (convertView == null) {
28 | convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_hero_grid, parent, false);
29 | holder = new ViewHolder();
30 | holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
31 | holder.ivAvatar = (ImageView) convertView.findViewById(R.id.ivAvatar);
32 | holder.tvName.setMaxLines(1);
33 | convertView.setTag(holder);
34 | } else {
35 | holder = (ViewHolder) convertView.getTag();
36 | }
37 | final Character character = getItem(position);
38 | holder.tvName.setText(character.getName());
39 | Resources resources = parent.getResources();
40 | int size = resources.getDimensionPixelOffset(R.dimen.hero_avatar_size);
41 | int width = resources.getDimensionPixelOffset(R.dimen.hero_avatar_border);
42 | Picasso.with(parent.getContext())
43 | .load(character.getAvatar())
44 | .resize(size, size)
45 | .transform(new CircleTransformation(width))
46 | .into(holder.ivAvatar);
47 | convertView.setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | Toast.makeText(v.getContext(), character.getName(), Toast.LENGTH_SHORT).show();
51 | }
52 | });
53 | return convertView;
54 | }
55 |
56 | public class ViewHolder {
57 | ImageView ivAvatar;
58 | TextView tvName;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/squareup/picasso/CircleTransformation.java:
--------------------------------------------------------------------------------
1 | package com.squareup.picasso;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.graphics.BitmapShader;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.Shader;
10 |
11 | /**
12 | * Created by aspsine on 15/9/5.
13 | */
14 | public class CircleTransformation implements Transformation {
15 | private static final int DEFAULT_BORDER_WIDTH = 10;
16 | private static final int DEFAULT_BORDER_COLOR = Color.parseColor("#000000");
17 |
18 | int mBorderWidth = 0;
19 | int mBorderColor = 0;
20 |
21 | public CircleTransformation() {
22 | mBorderWidth = DEFAULT_BORDER_WIDTH;
23 | mBorderColor = DEFAULT_BORDER_COLOR;
24 | }
25 |
26 | public CircleTransformation(int borderWidth) {
27 | this.mBorderWidth = borderWidth;
28 | this.mBorderColor = DEFAULT_BORDER_COLOR;
29 | }
30 |
31 | public CircleTransformation(int borderWidth, int borderColor) {
32 | this.mBorderWidth = borderWidth;
33 | this.mBorderColor = borderColor;
34 | }
35 |
36 | @Override
37 | public Bitmap transform(Bitmap source) {
38 | int width = source.getWidth();
39 | int height = source.getHeight();
40 | int diameter = Math.min(width, height);
41 | int x = (width - diameter)/2;
42 | int y =(height - diameter)/2;
43 | Bitmap squareBitmap = Bitmap.createBitmap(source, x, y, diameter, diameter);
44 | if (squareBitmap != source) {
45 | source.recycle();
46 | }
47 | Bitmap bitmap = Bitmap.createBitmap(diameter, diameter, source.getConfig());
48 | Canvas canvas = new Canvas(bitmap);
49 | Paint paint = new Paint();
50 | BitmapShader shader = new BitmapShader(squareBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
51 | paint.setShader(shader);
52 | paint.setAntiAlias(true);
53 |
54 | float radius = diameter / 2f;
55 |
56 | if (mBorderWidth > 0) {
57 | Paint bgPaint = new Paint();
58 | bgPaint.setColor(mBorderColor);
59 | bgPaint.setAntiAlias(true);
60 | canvas.drawCircle(radius , radius , radius , bgPaint);
61 | }
62 | canvas.drawCircle(radius, radius, radius-mBorderWidth, paint);
63 | squareBitmap.recycle();
64 | squareBitmap = null;
65 | return bitmap;
66 | }
67 |
68 | @Override
69 | public String key() {
70 | return getClass().getSimpleName();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/footer/ClassicLoadMoreFooterView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.footer;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.ImageView;
6 | import android.widget.ProgressBar;
7 | import android.widget.TextView;
8 |
9 | import com.aspsine.swipetoloadlayout.SwipeLoadMoreFooterLayout;
10 | import com.aspsine.swipetoloadlayout.demo.R;
11 |
12 | /**
13 | * Created by Aspsine on 2015/9/2.
14 | */
15 | public class ClassicLoadMoreFooterView extends SwipeLoadMoreFooterLayout {
16 | private TextView tvLoadMore;
17 | private ImageView ivSuccess;
18 | private ProgressBar progressBar;
19 |
20 | private int mFooterHeight;
21 |
22 | public ClassicLoadMoreFooterView(Context context) {
23 | this(context, null);
24 | }
25 |
26 | public ClassicLoadMoreFooterView(Context context, AttributeSet attrs) {
27 | this(context, attrs, 0);
28 | }
29 |
30 | public ClassicLoadMoreFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
31 | super(context, attrs, defStyleAttr);
32 | mFooterHeight = getResources().getDimensionPixelOffset(R.dimen.load_more_footer_height_classic);
33 | }
34 |
35 | @Override
36 | protected void onFinishInflate() {
37 | super.onFinishInflate();
38 | tvLoadMore = (TextView) findViewById(R.id.tvLoadMore);
39 | ivSuccess = (ImageView) findViewById(R.id.ivSuccess);
40 | progressBar = (ProgressBar) findViewById(R.id.progressbar);
41 | }
42 |
43 | @Override
44 | public void onPrepare() {
45 | ivSuccess.setVisibility(GONE);
46 | }
47 |
48 | @Override
49 | public void onMove(int y, boolean isComplete, boolean automatic) {
50 | if (!isComplete) {
51 | ivSuccess.setVisibility(GONE);
52 | progressBar.setVisibility(GONE);
53 | if (-y >= mFooterHeight) {
54 | tvLoadMore.setText("RELEASE TO LOAD MORE");
55 | } else {
56 | tvLoadMore.setText("SWIPE TO LOAD MORE");
57 | }
58 | }
59 | }
60 |
61 | @Override
62 | public void onLoadMore() {
63 | tvLoadMore.setText("LOADING MORE");
64 | progressBar.setVisibility(VISIBLE);
65 | }
66 |
67 | @Override
68 | public void onRelease() {
69 |
70 | }
71 |
72 | @Override
73 | public void onComplete() {
74 | progressBar.setVisibility(GONE);
75 | ivSuccess.setVisibility(VISIBLE);
76 | }
77 |
78 | @Override
79 | public void onReset() {
80 | ivSuccess.setVisibility(GONE);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/NavJDFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.aspsine.swipetoloadlayout.OnRefreshListener;
11 | import com.aspsine.swipetoloadlayout.SwipeToLoadLayout;
12 | import com.aspsine.swipetoloadlayout.demo.R;
13 |
14 | /**
15 | * A simple {@link Fragment} subclass.
16 | * Use the {@link NavJDFragment#newInstance} factory method to
17 | * create an instance of this fragment.
18 | */
19 | public class NavJDFragment extends BaseNavigationFragment implements OnRefreshListener {
20 |
21 | SwipeToLoadLayout swipeToLoadLayout;
22 |
23 | public NavJDFragment() {
24 | // Required empty public constructor
25 | }
26 |
27 | /**
28 | * Use this factory method to create a new instance of
29 | * this fragment using the provided parameters.
30 | */
31 | public static BaseNavigationFragment newInstance() {
32 | NavJDFragment fragment = new NavJDFragment();
33 | return fragment;
34 | }
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | }
40 |
41 | @Override
42 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
43 | Bundle savedInstanceState) {
44 | // Inflate the layout for this fragment
45 | return inflater.inflate(R.layout.fragment_nav_jd, container, false);
46 | }
47 |
48 | @Override
49 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
50 | super.onViewCreated(view, savedInstanceState);
51 | swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
52 | swipeToLoadLayout.setOnRefreshListener(this);
53 | }
54 |
55 | @Override
56 | public void onActivityCreated(Bundle savedInstanceState) {
57 | super.onActivityCreated(savedInstanceState);
58 | swipeToLoadLayout.post(new Runnable() {
59 | @Override
60 | public void run() {
61 | swipeToLoadLayout.setRefreshing(true);
62 | }
63 | });
64 | }
65 |
66 | @Override
67 | public void onRefresh() {
68 | swipeToLoadLayout.postDelayed(new Runnable() {
69 | @Override
70 | public void run() {
71 | swipeToLoadLayout.setRefreshing(false);
72 | }
73 | }, 3000);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/header/GoogleRefreshHeaderView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.header;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.AttributeSet;
6 | import android.widget.FrameLayout;
7 | import android.widget.ImageView;
8 |
9 | import com.aspsine.swipetoloadlayout.SwipeRefreshTrigger;
10 | import com.aspsine.swipetoloadlayout.SwipeTrigger;
11 | import com.aspsine.swipetoloadlayout.demo.R;
12 | import com.aspsine.swipetoloadlayout.demo.view.drawable.google.RingProgressDrawable;
13 |
14 | /**
15 | * Created by aspsine on 15/9/10.
16 | */
17 | public class GoogleRefreshHeaderView extends FrameLayout implements SwipeTrigger, SwipeRefreshTrigger {
18 | private ImageView ivRefresh;
19 |
20 | private int mTriggerOffset;
21 |
22 | private RingProgressDrawable ringProgressDrawable;
23 |
24 | public GoogleRefreshHeaderView(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public GoogleRefreshHeaderView(Context context, AttributeSet attrs) {
29 | this(context, attrs, 0);
30 | }
31 |
32 | public GoogleRefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
33 | super(context, attrs, defStyleAttr);
34 | ringProgressDrawable = new RingProgressDrawable(context);
35 | Resources res = getResources();
36 | ringProgressDrawable.setColors(
37 | res.getColor(R.color.google_blue),
38 | res.getColor(R.color.google_red),
39 | res.getColor(R.color.google_yellow),
40 | res.getColor(R.color.google_green));
41 | mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_trigger_offset_google);
42 | }
43 |
44 | @Override
45 | protected void onFinishInflate() {
46 | super.onFinishInflate();
47 | ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
48 | ivRefresh.setBackgroundDrawable(ringProgressDrawable);
49 | }
50 |
51 | @Override
52 | public void onRefresh() {
53 | ringProgressDrawable.start();
54 | }
55 |
56 | @Override
57 | public void onPrepare() {
58 |
59 | }
60 |
61 | @Override
62 | public void onMove(int y, boolean isComplete, boolean automatic) {
63 | if (!isComplete) {
64 | ringProgressDrawable.setPercent(y / (float) mTriggerOffset);
65 | }
66 | }
67 |
68 | @Override
69 | public void onRelease() {
70 |
71 | }
72 |
73 | @Override
74 | public void onComplete() {
75 | ringProgressDrawable.stop();
76 | }
77 |
78 | @Override
79 | public void onReset() {
80 |
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/footer/GoogleLoadMoreFooterView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.footer;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.util.AttributeSet;
6 | import android.widget.FrameLayout;
7 | import android.widget.ImageView;
8 |
9 | import com.aspsine.swipetoloadlayout.SwipeLoadMoreTrigger;
10 | import com.aspsine.swipetoloadlayout.SwipeTrigger;
11 | import com.aspsine.swipetoloadlayout.demo.R;
12 | import com.aspsine.swipetoloadlayout.demo.view.drawable.google.RingProgressDrawable;
13 |
14 | /**
15 | * Created by Aspsine on 2015/11/5.
16 | */
17 | public class GoogleLoadMoreFooterView extends FrameLayout implements SwipeTrigger, SwipeLoadMoreTrigger {
18 | private ImageView ivLoadMore;
19 |
20 | private int mTriggerOffset;
21 |
22 | private RingProgressDrawable ringProgressDrawable;
23 | public GoogleLoadMoreFooterView(Context context) {
24 | this(context, null);
25 | }
26 |
27 | public GoogleLoadMoreFooterView(Context context, AttributeSet attrs) {
28 | this(context, attrs, 0);
29 | }
30 |
31 | public GoogleLoadMoreFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | ringProgressDrawable = new RingProgressDrawable(context);
34 | Resources res = getResources();
35 | ringProgressDrawable.setColors(
36 | res.getColor(R.color.google_blue),
37 | res.getColor(R.color.google_red),
38 | res.getColor(R.color.google_yellow),
39 | res.getColor(R.color.google_green));
40 | mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.load_more_trigger_offset_google);
41 | }
42 |
43 | @Override
44 | protected void onFinishInflate() {
45 | super.onFinishInflate();
46 | ivLoadMore = (ImageView) findViewById(R.id.ivLoadMore);
47 | ivLoadMore.setBackgroundDrawable(ringProgressDrawable);
48 | }
49 |
50 | @Override
51 | public void onLoadMore() {
52 | ringProgressDrawable.start();
53 | }
54 |
55 | @Override
56 | public void onPrepare() {
57 |
58 | }
59 |
60 | @Override
61 | public void onMove(int y, boolean isComplete, boolean automatic) {
62 | if (!isComplete){
63 | ringProgressDrawable.setPercent(-y / (float) mTriggerOffset);
64 | }
65 | }
66 |
67 | @Override
68 | public void onRelease() {
69 |
70 | }
71 |
72 | @Override
73 | public void onComplete() {
74 | ringProgressDrawable.stop();
75 | }
76 |
77 | @Override
78 | public void onReset() {
79 |
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/header/YalantisPhoenixRefreshHeaderView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.header;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.FrameLayout;
6 | import android.widget.ImageView;
7 |
8 | import com.aspsine.swipetoloadlayout.SwipeRefreshTrigger;
9 | import com.aspsine.swipetoloadlayout.SwipeTrigger;
10 | import com.aspsine.swipetoloadlayout.demo.R;
11 | import com.aspsine.swipetoloadlayout.demo.util.DensityUtil;
12 | import com.aspsine.swipetoloadlayout.demo.view.drawable.yalantis.BaseRefreshDrawable;
13 | import com.aspsine.swipetoloadlayout.demo.view.drawable.yalantis.SunRefreshDrawable;
14 |
15 | /**
16 | * Created by Aspsine on 2015/11/5.
17 | */
18 | public class YalantisPhoenixRefreshHeaderView extends FrameLayout implements SwipeTrigger, SwipeRefreshTrigger {
19 |
20 | private ImageView ivRefresh;
21 |
22 | private BaseRefreshDrawable mDrawable;
23 |
24 | private int mTriggerOffset;
25 |
26 | public YalantisPhoenixRefreshHeaderView(Context context) {
27 | this(context, null);
28 | }
29 |
30 | public YalantisPhoenixRefreshHeaderView(Context context, AttributeSet attrs) {
31 | this(context, attrs, 0);
32 | }
33 |
34 | public YalantisPhoenixRefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | mTriggerOffset = getResources().getDimensionPixelOffset(R.dimen.refresh_header_height_yalantis);
37 | }
38 |
39 | @Override
40 | protected void onFinishInflate() {
41 | super.onFinishInflate();
42 | ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
43 | mDrawable = new SunRefreshDrawable(getContext(), this, mTriggerOffset, DensityUtil.getScreenWidth(getContext()));
44 | ivRefresh.setBackgroundDrawable(mDrawable);
45 | }
46 |
47 |
48 | @Override
49 | public void onRefresh() {
50 | if (!mDrawable.isRunning()){
51 | mDrawable.start();
52 | }
53 | }
54 |
55 | @Override
56 | public void onPrepare() {
57 |
58 | }
59 |
60 | private int mOldY = 0;
61 |
62 | @Override
63 | public void onMove(int y, boolean isComplete, boolean automatic) {
64 | int delta = y - mOldY;
65 | mDrawable.offsetTopAndBottom(delta);
66 | mDrawable.setPercent(y / (float) mTriggerOffset, true);
67 | mOldY = y;
68 | }
69 |
70 | @Override
71 | public void onRelease() {
72 | if (!mDrawable.isRunning()){
73 | mDrawable.start();
74 | }
75 | }
76 |
77 | @Override
78 | public void onComplete() {
79 |
80 | }
81 |
82 | @Override
83 | public void onReset() {
84 | mDrawable.stop();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/header/JdRefreshHeaderView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.header;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.AnimationDrawable;
5 | import android.util.AttributeSet;
6 | import android.view.animation.Animation;
7 | import android.view.animation.AnimationUtils;
8 | import android.widget.ImageView;
9 | import android.widget.RelativeLayout;
10 |
11 | import com.aspsine.swipetoloadlayout.SwipeRefreshTrigger;
12 | import com.aspsine.swipetoloadlayout.SwipeTrigger;
13 | import com.aspsine.swipetoloadlayout.demo.R;
14 |
15 | /**
16 | * Created by Aspsine on 2015/11/5.
17 | */
18 | public class JdRefreshHeaderView extends RelativeLayout implements SwipeTrigger, SwipeRefreshTrigger {
19 |
20 | private ImageView ivSpeed;
21 |
22 | private ImageView ivRefresh;
23 |
24 | private AnimationDrawable mAnimDrawable;
25 |
26 | private Animation mTwinkleAnim;
27 |
28 | private int mTriggerOffset;
29 |
30 |
31 | public JdRefreshHeaderView(Context context) {
32 | super(context);
33 | }
34 |
35 | public JdRefreshHeaderView(Context context, AttributeSet attrs) {
36 | super(context, attrs);
37 | }
38 |
39 | public JdRefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
40 | super(context, attrs, defStyleAttr);
41 | mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_header_height_jd);
42 | }
43 |
44 | @Override
45 | protected void onFinishInflate() {
46 | super.onFinishInflate();
47 | ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
48 | ivSpeed = (ImageView) findViewById(R.id.ivSpeed);
49 | mAnimDrawable = (AnimationDrawable) ivRefresh.getBackground();
50 | mTwinkleAnim = AnimationUtils.loadAnimation(getContext(), R.anim.twinkle);
51 | }
52 |
53 | @Override
54 | public void onRefresh() {
55 | ivSpeed.setVisibility(VISIBLE);
56 | ivSpeed.startAnimation(mTwinkleAnim);
57 | if (!mAnimDrawable.isRunning()){
58 | mAnimDrawable.start();
59 | }
60 | }
61 |
62 | @Override
63 | public void onPrepare() {
64 | ivSpeed.clearAnimation();
65 | ivSpeed.setVisibility(GONE);
66 | }
67 |
68 | @Override
69 | public void onMove(int y, boolean isComplete, boolean automatic) {
70 | }
71 |
72 | @Override
73 | public void onRelease() {
74 | if (!mAnimDrawable.isRunning()){
75 | mAnimDrawable.start();
76 | }
77 | }
78 |
79 | @Override
80 | public void onComplete() {
81 | }
82 |
83 | @Override
84 | public void onReset() {
85 | mAnimDrawable.stop();
86 | ivSpeed.clearAnimation();
87 | ivSpeed.setVisibility(GONE);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/README_CN.md:
--------------------------------------------------------------------------------
1 | [](http://android-arsenal.com/details/1/2812)
2 | # SwipeToLoadLayout
3 | SwipeToLoadLayout是一个可以帮助你实现下拉刷新和加载更多的Layout
4 |
5 | ## 支持的View
6 | 理论上支持所有的View
7 |
8 | ## Demo
9 | [Download](https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/master/art/demo.apk)
10 |
11 | ## Demo 截图 & 视频(Youku)
12 | - ListView & GridView
13 |
14 | [](http://player.youku.com/embed/XMTM5MjA1MTIyOA==)
15 |
16 | - RecyclerView(With all kinds of layoutManagers)
17 |
18 | [](http://player.youku.com/embed/XMTM5MjA1Mjc3Mg==)
19 |
20 | - WebView & ScrollView & Other Views
21 |
22 | [](http://player.youku.com/embed/XMTM5MjA1MzIxNg==)
23 |
24 | - Google SwipeRefreshLayout style
25 |
26 | [](http://player.youku.com/embed/XMTM5MjA1MzU4NA==)
27 |
28 | - JD.com Style
29 |
30 | [](https://youtu.be/QrsZ5nygTp0)
31 |
32 | - Yalantis Phoenix Style
33 |
34 | [](http://player.youku.com/embed/XMTM5MjA1NDQ4MA==)
35 |
36 | 你也可以自定义自己喜欢的头部和尾部,插件试替换,非常简单哦!
37 |
38 | ## How to
39 |
40 | - Step 1. 把 JitPack repository 添加到build.gradle文件中 repositories的末尾:
41 | ```
42 | repositories {
43 | maven { url "https://jitpack.io" }
44 | }
45 | ```
46 | - Step 2. 在你的app build.gradle 的 dependencies 中添加依赖
47 | ```
48 | dependencies {
49 | compile 'com.github.Aspsine:SwipeToLoadLayout:1.0.4'
50 | }
51 | ```
52 | - Step 3. 查看[快速集成文档](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup)
53 |
54 | ## 致谢
55 | - Google SwipeRefreshLayout
56 | - [liaohuqiu android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh)
57 | - [Yalantis Phoenix](https://github.com/Yalantis/Phoenix)
58 |
59 | ## 联系我
60 | - Github: github.com/aspsine
61 | - Email: littleximail@gmail.com
62 | - Linkedin: cn.linkedin.com/in/aspsine
63 |
64 | ## License
65 |
66 | Copyright 2015 Aspsine. All rights reserved.
67 |
68 | Licensed under the Apache License, Version 2.0 (the "License");
69 | you may not use this file except in compliance with the License.
70 | You may obtain a copy of the License at
71 |
72 | http://www.apache.org/licenses/LICENSE-2.0
73 |
74 | Unless required by applicable law or agreed to in writing, software
75 | distributed under the License is distributed on an "AS IS" BASIS,
76 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77 | See the License for the specific language governing permissions and
78 | limitations under the License.
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/footer/GoogleCircleHookLoadMoreFooterView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.footer;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewCompat;
5 | import android.util.AttributeSet;
6 | import android.widget.FrameLayout;
7 |
8 | import com.aspsine.swipetoloadlayout.SwipeLoadMoreTrigger;
9 | import com.aspsine.swipetoloadlayout.SwipeTrigger;
10 | import com.aspsine.swipetoloadlayout.demo.R;
11 | import com.aspsine.swipetoloadlayout.demo.view.GoogleCircleProgressView;
12 |
13 | /**
14 | * Created by aspsine on 16/1/27.
15 | */
16 | public class GoogleCircleHookLoadMoreFooterView extends FrameLayout implements SwipeTrigger, SwipeLoadMoreTrigger {
17 |
18 | private GoogleCircleProgressView progressView;
19 |
20 | private int mTriggerOffset;
21 |
22 | private int mFinalOffset;
23 |
24 | public GoogleCircleHookLoadMoreFooterView(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public GoogleCircleHookLoadMoreFooterView(Context context, AttributeSet attrs) {
29 | this(context, attrs, 0);
30 | }
31 |
32 | public GoogleCircleHookLoadMoreFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
33 | super(context, attrs, defStyleAttr);
34 | mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.load_more_footer_height_google);
35 | mFinalOffset = context.getResources().getDimensionPixelOffset(R.dimen.load_more_final_offset_google);
36 | }
37 |
38 |
39 | @Override
40 | protected void onFinishInflate() {
41 | super.onFinishInflate();
42 | progressView = (GoogleCircleProgressView) findViewById(R.id.googleProgress);
43 | progressView.setColorSchemeResources(
44 | R.color.google_blue,
45 | R.color.google_red,
46 | R.color.google_yellow,
47 | R.color.google_green);
48 | progressView.setStartEndTrim(0, (float) 0.75);
49 | }
50 |
51 | @Override
52 | public void onLoadMore() {
53 | progressView.start();
54 | }
55 |
56 | @Override
57 | public void onPrepare() {
58 | progressView.setStartEndTrim(0, (float) 0.75);
59 | }
60 |
61 | @Override
62 | public void onMove(int y, boolean isComplete, boolean automatic) {
63 | float alpha = -y / (float) mTriggerOffset;
64 | ViewCompat.setAlpha(progressView, alpha);
65 | if (!isComplete) {
66 | progressView.setProgressRotation(-y / (float) mFinalOffset);
67 | }
68 | }
69 |
70 | @Override
71 | public void onRelease() {
72 |
73 | }
74 |
75 | @Override
76 | public void onComplete() {
77 | }
78 |
79 | @Override
80 | public void onReset() {
81 | progressView.stop();
82 | ViewCompat.setAlpha(progressView, 1f);
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/drawable/google/ProgressDrawable.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.drawable.google;
2 |
3 | import android.content.Context;
4 | import android.graphics.ColorFilter;
5 | import android.graphics.PixelFormat;
6 | import android.graphics.drawable.Animatable;
7 | import android.graphics.drawable.Drawable;
8 | import android.os.Handler;
9 | import android.os.Looper;
10 | import android.util.TypedValue;
11 |
12 | /**
13 | * Created by Aspsine on 2015/9/11.
14 | */
15 | public abstract class ProgressDrawable extends Drawable implements Animatable {
16 |
17 | /**
18 | * smooth animation requires 60 frame in 1000ms
19 | * We can know fresh 1 frame requires 1000/60 ms
20 | */
21 | public static final int DELAY = 1000 / 60;
22 |
23 | private final Context mContext;
24 |
25 | private boolean mRunning;
26 |
27 | private Handler mHandler;
28 |
29 | private int[] mColors;
30 |
31 |
32 | public ProgressDrawable(Context context) {
33 | mContext = context;
34 | }
35 |
36 | public void setColors(int... colors) {
37 | mColors = colors;
38 | }
39 |
40 | public int[] getColors() {
41 | return mColors;
42 | }
43 |
44 | public abstract void setPercent(float progress, boolean isUser);
45 |
46 | public void setPercent(float progress) {
47 | setPercent(progress, false);
48 | }
49 |
50 | public void setRunning(boolean running) {
51 | this.mRunning = running;
52 | }
53 |
54 | @Override
55 | public boolean isRunning() {
56 | return mRunning;
57 | }
58 |
59 | @Override
60 | public void setAlpha(int alpha) {
61 |
62 | }
63 |
64 | @Override
65 | public void setColorFilter(ColorFilter colorFilter) {
66 |
67 | }
68 |
69 | @Override
70 | public int getOpacity() {
71 | return PixelFormat.TRANSLUCENT;
72 | }
73 |
74 | protected Context getContext() {
75 | return mContext;
76 | }
77 |
78 | protected void post(Runnable runnable) {
79 | postDelayed(runnable, 0);
80 | }
81 |
82 | protected void postDelayed(Runnable runnable, int delayMillis) {
83 | if (mHandler == null) {
84 | synchronized (ProgressDrawable.class) {
85 | mHandler = new Handler(Looper.getMainLooper());
86 | }
87 | }
88 | mHandler.postDelayed(runnable, delayMillis);
89 |
90 | }
91 |
92 | protected void removeCallBacks(Runnable runnable) {
93 | if (mHandler != null) {
94 | mHandler.removeCallbacks(runnable);
95 | }
96 | }
97 |
98 |
99 | protected int dp2px(int dp) {
100 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getContext().getResources().getDisplayMetrics());
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/drawable/yalantis/BaseRefreshDrawable.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.drawable.yalantis;
2 |
3 | import android.content.Context;
4 | import android.graphics.ColorFilter;
5 | import android.graphics.PixelFormat;
6 | import android.graphics.drawable.Animatable;
7 | import android.graphics.drawable.Drawable;
8 | import android.os.Handler;
9 | import android.os.Looper;
10 | import android.support.annotation.NonNull;
11 |
12 | /**
13 | * Copy from https://github.com/Yalantis/Phoenix
14 | * Aspsine makes some changes
15 | */
16 | public abstract class BaseRefreshDrawable extends Drawable implements Drawable.Callback, Animatable {
17 |
18 | private boolean mEndOfRefreshing;
19 |
20 | private Context mContext;
21 |
22 | private Handler mHandler;
23 |
24 | public BaseRefreshDrawable(Context context) {
25 | mContext = context;
26 | }
27 |
28 | public Context getContext() {
29 | return mContext;
30 | }
31 |
32 | public abstract void setPercent(float percent, boolean invalidate);
33 |
34 | public abstract void offsetTopAndBottom(int offset);
35 |
36 | @Override
37 | public void invalidateDrawable(@NonNull Drawable who) {
38 | final Callback callback = getCallback();
39 | if (callback != null) {
40 | callback.invalidateDrawable(this);
41 | }
42 | }
43 |
44 | @Override
45 | public void scheduleDrawable(Drawable who, Runnable what, long when) {
46 | final Callback callback = getCallback();
47 | if (callback != null) {
48 | callback.scheduleDrawable(this, what, when);
49 | }
50 | }
51 |
52 | @Override
53 | public void unscheduleDrawable(Drawable who, Runnable what) {
54 | final Callback callback = getCallback();
55 | if (callback != null) {
56 | callback.unscheduleDrawable(this, what);
57 | }
58 | }
59 |
60 | @Override
61 | public int getOpacity() {
62 | return PixelFormat.TRANSLUCENT;
63 | }
64 |
65 | @Override
66 | public void setAlpha(int alpha) {
67 |
68 | }
69 |
70 | @Override
71 | public void setColorFilter(ColorFilter cf) {
72 |
73 | }
74 |
75 | /**
76 | * Our animation depend on type of current work of refreshing.
77 | * We should to do different things when it's end of refreshing
78 | *
79 | * @param endOfRefreshing - we will check current state of refresh with this
80 | */
81 | public void setEndOfRefreshing(boolean endOfRefreshing) {
82 | mEndOfRefreshing = endOfRefreshing;
83 | }
84 |
85 | protected void post(Runnable runnable) {
86 | postDelayed(runnable, 0);
87 | }
88 |
89 | protected void postDelayed(Runnable runnable, int delayMillis) {
90 | if (mHandler == null) {
91 | synchronized (BaseRefreshDrawable.class) {
92 | mHandler = new Handler(Looper.getMainLooper());
93 | }
94 | }
95 | mHandler.postDelayed(runnable, delayMillis);
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](http://android-arsenal.com/details/1/2812)
2 | # SwipeToLoadLayout
3 | SwipeToLoadLayout is a reusable pull-to-refresh and pull-to-load-more widget.
4 |
5 | ## Supported View
6 | Theoretically support all kinds of views.
7 |
8 | ## Demo
9 | [Download](https://raw.githubusercontent.com/Aspsine/SwipeToLoadLayout/master/art/demo.apk)
10 |
11 | ## Demo ScreenShot & Video(Youtube)
12 | - ListView & GridView
13 |
14 | [](https://youtu.be/ThIKO3vz6Bs)
15 |
16 | - RecyclerView(With all kinds of layoutManagers)
17 |
18 | [](https://youtu.be/ZVYkoi84Vr8)
19 |
20 | - WebView & ScrollView & Other Views
21 |
22 | [](https://youtu.be/RGtWvdrVmGM)
23 |
24 | - Google SwipeRefreshLayout style
25 |
26 | [](https://youtu.be/38NbDiUoXmg)
27 |
28 | - JD.com Style
29 |
30 | [](https://youtu.be/QrsZ5nygTp0)
31 |
32 | - Yalantis Phoenix Style
33 |
34 | [](https://youtu.be/FAqrzSjt85c)
35 |
36 | You can also create your own header and footer. It's very simple.
37 |
38 | ## How to
39 |
40 | - Step 1. Add the JitPack repository in your build.gradle at the end of repositories:
41 | ```
42 | repositories {
43 | maven { url "https://jitpack.io" }
44 | }
45 | ```
46 | - Step 2. Add the dependency in the form
47 | ```
48 | dependencies {
49 | compile 'com.github.Aspsine:SwipeToLoadLayout:1.0.4'
50 | }
51 | ```
52 | - Step 3.
53 | Look over [Quick Setup](https://github.com/Aspsine/SwipeToLoadLayout/wiki/Quick-Setup) for more details.
54 | You can find more customized header view and footer view in the demo app.
55 |
56 | ## Thanks
57 | - Google SwipeRefreshLayout
58 | - [liaohuqiu android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh)
59 | - [Yalantis Phoenix](https://github.com/Yalantis/Phoenix)
60 |
61 | ## Contact Me
62 | - Github: github.com/aspsine
63 | - Email: littleximail@gmail.com
64 | - WeiBo: [@Aspsine](http://weibo.com/wetze)
65 | - Linkedin: cn.linkedin.com/in/aspsine
66 |
67 | ## License
68 |
69 | Copyright 2015 Aspsine. All rights reserved.
70 |
71 | Licensed under the Apache License, Version 2.0 (the "License");
72 | you may not use this file except in compliance with the License.
73 | You may obtain a copy of the License at
74 |
75 | http://www.apache.org/licenses/LICENSE-2.0
76 |
77 | Unless required by applicable law or agreed to in writing, software
78 | distributed under the License is distributed on an "AS IS" BASIS,
79 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80 | See the License for the specific language governing permissions and
81 | limitations under the License.
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/BaseNavPagerFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.design.widget.TabLayout;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.app.FragmentManager;
9 | import android.support.v4.app.FragmentPagerAdapter;
10 | import android.support.v4.view.ViewPager;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 |
15 | import com.aspsine.swipetoloadlayout.demo.R;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | /**
21 | * A simple {@link Fragment} subclass.
22 | */
23 | public abstract class BaseNavPagerFragment extends BaseNavigationFragment {
24 | private ViewPager viewPager;
25 | private TabLayout tabLayout;
26 | private Adapter mAdapter;
27 |
28 | public BaseNavPagerFragment() {
29 | // Required empty public constructor
30 | }
31 |
32 | protected abstract String[] getTitles();
33 |
34 | protected abstract Fragment getFragment(int position);
35 |
36 | @Override
37 | public void onCreate(@Nullable Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | mAdapter = new Adapter(getChildFragmentManager());
40 | String[] titles = getTitles();
41 | for (int i = 0; i < titles.length; i++) {
42 | mAdapter.addFragment(getFragment(i), titles[i]);
43 | }
44 | }
45 |
46 | @Override
47 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
48 | Bundle savedInstanceState) {
49 | // Inflate the layout for this fragment
50 | return inflater.inflate(R.layout.fragment_base_nav_pager, container, false);
51 | }
52 |
53 | @Override
54 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
55 | super.onViewCreated(view, savedInstanceState);
56 | tabLayout = (TabLayout) view.findViewById(R.id.tabs);
57 | viewPager = (ViewPager) view.findViewById(R.id.viewPager);
58 | viewPager.setAdapter(mAdapter);
59 | tabLayout.setupWithViewPager(viewPager);
60 | }
61 |
62 | protected static class Adapter extends FragmentPagerAdapter {
63 | private List fragments = new ArrayList<>();
64 | private List titles = new ArrayList<>();
65 |
66 | public Adapter(FragmentManager fm) {
67 | super(fm);
68 | }
69 |
70 | public void addFragment(Fragment fragment, CharSequence title) {
71 | fragments.add(fragment);
72 | titles.add(title);
73 | }
74 |
75 | @Override
76 | public Fragment getItem(int position) {
77 | return fragments.get(position);
78 | }
79 |
80 | @Override
81 | public int getCount() {
82 | return fragments.size();
83 | }
84 |
85 | @Override
86 | public CharSequence getPageTitle(int position) {
87 | return titles.get(position);
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/header/GoogleCircleHookRefreshHeaderView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.header;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.support.v4.view.ViewCompat;
7 | import android.util.AttributeSet;
8 | import android.widget.FrameLayout;
9 |
10 | import com.aspsine.swipetoloadlayout.SwipeRefreshTrigger;
11 | import com.aspsine.swipetoloadlayout.SwipeTrigger;
12 | import com.aspsine.swipetoloadlayout.demo.R;
13 | import com.aspsine.swipetoloadlayout.demo.view.GoogleCircleProgressView;
14 |
15 | /**
16 | * Created by aspsine on 15/11/7.
17 | */
18 | public class GoogleCircleHookRefreshHeaderView extends FrameLayout implements SwipeTrigger, SwipeRefreshTrigger {
19 | private GoogleCircleProgressView progressView;
20 |
21 | private int mTriggerOffset;
22 |
23 | private int mFinalOffset;
24 |
25 | public GoogleCircleHookRefreshHeaderView(Context context) {
26 | this(context, null);
27 | }
28 |
29 | public GoogleCircleHookRefreshHeaderView(Context context, AttributeSet attrs) {
30 | this(context, attrs, 0);
31 | }
32 |
33 | public GoogleCircleHookRefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
34 | super(context, attrs, defStyleAttr);
35 | mTriggerOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_header_height_google);
36 | mFinalOffset = context.getResources().getDimensionPixelOffset(R.dimen.refresh_final_offset_google);
37 | }
38 |
39 |
40 | @Override
41 | protected void onFinishInflate() {
42 | super.onFinishInflate();
43 | progressView = (GoogleCircleProgressView) findViewById(R.id.googleProgress);
44 | progressView.setColorSchemeResources(
45 | R.color.google_blue,
46 | R.color.google_red,
47 | R.color.google_yellow,
48 | R.color.google_green);
49 | progressView.setStartEndTrim(0, (float) 0.75);
50 | }
51 |
52 | @Override
53 | public void onRefresh() {
54 | progressView.start();
55 | }
56 |
57 | @Override
58 | public void onPrepare() {
59 | progressView.setStartEndTrim(0, (float) 0.75);
60 | }
61 |
62 | @Override
63 | public void onMove(int y, boolean isComplete, boolean automatic) {
64 | float alpha = y / (float) mTriggerOffset;
65 | ViewCompat.setAlpha(progressView, alpha);
66 | if (!isComplete) {
67 | progressView.setProgressRotation(y / (float) mFinalOffset);
68 | }
69 | }
70 |
71 | @Override
72 | public void onRelease() {
73 |
74 | }
75 |
76 | @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
77 | @Override
78 | public void onComplete() {
79 | progressView.animate().scaleX(0).scaleY(0).setDuration(300);
80 | }
81 |
82 | @Override
83 | public void onReset() {
84 | progressView.stop();
85 | ViewCompat.setAlpha(progressView, 1f);
86 | ViewCompat.setScaleX(progressView, 1f);
87 | ViewCompat.setScaleY(progressView, 1f);
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.design.widget.NavigationView;
7 | import android.support.v4.view.GravityCompat;
8 | import android.support.v4.widget.DrawerLayout;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.MenuItem;
11 |
12 | import com.aspsine.fragmentnavigator.FragmentNavigator;
13 | import com.aspsine.swipetoloadlayout.demo.fragment.BaseToolbarFragment;
14 |
15 | import java.util.Arrays;
16 | import java.util.List;
17 |
18 | public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener
19 | , BaseToolbarFragment.ToggleDrawerCallBack {
20 |
21 | private static final Integer ID_ARRAY[] = {
22 | R.id.nav_Twitter_style,
23 | R.id.nav_google_style,
24 | R.id.nav_yalantis_style,
25 | R.id.nav_jd_style,
26 | R.id.nav_set_header_footer_via_code
27 | };
28 |
29 | private static final List IDS = Arrays.asList(ID_ARRAY);
30 |
31 | private static final int DEFAULT_POSITION = 0;
32 |
33 | private DrawerLayout drawerLayout;
34 |
35 | /**
36 | * https://github.com/Aspsine/FragmentNavigator
37 | */
38 | private FragmentNavigator mFragmentNavigator;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 |
44 | mFragmentNavigator = new FragmentNavigator(getSupportFragmentManager(), new MainFragmentAdapter(), R.id.container);
45 |
46 | mFragmentNavigator.setDefaultPosition(DEFAULT_POSITION);
47 |
48 | mFragmentNavigator.onCreate(savedInstanceState);
49 |
50 | setContentView(R.layout.activity_main);
51 |
52 | drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
53 |
54 | NavigationView navigationView = (NavigationView) findViewById(R.id.navigationView);
55 |
56 | navigationView.setNavigationItemSelectedListener(this);
57 |
58 | navigationView.setCheckedItem(IDS.get(DEFAULT_POSITION));
59 |
60 | mFragmentNavigator.showFragment(mFragmentNavigator.getCurrentPosition());
61 | }
62 |
63 | @Override
64 | protected void onSaveInstanceState(Bundle outState) {
65 | super.onSaveInstanceState(outState);
66 | mFragmentNavigator.onSaveInstanceState(outState);
67 | }
68 |
69 | @Override
70 | public void openDrawer() {
71 | drawerLayout.openDrawer(GravityCompat.START);
72 | }
73 |
74 | @Override
75 | public boolean onNavigationItemSelected(final MenuItem menuItem) {
76 | drawerLayout.closeDrawer(GravityCompat.START);
77 | drawerLayout.postDelayed(new Runnable() {
78 | @Override
79 | public void run() {
80 | int itemId = menuItem.getItemId();
81 | if (itemId == R.id.nav_about) {
82 | startActivity(new Intent(MainActivity.this, AboutActivity.class));
83 | } else {
84 | mFragmentNavigator.showFragment(IDS.indexOf(itemId));
85 | }
86 | }
87 | }, 200);
88 | return true;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/NavTwitterFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.aspsine.swipetoloadlayout.demo.R;
11 |
12 | /**
13 | * A simple {@link Fragment} subclass.
14 | */
15 | public class NavTwitterFragment extends BaseNavPagerFragment {
16 |
17 | public static BaseNavigationFragment newInstance() {
18 | BaseNavigationFragment fragment = new NavTwitterFragment();
19 | return fragment;
20 | }
21 |
22 |
23 | public NavTwitterFragment() {
24 | // Required empty public constructor
25 | }
26 |
27 | @Override
28 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
29 | // override the method
30 | // delete app:layout_scrollFlags="scroll|enterAlways"
31 | // delete reason: ListView don't support coordinate scroll
32 | // these property lead height measure issue and scroll issue
33 | // it's not an bug of SwipeToLoadLayout
34 | return inflater.inflate(R.layout.fragment_nav_twitter, container, false);
35 | }
36 |
37 | @Override
38 | public void onActivityCreated(Bundle savedInstanceState) {
39 | super.onActivityCreated(savedInstanceState);
40 | setTitle("Twitter Style");
41 | }
42 |
43 | @Override
44 | protected String[] getTitles() {
45 | return new String[]{"ListView", "GridView",
46 | "RecyclerView", "Grid RecyclerView", "StaggeredGrid RecyclerView",
47 | "ScrollView", "WebView",
48 | "FrameLayout", "RelativeLayout",
49 | "LinearLayout", "ImageView", "TextView"};
50 | }
51 |
52 | @Override
53 | protected Fragment getFragment(int position) {
54 | String title = getTitles()[position];
55 | Fragment fragment = null;
56 | if (title.equals("ListView")) {
57 | fragment = new TwitterListViewFragment();
58 | } else if (title.equals("GridView")) {
59 | fragment = new TwitterGridViewFragment();
60 | } else if (title.equals("RecyclerView")) {
61 | fragment = TwitterRecyclerFragment.newInstance(TwitterRecyclerFragment.TYPE_LINEAR);
62 | } else if (title.equals("Grid RecyclerView")) {
63 | // grid
64 | fragment = TwitterRecyclerFragment.newInstance(TwitterRecyclerFragment.TYPE_GRID);
65 | } else if (title.equals("StaggeredGrid RecyclerView")) {
66 | fragment = TwitterRecyclerFragment.newInstance(TwitterRecyclerFragment.TYPE_STAGGERED_GRID);
67 | } else if (title.equals("ScrollView")) {
68 | fragment = new TwitterScrollViewFragment();
69 | } else if (title.equals("WebView")) {
70 | fragment = new TwitterWebViewFragment();
71 | } else if (title.equals("FrameLayout")
72 | || title.equals("RelativeLayout")
73 | || title.equals("LinearLayout")
74 | || title.equals("ImageView")
75 | || title.equals("TextView")) {
76 | fragment = TwitterOtherViewFragment.newInstance(title);
77 | }
78 | return fragment;
79 | }
80 |
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_twitter_scroll_view.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
14 |
15 |
19 |
20 |
26 |
27 |
28 |
37 |
38 |
47 |
48 |
57 |
58 |
67 |
68 |
75 |
76 |
77 |
78 |
81 |
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/drawable/google/RingProgressDrawable.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.drawable.google;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.graphics.RectF;
9 |
10 | /**
11 | * Created by aspsine on 15/9/11.
12 | */
13 | public class RingProgressDrawable extends ProgressDrawable {
14 | /**
15 | * in dp
16 | */
17 | private static final int DEFAULT_BORDER_WIDTH = 3;
18 |
19 | private static final int DEFAULT_START_ANGLE = 270;
20 |
21 | private static final int DEFAULT_FINAL_DEGREES = 360;
22 |
23 | private Paint mPaint;
24 |
25 | private Path mPath;
26 |
27 | private RectF mBounds;
28 |
29 | private int mAlpha;
30 |
31 | private float mDegrees;
32 |
33 | private float mAngle;
34 |
35 | private int mColorIndex;
36 |
37 | private float mPercent;
38 |
39 |
40 | public RingProgressDrawable(Context context) {
41 | super(context);
42 | mBounds = new RectF();
43 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
44 | mPaint.setStyle(Paint.Style.STROKE);
45 | mPaint.setStrokeWidth(dp2px(DEFAULT_BORDER_WIDTH));
46 | mPath = new Path();
47 | mPaint.setColor(Color.WHITE);
48 | }
49 |
50 | @Override
51 | public void setPercent(float percent, boolean isUser) {
52 | if (percent >= 1) {
53 | percent = 1;
54 | }
55 | int colors[] = getColors();
56 | mPaint.setColor(colors[0]);
57 | mAngle = DEFAULT_FINAL_DEGREES * percent - 0.001f;
58 | mAlpha = (int) (255 * percent);
59 | mDegrees = 360 * percent;
60 | invalidateSelf();
61 | }
62 |
63 | @Override
64 | public void start() {
65 | setRunning(true);
66 | post(mAnimRunnable);
67 | }
68 |
69 | @Override
70 | public void stop() {
71 | setRunning(false);
72 | removeCallBacks(mAnimRunnable);
73 | mAngle = 0;
74 | mDegrees = 0;
75 | }
76 |
77 | private Runnable mAnimRunnable = new Runnable() {
78 | @Override
79 | public void run() {
80 | if (isRunning()) {
81 | int[] colors = getColors();
82 | int length = colors.length;
83 | mDegrees += 5;
84 | if (mDegrees >= 360) {
85 | mDegrees = 0;
86 | mColorIndex++;
87 | if (mColorIndex >= length) {
88 | mColorIndex = 0;
89 | }
90 | mPaint.setColor(colors[mColorIndex]);
91 | }
92 | mAngle = mDegrees;
93 | invalidateSelf();
94 | postDelayed(this, DELAY);
95 | }
96 | }
97 | };
98 |
99 | @Override
100 | public void setAlpha(int alpha) {
101 | mAlpha = alpha;
102 | invalidateSelf();
103 | }
104 |
105 | @Override
106 | public void draw(Canvas canvas) {
107 | canvas.save();
108 | canvas.rotate(mDegrees, canvas.getWidth() / 2, canvas.getHeight() / 2);
109 |
110 | mPath.reset();
111 | float d = Math.min(canvas.getWidth(), canvas.getHeight());
112 | float left = dp2px(DEFAULT_BORDER_WIDTH);
113 | float top = dp2px(DEFAULT_BORDER_WIDTH);
114 | float right = (d - dp2px(DEFAULT_BORDER_WIDTH));
115 | float bottom = (d - dp2px(DEFAULT_BORDER_WIDTH));
116 | mBounds.set(left, top, right, bottom);
117 | mPath.arcTo(mBounds, DEFAULT_START_ANGLE, mAngle, true);
118 | mPaint.setAlpha(mAlpha);
119 | canvas.drawPath(mPath, mPaint);
120 | canvas.restore();
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/view/header/TwitterRefreshHeaderView.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.view.header;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.view.animation.Animation;
7 | import android.view.animation.AnimationUtils;
8 | import android.widget.ImageView;
9 | import android.widget.ProgressBar;
10 | import android.widget.TextView;
11 |
12 | import com.aspsine.swipetoloadlayout.SwipeRefreshHeaderLayout;
13 | import com.aspsine.swipetoloadlayout.demo.R;
14 |
15 | /**
16 | * Created by Aspsine on 2015/9/9.
17 | */
18 | public class TwitterRefreshHeaderView extends SwipeRefreshHeaderLayout {
19 |
20 | private ImageView ivArrow;
21 |
22 | private ImageView ivSuccess;
23 |
24 | private TextView tvRefresh;
25 |
26 | private ProgressBar progressBar;
27 |
28 | private int mHeaderHeight;
29 |
30 | private Animation rotateUp;
31 |
32 | private Animation rotateDown;
33 |
34 | private boolean rotated = false;
35 |
36 | public TwitterRefreshHeaderView(Context context) {
37 | this(context, null);
38 | }
39 |
40 | public TwitterRefreshHeaderView(Context context, AttributeSet attrs) {
41 | this(context, attrs, 0);
42 | }
43 |
44 | public TwitterRefreshHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
45 | super(context, attrs, defStyleAttr);
46 | mHeaderHeight = getResources().getDimensionPixelOffset(R.dimen.refresh_header_height_twitter);
47 | rotateUp = AnimationUtils.loadAnimation(context, R.anim.rotate_up);
48 | rotateDown = AnimationUtils.loadAnimation(context, R.anim.rotate_down);
49 | }
50 |
51 | @Override
52 | protected void onFinishInflate() {
53 | super.onFinishInflate();
54 |
55 | tvRefresh = (TextView) findViewById(R.id.tvRefresh);
56 | ivArrow = (ImageView) findViewById(R.id.ivArrow);
57 | ivSuccess = (ImageView) findViewById(R.id.ivSuccess);
58 | progressBar = (ProgressBar) findViewById(R.id.progressbar);
59 | }
60 |
61 | @Override
62 | public void onRefresh() {
63 | ivSuccess.setVisibility(GONE);
64 | ivArrow.clearAnimation();
65 | ivArrow.setVisibility(GONE);
66 | progressBar.setVisibility(VISIBLE);
67 | tvRefresh.setText("REFRESHING");
68 | }
69 |
70 | @Override
71 | public void onPrepare() {
72 | Log.d("TwitterRefreshHeader", "onPrepare()");
73 | }
74 |
75 | @Override
76 | public void onMove(int y, boolean isComplete, boolean automatic) {
77 | if (!isComplete) {
78 | ivArrow.setVisibility(VISIBLE);
79 | progressBar.setVisibility(GONE);
80 | ivSuccess.setVisibility(GONE);
81 | if (y > mHeaderHeight) {
82 | tvRefresh.setText("RELEASE TO REFRESH");
83 | if (!rotated) {
84 | ivArrow.clearAnimation();
85 | ivArrow.startAnimation(rotateUp);
86 | rotated = true;
87 | }
88 | } else if (y < mHeaderHeight) {
89 | if (rotated) {
90 | ivArrow.clearAnimation();
91 | ivArrow.startAnimation(rotateDown);
92 | rotated = false;
93 | }
94 |
95 | tvRefresh.setText("SWIPE TO REFRESH");
96 | }
97 | }
98 | }
99 |
100 | @Override
101 | public void onRelease() {
102 | Log.d("TwitterRefreshHeader", "onRelease()");
103 | }
104 |
105 | @Override
106 | public void onComplete() {
107 | rotated = false;
108 | ivSuccess.setVisibility(VISIBLE);
109 | ivArrow.clearAnimation();
110 | ivArrow.setVisibility(GONE);
111 | progressBar.setVisibility(GONE);
112 | tvRefresh.setText("COMPLETE");
113 | }
114 |
115 | @Override
116 | public void onReset() {
117 | rotated = false;
118 | ivSuccess.setVisibility(GONE);
119 | ivArrow.clearAnimation();
120 | ivArrow.setVisibility(GONE);
121 | progressBar.setVisibility(GONE);
122 | }
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/TwitterWebViewFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Build;
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.webkit.WebResourceError;
11 | import android.webkit.WebResourceRequest;
12 | import android.webkit.WebResourceResponse;
13 | import android.webkit.WebView;
14 | import android.webkit.WebViewClient;
15 |
16 | import com.aspsine.swipetoloadlayout.OnLoadMoreListener;
17 | import com.aspsine.swipetoloadlayout.OnRefreshListener;
18 | import com.aspsine.swipetoloadlayout.SwipeToLoadLayout;
19 | import com.aspsine.swipetoloadlayout.demo.R;
20 |
21 | /**
22 | * A simple {@link Fragment} subclass.
23 | */
24 | public class TwitterWebViewFragment extends BaseFragment implements OnRefreshListener, OnLoadMoreListener{
25 | private SwipeToLoadLayout swipeToLoadLayout;
26 | private WebView webView;
27 |
28 | public TwitterWebViewFragment() {
29 | // Required empty public constructor
30 | }
31 |
32 |
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
35 | Bundle savedInstanceState) {
36 | // Inflate the layout for this fragment
37 | return inflater.inflate(R.layout.fragment_twitter_web_view, container, false);
38 | }
39 |
40 | @Override
41 | public void onViewCreated(View view, Bundle savedInstanceState) {
42 | super.onViewCreated(view, savedInstanceState);
43 | swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
44 | webView = (WebView) view.findViewById(R.id.swipe_target);
45 | swipeToLoadLayout.setOnRefreshListener(this);
46 | swipeToLoadLayout.setOnLoadMoreListener(this);
47 | webView.setWebViewClient(new WebViewClient(){
48 | @Override
49 | public void onPageFinished(WebView view, String url) {
50 | super.onPageFinished(view, url);
51 | swipeToLoadLayout.setRefreshing(false);
52 | }
53 |
54 | @Override
55 | public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
56 | super.onReceivedError(view, request, error);
57 | swipeToLoadLayout.setRefreshing(false);
58 | }
59 |
60 | @Override
61 | public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
62 | super.onReceivedHttpError(view, request, errorResponse);
63 | swipeToLoadLayout.setRefreshing(false);
64 | }
65 | });
66 | }
67 |
68 | @Override
69 | public void onActivityCreated(Bundle savedInstanceState) {
70 | super.onActivityCreated(savedInstanceState);
71 | swipeToLoadLayout.post(new Runnable() {
72 | @Override
73 | public void run() {
74 | swipeToLoadLayout.setRefreshing(true);
75 | }
76 | });
77 | }
78 |
79 | @Override
80 | public void onResume() {
81 | super.onResume();
82 | if (webView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
83 | webView.onResume();
84 | }
85 | }
86 |
87 | @Override
88 | public void onPause() {
89 | super.onPause();
90 | if (webView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
91 | webView.onPause();
92 | }
93 | }
94 |
95 | @Override
96 | public void onDestroy() {
97 | super.onDestroy();
98 | if (webView != null) {
99 | webView.destroy();
100 | }
101 | }
102 |
103 |
104 | @Override
105 | public void onLoadMore() {
106 | swipeToLoadLayout.postDelayed(new Runnable() {
107 | @Override
108 | public void run() {
109 | swipeToLoadLayout.setLoadingMore(false);
110 | }
111 | }, 2000);
112 | }
113 |
114 | @Override
115 | public void onRefresh() {
116 | webView.loadUrl("http://www.weibo.com/");
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/LoopViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.content.res.Resources;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Build;
6 | import android.support.v4.view.ViewPager;
7 | import android.util.Log;
8 | import android.view.Gravity;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ImageView;
13 | import android.widget.LinearLayout;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 |
17 | import com.aspsine.swipetoloadlayout.demo.R;
18 | import com.aspsine.swipetoloadlayout.demo.model.Character;
19 | import com.squareup.picasso.Picasso;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 |
24 | /**
25 | * Created by Aspsine on 2015/9/7.
26 | */
27 | public class LoopViewPagerAdapter extends BaseLoopPagerAdapter {
28 |
29 | private final List mHeroes;
30 |
31 | private final ViewGroup mIndicators;
32 |
33 | private int mLastPosition;
34 |
35 | public LoopViewPagerAdapter(ViewPager viewPager, ViewGroup indicators) {
36 | super(viewPager);
37 | mIndicators = indicators;
38 | mHeroes = new ArrayList<>();
39 | }
40 |
41 | public void setList(List heroes) {
42 | mHeroes.clear();
43 | mHeroes.addAll(heroes);
44 | notifyDataSetChanged();
45 | }
46 |
47 | /**
48 | * oh shit! An indicator view is badly needed!
49 | * this shit have no animation at all.
50 | */
51 | private void initIndicators() {
52 | if (mIndicators.getChildCount() != mHeroes.size() && mHeroes.size() > 1) {
53 | mIndicators.removeAllViews();
54 | Resources res = mIndicators.getResources();
55 | int size = res.getDimensionPixelOffset(R.dimen.indicator_size);
56 | int margin = res.getDimensionPixelOffset(R.dimen.indicator_margin);
57 | for (int i = 0; i < getPagerCount(); i++) {
58 | ImageView indicator = new ImageView(mIndicators.getContext());
59 | indicator.setAlpha(180);
60 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(size, size);
61 | lp.setMargins(margin, 0, 0, 0);
62 | lp.gravity = Gravity.CENTER;
63 | indicator.setLayoutParams(lp);
64 | Drawable drawable = res.getDrawable(R.drawable.selector_indicator);
65 | indicator.setImageDrawable(drawable);
66 | mIndicators.addView(indicator);
67 | }
68 | }
69 | }
70 |
71 | @Override
72 | public void notifyDataSetChanged() {
73 | initIndicators();
74 | super.notifyDataSetChanged();
75 | }
76 |
77 | @Override
78 | public int getPagerCount() {
79 | return mHeroes.size();
80 | }
81 |
82 | @Override
83 | public Character getItem(int position) {
84 | return mHeroes.get(position);
85 | }
86 |
87 | @Override
88 | public View getView(final int position, View convertView, ViewGroup parent) {
89 | ViewHolder holder = null;
90 | if (convertView == null) {
91 | convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_viewpager, parent, false);
92 | holder = new ViewHolder();
93 | holder.ivBanner = (ImageView) convertView.findViewById(R.id.ivBanner);
94 | holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
95 | convertView.setTag(holder);
96 | } else {
97 | holder = (ViewHolder) convertView.getTag();
98 | }
99 | convertView.setOnClickListener(new View.OnClickListener() {
100 | @Override
101 | public void onClick(View view) {
102 | Toast.makeText(view.getContext(), mHeroes.get(position).getName(), Toast.LENGTH_SHORT).show();
103 | }
104 | });
105 | Character character = mHeroes.get(position);
106 | holder.tvName.setText(character.getName().replace(" ", System.getProperty("line.separator")));
107 | Picasso.with(parent.getContext()).load(character.getAvatar()).into(holder.ivBanner);
108 | return convertView;
109 | }
110 |
111 | @Override
112 | public void onPageItemSelected(int position) {
113 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
114 | mIndicators.getChildAt(mLastPosition).setActivated(false);
115 | mIndicators.getChildAt(position).setActivated(true);
116 | }
117 | mLastPosition = position;
118 | }
119 |
120 | public static class ViewHolder {
121 | ImageView ivBanner;
122 | TextView tvName;
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_dialog_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
19 |
20 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
44 |
49 |
50 |
51 |
52 |
60 |
61 |
66 |
67 |
72 |
73 |
78 |
79 |
84 |
85 |
90 |
91 |
92 |
100 |
101 |
106 |
107 |
112 |
117 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/TwitterOtherViewFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.aspsine.swipetoloadlayout.OnLoadMoreListener;
13 | import com.aspsine.swipetoloadlayout.OnRefreshListener;
14 | import com.aspsine.swipetoloadlayout.SwipeToLoadLayout;
15 | import com.aspsine.swipetoloadlayout.demo.R;
16 | import com.squareup.picasso.Picasso;
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | */
21 | public class TwitterOtherViewFragment extends BaseFragment implements OnRefreshListener, OnLoadMoreListener {
22 | private SwipeToLoadLayout swipeToLoadLayout;
23 | private TextView tvTitle;
24 | private ImageView ivContent;
25 | private String mTitle;
26 |
27 | public static Fragment newInstance(String title) {
28 | TwitterOtherViewFragment fragment = new TwitterOtherViewFragment();
29 | Bundle bundle = new Bundle();
30 | bundle.putString("OTHER_VIEW_TITLE", title);
31 | fragment.setArguments(bundle);
32 | return fragment;
33 | }
34 |
35 | public TwitterOtherViewFragment() {
36 | // Required empty public constructor
37 | }
38 |
39 | @Override
40 | public void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | mTitle = getArguments().getString("OTHER_VIEW_TITLE");
43 | }
44 |
45 | @Override
46 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
47 | Bundle savedInstanceState) {
48 | View view = null;
49 | if (mTitle.equals("FrameLayout")) {
50 | view = inflater.inflate(R.layout.fragment_twitter_other_framelayout, container, false);
51 | } else if (mTitle.equals("RelativeLayout")) {
52 | view = inflater.inflate(R.layout.fragment_twitter_other_relativelayout, container, false);
53 | } else if (mTitle.equals("LinearLayout")) {
54 | view = inflater.inflate(R.layout.fragment_twitter_other_linearlayout, container, false);
55 | } else if (mTitle.equals("ImageView")) {
56 | view = inflater.inflate(R.layout.fragment_twitter_other_imageview, container, false);
57 | } else if (mTitle.equals("TextView")) {
58 | view = inflater.inflate(R.layout.fragment_twitter_other_textview, container, false);
59 | }
60 | // Inflate the layout for this fragment
61 | return view;
62 | }
63 |
64 | @Override
65 | public void onViewCreated(View view, Bundle savedInstanceState) {
66 | super.onViewCreated(view, savedInstanceState);
67 | swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
68 | tvTitle = (TextView) view.findViewById(R.id.tvTitle);
69 | View targetView = view.findViewById(R.id.swipe_target);
70 | swipeToLoadLayout.setOnRefreshListener(this);
71 | swipeToLoadLayout.setOnLoadMoreListener(this);
72 | if (targetView != null) {
73 | if (targetView instanceof TextView) {
74 | tvTitle = (TextView) targetView;
75 | } else if (targetView instanceof ImageView) {
76 | ivContent = (ImageView) targetView;
77 | }
78 | }
79 | if (tvTitle != null) {
80 | tvTitle.setText(mTitle + " Demo");
81 | }
82 | }
83 |
84 | @Override
85 | public void onActivityCreated(Bundle savedInstanceState) {
86 | super.onActivityCreated(savedInstanceState);
87 | swipeToLoadLayout.post(new Runnable() {
88 | @Override
89 | public void run() {
90 | swipeToLoadLayout.setRefreshing(true);
91 | }
92 | });
93 | }
94 |
95 | @Override
96 | public void onPause() {
97 | super.onPause();
98 | if (swipeToLoadLayout.isLoadingMore()) {
99 | swipeToLoadLayout.setLoadingMore(false);
100 | }
101 | if (swipeToLoadLayout.isRefreshing()) {
102 | swipeToLoadLayout.setRefreshing(false);
103 | }
104 | }
105 |
106 | @Override
107 | public void onLoadMore() {
108 | swipeToLoadLayout.postDelayed(new Runnable() {
109 | @Override
110 | public void run() {
111 | swipeToLoadLayout.setLoadingMore(false);
112 | }
113 | }, 2000);
114 | }
115 |
116 | @Override
117 | public void onRefresh() {
118 | swipeToLoadLayout.postDelayed(new Runnable() {
119 | @Override
120 | public void run() {
121 | if (ivContent != null) {
122 | Picasso.with(getActivity()).load("https://avatars0.githubusercontent.com/u/1912775?v=3&s=460").into(ivContent);
123 | }
124 | swipeToLoadLayout.setRefreshing(false);
125 | }
126 | }, 2000);
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/adapter/SectionAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.adapter;
2 |
3 | import android.content.res.Resources;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | import com.aspsine.swipetoloadlayout.demo.R;
11 | import com.aspsine.swipetoloadlayout.demo.model.Character;
12 | import com.aspsine.swipetoloadlayout.demo.model.Section;
13 | import com.squareup.picasso.CircleTransformation;
14 | import com.squareup.picasso.Picasso;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | /**
20 | * Created by aspsine on 15/9/4.
21 | */
22 | public class SectionAdapter extends BaseGroupAdapter {
23 | List mSections;
24 |
25 | public SectionAdapter() {
26 | mSections = new ArrayList<>();
27 | }
28 |
29 | public void setList(List sections) {
30 | mSections.clear();
31 | append(sections);
32 | }
33 |
34 | public void append(List sections) {
35 | mSections.addAll(sections);
36 | notifyDataSetChanged();
37 | }
38 |
39 | @Override
40 | protected int getParentViewType(int groupPosition) {
41 | return -1;
42 | }
43 |
44 | @Override
45 | public int getGroupCount() {
46 | return mSections.size();
47 | }
48 |
49 | @Override
50 | protected Section getGroup(int groupPosition) {
51 | return mSections.get(groupPosition);
52 | }
53 |
54 | @Override
55 | protected View getGroupView(final int groupPosition, View convertView, ViewGroup parent) {
56 | HeaderViewHolder holder = null;
57 | if (convertView == null) {
58 | convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_header, parent, false);
59 | holder = new HeaderViewHolder();
60 | holder.tvHeader = (TextView) convertView.findViewById(R.id.tvHeader);
61 | convertView.setTag(holder);
62 | } else {
63 | holder = (HeaderViewHolder) convertView.getTag();
64 | }
65 | final String header = getGroup(groupPosition).getName();
66 | holder.tvHeader.setText(header);
67 | return convertView;
68 | }
69 |
70 | @Override
71 | protected int getChildViewType(int groupPosition, int childPositionInGroup) {
72 | return 1;
73 | }
74 |
75 | @Override
76 | public int getChildCount(int groupPosition) {
77 | List characters = getGroup(groupPosition).getCharacters();
78 | return characters != null ? characters.size() : 0;
79 | }
80 |
81 | @Override
82 | protected Character getChild(int groupPosition, int childPosition) {
83 | return getGroup(groupPosition).getCharacters().get(childPosition);
84 | }
85 |
86 | @Override
87 | protected View getChildView(final int groupPosition, final int childPosition, View convertView, ViewGroup parent) {
88 | ChildViewHolder holder = null;
89 | if (convertView == null) {
90 | convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_hero, parent, false);
91 | holder = new ChildViewHolder();
92 | holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
93 | holder.ivAvatar = (ImageView) convertView.findViewById(R.id.ivAvatar);
94 | convertView.setTag(holder);
95 | } else {
96 | holder = (ChildViewHolder) convertView.getTag();
97 | }
98 | final Character character = getChild(groupPosition, childPosition);
99 | holder.tvName.setText(character.getName());
100 | Resources resources = parent.getResources();
101 | int size = resources.getDimensionPixelOffset(R.dimen.hero_avatar_size);
102 | int width = resources.getDimensionPixelOffset(R.dimen.hero_avatar_border);
103 | Picasso.with(parent.getContext())
104 | .load(character.getAvatar())
105 | .resize(size, size)
106 | .transform(new CircleTransformation(width))
107 | .into(holder.ivAvatar);
108 | final View finalConvertView = convertView;
109 | convertView.setOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View v) {
112 | if (mOnChildItemClickListener != null) {
113 | mOnChildItemClickListener.onChildItemClick(groupPosition, childPosition, character, finalConvertView);
114 | }
115 | }
116 | });
117 |
118 | convertView.setOnLongClickListener(new View.OnLongClickListener() {
119 | @Override
120 | public boolean onLongClick(View v) {
121 | if (mOnChildItemLongClickListener != null) {
122 | return mOnChildItemLongClickListener.onClickItemLongClick(groupPosition, childPosition, character, finalConvertView);
123 | }
124 | return false;
125 | }
126 | });
127 | return convertView;
128 | }
129 |
130 | public class HeaderViewHolder {
131 | TextView tvHeader;
132 |
133 | }
134 |
135 | public class ChildViewHolder {
136 | ImageView ivAvatar;
137 | TextView tvName;
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/app/src/main/java/com/aspsine/swipetoloadlayout/demo/fragment/NavYalantisFragment.java:
--------------------------------------------------------------------------------
1 | package com.aspsine.swipetoloadlayout.demo.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.ListView;
13 |
14 | import com.aspsine.swipetoloadlayout.OnRefreshListener;
15 | import com.aspsine.swipetoloadlayout.SwipeToLoadLayout;
16 | import com.aspsine.swipetoloadlayout.demo.R;
17 | import com.aspsine.swipetoloadlayout.demo.adapter.BaseArrayAdapter;
18 |
19 | import java.util.ArrayList;
20 | import java.util.HashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * A simple {@link Fragment} subclass.
26 | * Use the {@link NavYalantisFragment#newInstance} factory method to
27 | * create an instance of this fragment.
28 | */
29 | public class NavYalantisFragment extends BaseNavigationFragment implements OnRefreshListener {
30 |
31 | private SwipeToLoadLayout swipeToLoadLayout;
32 |
33 | public static final String KEY_ICON = "icon";
34 | public static final String KEY_COLOR = "color";
35 |
36 | protected List