├── Wechat
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── ic_tab_msg.png
│ │ │ │ ├── ic_tab_msg_h.png
│ │ │ │ ├── ic_tab_contact.png
│ │ │ │ ├── ic_tab_moments.png
│ │ │ │ ├── ic_tab_profile.png
│ │ │ │ ├── ic_tab_contact_h.png
│ │ │ │ ├── ic_tab_moments_h.png
│ │ │ │ ├── ic_tab_profile_h.png
│ │ │ │ ├── ic_toolbar_back.png
│ │ │ │ ├── tab_wechat_normal.png
│ │ │ │ ├── list_divider.xml
│ │ │ │ ├── selector_tab_msg.xml
│ │ │ │ ├── selector_tab_contact.xml
│ │ │ │ ├── selector_tab_moments.xml
│ │ │ │ ├── selector_tab_profile.xml
│ │ │ │ └── shape_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── colors.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── contact_item.xml
│ │ │ │ ├── wechat_layout.xml
│ │ │ │ ├── me_layout.xml
│ │ │ │ ├── discvover_layout.xml
│ │ │ │ ├── contacts_layout.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── tab_view.xml
│ │ ├── java
│ │ │ └── star
│ │ │ │ └── yx
│ │ │ │ ├── tabview
│ │ │ │ ├── ITabClickListener.java
│ │ │ │ ├── TabItem.java
│ │ │ │ ├── DiscoverFragment.java
│ │ │ │ ├── ProfileFragment.java
│ │ │ │ ├── BaseFragment.java
│ │ │ │ ├── TabView.java
│ │ │ │ ├── WechatFragment.java
│ │ │ │ ├── ContactsFragment.java
│ │ │ │ ├── TabLayout.java
│ │ │ │ └── MainActivity.java
│ │ │ │ └── test
│ │ │ │ ├── BaseSwipeRefreshLayout.java
│ │ │ │ ├── DensityUtil.java
│ │ │ │ └── BaseRecyclerViewAdapter.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── star
│ │ │ └── yx
│ │ │ └── tabview
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── star
│ │ └── yx
│ │ └── tabview
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_new_msg.png
│ │ │ │ ├── bottom_bar.9.png
│ │ │ │ ├── ic_new_msg_card.png
│ │ │ │ ├── ic_new_msg_dot.png
│ │ │ │ ├── tab_friend_normal.png
│ │ │ │ ├── tab_wechat_normal.png
│ │ │ │ ├── tab_contacts_normal.png
│ │ │ │ ├── tab_friend_selected.png
│ │ │ │ ├── tab_settings_normal.png
│ │ │ │ ├── tab_wechat_selected.png
│ │ │ │ ├── tab_contacts_selected.png
│ │ │ │ └── tab_settings_selected.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── fragment_contacts.xml
│ │ │ │ ├── fragment_friend.xml
│ │ │ │ ├── fragment_setting.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── view_tab.xml
│ │ │ │ └── fragment_wechat.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── tabtest
│ │ │ │ ├── App.java
│ │ │ │ ├── FriendFragment.java
│ │ │ │ ├── SettingFragment.java
│ │ │ │ ├── ContactsFragment.java
│ │ │ │ ├── TabItem.java
│ │ │ │ ├── WeChatFragment.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── tabtest
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── tabtest
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
├── modules.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── QQBottomTab
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── drawable-hdpi
│ │ │ ├── me.png
│ │ │ ├── home.png
│ │ │ ├── course.png
│ │ │ ├── me_press.png
│ │ │ ├── course_press.png
│ │ │ ├── home_press.png
│ │ │ ├── direct_setting.png
│ │ │ ├── direct_seding_press.png
│ │ │ ├── icon_direct_seeding.xml
│ │ │ ├── icon_direct_seeding_pressed.xml
│ │ │ ├── icon_home.xml
│ │ │ ├── icon_home_pressed.xml
│ │ │ ├── icon_me.xml
│ │ │ ├── icon_me_green.xml
│ │ │ ├── icon_me_green_presed.xml
│ │ │ ├── icon_course.xml
│ │ │ └── icon_course_pressed.xml
│ │ ├── mipmap-xxhdpi
│ │ │ ├── img1.jpg
│ │ │ ├── img2.jpg
│ │ │ ├── img3.jpg
│ │ │ ├── img4.jpg
│ │ │ ├── img5.jpg
│ │ │ └── ic_launcher.png
│ │ ├── drawable
│ │ │ ├── ic_launcher.png
│ │ │ ├── sel_bottom_tab_text.xml
│ │ │ ├── background_tab.xml
│ │ │ ├── sel_me.xml
│ │ │ ├── sel_home.xml
│ │ │ ├── sel_course.xml
│ │ │ ├── carousel_layout_page.xml
│ │ │ └── sel_direct_seeding.xml
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ ├── head_view.xml
│ │ │ ├── item_string.xml
│ │ │ ├── tab_layout.xml
│ │ │ ├── fragment_first.xml
│ │ │ ├── fragment_test.xml
│ │ │ ├── carousel_layout.xml
│ │ │ ├── fragment_base_view_pager.xml
│ │ │ ├── fragment_course_list.xml
│ │ │ ├── activity_first_style.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── activity_four.xml
│ │ │ ├── activity_three.xml
│ │ │ └── activity_second_style.xml
│ │ ├── java
│ │ └── com
│ │ │ └── xujun
│ │ │ └── fragmenttabhostdemo
│ │ │ ├── fragment
│ │ │ ├── FirstFragment.java
│ │ │ ├── ItemFragement.java
│ │ │ ├── CourseListFragment.java
│ │ │ └── CourseListFragmentWithHeadView.java
│ │ │ ├── widget
│ │ │ └── ConvertUtils.java
│ │ │ ├── adapter
│ │ │ └── StringAdapter.java
│ │ │ ├── activity
│ │ │ ├── MainActivity.java
│ │ │ ├── SecondStyleActivity.java
│ │ │ ├── ThreeActivity.java
│ │ │ ├── FirstStyleActivity.java
│ │ │ └── FourActivity.java
│ │ │ ├── ItemFragement.java
│ │ │ ├── CourseFragment.java
│ │ │ ├── FragmentInfo.java
│ │ │ ├── TestFragemnt.java
│ │ │ ├── base
│ │ │ ├── BaseFragmentAdapter.java
│ │ │ ├── BaseViewPagerFragment.java
│ │ │ ├── WrapperUtils.java
│ │ │ ├── EndlessRecyclerOnScrollListener.java
│ │ │ ├── BasePageFragment.java
│ │ │ ├── HeaderAndFooterWrapper.java
│ │ │ └── BaseRecyclerHolder.java
│ │ │ └── MainFragmentFactory.java
│ │ └── AndroidManifest.xml
├── .gitignore
└── build.gradle
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/Wechat/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':QQBottomTab', ':app', ':Wechat'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TabTest
3 |
4 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FragmentTabHostDemo
3 |
4 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/me.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_msg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_msg.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_msg_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_msg_h.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_new_msg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/ic_new_msg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/home.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxhdpi/img1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxhdpi/img1.jpg
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxhdpi/img2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxhdpi/img2.jpg
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxhdpi/img3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxhdpi/img3.jpg
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxhdpi/img4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxhdpi/img4.jpg
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxhdpi/img5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxhdpi/img5.jpg
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_contact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_contact.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_moments.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_moments.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_profile.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/bottom_bar.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/bottom_bar.9.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/course.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/course.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_contact_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_contact_h.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_moments_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_moments_h.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_tab_profile_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_tab_profile_h.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/ic_toolbar_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/ic_toolbar_back.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/tab_wechat_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/drawable/tab_wechat_normal.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Wechat/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/Wechat/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_new_msg_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/ic_new_msg_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_new_msg_dot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/ic_new_msg_dot.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/me_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/me_press.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_friend_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_friend_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_wechat_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_wechat_normal.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/course_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/course_press.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/home_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/home_press.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_contacts_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_contacts_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_friend_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_friend_selected.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_settings_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_settings_normal.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_wechat_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_wechat_selected.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/direct_setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/direct_setting.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_contacts_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_contacts_selected.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/tab_settings_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/app/src/main/res/drawable-hdpi/tab_settings_selected.png
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/direct_seding_press.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdutxiaoxu/QQBottomTab/HEAD/QQBottomTab/src/main/res/drawable-hdpi/direct_seding_press.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /.idea/
11 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/QQBottomTab/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | /build/
11 | /.idea/
12 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/ITabClickListener.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | /**
4 | * Created by yx on 16/4/6.
5 | */
6 | public interface ITabClickListener {
7 |
8 |
9 | void onMenuItemClick();
10 |
11 | BaseFragment getFragment();
12 | }
13 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TabView
3 | 微信
4 | 联系人
5 | 发现
6 | 我
7 |
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Mar 15 15:12:46 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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #73C53D
7 |
8 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/list_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Wechat/src/test/java/star/yx/tabview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
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/test/java/com/example/tabtest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
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 | }
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/contact_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/Wechat/src/androidTest/java/star/yx/tabview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
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/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/tabtest/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
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 | }
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/sel_bottom_tab_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/background_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/selector_tab_msg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/App.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.app.Application;
4 |
5 | /**
6 | * @author meitu.xujun on 2017/4/20 13:52
7 | * @version 0.1
8 | */
9 |
10 | public class App extends Application {
11 |
12 | static App mApp;
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | mApp=this;
18 | }
19 |
20 | public static App getInstance() {
21 | return mApp;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/selector_tab_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/selector_tab_moments.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/selector_tab_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #80c3db
5 | #45b9de
6 | #00000000
7 | #FFFFFF
8 | #808080
9 | #000000
10 | #ff999999
11 | #ff45c01a
12 |
13 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/wechat_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/fragment/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.fragment;
2 |
3 | import android.support.v4.view.PagerAdapter;
4 |
5 | import com.xujun.fragmenttabhostdemo.base.BaseViewPagerFragment;
6 |
7 | /**
8 | * @author xujun on 2016/12/26.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public class FirstFragment extends BaseViewPagerFragment {
13 |
14 | @Override
15 | protected PagerAdapter getViewPagerAdapter() {
16 | return null;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/me_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/drawable/shape_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
10 |
11 |
14 |
16 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/discvover_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
13 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/sel_me.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #6633B5E5
8 | #80FF80
9 |
10 | #272636
11 | #fff
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_contacts.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_friend.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/head_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/sel_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/sel_course.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/contacts_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/carousel_layout_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable/sel_direct_seeding.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/widget/ConvertUtils.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.widget;
2 |
3 | import android.content.Context;
4 |
5 | public class ConvertUtils {
6 |
7 | public static int dip2px(Context context, float dipValue){
8 | final float scale = context.getResources().getDisplayMetrics().density;
9 | return (int)(dipValue * scale + 0.5f);
10 | }
11 |
12 | public static int px2dip(Context context, float pxValue){
13 | final float scale = context.getResources().getDisplayMetrics().density;
14 | return (int)(pxValue / scale + 0.5f);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/item_string.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/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:\AndroidSdk/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/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.example.tabnews"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.3.0'
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/FriendFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * 朋友 Fragment
11 | */
12 | public class FriendFragment extends Fragment {
13 |
14 | public FriendFragment() {
15 | // Required empty public constructor
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_friend, container, false);
22 | return view;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/SettingFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * 设置 Fragment
11 | */
12 | public class SettingFragment extends Fragment {
13 |
14 | public SettingFragment() {
15 | // Required empty public constructor
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_setting, container, false);
22 | return view;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/tab_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/ContactsFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * 联系人 Fragment
11 | */
12 | public class ContactsFragment extends Fragment {
13 |
14 | public ContactsFragment() {
15 | // Required empty public constructor
16 | }
17 |
18 | @Override
19 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
20 | Bundle savedInstanceState) {
21 | View view = inflater.inflate(R.layout.fragment_contacts, container, false);
22 | return view;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Wechat/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Wechat/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 /Users/yx/Documents/adt-bundle-mac-x86_64-20140702/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 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/fragment_first.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/fragment_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/Wechat/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "star.yx.tabview"
9 | minSdkVersion 19
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.3.0'
26 | compile 'com.android.support:recyclerview-v7:23.3.0'
27 | }
28 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/TabItem.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | /**
4 | * Created by yx on 16/4/3.
5 | */
6 | public class TabItem {
7 |
8 | /**
9 | * icon
10 | */
11 | public int imageResId;
12 | /**
13 | * 文本
14 | */
15 | public int lableResId;
16 |
17 | public String count;
18 |
19 |
20 | public Class extends BaseFragment>tagFragmentClz;
21 |
22 | public TabItem(int imageResId, int lableResId) {
23 | this.imageResId = imageResId;
24 | this.lableResId = lableResId;
25 | }
26 |
27 |
28 | public TabItem(int imageResId, int lableResId, Class extends BaseFragment> tagFragmentClz) {
29 | this.imageResId = imageResId;
30 | this.lableResId = lableResId;
31 | this.tagFragmentClz = tagFragmentClz;
32 | }
33 | }
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/adapter/StringAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.adapter;
2 |
3 | import android.content.Context;
4 |
5 | import com.xujun.fragmenttabhostdemo.R;
6 | import com.xujun.fragmenttabhostdemo.base.BaseRecyclerAdapter;
7 | import com.xujun.fragmenttabhostdemo.base.BaseRecyclerHolder;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * @author xujun on 2016/12/26.
13 | * @email gdutxiaoxu@163.com
14 | */
15 |
16 | public class StringAdapter extends BaseRecyclerAdapter {
17 |
18 | public StringAdapter(Context context, List datas) {
19 | super(context, R.layout.item_string, datas);
20 | }
21 |
22 | @Override
23 | public void convert(BaseRecyclerHolder holder, String item, int position) {
24 | holder.setText(R.id.tv_content,item);
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/carousel_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 |
11 |
18 |
19 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/DiscoverFragment.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | /**
9 | * Created by yx on 16/4/3.
10 | */
11 | public class DiscoverFragment extends BaseFragment implements ITabClickListener{
12 | @Override
13 | public void fetchData() {
14 |
15 | }
16 |
17 | @Override
18 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
19 | View view = inflater.inflate(R.layout.discvover_layout, container, false);
20 | return view;
21 | }
22 |
23 | @Override
24 | public void onMenuItemClick() {
25 |
26 | }
27 |
28 | @Override
29 | public BaseFragment getFragment() {
30 | return this;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/fragment_base_view_pager.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
14 |
15 |
16 |
17 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/fragment_course_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
15 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/QQBottomTab/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.xujun.fragmenttabhostdemo"
9 | minSdkVersion 15
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(include: ['*.jar'], dir: 'libs')
27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support:appcompat-v7:24.2.1'
31 | testCompile 'junit:junit:4.12'
32 | compile 'com.android.support:support-v4:24.2.1'
33 | compile 'com.android.support:design:25.1.0'
34 | }
35 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
21 |
28 |
29 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/activity_first_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
21 |
22 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/ProfileFragment.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * Created by yx on 16/4/3.
11 | */
12 | public class ProfileFragment extends BaseFragment implements ITabClickListener{
13 |
14 | private static final String TAG = "ProfileFragment";
15 | @Override
16 | public void fetchData() {
17 |
18 | }
19 |
20 | @Override
21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
22 | View view = inflater.inflate(R.layout.me_layout, container, false);
23 | view.setOnClickListener(new View.OnClickListener() {
24 | @Override
25 | public void onClick(View v) {
26 | Log.i(TAG, "onClick: =" );
27 | }
28 | });
29 | return view;
30 | }
31 |
32 | @Override
33 | public void onMenuItemClick() {
34 |
35 | }
36 |
37 | @Override
38 | public BaseFragment getFragment() {
39 | return this;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/test/BaseSwipeRefreshLayout.java:
--------------------------------------------------------------------------------
1 | package star.yx.test;
2 |
3 | import android.content.Context;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | import star.yx.tabview.R;
9 |
10 | /**
11 | * Created by Administrator on 2016/10/23 0023.
12 | */
13 |
14 | public class BaseSwipeRefreshLayout extends SwipeRefreshLayout {
15 | public BaseSwipeRefreshLayout(Context context) {
16 | super(context);
17 | this.init();
18 | }
19 |
20 | public BaseSwipeRefreshLayout(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | this.init();
23 | }
24 |
25 | private void init() {
26 | this.setProgressViewOffset(false, DensityUtil.dip2px(this.getContext(), -50.0F), DensityUtil.dip2px(this.getContext(), 30.0F));
27 | this.setColorSchemeColors(new int[]{this.getContext().getResources().getColor(R.color.tab_green)});
28 | }
29 |
30 | public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
31 | return !this.isRefreshing() && super.onStartNestedScroll(child, target, nestedScrollAxes);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
17 |
22 |
23 |
24 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
23 |
24 |
25 |
31 |
32 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
19 |
20 |
25 |
26 |
27 |
28 |
37 |
38 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 | /* android:layout_width="0dp"
16 | android:layout_height="wrap_content"
17 | android:layout_weight="1"
18 | android:text="新闻"
19 | android:gravity="center"
20 | android:textColor="@drawable/sel_bottom_tab_text"
21 | android:padding="8dp"
22 | android:button="@null"
23 | android:drawableTop="@drawable/sel_news"*/
24 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 |
9 | import com.xujun.fragmenttabhostdemo.R;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 | }
18 |
19 | public void onButtonClick(View view){
20 |
21 | switch (view.getId()){
22 | case R.id.btn_first_style:
23 | jump(FirstStyleActivity.class);
24 | break;
25 | case R.id.btn_second_style:
26 | jump(SecondStyleActivity.class);
27 | break;
28 |
29 | case R.id.btn_third_style:
30 | jump(ThreeActivity.class);
31 | break;
32 |
33 | case R.id.btn_four_style:
34 | jump(FourActivity.class);
35 | break;
36 | default:
37 | break;
38 | }
39 | }
40 |
41 | public void jump(Class extends Activity> clz){
42 | Intent intent = new Intent();
43 | intent.setClass(this,clz);
44 | startActivity(intent);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 |
6 | /**
7 | * Created by yx on 16/4/3.
8 | */
9 | public abstract class BaseFragment extends Fragment {
10 |
11 | protected boolean isViewInitiated;
12 | protected boolean isVisibleToUser;
13 | protected boolean isDataInitiated;
14 |
15 | @Override
16 | public void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | }
19 |
20 | @Override
21 | public void onActivityCreated(Bundle savedInstanceState) {
22 | super.onActivityCreated(savedInstanceState);
23 | isViewInitiated = true;
24 | prepareFetchData();
25 | }
26 |
27 | @Override
28 | public void setUserVisibleHint(boolean isVisibleToUser) {
29 | super.setUserVisibleHint(isVisibleToUser);
30 | this.isVisibleToUser = isVisibleToUser;
31 | prepareFetchData();
32 | }
33 |
34 | public abstract void fetchData();
35 |
36 | public boolean prepareFetchData() {
37 | return prepareFetchData(false);
38 | }
39 |
40 | public boolean prepareFetchData(boolean forceUpdate) {
41 | if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
42 | fetchData();
43 | isDataInitiated = true;
44 | return true;
45 | }
46 | return false;
47 | }
48 |
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/ItemFragement.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.View;
6 | import android.widget.TextView;
7 |
8 | import com.xujun.fragmenttabhostdemo.base.BasePageFragment;
9 |
10 | /**
11 | * @ explain:
12 | * @ author:xujun on 2016/10/15 11:09
13 | * @ email:gdutxiaoxu@163.com
14 | */
15 | public class ItemFragement extends BasePageFragment {
16 |
17 | public static final String tag="tag";
18 | private String mText="";
19 | protected TextView mTextView;
20 |
21 | public static ItemFragement newInstance(String text){
22 | ItemFragement itemFragement = new ItemFragement();
23 | Bundle bundle = new Bundle();
24 | if(text!=null){
25 | bundle.putString(tag,text);
26 | itemFragement.setArguments(bundle);
27 | }
28 | return itemFragement;
29 | }
30 | private static final String TAG = "xujun";
31 |
32 | @Override
33 | protected void initView(View view) {
34 | mTextView= (TextView) mView.findViewById(R.id.tv_content);
35 | Bundle arguments = getArguments();
36 | if(arguments!=null){
37 | mText = arguments.getString(tag);
38 | mTextView.setText(mText);
39 | }
40 | }
41 |
42 | @Override
43 | protected void initData() {
44 | mTextView.setText(mText);
45 | }
46 |
47 | @Override
48 | protected int getLayoutId() {
49 | return R.layout.fragment_test;
50 | }
51 |
52 | @Override
53 | public void fetchData() {
54 | Log.i(TAG, "fetchData" );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Wechat/src/main/res/layout/tab_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
15 |
16 |
23 |
24 |
25 |
26 |
37 |
38 |
45 |
46 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_direct_seeding.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
29 |
30 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_direct_seeding_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
29 |
30 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/CourseFragment.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.view.PagerAdapter;
5 |
6 | import com.xujun.fragmenttabhostdemo.base.BaseFragmentAdapter;
7 | import com.xujun.fragmenttabhostdemo.base.BaseViewPagerFragment;
8 | import com.xujun.fragmenttabhostdemo.fragment.CourseListFragment;
9 | import com.xujun.fragmenttabhostdemo.fragment.CourseListFragmentWithHeadView;
10 |
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * @author xujun on 2016/12/26.
15 | * @email gdutxiaoxu@163.com
16 | */
17 |
18 | public class CourseFragment extends BaseViewPagerFragment {
19 |
20 | String[] mTitles=new String[]{
21 | "语文","数学","英语","化学","物理","生物","政治"
22 | };
23 | private ArrayList mFragments;
24 |
25 | @Override
26 | protected PagerAdapter getViewPagerAdapter() {
27 | mFragments = new ArrayList<>();
28 | for(int i=0;i
2 |
9 |
10 |
15 |
16 |
17 |
18 |
25 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/activity_three.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
18 |
25 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/layout/activity_second_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
18 |
25 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/FragmentInfo.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 |
6 | /**
7 | * @ explain:
8 | * @ author:xujun on 2016/10/12 09:42
9 | * @ email:gdutxiaoxu@163.com
10 | */
11 | public class FragmentInfo {
12 |
13 | private Class extends Fragment> clz;
14 | private String title="";
15 | private Bundle arugment;
16 |
17 | // mImagIds[0] 未选中的图片资源,mImagIds[1] 选中的图片资源,
18 | private int[] mImagIds=new int[2];
19 | // mColors【0】 未选中字体的显示颜色, mColors【1】 未选中字体的显示颜色
20 | private int [] mColors=new int[2];
21 |
22 | public FragmentInfo(Class extends Fragment> clz, String title, Bundle arugment, int[]
23 | imagIds, int[] colors) {
24 | this.clz = clz;
25 | this.title = title;
26 | this.arugment = arugment;
27 | mImagIds = imagIds;
28 | mColors = colors;
29 | }
30 |
31 | public Class extends Fragment> getClz() {
32 | return clz;
33 | }
34 |
35 | public void setClz(Class extends Fragment> clz) {
36 | this.clz = clz;
37 | }
38 |
39 | public String getTitle() {
40 | return title;
41 | }
42 |
43 | public void setTitle(String title) {
44 | this.title = title;
45 | }
46 |
47 | public Bundle getArugment() {
48 | return arugment;
49 | }
50 |
51 | public void setArugment(Bundle arugment) {
52 | this.arugment = arugment;
53 | }
54 |
55 | public int[] getImagIds() {
56 | return mImagIds;
57 | }
58 |
59 | public void setImagIds(int[] imagIds) {
60 | mImagIds = imagIds;
61 | }
62 |
63 | public int[] getColors() {
64 | return mColors;
65 | }
66 |
67 | public void setColors(int[] colors) {
68 | mColors = colors;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_home_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/TestFragemnt.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | /**
13 | * @ explain:
14 | * @ author:xujun on 2016/10/11 23:47
15 | * @ email:gdutxiaoxu@163.com
16 | */
17 | public class TestFragemnt extends Fragment {
18 |
19 | TextView tvContent;
20 | String tag="tag";
21 | private static final String TAG = "xujun";
22 | private View mView;
23 |
24 | @Nullable
25 | @Override
26 | public View onCreateView(LayoutInflater inflater,
27 | @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
28 | Log.i(TAG, "onCreateView");
29 |
30 |
31 | if(mView==null){
32 | Log.i(TAG, "实例化View");
33 | mView = View.inflate(getContext(), R.layout.fragment_test, null);
34 | tvContent= (TextView) mView.findViewById(R.id.tv_content);
35 |
36 | Bundle arguments = getArguments();
37 | if(arguments!=null){
38 | String string = arguments.getString(tag);
39 | Log.i(TAG, "onCreateView:=string" +string);
40 | tvContent.setText(string);
41 | }
42 | }
43 |
44 | // 缓存的rootView需要判断是否已经被加过parent,如果有parent需要从parent删除,
45 | // 要不然会发生这个rootview已经有parent的错误。
46 | ViewGroup parent = (ViewGroup) mView.getParent();
47 | if (parent != null)
48 | {
49 | parent.removeView(mView);
50 | }
51 |
52 |
53 | return mView;
54 | }
55 |
56 | @Override
57 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
58 | super.onActivityCreated(savedInstanceState);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/base/BaseFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.base;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * @ explain:
12 | * @ author:xujun on 2016/4/28 17:34
13 | * @ email:gdutxiaoxu@163.com
14 | */
15 | public class BaseFragmentAdapter extends FragmentPagerAdapter {
16 |
17 | protected List fragmentList;
18 |
19 | protected String[] mTitles;
20 |
21 | public BaseFragmentAdapter(FragmentManager fm) {
22 | this(fm, null, null);
23 | }
24 |
25 | public BaseFragmentAdapter(FragmentManager fm, List fragmentList, String[] mTitles) {
26 | super(fm);
27 | if (fragmentList == null) {
28 | fragmentList = new ArrayList<>();
29 | }
30 | this.fragmentList = fragmentList;
31 | this.mTitles = mTitles;
32 | }
33 |
34 | public void add(Fragment fragment) {
35 | if (isEmpty()) {
36 | fragmentList = new ArrayList<>();
37 |
38 | }
39 | fragmentList.add(fragment);
40 | }
41 |
42 | @Override
43 | public Fragment getItem(int position) {
44 | // Logger.i("BaseFragmentAdapter position=" +position);
45 | return isEmpty() ? null : fragmentList.get(position);
46 | }
47 |
48 | @Override
49 | public int getCount() {
50 | return isEmpty() ? 0 : fragmentList.size();
51 | }
52 |
53 | public boolean isEmpty() {
54 | return fragmentList == null;
55 |
56 | }
57 |
58 | @Override
59 | public CharSequence getPageTitle(int position) {
60 | return mTitles[position];
61 | }
62 |
63 | /* @Override
64 | public int getItemPosition(Object object) {
65 | return PagerAdapter.POSITION_NONE;
66 | }*/
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/base/BaseViewPagerFragment.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.design.widget.TabLayout;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.view.PagerAdapter;
8 | import android.support.v4.view.ViewPager;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | import com.xujun.fragmenttabhostdemo.R;
14 |
15 | /**
16 | * @author xujun on 2016/12/26.
17 | * @email gdutxiaoxu@163.com
18 | */
19 |
20 | public abstract class BaseViewPagerFragment extends Fragment {
21 |
22 | private View mView;
23 | private TabLayout mTabLayout;
24 | private ViewPager mViewPager;
25 | private PagerAdapter mViewPagerAdapter;
26 |
27 | @Override
28 | public void onCreate(@Nullable Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 |
31 | }
32 |
33 | @Nullable
34 | @Override
35 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
36 | Bundle savedInstanceState) {
37 | mView = inflater.inflate(R.layout.fragment_base_view_pager, container, false);
38 | mView.findViewById(R.id.tabLayout);
39 | initView();
40 | return mView;
41 | }
42 |
43 | @Override
44 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
45 | super.onActivityCreated(savedInstanceState);
46 | mViewPagerAdapter = getViewPagerAdapter();
47 | mViewPager.setAdapter(mViewPagerAdapter);
48 | mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
49 | mTabLayout.setupWithViewPager(mViewPager);
50 | }
51 |
52 | protected abstract PagerAdapter getViewPagerAdapter();
53 |
54 | private void initView() {
55 | mTabLayout = (TabLayout) mView.findViewById(R.id.tabLayout);
56 | mViewPager = (ViewPager) mView.findViewById(R.id.view_pager);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/base/WrapperUtils.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.base;
2 |
3 | import android.support.v7.widget.GridLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.support.v7.widget.StaggeredGridLayoutManager;
6 | import android.view.ViewGroup;
7 |
8 | /**
9 | * Created by zhy on 16/6/28.
10 | */
11 | public class WrapperUtils
12 | {
13 | public interface SpanSizeCallback
14 | {
15 | int getSpanSize(GridLayoutManager layoutManager, GridLayoutManager.SpanSizeLookup
16 | oldLookup, int position);
17 | }
18 |
19 | public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback)
20 | {
21 | innerAdapter.onAttachedToRecyclerView(recyclerView);
22 |
23 | RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
24 | if (layoutManager instanceof GridLayoutManager)
25 | {
26 | final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
27 | final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup();
28 |
29 | gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup()
30 | {
31 | @Override
32 | public int getSpanSize(int position)
33 | {
34 | return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position);
35 | }
36 | });
37 | gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount());
38 | }
39 | }
40 |
41 | public static void setFullSpan(RecyclerView.ViewHolder holder)
42 | {
43 | ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
44 |
45 | if (lp != null
46 | && lp instanceof StaggeredGridLayoutManager.LayoutParams)
47 | {
48 |
49 | StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
50 |
51 | p.setFullSpan(true);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_me.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_me_green.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_me_green_presed.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/test/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package star.yx.test;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.graphics.Point;
6 | import android.view.Display;
7 | import android.view.WindowManager;
8 |
9 | import java.util.logging.Logger;
10 |
11 | /**
12 | * Created by Administrator on 2016/10/23 0023.
13 | */
14 |
15 | public class DensityUtil {
16 | public DensityUtil() {
17 | }
18 |
19 | public static int dip2px(Context context, float dpValue) {
20 | float scale = context.getResources().getDisplayMetrics().density;
21 | return (int) (dpValue * scale + 0.5F);
22 | }
23 |
24 | public static int px2dip(Context context, float pxValue) {
25 | float scale = context.getResources().getDisplayMetrics().density;
26 | return (int) (pxValue / scale + 0.5F);
27 | }
28 |
29 | // public static int getScreenWidth(Context context) {
30 | // WindowManager manager = (WindowManager) context.getSystemService("window");
31 | // Display display = manager.getDefaultDisplay();
32 | // Point size = new Point();
33 | // display.getSize(size);
34 | // return size.x;
35 | // }
36 | //
37 | // public static int getScreenHeight(Context context) {
38 | // WindowManager manager = (WindowManager) context.getSystemService("window");
39 | // Display display = manager.getDefaultDisplay();
40 | // Point size = new Point();
41 | // display.getSize(size);
42 | // return size.y;
43 | // }
44 | //
45 | // public static int[] getScreenSize(Context context) {
46 | // WindowManager manager = (WindowManager) context.getSystemService("window");
47 | // Display display = manager.getDefaultDisplay();
48 | // int[] size = new int[]{display.getWidth(), display.getHeight()};
49 | // return size;
50 | // }
51 |
52 | public static int getNavigationBarHeight(Context context) {
53 | Resources resources = context.getResources();
54 | int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
55 | int height = resources.getDimensionPixelSize(resourceId);
56 | return height;
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_course.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
38 |
39 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/res/drawable-hdpi/icon_course_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
38 |
39 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/base/EndlessRecyclerOnScrollListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.base;
2 |
3 | import android.support.v7.widget.LinearLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 |
7 | /**
8 | * @author xujun on 2016/12/26.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
13 | public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
14 |
15 | private int previousTotal = 0; // The total number of items in the dataset after the last load
16 | private boolean loading = true; // True if we are still waiting for the last set of data to load.
17 | private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
18 | int firstVisibleItem, visibleItemCount, totalItemCount;
19 |
20 | private int current_page = 1;
21 |
22 | private LinearLayoutManager mLinearLayoutManager;
23 |
24 | public EndlessRecyclerOnScrollListener(LinearLayoutManager linearLayoutManager) {
25 | this.mLinearLayoutManager = linearLayoutManager;
26 | }
27 |
28 | @Override
29 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
30 | super.onScrolled(recyclerView, dx, dy);
31 |
32 | visibleItemCount = recyclerView.getChildCount();
33 | totalItemCount = mLinearLayoutManager.getItemCount();
34 | firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();
35 |
36 | if (loading) {
37 | if (totalItemCount > previousTotal) {
38 | loading = false;
39 | previousTotal = totalItemCount;
40 | }
41 | }
42 | if (!loading && visibleItemCount>visibleThreshold ) {
43 | // End has been reached
44 |
45 | // Do something
46 | current_page++;
47 | Log.d("End", "Sucess");
48 |
49 | onLoadMore(current_page);
50 |
51 | loading = true;
52 | }
53 | }
54 |
55 | public void reset(){
56 | previousTotal=0;
57 | loading=false;
58 | }
59 |
60 | public void loadMoreFinish(){
61 | loading=false;
62 | previousTotal= mLinearLayoutManager.getItemCount();
63 | }
64 |
65 | public abstract void onLoadMore(int current_page);
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/TabView.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.AttributeSet;
6 | import android.view.Gravity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.ImageView;
10 | import android.widget.RelativeLayout;
11 | import android.widget.TextView;
12 |
13 | /**
14 | * Created by yx on 16/4/3.
15 | */
16 |
17 | public class TabView extends RelativeLayout implements View.OnClickListener{
18 |
19 | private ImageView mTabImage;
20 | private TextView mTabLable;
21 | private View mUnderLine;
22 | private View mLl;
23 | private TextView mTvMsgCount;
24 |
25 | private static final String TAG = "TabView";
26 |
27 | public TabView(Context context) {
28 | super(context);
29 | initView(context);
30 | }
31 |
32 | public TabView(Context context, AttributeSet attrs) {
33 | super(context, attrs);
34 | initView(context);
35 | }
36 |
37 | public TabView(Context context, AttributeSet attrs, int defStyle) {
38 | super(context, attrs, defStyle);
39 | initView(context);
40 | }
41 |
42 | private void initView(Context context){
43 | setGravity(Gravity.CENTER);
44 | LayoutInflater.from(context).inflate(R.layout.tab_view,this,true);
45 | mTabImage=(ImageView)findViewById(R.id.tab_image);
46 | mTabLable=(TextView)findViewById(R.id.tab_lable);
47 | mUnderLine=findViewById(R.id.under_line);
48 | mUnderLine.setVisibility(View.GONE);
49 | // mLl=findViewById(R.id.ll);
50 | mTvMsgCount =(TextView)findViewById(R.id.tv_new_msg);
51 |
52 | }
53 |
54 | public void initData(TabItem tabItem){
55 | mTabImage.setImageResource(tabItem.imageResId);
56 | mTabLable.setText(tabItem.lableResId);
57 | String count = tabItem.count;
58 | mTvMsgCount.setText(TextUtils.isEmpty(count)?"" + "":count);
59 | setHintVisibility(View.GONE);
60 | }
61 |
62 | public void setUnderViewVisibility(int visibility){
63 | mUnderLine.setVisibility(visibility);
64 | }
65 |
66 | public void setHintVisibility(int visibility){
67 | mTvMsgCount.setVisibility(visibility);
68 | }
69 |
70 |
71 | private int getChildMode(int widthMode) {
72 | int childWidthMode;
73 | if (widthMode == MeasureSpec.EXACTLY) {
74 | childWidthMode = MeasureSpec.AT_MOST;
75 | } else {
76 | childWidthMode = widthMode;
77 | }
78 | return childWidthMode;
79 | }
80 |
81 | @Override
82 | public void onClick(View v) {
83 |
84 | }
85 | public void onDataChanged(int badgeCount) {
86 | // TODO notify new message, change the badgeView
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/WechatFragment.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import star.yx.test.BaseRecyclerViewAdapter;
11 | import star.yx.test.BaseSwipeRefreshLayout;
12 |
13 | /**
14 | * Created by yx on 16/4/3.
15 | */
16 | public class WechatFragment extends BaseFragment implements ITabClickListener {
17 | private BaseSwipeRefreshLayout mSwipeRefreshLayout;
18 | private RecyclerView mListView;
19 | private LinearLayoutManager layoutManager;
20 | WechatAdapter adapter;
21 |
22 | @Override
23 | public void fetchData() {
24 | getData();
25 | }
26 |
27 | @Override
28 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
29 | View view = inflater.inflate(R.layout.contacts_layout, container, false);
30 | mSwipeRefreshLayout = (BaseSwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
31 | mListView = (RecyclerView) view.findViewById(R.id.list);
32 | this.layoutManager = new LinearLayoutManager(this.getContext());
33 | this.layoutManager.setOrientation(1);
34 | this.mListView.setLayoutManager(this.layoutManager);
35 | adapter = new WechatAdapter();
36 | mListView.setAdapter(adapter);
37 | return view;
38 | }
39 |
40 |
41 | private void getData() {
42 | //模拟子线程耗时操作
43 | new Thread() {
44 | @Override
45 | public void run() {
46 | try {
47 | Thread.sleep(3000);
48 | mSwipeRefreshLayout.post(new Runnable() {
49 | @Override
50 | public void run() {
51 | mSwipeRefreshLayout.setRefreshing(false);
52 | }
53 | });
54 |
55 | } catch (InterruptedException e) {
56 | e.printStackTrace();
57 | }
58 |
59 | }
60 | }.start();
61 |
62 | }
63 |
64 | @Override
65 | public void onMenuItemClick() {
66 |
67 | }
68 |
69 | @Override
70 | public BaseFragment getFragment() {
71 | return this;
72 | }
73 |
74 |
75 | class WechatAdapter extends BaseRecyclerViewAdapter {
76 | public WechatAdapter() {
77 | super(R.layout.contact_item);
78 | }
79 |
80 | @Override
81 | public void onBindViewData(ViewHolder var1, int var2) {
82 | var1.getTextView(R.id.contact).setText("你有新消息");
83 | }
84 |
85 | @Override
86 | public int getItemCount() {
87 | return 20;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/TabItem.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.support.v4.app.Fragment;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | /**
11 | * @author meitu.xujun on 2017/4/20 13:50
12 | * @version 0.1
13 | */
14 |
15 | class TabItem {
16 |
17 | private final int mSelectTextcolor;
18 | private ImageView mIvTab;
19 |
20 | /**
21 | * 正常状态的图片
22 | */
23 | private int imageNormal;
24 |
25 | /**
26 | * 选中状态的图片
27 | */
28 | private int imageSelected;
29 |
30 | private TextView mTvTab;
31 |
32 | /**
33 | * 文字
34 | */
35 | private String tabText;
36 |
37 | /**
38 | * Fragment
39 | */
40 | private Class extends Fragment> fragmentClass;
41 |
42 | private View mTabView;
43 |
44 | /**
45 | * 新消息
46 | */
47 | private TextView mTvNewMsg;
48 |
49 | public TabItem(int imageNormal, int imageSelected, String text, Class extends Fragment> fragmentClass,int selectTextcolor) {
50 | this.imageNormal = imageNormal;
51 | this.imageSelected = imageSelected;
52 | this.tabText = text;
53 | this.fragmentClass = fragmentClass;
54 | mSelectTextcolor = selectTextcolor;
55 | }
56 |
57 | public Class extends Fragment> getFragmentClass() {
58 | return fragmentClass;
59 | }
60 |
61 | /**
62 | * 获取 tab 上的文字
63 | *
64 | * @return tab 上的文字
65 | */
66 | public String getTabText() {
67 | return tabText;
68 | }
69 |
70 | /**
71 | * 设置选中
72 | *
73 | * @param checked 是否选中
74 | */
75 | public void setChecked(boolean checked) {
76 | if (checked) {
77 | mTvTab.setTextColor(mSelectTextcolor);
78 | mIvTab.setImageResource(imageSelected);
79 | } else {
80 | mTvTab.setTextColor(Color.WHITE);
81 | mIvTab.setImageResource(imageNormal);
82 | }
83 | }
84 |
85 | public View getTabView(Context context) {
86 | mTabView = View.inflate(context, R.layout.view_tab, null);
87 | mIvTab = (ImageView) mTabView.findViewById(R.id.iv_tab);
88 | mTvTab = (TextView) mTabView.findViewById(R.id.tv_tab);
89 | mTvNewMsg = (TextView) mTabView.findViewById(R.id.tv_new_msg);
90 | mIvTab.setImageResource(imageNormal);
91 | mTvTab.setText(tabText);
92 | return mTabView;
93 | }
94 |
95 | /**
96 | * 设置新消息数量
97 | */
98 | public void setNewMsgCount(int count) {
99 | if (count > 0) {
100 | mTvNewMsg.setText(String.valueOf(count));
101 | }
102 | mTvNewMsg.setBackgroundResource(R.drawable.ic_new_msg);
103 | }
104 | }
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/MainFragmentFactory.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo;
2 |
3 | import android.os.Bundle;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @ explain:
10 | * @ author:xujun on 2016/10/12 09:45
11 | * @ email:gdutxiaoxu@163.com
12 | */
13 | public class MainFragmentFactory {
14 | private static volatile MainFragmentFactory mInstace;
15 | List mList;
16 | private FragmentInfo mPerson;
17 |
18 | String[] mTiltles=new String[]{
19 | "首页","课程","直播","个人"
20 | };
21 |
22 |
23 | int [] mColors=new int[]{
24 | R.color.bg_tab_unselect ,R.color.bg_tab_select
25 | };
26 | private String tag = "tag";;
27 |
28 | private MainFragmentFactory() {
29 |
30 | }
31 |
32 | public static MainFragmentFactory getInstance() {
33 |
34 | if (mInstace == null) {
35 | synchronized (MainFragmentFactory.class) {
36 | if (mInstace == null) {
37 | mInstace = new MainFragmentFactory();
38 | }
39 | }
40 |
41 | }
42 | return mInstace;
43 |
44 | }
45 |
46 | public void add(FragmentInfo entity) {
47 | if (mList == null) {
48 | mList = new ArrayList<>();
49 | }
50 | mList.add(entity);
51 | }
52 |
53 | public List getList() {
54 | if (mList == null) {
55 | mList = new ArrayList<>();
56 |
57 |
58 | Bundle bundle = new Bundle();
59 | bundle.putString(tag,mTiltles[0]);
60 | FragmentInfo home = new FragmentInfo(TestFragemnt.class, "首页", bundle,new int[]{
61 | R.drawable.icon_home,R.drawable.icon_home_pressed
62 | },mColors);
63 | Bundle bundle1 = new Bundle();
64 | bundle.putString(tag,mTiltles[1]);
65 | FragmentInfo course = new FragmentInfo(TestFragemnt.class, "课程", bundle1,new int[]{
66 | R.drawable.icon_course,R.drawable.icon_course_pressed
67 | },mColors);
68 | Bundle bundle2 = new Bundle();
69 | bundle.putString(tag,mTiltles[2]);
70 | FragmentInfo zhibo = new FragmentInfo(TestFragemnt.class, "直播", bundle2,new int[]{
71 | R.drawable.icon_direct_seeding,R.drawable.icon_direct_seeding_pressed
72 | },mColors);
73 | Bundle bundle3 = new Bundle();
74 | bundle.putString(tag,mTiltles[3]);
75 | FragmentInfo person = new FragmentInfo(TestFragemnt.class, "个人", bundle3,new int[]{
76 | R.drawable.icon_me,R.drawable.icon_me_green_presed
77 | },mColors);
78 |
79 | mList.add(home);
80 | mList.add(course);
81 | mList.add(zhibo);
82 | mList.add(person);
83 |
84 |
85 | }
86 | return mList;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/ContactsFragment.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.os.Bundle;
4 | import android.os.Handler;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | import star.yx.test.BaseRecyclerViewAdapter;
13 | import star.yx.test.BaseSwipeRefreshLayout;
14 |
15 | /**
16 | * Created by yx on 16/4/3.
17 | */
18 | public class ContactsFragment extends BaseFragment implements ITabClickListener {
19 |
20 | BaseSwipeRefreshLayout mSwipeRefreshLayout;
21 | RecyclerView mListView;
22 | private LinearLayoutManager layoutManager;
23 | ConstactsAdapter adapter;
24 |
25 | @Override
26 | public void fetchData() {
27 | getData();
28 | }
29 |
30 | @Override
31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
32 | View view = inflater.inflate(R.layout.contacts_layout, container, false);
33 | mSwipeRefreshLayout = (BaseSwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
34 | mListView = (RecyclerView) view.findViewById(R.id.list);
35 | this.layoutManager = new LinearLayoutManager(this.getContext());
36 | this.layoutManager.setOrientation(1);
37 | this.mListView.setLayoutManager(this.layoutManager);
38 | adapter = new ConstactsAdapter();
39 | mListView.setAdapter(adapter);
40 | return view;
41 | }
42 |
43 |
44 | private void getData() {
45 | //模拟子线程耗时操作
46 | new Thread() {
47 | @Override
48 | public void run() {
49 | try {
50 | Thread.sleep(3000);
51 | mSwipeRefreshLayout.post(new Runnable() {
52 | @Override
53 | public void run() {
54 | mSwipeRefreshLayout.setRefreshing(false);
55 | }
56 | });
57 |
58 | } catch (InterruptedException e) {
59 | e.printStackTrace();
60 | }
61 |
62 | }
63 | }.start();
64 |
65 | }
66 |
67 | @Override
68 | public void onMenuItemClick() {
69 |
70 | }
71 |
72 | @Override
73 | public BaseFragment getFragment() {
74 | return this;
75 | }
76 |
77 |
78 | class ConstactsAdapter extends BaseRecyclerViewAdapter {
79 | public ConstactsAdapter() {
80 | super(R.layout.contact_item);
81 | }
82 |
83 | @Override
84 | public void onBindViewData(ViewHolder var1, int var2) {
85 | var1.getTextView(R.id.contact).setText("联系人");
86 | }
87 |
88 | @Override
89 | public int getItemCount() {
90 | return 20;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_wechat.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
19 |
20 |
25 |
26 |
27 |
28 |
32 |
33 |
40 |
41 |
46 |
47 |
48 |
49 |
53 |
54 |
61 |
62 |
67 |
68 |
69 |
70 |
74 |
75 |
82 |
83 |
88 |
89 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/WeChatFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.text.TextUtils;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 |
12 | /**
13 | * 微信 Fragment
14 | */
15 | public class WeChatFragment extends Fragment implements View.OnClickListener {
16 |
17 | private EditText mEdWeChat;
18 | private EditText mEdFriend;
19 | private EditText mEdContacts;
20 | private EditText mEdSetting;
21 |
22 | public WeChatFragment() {
23 | // Required empty public constructor
24 | }
25 |
26 | @Override
27 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
28 | Bundle savedInstanceState) {
29 | View view = inflater.inflate(R.layout.fragment_wechat, container, false);
30 |
31 | mEdWeChat = (EditText) view.findViewById(R.id.et_wechat);
32 | mEdFriend = (EditText) view.findViewById(R.id.et_friend);
33 | mEdContacts = (EditText) view.findViewById(R.id.et_contacts);
34 | mEdSetting = (EditText) view.findViewById(R.id.et_setting);
35 |
36 | Button btnWeChat = (Button) view.findViewById(R.id.btn_wechat);
37 | Button btnFrrend = (Button) view.findViewById(R.id.btn_friend);
38 | Button btnContacts = (Button) view.findViewById(R.id.btn_contacts);
39 | Button btnSetting = (Button) view.findViewById(R.id.btn_setting);
40 |
41 | btnWeChat.setOnClickListener(this);
42 | btnFrrend.setOnClickListener(this);
43 | btnContacts.setOnClickListener(this);
44 | btnSetting.setOnClickListener(this);
45 | return view;
46 | }
47 |
48 | @Override
49 | public void onClick(View v) {
50 | // 新消息数量
51 | String number;
52 | // 获取 Fragment 的托管 Activity
53 | MainActivity mainActivity = (MainActivity) getActivity();
54 |
55 | switch (v.getId()) {
56 | case R.id.btn_wechat:
57 | number = mEdWeChat.getText().toString().trim();
58 | if (!TextUtils.isEmpty(number)) {
59 | mainActivity.updateMsgCount(MainActivity.TAB_WECHAT, Integer.valueOf(number));
60 | }
61 | break;
62 | case R.id.btn_friend:
63 | number = mEdFriend.getText().toString().trim();
64 | if (!TextUtils.isEmpty(number)) {
65 | mainActivity.updateMsgCount(MainActivity.TAB_FRIEND, Integer.valueOf(number));
66 | }
67 | break;
68 | case R.id.btn_contacts:
69 | number = mEdContacts.getText().toString().trim();
70 | if (!TextUtils.isEmpty(number)) {
71 | mainActivity.updateMsgCount(MainActivity.TAB_CONTACTS, Integer.valueOf(number));
72 | }
73 | break;
74 | case R.id.btn_setting:
75 | number = mEdSetting.getText().toString().trim();
76 | if (!TextUtils.isEmpty(number)) {
77 | mainActivity.updateMsgCount(MainActivity.TAB_SETTING, Integer.valueOf(number));
78 | }
79 | break;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/TabLayout.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Point;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.view.WindowManager;
9 | import android.widget.LinearLayout;
10 |
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Created by yx on 16/4/3.
15 | */
16 | public class TabLayout extends LinearLayout implements View.OnClickListener{
17 |
18 | private ArrayList tabs;
19 | private OnTabClickListener listener;
20 | private View selectView;
21 | private int tabCount;
22 | private Context mContext;
23 |
24 |
25 | public TabLayout(Context context) {
26 | this(context,null);
27 |
28 | }
29 |
30 | public TabLayout(Context context, AttributeSet attrs) {
31 | this(context, attrs,0);
32 |
33 | }
34 |
35 | public TabLayout(Context context, AttributeSet attrs, int defStyle) {
36 | super(context, attrs, defStyle);
37 | mContext = context;
38 | initView();
39 | }
40 |
41 | private void initView(){
42 | setOrientation(HORIZONTAL);
43 | }
44 |
45 | public void setCurrentTab(int i) {
46 | if (i < tabCount && i >= 0) {
47 | View view = getChildAt(i);
48 | if (selectView != view) {
49 | view.setSelected(true);
50 | if (selectView != null) {
51 | selectView.setSelected(false);
52 |
53 | }
54 | selectView = view;
55 | }
56 | }
57 | }
58 |
59 | public void onDataChanged(int i, int badgeCount) {
60 | if (i < tabCount && i >= 0) {
61 | TabView view = (TabView) getChildAt(i);
62 | view.onDataChanged(badgeCount);
63 | }
64 | }
65 |
66 | public void initData(ArrayList tabs,OnTabClickListener listener){
67 | this.tabs=tabs;
68 | int size = tabs.size();
69 | this.listener=listener;
70 | LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT);
71 | params.weight=1;
72 | Point point = get(mContext);
73 |
74 | if(tabs!=null&&tabs.size()>0){
75 | tabCount=tabs.size();
76 | TabView mTabView=null;
77 | for(int i=0;i< tabs.size();i++){
78 | mTabView=new TabView(getContext());
79 | mTabView.setTag(tabs.get(i));
80 | mTabView.initData(tabs.get(i));
81 | mTabView.setOnClickListener(this);
82 | mTabView.setUnderViewVisibility(View.INVISIBLE);
83 | addView(mTabView,params);
84 | }
85 | setCurrentTab(0);
86 | }else{
87 | throw new IllegalArgumentException("tabs can not be empty");
88 | }
89 |
90 |
91 | }
92 |
93 | public Point get(Context context){
94 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
95 | int width = wm.getDefaultDisplay().getWidth();
96 | int height = wm.getDefaultDisplay().getHeight();
97 | return new Point(width,height);
98 | }
99 |
100 |
101 | @Override
102 | public void onClick(View v) {
103 | listener.onTabClick((TabItem) v.getTag());
104 |
105 | }
106 | public interface OnTabClickListener{
107 | void onTabClick(TabItem tabItem);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/activity/SecondStyleActivity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.view.ViewPager;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.widget.RadioButton;
8 | import android.widget.RadioGroup;
9 |
10 | import com.xujun.fragmenttabhostdemo.fragment.ItemFragement;
11 | import com.xujun.fragmenttabhostdemo.R;
12 | import com.xujun.fragmenttabhostdemo.base.BaseFragmentAdapter;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | public class SecondStyleActivity extends AppCompatActivity {
18 |
19 | public static final String[] mTiltles = new String[]{
20 | "首页", "课程", "直播", "个人"
21 | };
22 | private List mFragments;
23 | ViewPager mViewPager;
24 | RadioGroup mRg;
25 | private int position = 0;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_second_style);
31 | mViewPager = (ViewPager) findViewById(R.id.viewPager);
32 | mRg = (RadioGroup) findViewById(R.id.rg);
33 | initListener();
34 | initData();
35 |
36 |
37 | }
38 |
39 | private void initData() {
40 | mFragments = new ArrayList<>();
41 | for (int i = 0; i < mTiltles.length; i++) {
42 | ItemFragement itemFragement = ItemFragement.newInstance(mTiltles[i]);
43 | mFragments.add(itemFragement);
44 | }
45 | BaseFragmentAdapter fragmentAdapter = new BaseFragmentAdapter
46 | (getSupportFragmentManager(), mFragments, mTiltles);
47 |
48 | mViewPager.setAdapter(fragmentAdapter);
49 | // 设置左右页面 能缓存的fragment 数量
50 | mViewPager.setOffscreenPageLimit(fragmentAdapter.getCount() - 1);
51 | mViewPager.setCurrentItem(position);
52 | ((RadioButton) mRg.getChildAt(position)).setChecked(true);
53 | }
54 |
55 | private void initListener() {
56 | mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
57 | @Override
58 | public void onPageSelected(int position) {
59 | RadioButton radioButton = (RadioButton) mRg.getChildAt(position);
60 | radioButton.setChecked(true);
61 | }
62 | });
63 |
64 | mRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
65 |
66 | @Override
67 | public void onCheckedChanged(RadioGroup group, int checkedId) {
68 | RadioButton rb = (RadioButton) group.findViewById(checkedId);
69 | if (!rb.isChecked()) {
70 | return;
71 | }
72 | switch (checkedId) {
73 | case R.id.rb_home:
74 | position = 0;
75 | break;
76 |
77 | case R.id.rb_course:
78 | position = 1;
79 | break;
80 |
81 | case R.id.rb_direct_seeding:
82 | position = 2;
83 | break;
84 |
85 | case R.id.rb_me:
86 | position = 3;
87 | break;
88 | default:
89 | position = 0;
90 | break;
91 |
92 | }
93 | mViewPager.setCurrentItem(position);
94 | }
95 | });
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/base/BasePageFragment.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.base;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.xujun.fragmenttabhostdemo.LUtils;
12 |
13 | /**
14 | * @ explain:
15 | * @ author:xujun on 2016-8-11 16:16
16 | * @ email:gdutxiaoxu@163.com
17 | */
18 | public abstract class BasePageFragment extends Fragment {
19 |
20 | protected View mView;
21 |
22 | /**
23 | * 表示View是否被初始化
24 | */
25 | protected boolean isViewInitiated;
26 | /**
27 | * 表示对用户是否可见
28 | */
29 | protected boolean isVisibleToUser;
30 | /**
31 | * 表示数据是否初始化
32 | */
33 | protected boolean isDataInitiated;
34 | protected Context mContext;
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | mContext=getContext();
40 | // LUtils.i(getClass().getSimpleName() + ">>>>>>>>>>> onCreate");
41 | }
42 |
43 | @Nullable
44 | @Override
45 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
46 | Bundle savedInstanceState) {
47 | // LUtils.i(getClass().getSimpleName() + ">>>>>>>>>>> onCreateView");
48 | if (mView == null) {
49 | mContext = getContext();
50 | mView = View.inflate(mContext, getLayoutId(), null);
51 | initView(mView);
52 |
53 | } else {
54 | // 缓存的rootView需要判断是否已经被加过parent,如果有parent需要从parent删除,
55 | // 要不然会发生这个rootview已经有parent的错误。
56 | ViewGroup parent = (ViewGroup) mView.getParent();
57 | if (parent != null) {
58 | parent.removeView(mView);
59 | }
60 |
61 | }
62 | return mView;
63 | }
64 |
65 | protected abstract void initView(View view);
66 |
67 | protected abstract int getLayoutId();
68 |
69 | @Override
70 | public void onActivityCreated(Bundle savedInstanceState) {
71 | super.onActivityCreated(savedInstanceState);
72 | LUtils.i(getClass().getSimpleName() + ">>>>>>>>>>> onActivityCreated");
73 | isViewInitiated = true;
74 | initData();
75 | prepareFetchData();
76 | }
77 |
78 | @Override
79 | public void setUserVisibleHint(boolean isVisibleToUser) {
80 | super.setUserVisibleHint(isVisibleToUser);
81 | this.isVisibleToUser = isVisibleToUser;
82 | prepareFetchData();
83 | }
84 |
85 | public abstract void fetchData();
86 |
87 | public boolean prepareFetchData() {
88 | return prepareFetchData(false);
89 | }
90 |
91 | /***
92 | * @param forceUpdate 表示是否在界面可见的时候是否强制刷新数据
93 | * @return
94 | */
95 | public boolean prepareFetchData(boolean forceUpdate) {
96 | if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
97 | // 界面可见的时候再去加载数据
98 | fetchData();
99 | isDataInitiated = true;
100 | return true;
101 | }
102 | return false;
103 | }
104 |
105 | @Override
106 | public void onDestroyView() {
107 | super.onDestroyView();
108 | LUtils.i(getClass().getSimpleName() + ">>>>>>>>>>> onDestroyView");
109 | }
110 |
111 | protected void initData() {
112 | }
113 |
114 |
115 |
116 | }
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/tabview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package star.yx.tabview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentPagerAdapter;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.ActionBar;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.util.Log;
11 |
12 | import java.util.ArrayList;
13 |
14 | public class MainActivity extends AppCompatActivity implements TabLayout.OnTabClickListener {
15 |
16 | private static final String TAG = "MainActivity";
17 |
18 | private TabLayout mTabLayout;
19 | private ViewPager mViewPager;
20 | private ArrayList tabs;
21 | private ActionBar actionBar;
22 | BaseFragment fragment;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_main);
28 | initView();
29 | initData();
30 | }
31 |
32 | private void initView() {
33 | mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
34 | mViewPager = (ViewPager) findViewById(R.id.viewpager);
35 | actionBar = getSupportActionBar();
36 | if (actionBar != null) {
37 | actionBar.setTitle(R.string.wechat);
38 | }
39 |
40 | }
41 |
42 | private void initData() {
43 |
44 | tabs = new ArrayList<>();
45 | tabs.add(new TabItem(R.drawable.selector_tab_msg, R.string.wechat, WechatFragment.class));
46 | tabs.add(new TabItem(R.drawable.selector_tab_contact, R.string.contacts, ContactsFragment.class));
47 | tabs.add(new TabItem(R.drawable.selector_tab_moments, R.string.discover, DiscoverFragment.class));
48 | tabs.add(new TabItem(R.drawable.selector_tab_profile, R.string.me, ProfileFragment.class));
49 |
50 | mTabLayout.initData(tabs, this);
51 | mTabLayout.setCurrentTab(0);
52 |
53 | FragAdapter adapter = new FragAdapter(getSupportFragmentManager());
54 | mViewPager.setAdapter(adapter);
55 | mViewPager.setOffscreenPageLimit(2);
56 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
57 | @Override
58 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
59 |
60 | }
61 |
62 | @Override
63 | public void onPageSelected(int position) {
64 | mTabLayout.setCurrentTab(position);
65 | actionBar.setTitle(tabs.get(position).lableResId);
66 | }
67 |
68 | @Override
69 | public void onPageScrollStateChanged(int state) {
70 |
71 | }
72 | });
73 |
74 | }
75 |
76 | @Override
77 | public void onTabClick(TabItem tabItem) {
78 |
79 |
80 | actionBar.setTitle(tabItem.lableResId);
81 | int item = tabs.indexOf(tabItem);
82 | Log.i(TAG, "onTabClick: item=" +item);
83 | mViewPager.setCurrentItem(item);
84 |
85 | }
86 |
87 |
88 | public class FragAdapter extends FragmentPagerAdapter {
89 |
90 |
91 | public FragAdapter(FragmentManager fm) {
92 | super(fm);
93 | // TODO Auto-generated constructor stub
94 | }
95 |
96 | @Override
97 | public Fragment getItem(int arg0) {
98 | // TODO Auto-generated method stub
99 | try {
100 | return tabs.get(arg0).tagFragmentClz.newInstance();
101 |
102 | } catch (InstantiationException e) {
103 | e.printStackTrace();
104 | } catch (IllegalAccessException e) {
105 | e.printStackTrace();
106 | }
107 | return fragment;
108 | }
109 |
110 | @Override
111 | public int getCount() {
112 | // TODO Auto-generated method stub
113 | return tabs.size();
114 | }
115 |
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/tabtest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.tabtest;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.FragmentTabHost;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.widget.TabHost;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | public static final int TAB_WECHAT = 0;
14 | public static final int TAB_FRIEND = 1;
15 | public static final int TAB_CONTACTS = 2;
16 | public static final int TAB_SETTING = 3;
17 |
18 | private List mFragmentList;
19 |
20 | private FragmentTabHost mFragmentTabHost;
21 |
22 | @Override
23 | protected void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_main);
26 | initTabItemData();
27 | }
28 |
29 | /**
30 | * 更新新消息数量
31 | *
32 | * @param tabIndex tab 的索引
33 | * @param msgCount 消息数量
34 | */
35 | public void updateMsgCount(int tabIndex, int msgCount) {
36 | mFragmentList.get(tabIndex).setNewMsgCount(msgCount);
37 | }
38 |
39 | /**
40 | * 初始化 Tab 数据
41 | */
42 | private void initTabItemData() {
43 | mFragmentList = new ArrayList<>();
44 | mFragmentList.add(new TabItem(
45 | R.drawable.tab_wechat_normal,
46 | R.drawable.tab_wechat_selected,
47 | "微信",
48 | WeChatFragment.class, R.color.colorTabText
49 | ));
50 |
51 | mFragmentList.add(new TabItem(
52 | R.drawable.tab_friend_normal,
53 | R.drawable.tab_friend_selected,
54 | "朋友",
55 | FriendFragment.class, R.color.colorTabText
56 | ));
57 |
58 | mFragmentList.add(new TabItem(
59 | R.drawable.tab_contacts_normal,
60 | R.drawable.tab_contacts_selected,
61 | "联系人",
62 | ContactsFragment.class, R.color.colorTabText
63 | ));
64 |
65 | mFragmentList.add(new TabItem(
66 | R.drawable.tab_settings_normal,
67 | R.drawable.tab_settings_selected, "设置",
68 | SettingFragment.class, R.color.colorTabText
69 | ));
70 |
71 | mFragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
72 | // 绑定 FragmentManager
73 | mFragmentTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
74 | // 删除分割线
75 | // mFragmentTabHost.getTabWidget().setDividerDrawable(null);
76 |
77 | for (int i = 0; i < mFragmentList.size(); i++) {
78 | TabItem tabItem = mFragmentList.get(i);
79 | // 创建 tab
80 | TabHost.TabSpec tabSpec = mFragmentTabHost.newTabSpec(
81 | tabItem.getTabText()).
82 | setIndicator(tabItem.getTabView(MainActivity.this));
83 | // 将创建的 tab 添加到底部 tab 栏中( @android:id/tabs )
84 | // 将 Fragment 添加到页面中( @android:id/tabcontent )
85 | mFragmentTabHost.addTab(tabSpec, tabItem.getFragmentClass(), null);
86 | // 底部 tab 栏设置背景图片
87 | mFragmentTabHost.getTabWidget().setBackgroundResource(R.drawable.bottom_bar);
88 |
89 | // 默认选中第一个 tab
90 | if (i == 0) {
91 | tabItem.setChecked(true);
92 | } else {
93 | tabItem.setChecked(false);
94 | }
95 | }
96 |
97 | // 切换 tab 时,回调此方法
98 | mFragmentTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
99 | @Override
100 | public void onTabChanged(String tabId) {
101 | for (int i = 0; i < mFragmentList.size(); i++) {
102 | TabItem tabItem = mFragmentList.get(i);
103 | // 通过 tag 检查用户点击的是哪个 tab
104 | if (tabId.equals(tabItem.getTabText())) {
105 | tabItem.setChecked(true);
106 | } else {
107 | tabItem.setChecked(false);
108 | }
109 | }
110 | }
111 | });
112 | }
113 |
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/activity/ThreeActivity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentTransaction;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.widget.FrameLayout;
9 | import android.widget.RadioButton;
10 | import android.widget.RadioGroup;
11 |
12 | import com.xujun.fragmenttabhostdemo.fragment.ItemFragement;
13 | import com.xujun.fragmenttabhostdemo.LUtils;
14 | import com.xujun.fragmenttabhostdemo.R;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class ThreeActivity extends AppCompatActivity {
20 |
21 | FrameLayout mFl;
22 | RadioGroup mRg;
23 | private FragmentManager mFragmentManager;
24 |
25 | private int position = 0;
26 |
27 | public static final String[] mTiltles = new String[]{
28 | "首页", "课程", "直播", "个人"
29 | };
30 | private List mFragments;
31 | private Fragment mCurFragment;
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_three);
37 | mFl = (FrameLayout) findViewById(R.id.fl);
38 | mRg = (RadioGroup) findViewById(R.id.rg);
39 | mFragments = new ArrayList<>();
40 | for (int i = 0; i < mTiltles.length; i++) {
41 | ItemFragement itemFragement = ItemFragement.newInstance(mTiltles[i]);
42 | mFragments.add(itemFragement);
43 | }
44 | mCurFragment = mFragments.get(position);
45 | replaceFragment(mCurFragment);
46 |
47 | ((RadioButton)mRg.getChildAt(position)).setChecked(true);
48 |
49 | initListener();
50 | }
51 |
52 | private void initListener() {
53 | mRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
54 |
55 | @Override
56 | public void onCheckedChanged(RadioGroup group, int checkedId) {
57 |
58 | RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
59 |
60 | if (false == radioButton.isChecked()) {
61 | return;
62 | }
63 |
64 |
65 | switch (checkedId) {
66 | case R.id.rb_home:
67 | position = 0;
68 | break;
69 |
70 | case R.id.rb_course:
71 | position = 1;
72 | break;
73 |
74 | case R.id.rb_direct_seeding:
75 | position = 2;
76 | break;
77 |
78 | case R.id.rb_me:
79 | position = 3;
80 | break;
81 | default:
82 | position = 0;
83 | break;
84 |
85 | }
86 | LUtils.i("position==" + position);
87 |
88 | Fragment to = mFragments.get(position);
89 | showFragment(mCurFragment, to);
90 | mCurFragment = to;
91 |
92 | }
93 |
94 | });
95 | }
96 |
97 | private void showFragment(Fragment from, Fragment to) {
98 | FragmentManager supportFragmentManager = getSupportFragmentManager();
99 | FragmentTransaction transaction = supportFragmentManager.beginTransaction();
100 | if (!to.isAdded()) { // 先判断是否被add过
101 | transaction.hide(from).add(R.id.fl, to).commit(); // 隐藏当前的fragment,add下一个到Activity中
102 | } else {
103 | transaction.hide(from).show(to).commit(); // 隐藏当前的fragment,显示下一个
104 | }
105 |
106 | }
107 |
108 | /**
109 | * 这个方法用老替换fragment
110 | * xujun
111 | * 2016/5/3 17:28.
112 | */
113 |
114 | private void replaceFragment(Fragment fragmeny) {
115 | FragmentManager supportFragmentManager = getSupportFragmentManager();
116 | FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
117 | fragmentTransaction.replace(R.id.fl, fragmeny).commit();
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/activity/FirstStyleActivity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.activity;
2 |
3 | import android.content.res.Resources;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentTabHost;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.ImageView;
10 | import android.widget.TabHost;
11 | import android.widget.TabWidget;
12 | import android.widget.TextView;
13 |
14 | import com.xujun.fragmenttabhostdemo.FragmentInfo;
15 | import com.xujun.fragmenttabhostdemo.MainFragmentFactory;
16 | import com.xujun.fragmenttabhostdemo.R;
17 |
18 | import java.util.List;
19 |
20 | public class FirstStyleActivity extends AppCompatActivity {
21 | FragmentTabHost mTabHost;
22 | private TabWidget mTabWidget;
23 | private List mFragmentEntities;
24 | private static final String TAG = "xujun";
25 | private static final String tag = "tag";
26 | public static final String[] mTiltles = new String[]{
27 | "首页", "课程", "直播", "个人"
28 | };
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_first_style);
34 | mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
35 |
36 | mTabHost.setup(this, getSupportFragmentManager(), R.id.main_layout_content);
37 | mTabWidget = mTabHost.getTabWidget();
38 | // 去掉分割线
39 | mTabWidget.setDividerDrawable(null);
40 | mFragmentEntities = MainFragmentFactory.getInstance().getList();
41 | initListener();
42 | initData();
43 |
44 |
45 | }
46 |
47 | private void initData() {
48 | int size = mFragmentEntities.size();
49 | for (int i = 0; i < size; i++) {
50 | Log.i(TAG, "size:=" + size);
51 | FragmentInfo fragmentInfo = mFragmentEntities.get(i);
52 | String title = fragmentInfo.getTitle();
53 | TabHost.TabSpec tabSpec = mTabHost.newTabSpec(title).setIndicator(getTabView
54 | (i));
55 | Bundle bundle = new Bundle();
56 | bundle.putString(tag, mTiltles[i]);
57 |
58 | mTabHost.addTab(tabSpec, fragmentInfo.getClz(), bundle);
59 | }
60 | updateTab(0);
61 | }
62 |
63 | private void initListener() {
64 | mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
65 | @Override
66 | public void onTabChanged(String tabId) {
67 | int currentTab = mTabHost.getCurrentTab();
68 | Log.i(TAG, "onTabChanged:currentTab:=" + currentTab);
69 | updateTab(currentTab);
70 | }
71 | });
72 | }
73 |
74 | private View getTabView(int i) {
75 | View view = View.inflate(this, R.layout.tab_layout, null);
76 | int currentTab = mTabHost.getCurrentTab();
77 | Log.i(TAG, "currentTab:=" + currentTab);
78 | setSingleView(view, currentTab, i);
79 | return view;
80 | }
81 |
82 | private void setSingleView(View view, int currentTab, int index) {
83 | FragmentInfo fragmentInfo = mFragmentEntities.get(index);
84 | int[] imagIds = fragmentInfo.getImagIds();
85 | int[] colors = fragmentInfo.getColors();
86 | TextView tv = (TextView) view.findViewById(R.id.tab_tv);
87 | ImageView iv = (ImageView) view.findViewById(R.id.tab_icon);
88 | tv.setText(fragmentInfo.getTitle());
89 | Resources resources = getResources();
90 | if (index == currentTab) {
91 |
92 | tv.setTextColor(resources.getColor(colors[1]));
93 | iv.setImageDrawable(resources.getDrawable(imagIds[1]));
94 | } else {
95 | tv.setTextColor(getResources().getColor(colors[0]));
96 | iv.setImageDrawable(resources.getDrawable(imagIds[0]));
97 | }
98 | }
99 |
100 | private void updateTab(int currentTab) {
101 |
102 | int childCount = mTabWidget.getChildCount();
103 | for (int i = 0; i < childCount; i++) {
104 | View view = mTabWidget.getChildTabViewAt(i);
105 | setSingleView(view, currentTab, i);
106 |
107 | }
108 |
109 |
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/activity/FourActivity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentTransaction;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.widget.FrameLayout;
9 | import android.widget.RadioButton;
10 | import android.widget.RadioGroup;
11 |
12 | import com.xujun.fragmenttabhostdemo.CourseFragment;
13 | import com.xujun.fragmenttabhostdemo.LUtils;
14 | import com.xujun.fragmenttabhostdemo.R;
15 | import com.xujun.fragmenttabhostdemo.fragment.ItemFragement;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | public class FourActivity extends AppCompatActivity {
21 |
22 | FrameLayout mFl;
23 | RadioGroup mRg;
24 | private FragmentManager mFragmentManager;
25 |
26 | private int position = 0;
27 |
28 | public static final String[] mTiltles = new String[]{
29 | "首页", "课程", "直播", "个人"
30 | };
31 | private List mFragments;
32 | private Fragment mCurFragment;
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_three);
38 | mFl = (FrameLayout) findViewById(R.id.fl);
39 | mRg = (RadioGroup) findViewById(R.id.rg);
40 | mFragments = new ArrayList<>();
41 | for (int i = 0; i < mTiltles.length; i++) {
42 |
43 | if(i==1){
44 | CourseFragment courseFragment = new CourseFragment();
45 | mFragments.add(courseFragment);
46 | }else{
47 | ItemFragement itemFragement = ItemFragement.newInstance(mTiltles[i]);
48 | mFragments.add(itemFragement);
49 | }
50 |
51 | }
52 | mCurFragment = mFragments.get(position);
53 | replaceFragment(mCurFragment);
54 |
55 | ((RadioButton)mRg.getChildAt(position)).setChecked(true);
56 |
57 | initListener();
58 | }
59 |
60 | private void initListener() {
61 | mRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
62 |
63 | @Override
64 | public void onCheckedChanged(RadioGroup group, int checkedId) {
65 |
66 | RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
67 |
68 | if (false == radioButton.isChecked()) {
69 | return;
70 | }
71 |
72 |
73 | switch (checkedId) {
74 | case R.id.rb_home:
75 | position = 0;
76 | break;
77 |
78 | case R.id.rb_course:
79 | position = 1;
80 | break;
81 |
82 | case R.id.rb_direct_seeding:
83 | position = 2;
84 | break;
85 |
86 | case R.id.rb_me:
87 | position = 3;
88 | break;
89 | default:
90 | position = 0;
91 | break;
92 |
93 | }
94 | LUtils.i("position==" + position);
95 |
96 | Fragment to = mFragments.get(position);
97 | showFragment(mCurFragment, to);
98 | mCurFragment = to;
99 |
100 | }
101 |
102 | });
103 | }
104 |
105 | private void showFragment(Fragment from, Fragment to) {
106 | FragmentManager supportFragmentManager = getSupportFragmentManager();
107 | FragmentTransaction transaction = supportFragmentManager.beginTransaction();
108 | if (!to.isAdded()) { // 先判断是否被add过
109 | transaction.hide(from).add(R.id.fl, to).commit(); // 隐藏当前的fragment,add下一个到Activity中
110 | } else {
111 | transaction.hide(from).show(to).commit(); // 隐藏当前的fragment,显示下一个
112 | }
113 |
114 | }
115 |
116 | /**
117 | * 这个方法用老替换fragment
118 | * xujun
119 | * 2016/5/3 17:28.
120 | */
121 |
122 | private void replaceFragment(Fragment fragmeny) {
123 | FragmentManager supportFragmentManager = getSupportFragmentManager();
124 | FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
125 | fragmentTransaction.replace(R.id.fl, fragmeny).commit();
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/Wechat/src/main/java/star/yx/test/BaseRecyclerViewAdapter.java:
--------------------------------------------------------------------------------
1 | package star.yx.test;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.util.SparseArray;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.Button;
9 | import android.widget.ImageView;
10 | import android.widget.RelativeLayout;
11 | import android.widget.TextView;
12 |
13 | /**
14 | * Created by Administrator on 2016/10/23 0023.
15 | */
16 |
17 | public abstract class BaseRecyclerViewAdapter extends RecyclerView.Adapter {
18 | private int mResourceId;
19 | private BaseRecyclerViewAdapter.OnItemClickListener mItemClickListener;
20 | private BaseRecyclerViewAdapter.OnItemLongClickListener mItemLongClickListener;
21 |
22 | public BaseRecyclerViewAdapter(int resourceId) {
23 | this.mResourceId = resourceId;
24 | }
25 |
26 | public android.support.v7.widget.RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
27 | View itemView = LayoutInflater.from(parent.getContext()).inflate(this.mResourceId, parent, false);
28 | return new BaseRecyclerViewAdapter.ViewHolder(itemView);
29 | }
30 |
31 | public void onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder holder, final int position) {
32 | if(this.mItemClickListener != null) {
33 | holder.itemView.setOnClickListener(new View.OnClickListener() {
34 | public void onClick(View v) {
35 | BaseRecyclerViewAdapter.this.mItemClickListener.onItemClick(v, position);
36 | }
37 | });
38 | }
39 |
40 | if(this.mItemLongClickListener != null) {
41 | holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
42 | public boolean onLongClick(View v) {
43 | BaseRecyclerViewAdapter.this.mItemLongClickListener.onItemLongClick(v, position);
44 | return false;
45 | }
46 | });
47 | }
48 |
49 | this.onBindViewData((BaseRecyclerViewAdapter.ViewHolder)holder, position);
50 | }
51 |
52 | public Object getItemData(int position) {
53 | return null;
54 | }
55 |
56 | public BaseRecyclerViewAdapter.OnItemClickListener getItemClickListener() {
57 | return this.mItemClickListener;
58 | }
59 |
60 | public void setItemClickListener(BaseRecyclerViewAdapter.OnItemClickListener clickListener) {
61 | this.mItemClickListener = clickListener;
62 | }
63 |
64 | public BaseRecyclerViewAdapter.OnItemLongClickListener getItemLongClickListener() {
65 | return this.mItemLongClickListener;
66 | }
67 |
68 | public void setItemLongClickListener(BaseRecyclerViewAdapter.OnItemLongClickListener longClickListener) {
69 | this.mItemLongClickListener = longClickListener;
70 | }
71 |
72 | public abstract void onBindViewData(BaseRecyclerViewAdapter.ViewHolder var1, int var2);
73 |
74 | public static final class ViewHolder extends android.support.v7.widget.RecyclerView.ViewHolder {
75 | private SparseArray viewArray;
76 |
77 | public ViewHolder(View itemView) {
78 | super(itemView);
79 | }
80 |
81 | public V getView(int id) {
82 | return (V) this.findView(id);
83 | }
84 |
85 | public TextView getTextView(int id) {
86 | return (TextView)this.getView(id);
87 | }
88 |
89 | public Button getButton(int id) {
90 | return (Button)this.getView(id);
91 | }
92 |
93 | public ImageView getImageView(int id) {
94 | return (ImageView)this.getView(id);
95 | }
96 |
97 | public RelativeLayout getRelativeLayout(int id) {
98 | return (RelativeLayout)this.getView(id);
99 | }
100 |
101 | private View findView(int id) {
102 | if(this.viewArray == null) {
103 | this.viewArray = new SparseArray();
104 | }
105 |
106 | View view = (View)this.viewArray.get(id);
107 | if(view == null) {
108 | view = this.itemView.findViewById(id);
109 | this.viewArray.put(id, view);
110 | }
111 |
112 | return view;
113 | }
114 | }
115 |
116 | public interface OnItemLongClickListener {
117 | void onItemLongClick(View var1, int var2);
118 | }
119 |
120 | public interface OnItemClickListener {
121 | void onItemClick(View var1, int var2);
122 | }
123 | }
124 |
125 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/base/HeaderAndFooterWrapper.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.base;
2 |
3 | import android.support.v4.util.SparseArrayCompat;
4 | import android.support.v7.widget.GridLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * Created by zhy on 16/6/23.
11 | */
12 | public class HeaderAndFooterWrapper extends RecyclerView.Adapter {
13 | private static final int BASE_ITEM_TYPE_HEADER = 100000;
14 | private static final int BASE_ITEM_TYPE_FOOTER = 200000;
15 |
16 | private SparseArrayCompat mHeaderViews = new SparseArrayCompat<>();
17 | private SparseArrayCompat mFootViews = new SparseArrayCompat<>();
18 |
19 | private RecyclerView.Adapter mInnerAdapter;
20 |
21 | public HeaderAndFooterWrapper(RecyclerView.Adapter adapter) {
22 | mInnerAdapter = adapter;
23 | }
24 |
25 | @Override
26 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
27 | if (mHeaderViews.get(viewType) != null) {
28 | ViewHolder holder = ViewHolder.createViewHolder(parent.getContext(), mHeaderViews.get
29 | (viewType));
30 | return holder;
31 |
32 | } else if (mFootViews.get(viewType) != null) {
33 | ViewHolder holder = ViewHolder.createViewHolder(parent.getContext(), mFootViews.get
34 | (viewType));
35 | return holder;
36 | }
37 | return mInnerAdapter.onCreateViewHolder(parent, viewType);
38 | }
39 |
40 | @Override
41 | public int getItemViewType(int position) {
42 | if (isHeaderViewPos(position)) {
43 | return mHeaderViews.keyAt(position);
44 | } else if (isFooterViewPos(position)) {
45 | return mFootViews.keyAt(position - getHeadersCount() - getRealItemCount());
46 | }
47 | return mInnerAdapter.getItemViewType(position - getHeadersCount());
48 | }
49 |
50 | private int getRealItemCount() {
51 | return mInnerAdapter.getItemCount();
52 | }
53 |
54 | @Override
55 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
56 | if (isHeaderViewPos(position)) {
57 | return;
58 | }
59 | if (isFooterViewPos(position)) {
60 | return;
61 | }
62 | mInnerAdapter.onBindViewHolder(holder, position - getHeadersCount());
63 | }
64 |
65 | @Override
66 | public int getItemCount() {
67 | return getHeadersCount() + getFootersCount() + getRealItemCount();
68 | }
69 |
70 | @Override
71 | public void onAttachedToRecyclerView(RecyclerView recyclerView) {
72 | WrapperUtils.onAttachedToRecyclerView(mInnerAdapter, recyclerView, new WrapperUtils
73 | .SpanSizeCallback() {
74 | @Override
75 | public int getSpanSize(GridLayoutManager layoutManager, GridLayoutManager
76 | .SpanSizeLookup oldLookup, int position) {
77 | int viewType = getItemViewType(position);
78 | if (mHeaderViews.get(viewType) != null) {
79 | return layoutManager.getSpanCount();
80 | } else if (mFootViews.get(viewType) != null) {
81 | return layoutManager.getSpanCount();
82 | }
83 | if (oldLookup != null)
84 | return oldLookup.getSpanSize(position);
85 | return 1;
86 | }
87 | });
88 | }
89 |
90 | @Override
91 | public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
92 | mInnerAdapter.onViewAttachedToWindow(holder);
93 | int position = holder.getLayoutPosition();
94 | if (isHeaderViewPos(position) || isFooterViewPos(position)) {
95 | WrapperUtils.setFullSpan(holder);
96 | }
97 | }
98 |
99 | private boolean isHeaderViewPos(int position) {
100 | return position < getHeadersCount();
101 | }
102 |
103 | private boolean isFooterViewPos(int position) {
104 | return position >= getHeadersCount() + getRealItemCount();
105 | }
106 |
107 | public void addHeaderView(View view) {
108 | mHeaderViews.put(mHeaderViews.size() + BASE_ITEM_TYPE_HEADER, view);
109 | }
110 |
111 | public void addFootView(View view) {
112 | mFootViews.put(mFootViews.size() + BASE_ITEM_TYPE_FOOTER, view);
113 | }
114 |
115 | public int getHeadersCount() {
116 | return mHeaderViews.size();
117 | }
118 |
119 | public int getFootersCount() {
120 | return mFootViews.size();
121 | }
122 |
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/fragment/CourseListFragment.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.widget.SwipeRefreshLayout;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.TextView;
13 |
14 | import com.xujun.fragmenttabhostdemo.LUtils;
15 | import com.xujun.fragmenttabhostdemo.R;
16 | import com.xujun.fragmenttabhostdemo.adapter.StringAdapter;
17 | import com.xujun.fragmenttabhostdemo.base.BasePageFragment;
18 | import com.xujun.fragmenttabhostdemo.base.EndlessRecyclerOnScrollListener;
19 |
20 | import java.util.ArrayList;
21 |
22 | /**
23 | * @author xujun on 2016/12/26.
24 | * @email gdutxiaoxu@163.com
25 | */
26 |
27 | public class CourseListFragment extends BasePageFragment {
28 |
29 | public static final String KEY_TITLE="key_title";
30 | public static final String KEY_POSITION="key_position";
31 | private String mTitle="";
32 | private int mPosition=-1;
33 |
34 | private SwipeRefreshLayout swipeRefreshLayout;
35 | private RecyclerView mRecyclerView;
36 |
37 | TextView tvContent;
38 | private ArrayList mList;
39 | private StringAdapter mAdapter;
40 | private EndlessRecyclerOnScrollListener mListener;
41 |
42 | @Override
43 | public void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | Bundle arguments = getArguments();
46 | mTitle = arguments.getString(KEY_TITLE);
47 | mPosition = arguments.getInt(KEY_POSITION);
48 | LUtils.i(getClass().getSimpleName() + ">>>>>>>>>>> onCreate mPosition=" +mPosition);
49 | }
50 |
51 | public static CourseListFragment newInstance(String title, int position){
52 | CourseListFragment courseListFragment = new CourseListFragment();
53 | Bundle bundle = new Bundle();
54 | bundle.putString(KEY_TITLE,title);
55 | bundle.putInt(KEY_POSITION,position);
56 | courseListFragment.setArguments(bundle);
57 | return courseListFragment;
58 | }
59 | @Override
60 | protected void initView(View view) {
61 |
62 | swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
63 | mRecyclerView =(RecyclerView) view.findViewById(R.id.recyclerView);
64 | }
65 |
66 | @Override
67 | protected void initData() {
68 | LinearLayoutManager layout = new LinearLayoutManager(mContext);
69 | swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
70 | @Override
71 | public void onRefresh() {
72 | refreshData();
73 | }
74 |
75 |
76 | });
77 | mListener = new EndlessRecyclerOnScrollListener(layout) {
78 | @Override
79 | public void onLoadMore(int current_page) {
80 | Log.i(TAG, "onLoadMore: current_page=" + current_page);
81 | loadMore();
82 | }
83 | };
84 | mRecyclerView.addOnScrollListener(mListener);
85 | super.initData();
86 | mList = new ArrayList<>();
87 |
88 | for(int i = 0; i< 20; i++){
89 | mList.add("I am "+i+" Item");
90 | }
91 | mAdapter = new StringAdapter(mContext, mList);
92 |
93 | mRecyclerView.setLayoutManager(layout);
94 | mRecyclerView.setAdapter(mAdapter);
95 |
96 |
97 | }
98 |
99 | private void refreshData() {
100 | Runnable runnable = new Runnable() {
101 |
102 | @Override
103 | public void run() {
104 | try {
105 | Thread.sleep(2000);
106 | } catch (InterruptedException e) {
107 | e.printStackTrace();
108 | }
109 | if(mList==null){
110 | mList=new ArrayList();
111 | }
112 | mList.clear();
113 | int start=mList.size();
114 | int end=start+20;
115 | for(int i=start;i();
147 | }
148 | int start=mList.size();
149 | int end=start+20;
150 | for(int i=start;i mViews;
27 | private View mConvertView;
28 | Context mContext;
29 |
30 |
31 |
32 | public BaseRecyclerHolder(View itemView,Context context) {
33 | super(itemView);
34 | mContext=context;
35 | mConvertView = itemView;
36 | mViews = new SparseArray<>();
37 | mConvertView.setTag(this);
38 | }
39 |
40 | public static BaseRecyclerHolder createViewHolder(View itemView) {
41 | return createViewHolder(itemView.getContext(),itemView);
42 | }
43 |
44 | public static BaseRecyclerHolder createViewHolder(Context context,View itemView) {
45 |
46 | BaseRecyclerHolder holder = new BaseRecyclerHolder(itemView,context);
47 | return holder;
48 | }
49 |
50 | public static BaseRecyclerHolder createViewHolder(Context context,ViewGroup parent, int layoutId) {
51 | View itemView = View.inflate(context,layoutId,null);
52 |
53 | return createViewHolder(context,itemView);
54 | }
55 |
56 | /**
57 | * 通过viewId获取控件
58 | */
59 | public T getView(int viewId) {
60 | View view = mViews.get(viewId);
61 | if (view == null) {
62 | view = mConvertView.findViewById(viewId);
63 | mViews.put(viewId, view);
64 | }
65 | return (T) view;
66 | }
67 |
68 | public View getConvertView() {
69 | return mConvertView;
70 | }
71 |
72 | /**
73 | * 设置TextView的值
74 | */
75 | public BaseRecyclerHolder setText(int viewId, String text) {
76 | TextView tv = getView(viewId);
77 | tv.setText(text);
78 | return this;
79 | }
80 |
81 | public BaseRecyclerHolder setImageResource(int viewId, int resId) {
82 | ImageView view = getView(viewId);
83 | view.setImageResource(resId);
84 | return this;
85 | }
86 |
87 | public BaseRecyclerHolder setImageBitmap(int viewId, Bitmap bitmap) {
88 | ImageView view = getView(viewId);
89 | view.setImageBitmap(bitmap);
90 | return this;
91 | }
92 |
93 | public BaseRecyclerHolder setImageDrawable(int viewId, Drawable drawable) {
94 | ImageView view = getView(viewId);
95 | view.setImageDrawable(drawable);
96 | return this;
97 | }
98 |
99 | public BaseRecyclerHolder setBackgroundColor(int viewId, int color) {
100 | View view = getView(viewId);
101 | view.setBackgroundColor(color);
102 | return this;
103 | }
104 |
105 | public BaseRecyclerHolder setBackgroundRes(int viewId, int backgroundRes) {
106 | View view = getView(viewId);
107 | view.setBackgroundResource(backgroundRes);
108 | return this;
109 | }
110 |
111 | public BaseRecyclerHolder setTextColor(int viewId, int textColor) {
112 | TextView view = getView(viewId);
113 | view.setTextColor(textColor);
114 | return this;
115 | }
116 |
117 | @SuppressLint("NewApi")
118 | public BaseRecyclerHolder setAlpha(int viewId, float value) {
119 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
120 | getView(viewId).setAlpha(value);
121 | } else {
122 | // Pre-honeycomb hack to set Alpha value
123 | AlphaAnimation alpha = new AlphaAnimation(value, value);
124 | alpha.setDuration(0);
125 | alpha.setFillAfter(true);
126 | getView(viewId).startAnimation(alpha);
127 | }
128 | return this;
129 | }
130 |
131 | public BaseRecyclerHolder setVisible(int viewId, boolean visible) {
132 | View view = getView(viewId);
133 | view.setVisibility(visible ? View.VISIBLE : View.GONE);
134 | return this;
135 | }
136 |
137 | public BaseRecyclerHolder linkify(int viewId) {
138 | TextView view = getView(viewId);
139 | Linkify.addLinks(view, Linkify.ALL);
140 | return this;
141 | }
142 |
143 | public BaseRecyclerHolder setTypeface(Typeface typeface, int... viewIds) {
144 | for (int viewId : viewIds) {
145 | TextView view = getView(viewId);
146 | view.setTypeface(typeface);
147 | view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
148 | }
149 | return this;
150 | }
151 |
152 | public BaseRecyclerHolder setProgress(int viewId, int progress) {
153 | ProgressBar view = getView(viewId);
154 | view.setProgress(progress);
155 | return this;
156 | }
157 |
158 | public BaseRecyclerHolder setProgress(int viewId, int progress, int max) {
159 | ProgressBar view = getView(viewId);
160 | view.setMax(max);
161 | view.setProgress(progress);
162 | return this;
163 | }
164 |
165 | public BaseRecyclerHolder setMax(int viewId, int max) {
166 | ProgressBar view = getView(viewId);
167 | view.setMax(max);
168 | return this;
169 | }
170 |
171 | public BaseRecyclerHolder setTag(int viewId, Object tag) {
172 | View view = getView(viewId);
173 | view.setTag(tag);
174 | return this;
175 | }
176 |
177 | public BaseRecyclerHolder setTag(int viewId, int key, Object tag) {
178 | View view = getView(viewId);
179 | view.setTag(key, tag);
180 | return this;
181 | }
182 |
183 | public BaseRecyclerHolder setChecked(int viewId, boolean checked) {
184 | Checkable view = getView(viewId);
185 | view.setChecked(checked);
186 | return this;
187 | }
188 |
189 | /**
190 | * 关于事件的
191 | */
192 | public BaseRecyclerHolder setOnClickListener(int viewId, View.OnClickListener listener) {
193 | View view = getView(viewId);
194 | view.setOnClickListener(listener);
195 | return this;
196 | }
197 |
198 | public BaseRecyclerHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
199 | View view = getView(viewId);
200 | view.setOnTouchListener(listener);
201 | return this;
202 | }
203 |
204 | public BaseRecyclerHolder setOnLongClickListener(int viewId, View.OnLongClickListener
205 | listener) {
206 | View view = getView(viewId);
207 | view.setOnLongClickListener(listener);
208 | return this;
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/QQBottomTab/src/main/java/com/xujun/fragmenttabhostdemo/fragment/CourseListFragmentWithHeadView.java:
--------------------------------------------------------------------------------
1 | package com.xujun.fragmenttabhostdemo.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 |
14 | import com.xujun.fragmenttabhostdemo.LUtils;
15 | import com.xujun.fragmenttabhostdemo.R;
16 | import com.xujun.fragmenttabhostdemo.adapter.StringAdapter;
17 | import com.xujun.fragmenttabhostdemo.base.BasePageFragment;
18 | import com.xujun.fragmenttabhostdemo.base.EndlessRecyclerOnScrollListener;
19 | import com.xujun.fragmenttabhostdemo.base.HeaderAndFooterWrapper;
20 | import com.xujun.fragmenttabhostdemo.widget.CarouselView;
21 | import com.xujun.fragmenttabhostdemo.widget.ConvertUtils;
22 |
23 | import java.util.ArrayList;
24 |
25 | /**
26 | * @author xujun on 2016/12/26.
27 | * @email gdutxiaoxu@163.com
28 | */
29 |
30 | public class CourseListFragmentWithHeadView extends BasePageFragment {
31 |
32 | public static final String KEY_TITLE="key_title";
33 | public static final String KEY_POSITION="key_position";
34 | private String mTitle="";
35 | private int mPosition=-1;
36 |
37 | private SwipeRefreshLayout swipeRefreshLayout;
38 | private RecyclerView mRecyclerView;
39 |
40 | TextView tvContent;
41 | private ArrayList mList;
42 | private StringAdapter mAdapter;
43 | private EndlessRecyclerOnScrollListener mListener;
44 | private HeaderAndFooterWrapper mHeaderAndFooterWrapper;
45 |
46 | private int[] mImagesSrc = {
47 | R.mipmap.img1,
48 | R.mipmap.img2,
49 | R.mipmap.img3,
50 | R.mipmap.img4,
51 | R.mipmap.img5
52 | };
53 |
54 | @Override
55 | public void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | Bundle arguments = getArguments();
58 | mTitle = arguments.getString(KEY_TITLE);
59 | mPosition = arguments.getInt(KEY_POSITION);
60 | LUtils.i(getClass().getSimpleName() + ">>>>>>>>>>> onCreate mPosition=" +mPosition);
61 | }
62 |
63 | public static CourseListFragmentWithHeadView newInstance(String title, int position){
64 | CourseListFragmentWithHeadView courseListFragment = new CourseListFragmentWithHeadView();
65 | Bundle bundle = new Bundle();
66 | bundle.putString(KEY_TITLE,title);
67 | bundle.putInt(KEY_POSITION,position);
68 | courseListFragment.setArguments(bundle);
69 | return courseListFragment;
70 | }
71 | @Override
72 | protected void initView(View view) {
73 |
74 | swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
75 | mRecyclerView =(RecyclerView) view.findViewById(R.id.recyclerView);
76 | }
77 |
78 | @Override
79 | protected void initData() {
80 | LinearLayoutManager layout = new LinearLayoutManager(mContext);
81 | swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
82 | @Override
83 | public void onRefresh() {
84 | refreshData();
85 | }
86 |
87 |
88 | });
89 | mListener = new EndlessRecyclerOnScrollListener(layout) {
90 | @Override
91 | public void onLoadMore(int current_page) {
92 | Log.i(TAG, "onLoadMore: current_page=" + current_page);
93 | loadMore();
94 | }
95 | };
96 | mRecyclerView.addOnScrollListener(mListener);
97 | super.initData();
98 | mList = new ArrayList<>();
99 |
100 | for(int i = 0; i< 20; i++){
101 | mList.add("I am "+i+" Item");
102 | }
103 | mAdapter = new StringAdapter(mContext, mList);
104 | mHeaderAndFooterWrapper = new HeaderAndFooterWrapper<>(mAdapter);
105 | View headView = View.inflate(mContext, R.layout.head_view, null);
106 | mHeaderAndFooterWrapper.addHeaderView(headView);
107 | CarouselView carouselView = (CarouselView)headView.findViewById(R.id.CarouselView);
108 | carouselView.setAdapter(new CarouselView.Adapter() {
109 | @Override
110 | public boolean isEmpty() {
111 | return false;
112 | }
113 |
114 | @Override
115 | public View getView(int position) {
116 | ImageView imageView = new ImageView(mContext);
117 | imageView.setImageResource(mImagesSrc[position]);
118 | return imageView;
119 | }
120 |
121 | @Override
122 | public int getCount() {
123 | return mImagesSrc.length;
124 | }
125 | });
126 | carouselView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
127 | ConvertUtils.dip2px(mContext,200)));
128 | mRecyclerView.setLayoutManager(layout);
129 | mRecyclerView.setAdapter(mHeaderAndFooterWrapper);
130 |
131 |
132 | }
133 |
134 | private void refreshData() {
135 | Runnable runnable = new Runnable() {
136 |
137 | @Override
138 | public void run() {
139 | try {
140 | Thread.sleep(2000);
141 | } catch (InterruptedException e) {
142 | e.printStackTrace();
143 | }
144 | if(mList==null){
145 | mList=new ArrayList();
146 | }
147 | mList.clear();
148 | int start=mList.size();
149 | int end=start+20;
150 | for(int i=start;i();
182 | }
183 | int start=mList.size();
184 | int end=start+20;
185 | for(int i=start;i