├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── answer.gif ├── app ├── .gitignore ├── build.gradle ├── libs │ └── fastjson-1.2.9.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── zhangyipeng │ │ └── anwerdemo │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── anwer.json │ │ └── course.json │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── zhangyipeng │ │ │ └── anwerdemo │ │ │ ├── AnswerReadActivity.java │ │ │ ├── AnwerActivity.java │ │ │ ├── CourseActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── ReadActivity.java │ │ │ ├── adapter │ │ │ ├── AnimalsAdapter.java │ │ │ ├── AnimalsHeadersAdapter.java │ │ │ ├── CourseAdapter.java │ │ │ ├── DividerDecoration.java │ │ │ ├── LayoutAdapter.java │ │ │ └── TopicAdapter.java │ │ │ ├── bean │ │ │ ├── AnwerInfo.java │ │ │ ├── BaseInfo.java │ │ │ ├── CourseSheetInfo.java │ │ │ ├── QuestionEntry.java │ │ │ └── QuestionList.java │ │ │ ├── fragment │ │ │ └── ReadFragment.java │ │ │ ├── listener │ │ │ └── RecyclerItemClickListener.java │ │ │ └── view │ │ │ ├── FixedSpeedScroller.java │ │ │ ├── FlipperLayout.java │ │ │ ├── MoveLinearLayout.java │ │ │ └── ReaderViewPager.java │ └── res │ │ ├── drawable │ │ ├── bg_shadow.xml │ │ ├── bg_topic.xml │ │ ├── bg_topic_no.xml │ │ ├── bg_topic_ok.xml │ │ └── shadow_right.png │ │ ├── layout │ │ ├── activity_anwer.xml │ │ ├── activity_anwers_read.xml │ │ ├── activity_course.xml │ │ ├── activity_main.xml │ │ ├── activity_read.xml │ │ ├── anwer_item.xml │ │ ├── course_item.xml │ │ ├── course_text.xml │ │ ├── fragment_read.xml │ │ ├── head_item.xml │ │ ├── item.xml │ │ └── item_topic.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── shadow_left.png │ │ └── shadow_right.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ ├── app.png │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── zhangyipeng │ └── anwerdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── lsjwzh │ │ └── widget │ │ └── recyclerviewpager │ │ ├── FragmentStatePagerAdapter.java │ │ ├── LoopRecyclerViewPager.java │ │ ├── LoopRecyclerViewPagerAdapter.java │ │ ├── RecyclerViewPager.java │ │ ├── RecyclerViewPagerAdapter.java │ │ └── ViewUtils.java │ └── res │ ├── layout │ └── rvp_fragment_container.xml │ └── values │ └── attrs.xml ├── library ├── build.gradle ├── build │ ├── generated │ │ └── source │ │ │ ├── buildConfig │ │ │ ├── androidTest │ │ │ │ └── debug │ │ │ │ │ └── com │ │ │ │ │ └── sothree │ │ │ │ │ └── slidinguppanel │ │ │ │ │ └── library │ │ │ │ │ └── test │ │ │ │ │ └── BuildConfig.java │ │ │ ├── debug │ │ │ │ └── com │ │ │ │ │ └── sothree │ │ │ │ │ └── slidinguppanel │ │ │ │ │ └── library │ │ │ │ │ └── BuildConfig.java │ │ │ └── release │ │ │ │ └── com │ │ │ │ └── sothree │ │ │ │ └── slidinguppanel │ │ │ │ └── library │ │ │ │ └── BuildConfig.java │ │ │ └── r │ │ │ ├── androidTest │ │ │ └── debug │ │ │ │ ├── android │ │ │ │ └── support │ │ │ │ │ └── v7 │ │ │ │ │ └── recyclerview │ │ │ │ │ └── R.java │ │ │ │ └── com │ │ │ │ └── sothree │ │ │ │ └── slidinguppanel │ │ │ │ └── library │ │ │ │ ├── R.java │ │ │ │ └── test │ │ │ │ └── R.java │ │ │ ├── debug │ │ │ ├── android │ │ │ │ └── support │ │ │ │ │ └── v7 │ │ │ │ │ └── recyclerview │ │ │ │ │ └── R.java │ │ │ └── com │ │ │ │ └── sothree │ │ │ │ └── slidinguppanel │ │ │ │ └── library │ │ │ │ └── R.java │ │ │ └── release │ │ │ ├── android │ │ │ └── support │ │ │ │ └── v7 │ │ │ │ └── recyclerview │ │ │ │ └── R.java │ │ │ └── com │ │ │ └── sothree │ │ │ └── slidinguppanel │ │ │ └── library │ │ │ └── R.java │ ├── intermediates │ │ ├── blame │ │ │ └── res │ │ │ │ ├── androidTest │ │ │ │ └── debug │ │ │ │ │ ├── multi │ │ │ │ │ └── values.json │ │ │ │ │ └── single │ │ │ │ │ └── drawable.json │ │ │ │ ├── debug │ │ │ │ ├── multi │ │ │ │ │ └── values.json │ │ │ │ └── single │ │ │ │ │ └── drawable.json │ │ │ │ └── release │ │ │ │ ├── multi │ │ │ │ └── values.json │ │ │ │ └── single │ │ │ │ └── drawable.json │ │ ├── bundles │ │ │ ├── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── R.txt │ │ │ │ ├── aapt │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ ├── classes.jar │ │ │ │ └── res │ │ │ │ │ ├── drawable │ │ │ │ │ ├── above_shadow.xml │ │ │ │ │ └── below_shadow.xml │ │ │ │ │ └── values │ │ │ │ │ └── values.xml │ │ │ └── release │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── R.txt │ │ │ │ ├── aapt │ │ │ │ └── AndroidManifest.xml │ │ │ │ ├── classes.jar │ │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ ├── above_shadow.xml │ │ │ │ └── below_shadow.xml │ │ │ │ └── values │ │ │ │ └── values.xml │ │ ├── classes │ │ │ ├── androidTest │ │ │ │ └── debug │ │ │ │ │ ├── android │ │ │ │ │ └── support │ │ │ │ │ │ └── v7 │ │ │ │ │ │ └── recyclerview │ │ │ │ │ │ ├── R$attr.class │ │ │ │ │ │ ├── R$dimen.class │ │ │ │ │ │ ├── R$id.class │ │ │ │ │ │ ├── R$styleable.class │ │ │ │ │ │ └── R.class │ │ │ │ │ └── com │ │ │ │ │ └── sothree │ │ │ │ │ └── slidinguppanel │ │ │ │ │ └── library │ │ │ │ │ ├── R$attr.class │ │ │ │ │ ├── R$dimen.class │ │ │ │ │ ├── R$drawable.class │ │ │ │ │ ├── R$id.class │ │ │ │ │ ├── R$styleable.class │ │ │ │ │ ├── R.class │ │ │ │ │ └── test │ │ │ │ │ ├── BuildConfig.class │ │ │ │ │ ├── R$attr.class │ │ │ │ │ ├── R$dimen.class │ │ │ │ │ ├── R$drawable.class │ │ │ │ │ ├── R$id.class │ │ │ │ │ ├── R$styleable.class │ │ │ │ │ └── R.class │ │ │ ├── debug │ │ │ │ ├── android │ │ │ │ │ └── support │ │ │ │ │ │ └── v7 │ │ │ │ │ │ └── recyclerview │ │ │ │ │ │ ├── R$attr.class │ │ │ │ │ │ ├── R$dimen.class │ │ │ │ │ │ ├── R$id.class │ │ │ │ │ │ ├── R$styleable.class │ │ │ │ │ │ └── R.class │ │ │ │ └── com │ │ │ │ │ └── sothree │ │ │ │ │ └── slidinguppanel │ │ │ │ │ ├── ScrollableViewHelper.class │ │ │ │ │ ├── SlidingUpPanelLayout$1.class │ │ │ │ │ ├── SlidingUpPanelLayout$2.class │ │ │ │ │ ├── SlidingUpPanelLayout$DragHelperCallback.class │ │ │ │ │ ├── SlidingUpPanelLayout$LayoutParams.class │ │ │ │ │ ├── SlidingUpPanelLayout$PanelSlideListener.class │ │ │ │ │ ├── SlidingUpPanelLayout$PanelState.class │ │ │ │ │ ├── SlidingUpPanelLayout$SavedState$1.class │ │ │ │ │ ├── SlidingUpPanelLayout$SavedState.class │ │ │ │ │ ├── SlidingUpPanelLayout$SimplePanelSlideListener.class │ │ │ │ │ ├── SlidingUpPanelLayout.class │ │ │ │ │ ├── ViewDragHelper$1.class │ │ │ │ │ ├── ViewDragHelper$2.class │ │ │ │ │ ├── ViewDragHelper$Callback.class │ │ │ │ │ ├── ViewDragHelper.class │ │ │ │ │ └── library │ │ │ │ │ ├── BuildConfig.class │ │ │ │ │ ├── R$attr.class │ │ │ │ │ ├── R$dimen.class │ │ │ │ │ ├── R$drawable.class │ │ │ │ │ ├── R$id.class │ │ │ │ │ ├── R$styleable.class │ │ │ │ │ └── R.class │ │ │ └── release │ │ │ │ ├── android │ │ │ │ └── support │ │ │ │ │ └── v7 │ │ │ │ │ └── recyclerview │ │ │ │ │ ├── R$attr.class │ │ │ │ │ ├── R$dimen.class │ │ │ │ │ ├── R$id.class │ │ │ │ │ ├── R$styleable.class │ │ │ │ │ └── R.class │ │ │ │ └── com │ │ │ │ └── sothree │ │ │ │ └── slidinguppanel │ │ │ │ ├── ScrollableViewHelper.class │ │ │ │ ├── SlidingUpPanelLayout$1.class │ │ │ │ ├── SlidingUpPanelLayout$2.class │ │ │ │ ├── SlidingUpPanelLayout$DragHelperCallback.class │ │ │ │ ├── SlidingUpPanelLayout$LayoutParams.class │ │ │ │ ├── SlidingUpPanelLayout$PanelSlideListener.class │ │ │ │ ├── SlidingUpPanelLayout$PanelState.class │ │ │ │ ├── SlidingUpPanelLayout$SavedState$1.class │ │ │ │ ├── SlidingUpPanelLayout$SavedState.class │ │ │ │ ├── SlidingUpPanelLayout$SimplePanelSlideListener.class │ │ │ │ ├── SlidingUpPanelLayout.class │ │ │ │ ├── ViewDragHelper$1.class │ │ │ │ ├── ViewDragHelper$2.class │ │ │ │ ├── ViewDragHelper$Callback.class │ │ │ │ ├── ViewDragHelper.class │ │ │ │ └── library │ │ │ │ ├── BuildConfig.class │ │ │ │ ├── R$attr.class │ │ │ │ ├── R$dimen.class │ │ │ │ ├── R$drawable.class │ │ │ │ ├── R$id.class │ │ │ │ ├── R$styleable.class │ │ │ │ └── R.class │ │ ├── exploded-aar │ │ │ └── com.android.support │ │ │ │ ├── recyclerview-v7 │ │ │ │ └── 23.1.1 │ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ │ ├── R.txt │ │ │ │ │ ├── aapt │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ ├── annotations.zip │ │ │ │ │ ├── jars │ │ │ │ │ └── classes.jar │ │ │ │ │ └── res │ │ │ │ │ └── values │ │ │ │ │ └── values.xml │ │ │ │ └── support-v4 │ │ │ │ └── 23.1.1 │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── aapt │ │ │ │ └── AndroidManifest.xml │ │ │ │ ├── aidl │ │ │ │ └── android │ │ │ │ │ └── support │ │ │ │ │ └── v4 │ │ │ │ │ ├── media │ │ │ │ │ ├── MediaMetadataCompat.aidl │ │ │ │ │ ├── RatingCompat.aidl │ │ │ │ │ └── session │ │ │ │ │ │ ├── MediaSessionCompat.aidl │ │ │ │ │ │ ├── ParcelableVolumeInfo.aidl │ │ │ │ │ │ └── PlaybackStateCompat.aidl │ │ │ │ │ └── os │ │ │ │ │ └── ResultReceiver.aidl │ │ │ │ ├── annotations.zip │ │ │ │ └── jars │ │ │ │ ├── classes.jar │ │ │ │ └── libs │ │ │ │ └── internal_impl-23.1.1.jar │ │ ├── incremental │ │ │ ├── compileDebugAidl │ │ │ │ └── dependency.store │ │ │ ├── compileDebugAndroidTestAidl │ │ │ │ └── dependency.store │ │ │ ├── compileReleaseAidl │ │ │ │ └── dependency.store │ │ │ ├── mergeDebugAndroidTestAssets │ │ │ │ └── merger.xml │ │ │ ├── mergeDebugAndroidTestResources │ │ │ │ └── merger.xml │ │ │ ├── mergeDebugAssets │ │ │ │ └── merger.xml │ │ │ ├── mergeDebugJniLibFolders │ │ │ │ └── merger.xml │ │ │ ├── mergeDebugResources │ │ │ │ └── merger.xml │ │ │ ├── mergeReleaseAssets │ │ │ │ └── merger.xml │ │ │ ├── mergeReleaseJniLibFolders │ │ │ │ └── merger.xml │ │ │ ├── mergeReleaseResources │ │ │ │ └── merger.xml │ │ │ ├── packageDebugResources │ │ │ │ └── merger.xml │ │ │ └── packageReleaseResources │ │ │ │ └── merger.xml │ │ ├── manifest │ │ │ └── androidTest │ │ │ │ └── debug │ │ │ │ └── AndroidManifest.xml │ │ ├── res │ │ │ ├── merged │ │ │ │ ├── androidTest │ │ │ │ │ └── debug │ │ │ │ │ │ ├── drawable │ │ │ │ │ │ ├── above_shadow.xml │ │ │ │ │ │ └── below_shadow.xml │ │ │ │ │ │ └── values │ │ │ │ │ │ └── values.xml │ │ │ │ ├── debug │ │ │ │ │ ├── drawable │ │ │ │ │ │ ├── above_shadow.xml │ │ │ │ │ │ └── below_shadow.xml │ │ │ │ │ └── values │ │ │ │ │ │ └── values.xml │ │ │ │ └── release │ │ │ │ │ ├── drawable │ │ │ │ │ ├── above_shadow.xml │ │ │ │ │ └── below_shadow.xml │ │ │ │ │ └── values │ │ │ │ │ └── values.xml │ │ │ └── resources-debug-androidTest.ap_ │ │ └── symbols │ │ │ └── androidTest │ │ │ └── debug │ │ │ └── R.txt │ └── outputs │ │ └── aar │ │ ├── library-debug.aar │ │ └── library-release.aar ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── sothree │ │ └── slidinguppanel │ │ ├── ScrollableViewHelper.java │ │ ├── SlidingUpPanelLayout.java │ │ └── ViewDragHelper.java │ └── res │ ├── drawable │ ├── above_shadow.xml │ └── below_shadow.xml │ └── values │ └── attrs.xml ├── settings.gradle └── sticky-head-library ├── .gitignore ├── build.gradle ├── gradle-maven-push.gradle ├── gradle.properties ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── timehop │ └── stickyheadersrecyclerview │ └── ApplicationTest.java └── main ├── AndroidManifest.xml └── java └── com └── timehop └── stickyheadersrecyclerview ├── HeaderPositionCalculator.java ├── ItemVisibilityAdapter.java ├── StickyRecyclerHeadersAdapter.java ├── StickyRecyclerHeadersDecoration.java ├── StickyRecyclerHeadersTouchListener.java ├── caching ├── HeaderProvider.java └── HeaderViewCache.java ├── calculation └── DimensionCalculator.java ├── rendering └── HeaderRenderer.java └── util ├── LinearLayoutOrientationProvider.java └── OrientationProvider.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | AnswerEffect -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 26 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | $USER_HOME$/.subversion 55 | 56 | 57 | 58 | 59 | 60 | 1.8 61 | 62 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnswerEffect 2 | 高仿驾考宝典翻页答题效果 3 | 4 | ![AnswerEffect](./answer.gif) 5 | 6 | License 7 | ------- 8 | 9 | Copyright 2016 drakeet. 10 | 11 | Licensed under the Apache License, Version 2.0 (the "License"); 12 | you may not use this file except in compliance with the License. 13 | You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software 18 | distributed under the License is distributed on an "AS IS" BASIS, 19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | See the License for the specific language governing permissions and 21 | limitations under the License. 22 | -------------------------------------------------------------------------------- /answer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzyyppqq/AnswerEffect/79354828eb2f84793e5a9f8cc7a7d537bb4246b7/answer.gif -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.example.zhangyipeng.anwerdemo" 9 | minSdkVersion 15 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 files('libs/fastjson-1.2.9.jar') 26 | // compile 'com.github.lsjwzh.RecyclerViewPager:lib:v1.1.0' 27 | // compile 'com.sothree.slidinguppanel:library:3.3.0' 28 | // compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.8.5' 29 | // compile 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar' 30 | compile project(':library') 31 | compile project(':sticky-head-library') 32 | compile project(':lib') 33 | compile 'com.android.support:appcompat-v7:23.4.0' 34 | compile 'com.android.support:recyclerview-v7:23.4.0' 35 | compile 'com.google.android.gms:play-services-appindexing:8.1.0' 36 | compile 'com.android.support:support-v4:23.4.0' 37 | } 38 | -------------------------------------------------------------------------------- /app/libs/fastjson-1.2.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzyyppqq/AnswerEffect/79354828eb2f84793e5a9f8cc7a7d537bb4246b7/app/libs/fastjson-1.2.9.jar -------------------------------------------------------------------------------- /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 /Users/zhangyipeng/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/zhangyipeng/anwerdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo; 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/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.View; 8 | 9 | import com.example.zhangyipeng.anwerdemo.adapter.LayoutAdapter; 10 | import com.example.zhangyipeng.anwerdemo.adapter.TopicAdapter; 11 | import com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager; 12 | import com.sothree.slidinguppanel.SlidingUpPanelLayout; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | private RecyclerViewPager mRecyclerView; 17 | private LayoutAdapter layoutAdapter; 18 | private SlidingUpPanelLayout mLayout; 19 | private TopicAdapter topicAdapter; 20 | private RecyclerView recyclerView; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | 27 | 28 | } 29 | 30 | public void zeroClick(View view) { 31 | 32 | startActivity(new Intent(this,ReadActivity.class)); 33 | } 34 | 35 | public void oneClick(View view) { 36 | 37 | startActivity(new Intent(this,AnwerActivity.class)); 38 | } 39 | 40 | public void twoClick(View view) { 41 | 42 | startActivity(new Intent(this,AnswerReadActivity.class)); 43 | } 44 | 45 | 46 | public void threeClick(View view) { 47 | startActivity(new Intent(this,CourseActivity.class)); 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/adapter/AnimalsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.Collection; 8 | 9 | 10 | /** 11 | * Adapter holding a list of animal names of type String. Note that each item must be unique. 12 | */ 13 | public abstract class AnimalsAdapter 14 | extends RecyclerView.Adapter { 15 | private ArrayList items = new ArrayList(); 16 | 17 | public AnimalsAdapter() { 18 | setHasStableIds(true); 19 | } 20 | 21 | public void add(String object) { 22 | items.add(object); 23 | notifyDataSetChanged(); 24 | } 25 | 26 | public void add(int index, String object) { 27 | items.add(index, object); 28 | notifyDataSetChanged(); 29 | } 30 | 31 | public void addAll(Collection collection) { 32 | if (collection != null) { 33 | items.addAll(collection); 34 | notifyDataSetChanged(); 35 | } 36 | } 37 | 38 | 39 | public void addAll(String... items) { 40 | addAll(Arrays.asList(items)); 41 | } 42 | 43 | public void clear() { 44 | items.clear(); 45 | notifyDataSetChanged(); 46 | } 47 | 48 | public void remove(String object) { 49 | items.remove(object); 50 | notifyDataSetChanged(); 51 | } 52 | 53 | public String getItem(int position) { 54 | return items.get(position); 55 | } 56 | 57 | @Override 58 | public long getItemId(int position) { 59 | return getItem(position).hashCode(); 60 | } 61 | 62 | @Override 63 | public int getItemCount() { 64 | return items.size(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/adapter/DividerDecoration.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Rect; 7 | import android.graphics.drawable.Drawable; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.view.View; 11 | 12 | 13 | public class DividerDecoration extends RecyclerView.ItemDecoration { 14 | 15 | private static final int[] ATTRS = new int[]{ 16 | android.R.attr.listDivider 17 | }; 18 | 19 | public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL; 20 | 21 | public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL; 22 | 23 | private Drawable mDivider; 24 | 25 | public DividerDecoration(Context context) { 26 | final TypedArray a = context.obtainStyledAttributes(ATTRS); 27 | mDivider = a.getDrawable(0); 28 | a.recycle(); 29 | } 30 | 31 | private int getOrientation(RecyclerView parent) { 32 | LinearLayoutManager layoutManager; 33 | try { 34 | layoutManager = (LinearLayoutManager) parent.getLayoutManager(); 35 | } catch (ClassCastException e) { 36 | throw new IllegalStateException("DividerDecoration can only be used with a " + 37 | "LinearLayoutManager.", e); 38 | } 39 | return layoutManager.getOrientation(); 40 | } 41 | 42 | @Override 43 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { 44 | super.onDraw(c, parent, state); 45 | 46 | if (getOrientation(parent) == VERTICAL_LIST) { 47 | drawVertical(c, parent); 48 | } else { 49 | drawHorizontal(c, parent); 50 | } 51 | } 52 | 53 | public void drawVertical(Canvas c, RecyclerView parent) { 54 | final int left = parent.getPaddingLeft(); 55 | final int right = parent.getWidth() - parent.getPaddingRight(); 56 | final int recyclerViewTop = parent.getPaddingTop(); 57 | final int recyclerViewBottom = parent.getHeight() - parent.getPaddingBottom(); 58 | final int childCount = parent.getChildCount(); 59 | for (int i = 0; i < childCount; i++) { 60 | final View child = parent.getChildAt(i); 61 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 62 | .getLayoutParams(); 63 | final int top = Math.max(recyclerViewTop, child.getBottom() + params.bottomMargin); 64 | final int bottom = Math.min(recyclerViewBottom, top + mDivider.getIntrinsicHeight()); 65 | mDivider.setBounds(left, top, right, bottom); 66 | mDivider.draw(c); 67 | } 68 | } 69 | 70 | public void drawHorizontal(Canvas c, RecyclerView parent) { 71 | final int top = parent.getPaddingTop(); 72 | final int bottom = parent.getHeight() - parent.getPaddingBottom(); 73 | final int recyclerViewLeft = parent.getPaddingLeft(); 74 | final int recyclerViewRight = parent.getWidth() - parent.getPaddingRight(); 75 | final int childCount = parent.getChildCount(); 76 | for (int i = 0; i < childCount; i++) { 77 | final View child = parent.getChildAt(i); 78 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child 79 | .getLayoutParams(); 80 | final int left = Math.max(recyclerViewLeft, child.getRight() + params.rightMargin); 81 | final int right = Math.min(recyclerViewRight, left + mDivider.getIntrinsicHeight()); 82 | mDivider.setBounds(left, top, right, bottom); 83 | mDivider.draw(c); 84 | } 85 | } 86 | 87 | @Override 88 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 89 | super.getItemOffsets(outRect, view, parent, state); 90 | if (getOrientation(parent) == VERTICAL_LIST) { 91 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight()); 92 | } else { 93 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0); 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/adapter/LayoutAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Lucas Rocha 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.example.zhangyipeng.anwerdemo.adapter; 18 | 19 | import android.content.Context; 20 | import android.support.v7.widget.RecyclerView; 21 | import android.view.LayoutInflater; 22 | import android.view.View; 23 | import android.view.ViewGroup; 24 | import android.widget.TextView; 25 | import android.widget.Toast; 26 | 27 | import com.example.zhangyipeng.anwerdemo.R; 28 | import com.example.zhangyipeng.anwerdemo.bean.AnwerInfo; 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | 33 | 34 | 35 | public class LayoutAdapter extends RecyclerView.Adapter { 36 | 37 | private final Context mContext; 38 | private final RecyclerView mRecyclerView; 39 | private List datas; 40 | 41 | public static class SimpleViewHolder extends RecyclerView.ViewHolder { 42 | public final TextView title; 43 | 44 | public SimpleViewHolder(View view) { 45 | super(view); 46 | title = (TextView) view.findViewById(R.id.title); 47 | } 48 | } 49 | 50 | public LayoutAdapter(Context context, RecyclerView recyclerView) { 51 | 52 | mContext = context; 53 | mRecyclerView = recyclerView; 54 | } 55 | 56 | public void setDataList(List datas){ 57 | this.datas = datas; 58 | notifyDataSetChanged(); 59 | } 60 | 61 | 62 | @Override 63 | public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 64 | final View view = LayoutInflater.from(mContext).inflate(R.layout.item, parent, false); 65 | return new SimpleViewHolder(view); 66 | } 67 | 68 | @Override 69 | public void onBindViewHolder(SimpleViewHolder holder, int position) { 70 | AnwerInfo.DataBean.SubDataBean subDataBean = datas.get(position); 71 | holder.title.setText(subDataBean.getQuestionid()+". "+subDataBean.getQuestion() 72 | +"\n\nA."+subDataBean.getOptiona() 73 | +"\nB."+subDataBean.getOptionb() 74 | +"\nC."+subDataBean.getOptionc() 75 | +"\nD."+subDataBean.getOptiond() 76 | +"\n\n\n答案解析:"+subDataBean.getExplain() 77 | ); 78 | 79 | final View itemView = holder.itemView; 80 | 81 | } 82 | 83 | @Override 84 | public int getItemCount() { 85 | return datas!=null?datas.size():0; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/adapter/TopicAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.adapter; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.graphics.Color; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.Button; 11 | import android.widget.TextView; 12 | 13 | import com.example.zhangyipeng.anwerdemo.R; 14 | 15 | /** 16 | * Created by zhangyipeng on 16/6/30. 17 | */ 18 | public class TopicAdapter extends RecyclerView.Adapter { 19 | 20 | private Context mContext; 21 | private final LayoutInflater inflater; 22 | private final Resources resources; 23 | 24 | 25 | public TopicAdapter(Context mContext) { 26 | this.mContext = mContext; 27 | inflater = LayoutInflater.from(mContext); 28 | resources = mContext.getResources(); 29 | 30 | } 31 | 32 | @Override 33 | public TopicAdapter.TopicViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 34 | 35 | View view = inflater.inflate(R.layout.item_topic, parent, false); 36 | return new TopicViewHolder(view); 37 | } 38 | 39 | @Override 40 | public void onBindViewHolder(final TopicAdapter.TopicViewHolder holder, final int position) { 41 | 42 | holder.tv_id.setText((position + 1) + ""); 43 | holder.tv_id.setTextColor(Color.parseColor("#b3afaf")); 44 | holder.tv_id.setBackgroundResource(R.drawable.bg_topic_no); 45 | if (prePosition == position) { 46 | holder.tv_id.setBackgroundResource(R.drawable.bg_topic_no); 47 | holder.tv_id.setTextColor(Color.parseColor("#b3afaf")); 48 | 49 | } 50 | if (curPosition == position) { 51 | holder.tv_id.setBackgroundResource(R.drawable.bg_topic_ok); 52 | holder.tv_id.setTextColor(Color.parseColor("#ffffff")); 53 | } 54 | holder.itemView.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | listener.onClick(holder, position); 58 | } 59 | }); 60 | } 61 | 62 | private OnTopicClickListener listener; 63 | 64 | public void setOnTopicClickListener(OnTopicClickListener listener) { 65 | this.listener = listener; 66 | } 67 | 68 | private int curPosition; 69 | 70 | public void notifyCurPosition(int curPosition) { 71 | this.curPosition = curPosition; 72 | notifyItemChanged(curPosition); 73 | } 74 | 75 | private int prePosition; 76 | 77 | public void notifyPrePosition(int prePosition) { 78 | this.prePosition = prePosition; 79 | notifyItemChanged(prePosition); 80 | } 81 | 82 | 83 | public interface OnTopicClickListener { 84 | void onClick(TopicAdapter.TopicViewHolder holder, int position); 85 | } 86 | 87 | private int num; 88 | 89 | public void setDataNum(int num) { 90 | this.num = num; 91 | notifyDataSetChanged(); 92 | } 93 | 94 | 95 | @Override 96 | public int getItemCount() { 97 | return num; 98 | } 99 | 100 | 101 | public static class TopicViewHolder extends RecyclerView.ViewHolder { 102 | public TextView tv_id; 103 | 104 | public TopicViewHolder(View itemView) { 105 | super(itemView); 106 | tv_id = (TextView) itemView.findViewById(R.id.tv_id); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/bean/BaseInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.bean; 2 | 3 | /** 4 | * Created by zhangyipeng on 16/6/30. 5 | */ 6 | public class BaseInfo { 7 | 8 | /** 9 | * code : 0 10 | * success : true 11 | * msg : 12 | */ 13 | 14 | private int code; 15 | private String success; 16 | private String msg; 17 | 18 | public int getCode() { 19 | return code; 20 | } 21 | 22 | public void setCode(int code) { 23 | this.code = code; 24 | } 25 | 26 | public String getSuccess() { 27 | return success; 28 | } 29 | 30 | public void setSuccess(String success) { 31 | this.success = success; 32 | } 33 | 34 | public String getMsg() { 35 | return msg; 36 | } 37 | 38 | public void setMsg(String msg) { 39 | this.msg = msg; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/bean/QuestionEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.bean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by zhangyipeng on 16/7/27. 7 | */ 8 | public class QuestionEntry { 9 | 10 | /** 11 | * explain : “违反道路交通安全法”,违反法律法规即为违法行为。官方已无违章/违规的说法。 12 | * question : 驾驶机动车在道路上违反道路交通安全法的行为,属于什么行为? 13 | * questionid : 1 14 | * mediatype : 0 15 | * mediacontent : 16 | * optiontype : 1 17 | * answer : 2 18 | * chapterid : 1 19 | * answer_arr : ["2"] 20 | * answers : ["违章行为","违法行为","过失行为","违规行为"] 21 | */ 22 | 23 | private String explain; 24 | private String question; 25 | private String questionid; 26 | private String mediatype; 27 | private String mediacontent; 28 | private String optiontype; 29 | private String answer; 30 | private String chapterid; 31 | private List answer_arr; 32 | private List answers; 33 | 34 | public String getExplain() { 35 | return explain; 36 | } 37 | 38 | public void setExplain(String explain) { 39 | this.explain = explain; 40 | } 41 | 42 | public String getQuestion() { 43 | return question; 44 | } 45 | 46 | public void setQuestion(String question) { 47 | this.question = question; 48 | } 49 | 50 | public String getQuestionid() { 51 | return questionid; 52 | } 53 | 54 | public void setQuestionid(String questionid) { 55 | this.questionid = questionid; 56 | } 57 | 58 | public String getMediatype() { 59 | return mediatype; 60 | } 61 | 62 | public void setMediatype(String mediatype) { 63 | this.mediatype = mediatype; 64 | } 65 | 66 | public String getMediacontent() { 67 | return mediacontent; 68 | } 69 | 70 | public void setMediacontent(String mediacontent) { 71 | this.mediacontent = mediacontent; 72 | } 73 | 74 | public String getOptiontype() { 75 | return optiontype; 76 | } 77 | 78 | public void setOptiontype(String optiontype) { 79 | this.optiontype = optiontype; 80 | } 81 | 82 | public String getAnswer() { 83 | return answer; 84 | } 85 | 86 | public void setAnswer(String answer) { 87 | this.answer = answer; 88 | } 89 | 90 | public String getChapterid() { 91 | return chapterid; 92 | } 93 | 94 | public void setChapterid(String chapterid) { 95 | this.chapterid = chapterid; 96 | } 97 | 98 | public List getAnswer_arr() { 99 | return answer_arr; 100 | } 101 | 102 | public void setAnswer_arr(List answer_arr) { 103 | this.answer_arr = answer_arr; 104 | } 105 | 106 | public List getAnswers() { 107 | return answers; 108 | } 109 | 110 | public void setAnswers(List answers) { 111 | this.answers = answers; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/bean/QuestionList.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.bean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by zhangyipeng on 16/7/27. 7 | */ 8 | public class QuestionList { 9 | private List questionList; 10 | 11 | public List getQuestionList() { 12 | return questionList; 13 | } 14 | 15 | public void setQuestionList(List questionList) { 16 | this.questionList = questionList; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/fragment/ReadFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.fragment; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.example.zhangyipeng.anwerdemo.R; 12 | import com.example.zhangyipeng.anwerdemo.bean.AnwerInfo; 13 | 14 | /** 15 | * A simple {@link Fragment} subclass. 16 | * Use the {@link ReadFragment#newInstance} factory method to 17 | * create an instance of this fragment. 18 | */ 19 | public class ReadFragment extends Fragment { 20 | // TODO: Rename parameter arguments, choose names that match 21 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 22 | private static final String ARG_PARAM1 = "param1"; 23 | private static final String ARG_PARAM2 = "param2"; 24 | 25 | // TODO: Rename and change types of parameters 26 | private AnwerInfo.DataBean.SubDataBean subDataBean; 27 | private View view; 28 | 29 | 30 | public ReadFragment() { 31 | // Required empty public constructor 32 | } 33 | 34 | /** 35 | * Use this factory method to create a new instance of 36 | * this fragment using the provided parameters. 37 | 38 | * @return A new instance of fragment ReadFragment. 39 | */ 40 | // TODO: Rename and change types and number of parameters 41 | public static ReadFragment newInstance(AnwerInfo.DataBean.SubDataBean subDataBean) { 42 | ReadFragment fragment = new ReadFragment(); 43 | Bundle args = new Bundle(); 44 | args.putSerializable(ARG_PARAM1, subDataBean); 45 | fragment.setArguments(args); 46 | return fragment; 47 | } 48 | 49 | @Override 50 | public void onCreate(Bundle savedInstanceState) { 51 | super.onCreate(savedInstanceState); 52 | if (getArguments() != null) { 53 | subDataBean = (AnwerInfo.DataBean.SubDataBean) getArguments().getSerializable(ARG_PARAM1); 54 | } 55 | } 56 | 57 | @Override 58 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 59 | Bundle savedInstanceState) { 60 | view = inflater.inflate(R.layout.fragment_read, container, false); 61 | 62 | initView(); 63 | // Inflate the layout for this fragment 64 | return view; 65 | } 66 | 67 | private void initView() { 68 | TextView tv_question = (TextView) view.findViewById(R.id.tv_question); 69 | 70 | tv_question.setText(subDataBean.getQuestionid()+". "+subDataBean.getQuestion() 71 | +"\n\nA."+subDataBean.getOptiona() 72 | +"\nB."+subDataBean.getOptionb() 73 | +"\nC."+subDataBean.getOptionc() 74 | +"\nD."+subDataBean.getOptiond() 75 | +"\n\n\n答案解析:"+subDataBean.getExplain() 76 | ); 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/listener/RecyclerItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.listener; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.GestureDetector; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | 9 | public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener { 10 | private OnItemClickListener mListener; 11 | 12 | public interface OnItemClickListener { 13 | void onItemClick(View view, int position); 14 | } 15 | 16 | GestureDetector mGestureDetector; 17 | 18 | public RecyclerItemClickListener(Context context, OnItemClickListener listener) { 19 | mListener = listener; 20 | mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { 21 | @Override public boolean onSingleTapUp(MotionEvent e) { 22 | return true; 23 | } 24 | }); 25 | } 26 | 27 | @Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) { 28 | View childView = view.findChildViewUnder(e.getX(), e.getY()); 29 | if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) { 30 | mListener.onItemClick(childView, view.getChildAdapterPosition(childView)); 31 | } 32 | return false; 33 | } 34 | 35 | @Override public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) { } 36 | 37 | @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { 38 | // do nothing 39 | } 40 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/view/FixedSpeedScroller.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.view; 2 | 3 | import android.content.Context; 4 | import android.view.animation.Interpolator; 5 | import android.widget.Scroller; 6 | 7 | public class FixedSpeedScroller extends Scroller { 8 | private int mDuration = 1500; 9 | 10 | public FixedSpeedScroller(Context context) { 11 | super(context); 12 | } 13 | 14 | public FixedSpeedScroller(Context context, Interpolator interpolator) { 15 | super(context, interpolator); 16 | } 17 | 18 | @Override 19 | public void startScroll(int startX, int startY, int dx, int dy, int duration) { 20 | // Ignore received duration, use fixed one instead 21 | super.startScroll(startX, startY, dx, dy, mDuration); 22 | } 23 | 24 | @Override 25 | public void startScroll(int startX, int startY, int dx, int dy) { 26 | // Ignore received duration, use fixed one instead 27 | super.startScroll(startX, startY, dx, dy, mDuration); 28 | } 29 | 30 | public void setmDuration(int time) { 31 | mDuration = time; 32 | } 33 | 34 | public int getmDuration() { 35 | return mDuration; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/view/MoveLinearLayout.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.widget.LinearLayout; 7 | import android.widget.ScrollView; 8 | import android.widget.Scroller; 9 | 10 | /** 11 | * Created by zhangyipeng on 16/7/5. 12 | */ 13 | public class MoveLinearLayout extends LinearLayout { 14 | 15 | 16 | private Scroller mScroller; 17 | 18 | public MoveLinearLayout(Context context) { 19 | this(context, null); 20 | } 21 | 22 | public MoveLinearLayout(Context context, AttributeSet attrs) { 23 | this(context, null, 0); 24 | } 25 | 26 | public MoveLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { 27 | super(context, attrs, defStyleAttr); 28 | 29 | } 30 | 31 | public void setScroller(Scroller scroller){ 32 | this.mScroller = scroller; 33 | } 34 | 35 | @Override 36 | public void computeScroll() { 37 | super.computeScroll(); 38 | if (mScroller==null){ 39 | return; 40 | } 41 | 42 | if(mScroller.computeScrollOffset()){ 43 | scrollTo(mScroller.getCurrX(),mScroller.getCurrY()); 44 | } 45 | invalidate();//必须要调用 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/zhangyipeng/anwerdemo/view/ReaderViewPager.java: -------------------------------------------------------------------------------- 1 | package com.example.zhangyipeng.anwerdemo.view; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.util.Log; 7 | import android.view.View; 8 | import android.view.animation.DecelerateInterpolator; 9 | 10 | import java.lang.reflect.Field; 11 | 12 | /** 13 | * Created by zhangyipeng on 16/8/13. 14 | */ 15 | public class ReaderViewPager extends ViewPager { 16 | 17 | 18 | 19 | public ReaderViewPager(Context context) { 20 | this(context, null); 21 | } 22 | 23 | 24 | public ReaderViewPager(Context context, AttributeSet attrs) { 25 | super(context, attrs); 26 | setReadEffect(); 27 | 28 | setScrollerDuration(); 29 | } 30 | 31 | private void setScrollerDuration() { 32 | try { 33 | Field field = ViewPager.class.getDeclaredField("mScroller"); 34 | field.setAccessible(true); 35 | FixedSpeedScroller scroller = new FixedSpeedScroller(getContext(), 36 | new DecelerateInterpolator()); 37 | field.set(this, scroller); 38 | scroller.setmDuration(300); 39 | } catch (Exception e) { 40 | Log.e("@", "", e); 41 | } 42 | } 43 | 44 | 45 | public void setReadEffect() { 46 | setPageTransformer(true, new PageTransformer() { 47 | private static final float MIN_SCALE = 0.75f; 48 | 49 | @Override 50 | public void transformPage(View view, float position) { 51 | Log.i("AAA", position + ""); 52 | int pageWidth = view.getWidth(); 53 | int pageHeight =view.getHeight(); 54 | 55 | if (position < -1) { // [-Infinity,-1) 56 | // This page is way off-screen to the left. 57 | view.setAlpha(0); 58 | 59 | } else if (position <= 0) { // [-1,0] 60 | // Use the default slide transition when moving to the left page 61 | view.setAlpha(1); 62 | view.setTranslationX(0); 63 | view.setScaleX(1); 64 | view.setScaleY(1); 65 | Log.i("T", position + ""); 66 | 67 | } else if (position <= 1) { // (0,1] 68 | Log.i("W", position + ""); 69 | // Fade the page out. 70 | // view.setAlpha(1 - position); 71 | // 72 | // // Counteract the default slide transition 73 | view.setAlpha(1); 74 | view.setTranslationX(pageWidth * -position); 75 | // 76 | // // Scale the page down (between MIN_SCALE and 1) 77 | // float scaleFactor = MIN_SCALE 78 | // + (1 - MIN_SCALE) * (1 - Math.abs(position)); 79 | // view.setScaleX(scaleFactor); 80 | // view.setScaleY(scaleFactor); 81 | 82 | } else { // (1,+Infinity] 83 | // This page is way off-screen to the right. 84 | view.setAlpha(0); 85 | } 86 | 87 | 88 | } 89 | }); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_topic.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_topic_no.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_topic_ok.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shadow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzyyppqq/AnswerEffect/79354828eb2f84793e5a9f8cc7a7d537bb4246b7/app/src/main/res/drawable/shadow_right.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_course.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 |