├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── keystore │ └── huaye.jks ├── mapping.txt ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── ody │ │ └── study │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── huaye │ │ │ └── odyandroidstore │ │ │ ├── MainActivity.java │ │ │ ├── base │ │ │ ├── Ad.java │ │ │ ├── App.java │ │ │ ├── BaseActivity.java │ │ │ ├── BaseBean.java │ │ │ └── BaseFragment.java │ │ │ ├── constraint │ │ │ └── ConstraintActivity.java │ │ │ ├── customview │ │ │ └── CircleMenuActivity.java │ │ │ ├── drawable │ │ │ └── ShapeDrawableActivity.java │ │ │ ├── expandablelist │ │ │ ├── ExpandView.java │ │ │ ├── ExpandableActivity.java │ │ │ ├── ExpandablePresenter.java │ │ │ ├── FileAdapter.java │ │ │ └── FilesMultiEntity.java │ │ │ ├── hotfix │ │ │ ├── HotFixActivity.java │ │ │ └── Update.java │ │ │ ├── imitate │ │ │ ├── lyf │ │ │ │ └── home │ │ │ │ │ ├── AdBean.java │ │ │ │ │ ├── HomeAdapter.java │ │ │ │ │ ├── HomeItem.java │ │ │ │ │ └── LYFHomeActivity.java │ │ │ └── taobao │ │ │ │ ├── ProductAdapter.java │ │ │ │ ├── SearchResultPresenter.java │ │ │ │ ├── SearchResultView.java │ │ │ │ └── TaobaoSearchResultActivity.java │ │ │ ├── library │ │ │ ├── Function.java │ │ │ ├── FunctionAdapter.java │ │ │ ├── FunctionPagerAdapter.java │ │ │ ├── LibraryFragment.java │ │ │ ├── LibraryPresenter.java │ │ │ └── LibraryView.java │ │ │ ├── md │ │ │ ├── AvatarImageBehavior.java │ │ │ ├── CoordinatorActivity.java │ │ │ ├── CoordinatorMobileActivity.java │ │ │ ├── CoordinatorPuckerActivity.java │ │ │ └── ToolBarActivity.java │ │ │ ├── my │ │ │ ├── BlankFragment.java │ │ │ └── MyFragment.java │ │ │ ├── retrofit │ │ │ ├── NetWorkApi.java │ │ │ ├── RetrofitFactory.java │ │ │ ├── RetrofitHelper.java │ │ │ └── taobao │ │ │ │ └── TaoBaoProductBean.java │ │ │ ├── subscribe │ │ │ ├── ApiSubscriber.java │ │ │ └── SubscriberListener.java │ │ │ ├── utils │ │ │ ├── ActivityUtils.java │ │ │ ├── AppUtils.java │ │ │ ├── BarUtils.java │ │ │ ├── CameraUtils.java │ │ │ ├── CleanUtils.java │ │ │ ├── ClipboardUtils.java │ │ │ ├── CloseUtils.java │ │ │ ├── ConstUtils.java │ │ │ ├── ConvertUtils.java │ │ │ ├── CrashUtils.java │ │ │ ├── DeviceUtils.java │ │ │ ├── EmptyUtils.java │ │ │ ├── EncodeUtils.java │ │ │ ├── EncryptUtils.java │ │ │ ├── FileUtils.java │ │ │ ├── FragmentUtils.java │ │ │ ├── HandlerUtils.java │ │ │ ├── ImageUtils.java │ │ │ ├── IntentUtils.java │ │ │ ├── KeyboardUtils.java │ │ │ ├── LocationUtils.java │ │ │ ├── LogUtils.java │ │ │ ├── LunarUtils.java │ │ │ ├── NetworkUtils.java │ │ │ ├── PhoneUtils.java │ │ │ ├── PinyinUtils.java │ │ │ ├── ProcessUtils.java │ │ │ ├── RegexUtils.java │ │ │ ├── SDCardUtils.java │ │ │ ├── SPUtils.java │ │ │ ├── ScreenUtils.java │ │ │ ├── ServiceUtils.java │ │ │ ├── ShellUtils.java │ │ │ ├── SizeUtils.java │ │ │ ├── SnackbarUtils.java │ │ │ ├── SpannableStringUtils.java │ │ │ ├── StringUtils.java │ │ │ ├── ThreadPoolUtils.java │ │ │ ├── TimeUtils.java │ │ │ ├── ToastUtils.java │ │ │ ├── Utils.java │ │ │ ├── VibrationUtils.java │ │ │ └── ZipUtils.java │ │ │ ├── web │ │ │ └── WebActivity.java │ │ │ ├── welfare │ │ │ └── WelfareFragment.java │ │ │ └── widget │ │ │ ├── DecorationSpace.java │ │ │ └── SquareImageView.java │ └── res │ │ ├── drawable-xhdpi │ │ └── constraint_ayout.gif │ │ ├── drawable │ │ ├── circle_menu_bg.xml │ │ ├── large.png │ │ ├── placeholder.png │ │ ├── selector_taobao_tab_bg.xml │ │ ├── selector_taobao_tab_txt.xml │ │ ├── shape_baoyou_bg.xml │ │ ├── shape_circle.xml │ │ ├── shape_corner.xml │ │ ├── shape_credit_score.xml │ │ ├── shape_cylinder.xml │ │ ├── shape_dash.xml │ │ ├── shape_glow.xml │ │ ├── shape_gradient0.xml │ │ ├── shape_gradient1.xml │ │ ├── shape_gradient2.xml │ │ ├── shape_gradient3.xml │ │ ├── shape_rec_stroke.xml │ │ ├── shape_ring.xml │ │ ├── shape_taobao_input_bg.xml │ │ ├── shape_taobao_jiao_bg.xml │ │ └── small.png │ │ ├── layout │ │ ├── activity_circle_menu.xml │ │ ├── activity_con.xml │ │ ├── activity_constraint.xml │ │ ├── activity_coordinator.xml │ │ ├── activity_coordinator_mobile.xml │ │ ├── activity_expandable.xml │ │ ├── activity_hot_fix.xml │ │ ├── activity_lyfhome.xml │ │ ├── activity_main.xml │ │ ├── activity_ppd.xml │ │ ├── activity_shape_drawable.xml │ │ ├── activity_taobao_search_result.xml │ │ ├── activity_tool_bar.xml │ │ ├── activity_web.xml │ │ ├── fragment_blank.xml │ │ ├── fragment_main.xml │ │ ├── fragment_my.xml │ │ ├── fragment_welfare.xml │ │ ├── item_directory.xml │ │ ├── item_file.xml │ │ ├── item_function.xml │ │ ├── item_taobao_product.xml │ │ ├── item_taobao_product_grid.xml │ │ ├── item_vp_fun.xml │ │ └── popup_sort.xml │ │ ├── menu │ │ ├── menu_nav.xml │ │ ├── menu_taobao.xml │ │ └── menu_title.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── android_icon_camera.png │ │ ├── arrow_down.png │ │ ├── arrow_right.png │ │ ├── arrow_up.png │ │ ├── back.png │ │ ├── coupons_car.png │ │ ├── coupons_film.png │ │ ├── coupons_food.png │ │ ├── coupons_gear.png │ │ ├── coupons_online.png │ │ ├── coupons_other.png │ │ ├── coupons_overseas.png │ │ ├── coupons_shopping.png │ │ ├── coupons_sing.png │ │ ├── coupons_travel.png │ │ ├── directory.png │ │ ├── doc.png │ │ ├── file.png │ │ ├── filter.png │ │ ├── grid.png │ │ ├── htao_check_activity.png │ │ ├── ic_launcher.png │ │ ├── icon_ku_156.png │ │ ├── library.png │ │ ├── list.png │ │ ├── my.png │ │ ├── project.png │ │ ├── share_friend.png │ │ ├── share_morepics.png │ │ ├── share_qq.png │ │ ├── share_qzone.png │ │ ├── share_wechat.png │ │ ├── share_weibo.png │ │ ├── spinner_down.png │ │ ├── taobao_back.png │ │ ├── tb_icon_actionbar_more.png │ │ ├── tb_icon_more_cart_56.png │ │ ├── tb_icon_more_home_56.png │ │ ├── tb_icon_more_msg_56.png │ │ ├── tb_icon_more_my_56.png │ │ ├── tb_icon_more_nearby_56.png │ │ ├── trail.png │ │ └── welfare.png │ │ ├── mipmap-xxhdpi │ │ ├── exp.png │ │ ├── ic_launcher.png │ │ ├── list_item_indicator.png │ │ └── user_profile_grass.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ ├── dimens.xml │ │ └── styles.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── ody │ └── study │ ├── AlgorithmTest.java │ ├── Author.java │ ├── AuthorDeserializer.java │ ├── Book.java │ ├── BookDeserializer.java │ ├── GsonTest.java │ ├── PPDTest.java │ ├── RecursionTest.java │ ├── ThreadTest.java │ ├── designpatterns │ ├── builder │ │ ├── App.java │ │ ├── Armor.java │ │ ├── HairColor.java │ │ ├── HairType.java │ │ ├── Hero.java │ │ ├── Profession.java │ │ └── Weapon.java │ ├── observer │ │ ├── App.java │ │ ├── Hobbits.java │ │ ├── Orcs.java │ │ ├── Weather.java │ │ ├── WeatherObserver.java │ │ ├── WeatherType.java │ │ └── generic │ │ │ ├── GHobbits.java │ │ │ ├── GOrcs.java │ │ │ ├── GWeather.java │ │ │ ├── Observable.java │ │ │ ├── Observer.java │ │ │ └── Race.java │ └── singleton │ │ ├── App.java │ │ ├── EagerPlusSingleton.java │ │ ├── EagerSingleton.java │ │ ├── EnumSingleton.java │ │ ├── LazyPlusSingleton.java │ │ ├── LazySingleton.java │ │ └── StaticInnerClassSingleton.java │ ├── json │ ├── Book.java │ ├── NullStringToEmpty.java │ ├── NullStringToEmptyAdapterFactory.java │ └── StringNullAdapter.java │ ├── leetcode │ └── AddTwoNumbers.java │ └── util │ └── LoggerFactory.java ├── build.gradle ├── circlemenu ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── huaye │ │ └── circlemenu │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── huaye │ │ │ └── circlemenu │ │ │ └── CircleMenuLayout.java │ └── res │ │ ├── layout │ │ └── circle_menu_item.xml │ │ └── values │ │ ├── ids.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── huaye │ └── circlemenu │ └── ExampleUnitTest.java ├── config.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── groovy.gradle └── settings.gradle /.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/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 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 安卓开发宝典 2 | ## 12、[CoordinatorLayout实现酷炫折叠效果](http://www.jianshu.com/p/5decc28f062e) 3 | ![](http://bmob-cdn-9267.b0.upaiyun.com/2017/09/30/0c5b346540060e4e803be4427dd8e5f4.gif) 4 | ## 11、[扩展EditText](http://www.jianshu.com/p/b55d901211c4) 5 | ## 10、[java设计模式---创建者模式(Builder)](http://www.jianshu.com/p/46c753b6e95e) 6 | ## 9、[java设计模式---观察者模式(Observer)](http://www.jianshu.com/p/4b408a1c12d4) 7 | ## 8、[java设计模式---单例模式(Singleton)](http://www.jianshu.com/p/8ebdbfe1c4bf) 8 | ## 7、[热修复-HotFix](http://www.jianshu.com/p/4ce6ae88b6b4) 9 | ## 6、[高仿淘宝搜索结果页]() 10 | ![](http://bmob-cdn-9267.b0.upaiyun.com/2017/03/15/ee12d5414021046680f60aeef39f2f58.gif) 11 | ## 5、[圆形菜单](http://www.jianshu.com/p/34b35a8c0a1c) 12 | ![圆形菜单](http://bmob-cdn-9267.b0.upaiyun.com/2017/03/10/490877fa40a9614e80f5ce50c0a7668e.gif) 13 | 14 | ## 4、[高仿摩拜单车个人中心](http://www.jianshu.com/p/b68dab7258df) 15 | ![摩拜单车](http://bmob-cdn-9267.b0.upaiyun.com/2017/02/28/4918bfd640d30bf080ccaa943de45af3.gif) 16 | 17 | ## 3、[Shape使用总结](http://www.jianshu.com/p/aa6c9b377cb0) 18 | ![Shape使用总结](http://bmob-cdn-9267.b0.upaiyun.com/2017/03/13/7a63162b40df4eec80e02d030c9cad9b.png) 19 | 20 | ## 2、[约束布局实战](http://www.jianshu.com/p/b3cd72524b11) 21 | ![约束布局](http://upload-images.jianshu.io/upload_images/4751442-cbb1516da38688bf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 22 | 23 | ## 1、[比ExpandableListView更强大的分组列表](http://www.jianshu.com/p/027395fd3c67) 24 | 25 | ![分组列表截图](http://upload-images.jianshu.io/upload_images/4751442-02adb2faf95c9bd7.png?imageMogr2/auto-orient/strip%7CimageView2/2) 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | signingConfigs { 5 | release { 6 | keyAlias '华晔软件工作室' 7 | keyPassword 'samuel' 8 | storeFile file('/keystore/huaye.jks') 9 | storePassword 'samuel' 10 | } 11 | } 12 | compileSdkVersion rootProject.ext.android.compileSdkVersion 13 | buildToolsVersion rootProject.ext.android.buildToolsVersion 14 | defaultConfig { 15 | applicationId "com.huaye.odyandroidstore" 16 | minSdkVersion rootProject.ext.android.minSdkVersion 17 | targetSdkVersion rootProject.ext.android.targetSdkVersion 18 | versionCode rootProject.ext.android.versionCode 19 | versionName rootProject.ext.android.versionName 20 | 21 | resConfigs "zh" 22 | 23 | javaCompileOptions { 24 | annotationProcessorOptions { 25 | arguments = [moduleName: project.getName()] 26 | } 27 | } 28 | 29 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 30 | } 31 | buildTypes { 32 | debug { 33 | signingConfig signingConfigs.release 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 36 | } 37 | release { 38 | signingConfig signingConfigs.release 39 | minifyEnabled true 40 | shrinkResources true 41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 42 | } 43 | } 44 | } 45 | 46 | dependencies { 47 | compile fileTree(include: ['*.jar'], dir: 'libs') 48 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 49 | exclude group: 'com.android.support', module: 'support-annotations' 50 | }) 51 | testCompile 'junit:junit:4.12' 52 | 53 | //圆型菜单 54 | compile project(':circlemenu') 55 | compile('com.android.support:appcompat-v7:' + rootProject.ext.dependencies.support_version) 56 | compile('com.android.support:recyclerview-v7:' + rootProject.ext.dependencies.support_version) 57 | // compile('com.android.support:customtabs:' + rootProject.ext.dependencies.support_version) 58 | compile('com.android.support:design:' + rootProject.ext.dependencies.support_version) 59 | compile('com.android.support:cardview-v7:' + rootProject.ext.dependencies.support_version) 60 | compile('com.android.support:support-v4:' + rootProject.ext.dependencies.support_version) 61 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 62 | compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:+' 63 | 64 | compile('com.squareup.retrofit2:retrofit:2.1.0') { 65 | exclude group: 'com.squareup.okhttp3' 66 | // exclude group: 'com.squareup.okio' 67 | } 68 | compile('com.squareup.retrofit2:converter-gson:2.1.0') { 69 | exclude group: 'com.google.code.gson' 70 | exclude group: 'com.squareup.okhttp3' 71 | } 72 | compile('com.squareup.retrofit2:adapter-rxjava:2.1.0') { 73 | exclude group: 'io.reactivex' 74 | exclude group: 'com.squareup.okhttp3' 75 | } 76 | compile 'org.greenrobot:eventbus:3.0.0' 77 | compile 'com.github.bumptech.glide:glide:3.7.0' 78 | compile 'de.hdodenhof:circleimageview:1.3.0' 79 | //Bmob依赖包 80 | compile 'cn.bmob.android:bmob-sdk:3.5.3' 81 | 82 | compile 'com.jakewharton:butterknife:8.5.1' 83 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 84 | 85 | //热修复 86 | compile 'com.taobao.android:alisdk-hotfix:2.0.6' 87 | 88 | //下拉刷新 89 | compile 'com.dinuscxj:recyclerrefreshlayout:2.0.3' 90 | 91 | //路由 92 | compile 'com.alibaba:arouter-api:1.2.1' 93 | annotationProcessor 'com.alibaba:arouter-compiler:1.1.2' 94 | 95 | compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar' 96 | // LeanCloud 基础包 97 | // compile('cn.leancloud.android:avoscloud-sdk:v4.4.4') 98 | } 99 | -------------------------------------------------------------------------------- /app/keystore/huaye.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sun8829/OdyAndroidStore/6b017b738dee3d625d203777820e1fcbd9c73f03/app/keystore/huaye.jks -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ody/study/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.ody.study; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | 12 | import rx.Observable; 13 | import rx.functions.Action1; 14 | import rx.functions.Func1; 15 | import rx.schedulers.Schedulers; 16 | 17 | import static org.junit.Assert.*; 18 | 19 | /** 20 | * Instrumentation test, which will execute on an Android device. 21 | * 22 | * @see Testing documentation 23 | */ 24 | @RunWith(AndroidJUnit4.class) 25 | public class ExampleInstrumentedTest { 26 | @Test 27 | public void useAppContext() throws Exception { 28 | // Context of the app under test. 29 | Context appContext = InstrumentationRegistry.getTargetContext(); 30 | 31 | assertEquals("com.ody.temp", appContext.getPackageName()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 47 | 50 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/base/Ad.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.base; 2 | 3 | /** 4 | * Created by Samuel on 2017/4/6. 5 | */ 6 | 7 | public class Ad { 8 | 9 | /** 10 | * id : 1014021400000024 11 | * name : 默认搜索词 12 | * startTime : 1488453425000 13 | * endTime : 1496229425000 14 | * sort : 0 15 | * type : 0 16 | * title : 粽子 17 | * content : 粽子 18 | * refType : 6 19 | * refId : null 20 | * linkUrl : lyf://searchresult?body=%7B%22keyword%22%3A%22%E7%B2%BD%E5%AD%90%22%7D 21 | * imageUrl : null 22 | * imageTitle : null 23 | * refObject : null 24 | * goods : false 25 | */ 26 | 27 | public long id; 28 | public String name; 29 | public long startTime; 30 | public long endTime; 31 | public int sort; 32 | public int type; 33 | public String title; 34 | public String content; 35 | public int refType; 36 | public long refId; 37 | public String linkUrl; 38 | public Object imageUrl; 39 | public Object imageTitle; 40 | public boolean goods; 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/base/App.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.base; 2 | 3 | import android.app.Application; 4 | 5 | import com.alibaba.android.arouter.launcher.ARouter; 6 | import com.huaye.odyandroidstore.BuildConfig; 7 | import com.huaye.odyandroidstore.utils.Utils; 8 | import com.taobao.sophix.SophixManager; 9 | import com.taobao.sophix.listener.PatchLoadStatusListener; 10 | import com.taobao.sophix.util.PatchStatus; 11 | 12 | /** 13 | * Created by sunhuahui on 2017/1/29. 14 | */ 15 | 16 | public class App extends Application { 17 | 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | Utils.init(this); 22 | ARouter.init(this); 23 | SophixManager.getInstance().setContext(this) 24 | .setAppVersion(BuildConfig.VERSION_NAME) 25 | .setAesKey(null) 26 | .setEnableDebug(true) 27 | .setPatchLoadStatusStub(new PatchLoadStatusListener() { 28 | @Override 29 | public void onload(final int mode, final int code, final String info, final int handlePatchVersion) { 30 | // 补丁加载回调通知 31 | if (code == PatchStatus.CODE_LOAD_SUCCESS) { 32 | // 表明补丁加载成功 33 | } else if (code == PatchStatus.CODE_LOAD_RELAUNCH) { 34 | // 表明新补丁生效需要重启. 开发者可提示用户或者强制重启; 35 | // 建议: 用户可以监听进入后台事件, 然后应用自杀 36 | } else if (code == PatchStatus.CODE_LOAD_FAIL) { 37 | // 内部引擎异常, 推荐此时清空本地补丁, 防止失败补丁重复加载 38 | SophixManager.getInstance().cleanPatches(); 39 | } else { 40 | // 其它错误信息, 查看PatchStatus类说明 41 | } 42 | } 43 | }).initialize(); 44 | SophixManager.getInstance().queryAndLoadNewPatch(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.base; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | 8 | /** 9 | * Created by sunhuahui on 2017/1/28. 10 | */ 11 | 12 | public abstract class BaseActivity extends AppCompatActivity { 13 | protected Context mContext; 14 | protected App app; 15 | protected void preOnCreate() { 16 | 17 | } 18 | 19 | protected void init() { 20 | 21 | } 22 | 23 | protected abstract int bindLayout(); 24 | 25 | 26 | /** 27 | * 初始化View 28 | */ 29 | protected abstract void initView(); 30 | 31 | /** 32 | * 数据初始化 33 | */ 34 | protected void initData() { 35 | 36 | } 37 | 38 | /** 39 | * 添加监听 40 | */ 41 | protected void initListener() { 42 | } 43 | 44 | 45 | @Override 46 | protected void onCreate(@Nullable Bundle savedInstanceState) { 47 | 48 | super.onCreate(savedInstanceState); 49 | setContentView(bindLayout()); 50 | mContext = this; 51 | app = (App) getApplication(); 52 | //StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.colorPrimary), 0); 53 | // BarUtils.setColor(this, ContextCompat.getColor(this, R.color.colorPrimary), 0); 54 | init(); 55 | initView(); 56 | 57 | initData(); 58 | initListener(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/base/BaseBean.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.base; 2 | 3 | /** 4 | * Created by Samuel on 2017/3/17. 5 | */ 6 | 7 | public abstract class BaseBean { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.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 | /** 12 | * Created by sunhuahui on 2017/1/30. 13 | */ 14 | 15 | public abstract class BaseFragment extends Fragment { 16 | protected Context mContext; 17 | 18 | protected void init() { 19 | 20 | } 21 | 22 | protected abstract int bindLayout(); 23 | 24 | 25 | /** 26 | * 初始化View 27 | */ 28 | protected abstract void initView(View view); 29 | 30 | /** 31 | * 数据初始化 32 | */ 33 | protected void initData() { 34 | 35 | } 36 | 37 | /** 38 | * 添加监听 39 | */ 40 | protected void initListener() { 41 | } 42 | 43 | @Override 44 | public void onAttach(Context context) { 45 | mContext = context; 46 | super.onAttach(context); 47 | } 48 | 49 | @Override 50 | public void onCreate(@Nullable Bundle savedInstanceState) { 51 | init(); 52 | super.onCreate(savedInstanceState); 53 | } 54 | 55 | @Nullable 56 | @Override 57 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 58 | return inflater.inflate(bindLayout(), container, false); 59 | } 60 | 61 | @Override 62 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 63 | initView(view); 64 | initData(); 65 | initListener(); 66 | super.onViewCreated(view, savedInstanceState); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/constraint/ConstraintActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.constraint; 2 | 3 | import android.os.Handler; 4 | import android.util.Log; 5 | 6 | import com.huaye.odyandroidstore.R; 7 | import com.huaye.odyandroidstore.base.BaseActivity; 8 | 9 | import java.util.concurrent.Callable; 10 | import java.util.concurrent.ExecutionException; 11 | import java.util.concurrent.ExecutorService; 12 | import java.util.concurrent.Executors; 13 | import java.util.concurrent.Future; 14 | 15 | public class ConstraintActivity extends BaseActivity { 16 | Future f; 17 | private Handler handler = new Handler(); 18 | 19 | @Override 20 | protected int bindLayout() { 21 | return R.layout.activity_constraint; 22 | } 23 | 24 | @Override 25 | protected void initView() { 26 | ExecutorService executor = Executors.newCachedThreadPool(); 27 | executor.execute(new Runnable() { 28 | @Override 29 | public void run() { 30 | Log.d("samuel", "tangye"); 31 | } 32 | }); 33 | f = executor.submit(new UploadCallable("孙华辉")); 34 | 35 | handler.postDelayed(new Runnable() { 36 | @Override 37 | public void run() { 38 | try { 39 | Log.d("samuel", f.get()); 40 | } catch (InterruptedException e) { 41 | e.printStackTrace(); 42 | } catch (ExecutionException e) { 43 | e.printStackTrace(); 44 | } 45 | } 46 | }, 5000); 47 | 48 | } 49 | 50 | class UploadCallable implements Callable { 51 | private String result; 52 | 53 | public UploadCallable(String temp) { 54 | result = temp; 55 | } 56 | 57 | @Override 58 | public String call() throws Exception { 59 | Log.d("samuel", result); 60 | return result += ", hello world!!"; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/customview/CircleMenuActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.customview; 2 | 3 | import android.view.View; 4 | import android.widget.ImageView; 5 | import android.widget.TextView; 6 | import android.widget.Toast; 7 | 8 | import com.bumptech.glide.Glide; 9 | import com.huaye.circlemenu.CircleMenuLayout; 10 | import com.huaye.odyandroidstore.R; 11 | import com.huaye.odyandroidstore.base.BaseActivity; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | import butterknife.BindView; 17 | import butterknife.ButterKnife; 18 | 19 | public class CircleMenuActivity extends BaseActivity { 20 | @BindView(R.id.id_menu_layout) 21 | CircleMenuLayout circleMenu; 22 | private List menuList = new ArrayList<>(); 23 | 24 | private String[] mItemTexts = new String[]{"朋友圈 ", "腾讯QQ", "QQ空间", 25 | "腾讯微博", "微信好友", "新浪微博"}; 26 | private int[] mItemImgs = new int[]{R.mipmap.share_friend, 27 | R.mipmap.share_qq, R.mipmap.share_qzone, 28 | R.mipmap.share_morepics, R.mipmap.share_wechat, 29 | R.mipmap.share_weibo}; 30 | 31 | 32 | @Override 33 | protected int bindLayout() { 34 | return R.layout.activity_circle_menu; 35 | } 36 | 37 | @Override 38 | protected void initView() { 39 | ButterKnife.bind(this); 40 | } 41 | 42 | @Override 43 | protected void initData() { 44 | super.initData(); 45 | for (int i = 0; i < mItemTexts.length; i++) { 46 | Menu m = new Menu(); 47 | m.imgId = mItemImgs[i]; 48 | m.label = mItemTexts[i]; 49 | menuList.add(m); 50 | } 51 | circleMenu.setMenus(menuList, new CircleMenuLayout.OnLoadResCallback() { 52 | 53 | @Override 54 | public void showItem(Object o, ImageView img, TextView txt) { 55 | Menu m = (Menu) o; 56 | Glide.with(mContext).load(m.imgId).into(img); 57 | txt.setText(m.label); 58 | } 59 | }); 60 | // circleMenu.setMenuItemIconsAndTexts(mItemImgs, mItemTexts); 61 | } 62 | 63 | @Override 64 | protected void initListener() { 65 | super.initListener(); 66 | circleMenu.setOnMenuItemClickListener(new CircleMenuLayout.OnMenuItemClickListener(){ 67 | 68 | @Override 69 | public void itemClick(View view, int pos){ 70 | Toast.makeText(CircleMenuActivity.this, mItemTexts[pos], 71 | Toast.LENGTH_SHORT).show(); 72 | 73 | } 74 | 75 | @Override 76 | public void itemCenterClick(View view){ 77 | Toast.makeText(CircleMenuActivity.this, 78 | "you can do something just like ccb ", 79 | Toast.LENGTH_SHORT).show(); 80 | 81 | } 82 | }); 83 | } 84 | 85 | private static class Menu{ 86 | public int imgId; 87 | public String label; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/drawable/ShapeDrawableActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.drawable; 2 | 3 | import com.huaye.odyandroidstore.R; 4 | import com.huaye.odyandroidstore.base.BaseActivity; 5 | 6 | public class ShapeDrawableActivity extends BaseActivity { 7 | 8 | @Override 9 | protected int bindLayout() { 10 | return R.layout.activity_shape_drawable; 11 | } 12 | 13 | @Override 14 | protected void initView() { 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/expandablelist/ExpandView.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.expandablelist; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by sunhuahui on 2017/1/28. 7 | */ 8 | 9 | public interface ExpandView { 10 | void fillData(int position, List list); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/expandablelist/ExpandableActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.expandablelist; 2 | 3 | import android.support.v7.widget.LinearLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.View; 7 | 8 | import com.chad.library.adapter.base.BaseQuickAdapter; 9 | import com.chad.library.adapter.base.listener.OnItemClickListener; 10 | import com.huaye.odyandroidstore.R; 11 | import com.huaye.odyandroidstore.base.BaseActivity; 12 | 13 | import java.util.List; 14 | 15 | public class ExpandableActivity extends BaseActivity implements ExpandView { 16 | private RecyclerView fileRv; 17 | private FileAdapter adapter; 18 | private ExpandablePresenter presenter; 19 | 20 | @Override 21 | protected void preOnCreate() { 22 | super.preOnCreate(); 23 | } 24 | 25 | @Override 26 | protected void init() { 27 | super.init(); 28 | adapter = new FileAdapter(); 29 | presenter = new ExpandablePresenter(this); 30 | } 31 | 32 | @Override 33 | protected int bindLayout() { 34 | return R.layout.activity_expandable; 35 | } 36 | 37 | @Override 38 | protected void initView() { 39 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 40 | setSupportActionBar(toolbar); 41 | fileRv = (RecyclerView) findViewById(R.id.fileRv); 42 | fileRv.setLayoutManager(new LinearLayoutManager(this)); 43 | fileRv.setAdapter(adapter); 44 | } 45 | 46 | @Override 47 | protected void initData() { 48 | super.initData(); 49 | presenter.getFiles(-1, presenter.getBasePath()); 50 | 51 | } 52 | 53 | @Override 54 | protected void initListener() { 55 | super.initListener(); 56 | fileRv.addOnItemTouchListener(new OnItemClickListener() { 57 | @Override 58 | public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) { 59 | FilesMultiEntity entity = (FilesMultiEntity) adapter.getItem(position); 60 | if (entity.isExpand) { 61 | adapter.collapse(position); 62 | } else { 63 | presenter.getFiles(position, entity.directory); 64 | } 65 | } 66 | }); 67 | } 68 | 69 | @Override 70 | public void fillData(int position, List list) { 71 | adapter.setNewData(list); 72 | if (position > -1) { 73 | adapter.expand(position); 74 | } 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/expandablelist/ExpandablePresenter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.expandablelist; 2 | 3 | import android.os.Environment; 4 | 5 | import com.huaye.odyandroidstore.subscribe.ApiSubscriber; 6 | import com.huaye.odyandroidstore.subscribe.SubscriberListener; 7 | import com.huaye.odyandroidstore.utils.TimeUtils; 8 | 9 | import java.io.File; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | import rx.Observable; 14 | import rx.android.schedulers.AndroidSchedulers; 15 | import rx.functions.Func1; 16 | import rx.schedulers.Schedulers; 17 | 18 | /** 19 | * Created by sunhuahui on 2017/1/28. 20 | */ 21 | 22 | public class ExpandablePresenter { 23 | 24 | private ExpandView mView; 25 | private List entityList = new ArrayList<>(); 26 | 27 | public ExpandablePresenter(ExpandView view) { 28 | mView = view; 29 | } 30 | 31 | public void getFiles(final int position, String path) { 32 | Observable.just(path) 33 | .map(new Func1() { 34 | @Override 35 | public Void call(String rootPath) { 36 | updateFilesMultiEntity(position, rootPath); 37 | return null; 38 | } 39 | }) 40 | .subscribeOn(Schedulers.io()) 41 | .observeOn(AndroidSchedulers.mainThread()) 42 | .subscribe(new ApiSubscriber(new SubscriberListener() { 43 | @Override 44 | public void onNext(Void aVoid) { 45 | mView.fillData(position, entityList); 46 | } 47 | })); 48 | } 49 | 50 | private void updateFilesMultiEntity(int position, String path) { 51 | File[] files = new File(path).listFiles(); 52 | for (File file : files) { 53 | FilesMultiEntity entity = new FilesMultiEntity(); 54 | if (file.isFile()) { 55 | entity.date = TimeUtils.millis2String(file.lastModified()); 56 | entity.itemType = FileAdapter.TYPE_FILE; 57 | } else { 58 | entity.itemType = FileAdapter.TYPE_DIRECTORY; 59 | } 60 | entity.name = file.getName(); 61 | entity.directory = file.getAbsolutePath(); 62 | 63 | if (position < 0) { 64 | entity.level = 0; 65 | entityList.add(entity); 66 | } else if (position < entityList.size()) { 67 | entity.level = entityList.get(position).level + 1; 68 | entityList.get(position).addSubItem(entity); 69 | } 70 | 71 | } 72 | } 73 | 74 | /** 75 | * 获取sd卡的绝对路径 76 | * 77 | * @return String 如果sd卡存在,返回sd卡的绝对路径,否则返回null 78 | **/ 79 | public String getSDPath() { 80 | String sdcard = Environment.getExternalStorageState(); 81 | if (sdcard.equals(Environment.MEDIA_MOUNTED)) { 82 | return Environment.getExternalStorageDirectory().getAbsolutePath(); 83 | } else { 84 | return null; 85 | } 86 | } 87 | 88 | /** 89 | * 获取一个基本的路径,一般应用创建存放应用数据可以用到 90 | * 91 | * @return String 如果SD卡存在,返回SD卡的绝对路径,如果SD卡不存在,返回Android数据目录的绝对路径 92 | **/ 93 | public String getBasePath() { 94 | String basePath = getSDPath(); 95 | if (basePath == null) { 96 | return Environment.getDataDirectory().getAbsolutePath(); 97 | } else { 98 | return basePath; 99 | } 100 | } 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/expandablelist/FileAdapter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.expandablelist; 2 | 3 | import android.support.annotation.IntRange; 4 | import android.view.View; 5 | import android.widget.LinearLayout; 6 | 7 | import com.chad.library.adapter.base.BaseMultiItemQuickAdapter; 8 | import com.chad.library.adapter.base.BaseViewHolder; 9 | import com.huaye.odyandroidstore.R; 10 | import com.huaye.odyandroidstore.utils.ConvertUtils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by sunhuahui on 2017/1/28. 17 | */ 18 | 19 | public class FileAdapter extends BaseMultiItemQuickAdapter { 20 | 21 | public static final int TYPE_FILE = 0; 22 | public static final int TYPE_DIRECTORY = 1; 23 | 24 | 25 | public FileAdapter() { 26 | this(new ArrayList()); 27 | } 28 | 29 | /** 30 | * Same as QuickAdapter#QuickAdapter(Context,int) but with 31 | * some initialization data. 32 | * 33 | * @param data A new list is created out of this one to avoid mutable list 34 | */ 35 | public FileAdapter(List data) { 36 | super(data); 37 | addItemType(TYPE_FILE, R.layout.item_file); 38 | addItemType(TYPE_DIRECTORY, R.layout.item_directory); 39 | } 40 | 41 | @Override 42 | protected void convert(BaseViewHolder helper, FilesMultiEntity item) { 43 | switch (helper.getItemViewType()) { 44 | case TYPE_FILE: 45 | helper.setImageResource(R.id.type_icon, R.mipmap.file) 46 | .setText(R.id.date, item.date); 47 | break; 48 | case TYPE_DIRECTORY: 49 | if (item.isExpand) { 50 | helper.setImageResource(R.id.arrow, R.mipmap.arrow_down); 51 | } else { 52 | helper.setImageResource(R.id.arrow, R.mipmap.arrow_right); 53 | } 54 | helper.setImageResource(R.id.type_icon, R.mipmap.directory); 55 | break; 56 | } 57 | View typeIcon = helper.getView(R.id.type_icon); 58 | LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) typeIcon.getLayoutParams(); 59 | 60 | params.setMargins(ConvertUtils.dp2px(8 * item.level), 0, 0, 0); 61 | typeIcon.setLayoutParams(params); 62 | helper.setText(R.id.name, item.name); 63 | } 64 | 65 | @Override 66 | public int expand(@IntRange(from = 0L) int position) { 67 | mData.get(position).isExpand = true; 68 | return super.expand(position); 69 | } 70 | 71 | @Override 72 | public int collapse(@IntRange(from = 0L) int position) { 73 | mData.get(position).isExpand = false; 74 | return super.collapse(position); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/expandablelist/FilesMultiEntity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.expandablelist; 2 | 3 | import com.chad.library.adapter.base.entity.AbstractExpandableItem; 4 | import com.chad.library.adapter.base.entity.MultiItemEntity; 5 | 6 | /** 7 | * Created by sunhuahui on 2017/1/28. 8 | */ 9 | 10 | public class FilesMultiEntity extends AbstractExpandableItem implements MultiItemEntity { 11 | 12 | public int level = 0; 13 | public int itemType = 0; 14 | public String name; 15 | public String date; 16 | public String directory; 17 | public boolean isExpand = false; 18 | 19 | @Override 20 | public int getLevel() { 21 | return level; 22 | } 23 | 24 | @Override 25 | public int getItemType() { 26 | return itemType; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/hotfix/HotFixActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.hotfix; 2 | 3 | import android.view.View; 4 | import android.widget.Button; 5 | import android.widget.TextView; 6 | 7 | import com.huaye.odyandroidstore.R; 8 | import com.huaye.odyandroidstore.base.BaseActivity; 9 | import com.huaye.odyandroidstore.utils.ToastUtils; 10 | 11 | import butterknife.BindView; 12 | import butterknife.ButterKnife; 13 | 14 | public class HotFixActivity extends BaseActivity { 15 | @BindView(R.id.toast) 16 | TextView toast; 17 | 18 | @BindView(R.id.download) 19 | Button download; 20 | 21 | @Override 22 | protected int bindLayout() { 23 | return R.layout.activity_hot_fix; 24 | } 25 | 26 | @Override 27 | protected void initView() { 28 | ButterKnife.bind(this); 29 | } 30 | 31 | private void showTip() { 32 | ToastUtils.showLongToast("new"); 33 | } 34 | 35 | @Override 36 | protected void initListener() { 37 | super.initListener(); 38 | toast.setOnClickListener(new View.OnClickListener() { 39 | @Override 40 | public void onClick(View v) { 41 | showTip(); 42 | } 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/hotfix/Update.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.hotfix; 2 | 3 | import cn.bmob.v3.BmobObject; 4 | import cn.bmob.v3.datatype.BmobFile; 5 | 6 | /** 7 | * Created by Samuel on 2017/4/5. 8 | */ 9 | 10 | public class Update extends BmobObject { 11 | private BmobFile updateFile; 12 | 13 | public BmobFile getUpdateFile() { 14 | return updateFile; 15 | } 16 | 17 | public void setUpdateFile(BmobFile updateFile) { 18 | this.updateFile = updateFile; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/lyf/home/AdBean.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.lyf.home; 2 | 3 | import com.huaye.odyandroidstore.base.Ad; 4 | import com.huaye.odyandroidstore.base.BaseBean; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by Samuel on 2017/4/6. 10 | */ 11 | 12 | public class AdBean extends BaseBean { 13 | public List ad_banner; 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/lyf/home/HomeAdapter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.lyf.home; 2 | 3 | import com.chad.library.adapter.base.BaseQuickAdapter; 4 | import com.chad.library.adapter.base.BaseViewHolder; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by Samuel on 2017/4/6. 10 | */ 11 | 12 | public class HomeAdapter extends BaseQuickAdapter { 13 | public HomeAdapter(int layoutResId, List data) { 14 | super(layoutResId, data); 15 | } 16 | 17 | @Override 18 | protected void convert(BaseViewHolder helper, HomeItem item) { 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/lyf/home/HomeItem.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.lyf.home; 2 | 3 | import com.huaye.odyandroidstore.base.Ad; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Samuel on 2017/4/6. 9 | */ 10 | 11 | public class HomeItem { 12 | public int itemType; 13 | public List banner; 14 | public Ad ad; 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/lyf/home/LYFHomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.lyf.home; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | import com.dinuscxj.refresh.RecyclerRefreshLayout; 6 | import com.huaye.odyandroidstore.R; 7 | import com.huaye.odyandroidstore.base.BaseActivity; 8 | 9 | import butterknife.BindView; 10 | import butterknife.ButterKnife; 11 | 12 | public class LYFHomeActivity extends BaseActivity { 13 | @BindView(R.id.rv) 14 | RecyclerView rv; 15 | 16 | @BindView(R.id.refreshLay) 17 | RecyclerRefreshLayout refreshLay; 18 | 19 | @Override 20 | protected int bindLayout() { 21 | return R.layout.activity_lyfhome; 22 | } 23 | 24 | @Override 25 | protected void initView() { 26 | ButterKnife.bind(this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/taobao/ProductAdapter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.taobao; 2 | 3 | import android.widget.ImageView; 4 | 5 | import com.bumptech.glide.Glide; 6 | import com.bumptech.glide.load.engine.DiskCacheStrategy; 7 | import com.chad.library.adapter.base.BaseQuickAdapter; 8 | import com.chad.library.adapter.base.BaseViewHolder; 9 | import com.huaye.odyandroidstore.R; 10 | import com.huaye.odyandroidstore.retrofit.taobao.TaoBaoProductBean; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Samuel on 2017/3/13. 17 | */ 18 | 19 | public class ProductAdapter extends BaseQuickAdapter { 20 | public ProductAdapter() { 21 | this(R.layout.item_taobao_product, new ArrayList()); 22 | } 23 | 24 | public ProductAdapter(int layoutResId) { 25 | super(layoutResId, new ArrayList()); 26 | } 27 | 28 | public ProductAdapter(int layoutResId, List data) { 29 | super(layoutResId, data); 30 | } 31 | 32 | @Override 33 | protected void convert(BaseViewHolder helper, TaoBaoProductBean.Product item) { 34 | helper.setText(R.id.price, item.price) 35 | .setText(R.id.title, item.title) 36 | .setText(R.id.area, item.area) 37 | .setText(R.id.act, item.act + "人付款"); 38 | //http://img.alicdn.com/imgextra/i2/1326605018494379751/TB27L5qholnpuFjSZFjXXXTaVXa_!!0-saturn_solar.jpg 39 | String img; 40 | if (item.img2.startsWith("http")) { 41 | img = item.img2; 42 | } else { 43 | img = "http:" + item.img2; 44 | } 45 | Glide.with(helper.itemView.getContext()) 46 | .load(img) 47 | .diskCacheStrategy(DiskCacheStrategy.ALL) 48 | .into((ImageView) helper.getView(R.id.img)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/taobao/SearchResultPresenter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.taobao; 2 | 3 | import com.huaye.odyandroidstore.retrofit.RetrofitFactory; 4 | import com.huaye.odyandroidstore.retrofit.taobao.TaoBaoProductBean; 5 | import com.huaye.odyandroidstore.subscribe.ApiSubscriber; 6 | import com.huaye.odyandroidstore.subscribe.SubscriberListener; 7 | import com.huaye.odyandroidstore.utils.StringUtils; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | import rx.android.schedulers.AndroidSchedulers; 13 | import rx.schedulers.Schedulers; 14 | 15 | /** 16 | * Created by Samuel on 2017/3/13. 17 | */ 18 | 19 | public class SearchResultPresenter { 20 | private SearchResultView mView; 21 | 22 | public SearchResultPresenter(SearchResultView view) { 23 | mView = view; 24 | } 25 | 26 | public void getProductList(String key, final int page) { 27 | getProductList(key, page, null); 28 | } 29 | 30 | public void getProductList(String key, final int page, String sort) { 31 | Map params = new HashMap<>(); 32 | params.put("q", key); 33 | params.put("page", String.valueOf(page)); 34 | if (!StringUtils.isEmpty(sort)) { 35 | params.put("sort", sort); 36 | } 37 | RetrofitFactory.getProductList(params) 38 | .subscribeOn(Schedulers.io()) 39 | .observeOn(AndroidSchedulers.mainThread()) 40 | .subscribe(new ApiSubscriber(new SubscriberListener() { 41 | @Override 42 | public void onNext(TaoBaoProductBean bean) { 43 | if (page > 1) { 44 | mView.addProduct(bean.listItem); 45 | } else { 46 | mView.showProduct(bean.listItem); 47 | } 48 | } 49 | })); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/imitate/taobao/SearchResultView.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.imitate.taobao; 2 | 3 | import com.huaye.odyandroidstore.retrofit.taobao.TaoBaoProductBean; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by Samuel on 2017/3/13. 9 | */ 10 | 11 | public interface SearchResultView { 12 | void showProduct(List list); 13 | 14 | void addProduct(List list); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/library/Function.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.library; 2 | 3 | /** 4 | * Created by sunhuahui on 2017/1/28. 5 | */ 6 | 7 | public class Function { 8 | private int imgId; 9 | private String docUrl; 10 | private String imgUrl; 11 | private String name; 12 | private String des; 13 | private String extra; 14 | private Class clazz; 15 | 16 | public Function() { 17 | } 18 | 19 | public Function(int imgId, String name, String des, String extra, Class clazz) { 20 | this.imgId = imgId; 21 | this.name = name; 22 | this.des = des; 23 | this.extra = extra; 24 | this.clazz = clazz; 25 | } 26 | 27 | public Function(String imgUrl, String name, String des, String extra, Class clazz) { 28 | this.imgUrl = imgUrl; 29 | this.name = name; 30 | this.des = des; 31 | this.extra = extra; 32 | this.clazz = clazz; 33 | } 34 | 35 | public Function(int imgId, String name, String des, Class clazz) { 36 | this.imgId = imgId; 37 | this.name = name; 38 | this.des = des; 39 | this.clazz = clazz; 40 | } 41 | 42 | public int getImgId() { 43 | return imgId; 44 | } 45 | 46 | public Function setImgId(int imgId) { 47 | this.imgId = imgId; 48 | return this; 49 | } 50 | 51 | public String getDocUrl() { 52 | return docUrl; 53 | } 54 | 55 | public Function setDocUrl(String docUrl) { 56 | this.docUrl = docUrl; 57 | return this; 58 | } 59 | 60 | public String getImgUrl() { 61 | return imgUrl; 62 | } 63 | 64 | public Function setImgUrl(String imgUrl) { 65 | this.imgUrl = imgUrl; 66 | return this; 67 | } 68 | 69 | public String getName() { 70 | return name; 71 | } 72 | 73 | public Function setName(String name) { 74 | this.name = name; 75 | return this; 76 | } 77 | 78 | public String getDes() { 79 | return des; 80 | } 81 | 82 | public Function setDes(String des) { 83 | this.des = des; 84 | return this; 85 | } 86 | 87 | public String getExtra() { 88 | return extra; 89 | } 90 | 91 | public Function setExtra(String extra) { 92 | this.extra = extra; 93 | return this; 94 | } 95 | 96 | public Class getClazz() { 97 | return clazz; 98 | } 99 | 100 | public Function setClazz(Class clazz) { 101 | this.clazz = clazz; 102 | return this; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/library/FunctionAdapter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.library; 2 | 3 | import com.chad.library.adapter.base.BaseQuickAdapter; 4 | import com.chad.library.adapter.base.BaseViewHolder; 5 | import com.huaye.odyandroidstore.R; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by sunhuahui on 2017/1/28. 12 | */ 13 | 14 | public class FunctionAdapter extends BaseQuickAdapter { 15 | 16 | public FunctionAdapter() { 17 | this(R.layout.item_function, new ArrayList()); 18 | } 19 | 20 | public FunctionAdapter(int layoutResId, List data) { 21 | super(layoutResId, data); 22 | } 23 | 24 | @Override 25 | protected void convert(BaseViewHolder helper, Function item) { 26 | helper.setText(R.id.item, item.getName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/library/FunctionPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.library; 2 | 3 | import android.support.v4.view.PagerAdapter; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by sunhuahui on 2017/1/29. 11 | */ 12 | 13 | public class FunctionPagerAdapter extends PagerAdapter { 14 | private List mViewList; 15 | 16 | public FunctionPagerAdapter(List mViewList) { 17 | this.mViewList = mViewList; 18 | } 19 | 20 | @Override 21 | public int getCount() {//必须实现 22 | return mViewList.size(); 23 | } 24 | 25 | @Override 26 | public boolean isViewFromObject(View view, Object object) {//必须实现 27 | return view == object; 28 | } 29 | 30 | @Override 31 | public Object instantiateItem(ViewGroup container, int position) {//必须实现,实例化 32 | View view = mViewList.get(position); 33 | if (view.getParent() != null) { 34 | container.removeView(view); 35 | } 36 | container.addView(view); 37 | return mViewList.get(position); 38 | } 39 | 40 | @Override 41 | public void destroyItem(ViewGroup container, int position, Object object) {//必须实现,销毁 42 | container.removeView(mViewList.get(position)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/library/LibraryPresenter.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.library; 2 | 3 | /** 4 | * Created by sunhuahui on 2017/1/28. 5 | */ 6 | 7 | public class LibraryPresenter { 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/library/LibraryView.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.library; 2 | 3 | /** 4 | * Created by sunhuahui on 2017/1/28. 5 | */ 6 | 7 | public interface LibraryView { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/md/CoordinatorMobileActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.md; 2 | 3 | import android.graphics.Color; 4 | import android.support.design.widget.AppBarLayout; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.Menu; 7 | import android.widget.TextView; 8 | 9 | import com.huaye.odyandroidstore.R; 10 | import com.huaye.odyandroidstore.base.BaseActivity; 11 | import com.huaye.odyandroidstore.utils.BarUtils; 12 | 13 | import butterknife.BindView; 14 | import butterknife.ButterKnife; 15 | 16 | /** 17 | * 18 | * 摩拜单车---个人中心 19 | * Created by 孙华辉 on 2017/2/23. 20 | */ 21 | 22 | public class CoordinatorMobileActivity extends BaseActivity { 23 | 24 | @BindView(R.id.toolbar) 25 | Toolbar toolbar; 26 | 27 | @BindView(R.id.main_abl_app_bar) 28 | AppBarLayout mAblBar; 29 | 30 | @BindView(R.id.main_tv_toolbar_title) 31 | TextView title; 32 | 33 | @Override 34 | protected int bindLayout() { 35 | return R.layout.activity_coordinator_mobile; 36 | } 37 | 38 | @Override 39 | protected void initView() { 40 | BarUtils.setColor(this, Color.parseColor("#5DC9D3"), 0); 41 | ButterKnife.bind(this); 42 | toolbar.setTitle(""); 43 | setSupportActionBar(toolbar); 44 | } 45 | 46 | @Override 47 | protected void initListener() { 48 | super.initListener(); 49 | mAblBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { 50 | @Override 51 | public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { 52 | int halfScroll = appBarLayout.getTotalScrollRange() / 2; 53 | int offSetAbs = Math.abs(verticalOffset); 54 | float percentage; 55 | if (offSetAbs < halfScroll) { 56 | title.setText("摩拜单车"); 57 | percentage = 1 - (float) offSetAbs / (float) halfScroll; 58 | } else { 59 | title.setText("个人中心"); 60 | percentage = (float) (offSetAbs - halfScroll) / (float) halfScroll; 61 | } 62 | toolbar.setAlpha(percentage); 63 | } 64 | }); 65 | } 66 | 67 | @Override 68 | public boolean onCreateOptionsMenu(Menu menu) { 69 | // getMenuInflater().inflate(R.menu.menu_title, menu); 70 | return true; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/md/CoordinatorPuckerActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.md; 2 | 3 | import android.support.design.widget.AppBarLayout; 4 | import android.widget.LinearLayout; 5 | 6 | import com.huaye.odyandroidstore.R; 7 | import com.huaye.odyandroidstore.base.BaseActivity; 8 | 9 | import butterknife.BindView; 10 | import butterknife.ButterKnife; 11 | 12 | public class CoordinatorPuckerActivity extends BaseActivity { 13 | @BindView(R.id.app_bar) 14 | AppBarLayout mAppBarLayout; 15 | @BindView(R.id.lin1) 16 | LinearLayout mLin1; 17 | @BindView(R.id.lin2) 18 | LinearLayout mLin2; 19 | 20 | @Override 21 | protected int bindLayout() { 22 | return R.layout.activity_ppd; 23 | } 24 | 25 | @Override 26 | protected void initView() { 27 | ButterKnife.bind(this); 28 | } 29 | 30 | @Override 31 | protected void initListener() { 32 | super.initListener(); 33 | mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { 34 | @Override 35 | public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { 36 | int height = appBarLayout.getTotalScrollRange(); 37 | int offSetAbs = Math.abs(verticalOffset); 38 | float p = (float) offSetAbs / (float) height; 39 | mLin1.setAlpha(1 - p); 40 | if ((1 - p) > 0.5) { 41 | mLin2.setAlpha(1 - p); 42 | mAppBarLayout.setAlpha(1 - p); 43 | } else { 44 | mLin2.setAlpha(p); 45 | mAppBarLayout.setAlpha(p); 46 | } 47 | } 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/md/ToolBarActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.md; 2 | 3 | import com.huaye.odyandroidstore.R; 4 | import com.huaye.odyandroidstore.base.BaseActivity; 5 | 6 | public class ToolBarActivity extends BaseActivity { 7 | 8 | @Override 9 | protected int bindLayout() { 10 | return R.layout.activity_tool_bar; 11 | } 12 | 13 | @Override 14 | protected void initView() { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/my/BlankFragment.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.my; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.huaye.odyandroidstore.R; 11 | 12 | /** 13 | * A simple {@link Fragment} subclass. 14 | * Use the {@link BlankFragment#newInstance} factory method to 15 | * create an instance of this fragment. 16 | */ 17 | public class BlankFragment extends Fragment { 18 | // TODO: Rename parameter arguments, choose names that match 19 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 20 | private static final String ARG_PARAM1 = "param1"; 21 | private static final String ARG_PARAM2 = "param2"; 22 | 23 | // TODO: Rename and change types of parameters 24 | private String mParam1; 25 | private String mParam2; 26 | 27 | 28 | public BlankFragment() { 29 | // Required empty public constructor 30 | } 31 | 32 | /** 33 | * Use this factory method to create a new instance of 34 | * this fragment using the provided parameters. 35 | * 36 | * @param param1 Parameter 1. 37 | * @param param2 Parameter 2. 38 | * @return A new instance of fragment BlankFragment. 39 | */ 40 | // TODO: Rename and change types and number of parameters 41 | public static BlankFragment newInstance(String param1, String param2) { 42 | BlankFragment fragment = new BlankFragment(); 43 | Bundle args = new Bundle(); 44 | args.putString(ARG_PARAM1, param1); 45 | args.putString(ARG_PARAM2, param2); 46 | fragment.setArguments(args); 47 | return fragment; 48 | } 49 | 50 | @Override 51 | public void onCreate(Bundle savedInstanceState) { 52 | super.onCreate(savedInstanceState); 53 | if (getArguments() != null) { 54 | mParam1 = getArguments().getString(ARG_PARAM1); 55 | mParam2 = getArguments().getString(ARG_PARAM2); 56 | } 57 | } 58 | 59 | @Override 60 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 61 | Bundle savedInstanceState) { 62 | // Inflate the layout for this fragment 63 | return inflater.inflate(R.layout.fragment_blank, container, false); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/my/MyFragment.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.my; 2 | 3 | 4 | import android.support.v4.app.Fragment; 5 | import android.view.View; 6 | 7 | import com.huaye.odyandroidstore.R; 8 | import com.huaye.odyandroidstore.base.BaseFragment; 9 | 10 | /** 11 | * A simple {@link Fragment} subclass. 12 | */ 13 | public class MyFragment extends BaseFragment { 14 | 15 | 16 | @Override 17 | protected int bindLayout() { 18 | return R.layout.fragment_my; 19 | } 20 | 21 | @Override 22 | protected void initView(View view) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/retrofit/NetWorkApi.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.retrofit; 2 | 3 | import com.huaye.odyandroidstore.imitate.lyf.home.AdBean; 4 | import com.huaye.odyandroidstore.retrofit.taobao.TaoBaoProductBean; 5 | 6 | import java.util.Map; 7 | 8 | import retrofit2.http.GET; 9 | import retrofit2.http.Query; 10 | import retrofit2.http.QueryMap; 11 | import rx.Observable; 12 | 13 | /** 14 | * Created by Administrator on 2016/11/30. 15 | */ 16 | 17 | public interface NetWorkApi { 18 | //https://s.m.taobao.com/search?event_submit_do_new_search_auction=1&_input_charset=utf-8&topSearch=1&atype=b&searchfrom=1&action=home%3Aredirect_app_action&from=1&sst=1&n=20&buying=buyitnow&m=api4h5&abtest=11&wlsort=11&style=list&closeModues=nav%2Cselecthot%2Conesearch&sort=_sale&page=1 19 | @GET("https://s.m.taobao.com/search?event_submit_do_new_search_auction=1&_input_charset=utf-8&topSearch=1&atype=b&searchfrom=1&action=home%3Aredirect_app_action&from=1&sst=1&n=20&buying=buyitnow&m=api4h5&abtest=13&wlsort=13") 20 | Observable getProductList(@Query("q") String q, @Query("page") int page); 21 | 22 | @GET("https://s.m.taobao.com/search?event_submit_do_new_search_auction=1&_input_charset=utf-8&topSearch=1&atype=b&searchfrom=1&action=home%3Aredirect_app_action&from=1&sst=1&n=20&buying=buyitnow&m=api4h5&abtest=13&wlsort=13") 23 | Observable getProductList(@QueryMap Map params); 24 | 25 | @GET("http://api.laiyifen.com/api/dolphin/list?&platform=3&platformId=0&pageCode=APP_HOME&adCode=ad_banner&areaCode=310115") 26 | Observable getAd(@QueryMap Map params); 27 | } -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/retrofit/RetrofitFactory.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.retrofit; 2 | 3 | import com.huaye.odyandroidstore.base.Ad; 4 | import com.huaye.odyandroidstore.imitate.lyf.home.AdBean; 5 | import com.huaye.odyandroidstore.retrofit.taobao.TaoBaoProductBean; 6 | 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import rx.Observable; 12 | import rx.Subscriber; 13 | import rx.functions.Func1; 14 | 15 | /** 16 | * Created by Administrator on 2016/11/30. 17 | */ 18 | 19 | public class RetrofitFactory { 20 | protected static final Object monitor = new Object(); 21 | static NetWorkApi sNetWorkApi = null; 22 | 23 | 24 | public static NetWorkApi getNetWorkApi() { 25 | synchronized (monitor) { 26 | if (sNetWorkApi == null) { 27 | sNetWorkApi = new RetrofitHelper().getCategoryService(); 28 | } 29 | return sNetWorkApi; 30 | } 31 | } 32 | 33 | /** 34 | * 获取分类页数据 35 | * 36 | * @param q 37 | * @return 38 | */ 39 | public static Observable getProductList(String q, String page) { 40 | Map params = new HashMap<>(); 41 | params.put("q", q); 42 | params.put("page", page); 43 | return getNetWorkApi().getProductList(params); 44 | } 45 | 46 | /** 47 | * 获取分类页数据 48 | * 49 | * @return 50 | */ 51 | public static Observable getProductList(Map params) { 52 | // Map params = new HashMap<>(); 53 | // params.put("q", q); 54 | // params.put("page", page); 55 | // params.put("sort", sort); 56 | return getNetWorkApi().getProductList(params); 57 | } 58 | 59 | /** 60 | * 获取广告数据 61 | */ 62 | public static Observable> getAd(String adCode, String pageCode) { 63 | Observable.create(new Observable.OnSubscribe() { 64 | @Override 65 | public void call(Subscriber subscriber) { 66 | 67 | } 68 | }); 69 | Map params = new HashMap<>(); 70 | params.put("adCode", adCode); 71 | params.put("pageCode", pageCode); 72 | return getNetWorkApi().getAd(params) 73 | .filter(new Func1() { 74 | @Override 75 | public Boolean call(AdBean adBean) { 76 | return adBean != null && adBean.ad_banner != null; 77 | } 78 | }) 79 | .map(new Func1>() { 80 | @Override 81 | public List call(AdBean adBean) { 82 | return adBean.ad_banner; 83 | } 84 | }); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/retrofit/RetrofitHelper.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.retrofit; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import okhttp3.OkHttpClient; 6 | import retrofit2.Retrofit; 7 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 8 | import retrofit2.converter.gson.GsonConverterFactory; 9 | 10 | /** 11 | * Created by Administrator on 2016/11/30. 12 | */ 13 | 14 | public class RetrofitHelper { 15 | public static final String BASE_URL = "https://s.m.taobao.com"; 16 | private static final int DEFAULT_TIMEOUT = 15; 17 | NetWorkApi netWorkApi; 18 | private Retrofit retrofit; 19 | 20 | public RetrofitHelper() { 21 | //手动创建一个OkHttpClient并设置超时时间 22 | OkHttpClient.Builder builder = new OkHttpClient.Builder(); 23 | builder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS); 24 | 25 | Retrofit.Builder b = new Retrofit.Builder() 26 | .client(builder.build()) 27 | .addConverterFactory(GsonConverterFactory.create()) 28 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 29 | .baseUrl(BASE_URL); 30 | 31 | retrofit = b.build(); 32 | } 33 | 34 | public NetWorkApi getCategoryService() { 35 | return retrofit.create(NetWorkApi.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/subscribe/ApiSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.subscribe; 2 | 3 | import rx.Subscriber; 4 | 5 | /** 6 | * 用于在Http请求开始时,自动显示一个ProgressDialog 7 | * 在Http请求结束是,关闭ProgressDialog 8 | * 调用者自己对请求数据进行处理 9 | * Created by 孙华辉 on 16/3/10. 10 | */ 11 | public class ApiSubscriber extends Subscriber { 12 | 13 | private SubscriberListener mSubscriberListener; 14 | 15 | public ApiSubscriber(SubscriberListener mSubscriberListener) { 16 | this.mSubscriberListener = mSubscriberListener; 17 | } 18 | 19 | /** 20 | * 订阅开始时调用 21 | * 显示ProgressDialog 22 | */ 23 | @Override 24 | public void onStart() { 25 | //showProgressDialog(); 26 | } 27 | 28 | /** 29 | * 完成,隐藏ProgressDialog 30 | */ 31 | @Override 32 | public void onCompleted() { 33 | // dismissProgressDialog(); 34 | if (mSubscriberListener != null) { 35 | mSubscriberListener.onCompleted(); 36 | } 37 | } 38 | 39 | /** 40 | * 对错误进行统一处理 41 | * 隐藏ProgressDialog 42 | * 43 | * @param e 44 | */ 45 | @Override 46 | public void onError(Throwable e) { 47 | if (mSubscriberListener != null) { 48 | mSubscriberListener.onError(e != null ? e.getMessage() : "位置错误"); 49 | } 50 | } 51 | 52 | /** 53 | * 将onNext方法中的返回结果交给Activity或Fragment自己处理 54 | * 55 | * @param t 创建Subscriber时的泛型类型 56 | */ 57 | @Override 58 | public void onNext(T t) { 59 | if (mSubscriberListener != null) { 60 | mSubscriberListener.onNext(t); 61 | } 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/subscribe/SubscriberListener.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.subscribe; 2 | 3 | /** 4 | * Created by sunhuahui on 16/3/10. 5 | */ 6 | public abstract class SubscriberListener { 7 | public abstract void onNext(T t); 8 | 9 | public void onCompleted() { 10 | } 11 | 12 | public void onError(String msg) { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/ActivityUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.content.pm.ResolveInfo; 7 | import android.os.Build; 8 | import android.os.Bundle; 9 | import android.util.ArrayMap; 10 | 11 | import java.lang.reflect.Field; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | *
 18 |  *     author: Blankj
 19 |  *     blog  : http://blankj.com
 20 |  *     time  : 2016/9/23
 21 |  *     desc  : Activity相关工具类
 22 |  * 
23 | */ 24 | public class ActivityUtils { 25 | 26 | private ActivityUtils() { 27 | throw new UnsupportedOperationException("u can't instantiate me..."); 28 | } 29 | 30 | /** 31 | * 判断是否存在Activity 32 | * 33 | * @param packageName 包名 34 | * @param className activity全路径类名 35 | * @return {@code true}: 是
{@code false}: 否 36 | */ 37 | public static boolean isActivityExists(String packageName, String className) { 38 | Intent intent = new Intent(); 39 | intent.setClassName(packageName, className); 40 | return !(Utils.getContext().getPackageManager().resolveActivity(intent, 0) == null || 41 | intent.resolveActivity(Utils.getContext().getPackageManager()) == null || 42 | Utils.getContext().getPackageManager().queryIntentActivities(intent, 0).size() == 0); 43 | } 44 | 45 | /** 46 | * 打开Activity 47 | * 48 | * @param packageName 包名 49 | * @param className 全类名 50 | */ 51 | public static void launchActivity(String packageName, String className) { 52 | launchActivity(packageName, className, null); 53 | } 54 | 55 | /** 56 | * 打开Activity 57 | * 58 | * @param packageName 包名 59 | * @param className 全类名 60 | * @param bundle bundle 61 | */ 62 | public static void launchActivity(String packageName, String className, Bundle bundle) { 63 | Utils.getContext().startActivity(IntentUtils.getComponentIntent(packageName, className, bundle)); 64 | } 65 | 66 | /** 67 | * 获取launcher activity 68 | * 69 | * @param packageName 包名 70 | * @return launcher activity 71 | */ 72 | public static String getLauncherActivity(String packageName) { 73 | Intent intent = new Intent(Intent.ACTION_MAIN, null); 74 | intent.addCategory(Intent.CATEGORY_LAUNCHER); 75 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 76 | PackageManager pm = Utils.getContext().getPackageManager(); 77 | List infos = pm.queryIntentActivities(intent, 0); 78 | for (ResolveInfo info : infos) { 79 | if (info.activityInfo.packageName.equals(packageName)) { 80 | return info.activityInfo.name; 81 | } 82 | } 83 | return "no " + packageName; 84 | } 85 | 86 | 87 | /** 88 | * 获取栈顶Activity 89 | * 90 | * @return 栈顶Activity 91 | */ 92 | public static Activity getTopActivity() { 93 | try { 94 | Class activityThreadClass = Class.forName("android.app.ActivityThread"); 95 | Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); 96 | Field activitiesField = activityThreadClass.getDeclaredField("mActivities"); 97 | activitiesField.setAccessible(true); 98 | Map activities = null; 99 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { 100 | activities = (HashMap) activitiesField.get(activityThread); 101 | } else { 102 | activities = (ArrayMap) activitiesField.get(activityThread); 103 | } 104 | for (Object activityRecord : activities.values()) { 105 | Class activityRecordClass = activityRecord.getClass(); 106 | Field pausedField = activityRecordClass.getDeclaredField("paused"); 107 | pausedField.setAccessible(true); 108 | if (!pausedField.getBoolean(activityRecord)) { 109 | Field activityField = activityRecordClass.getDeclaredField("activity"); 110 | activityField.setAccessible(true); 111 | return (Activity) activityField.get(activityRecord); 112 | } 113 | } 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | return null; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/CleanUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | *
  7 |  *     author: Blankj
  8 |  *     blog  : http://blankj.com
  9 |  *     time  : 2016/9/27
 10 |  *     desc  : 清除相关工具类
 11 |  * 
12 | */ 13 | public class CleanUtils { 14 | 15 | private CleanUtils() { 16 | throw new UnsupportedOperationException("u can't instantiate me..."); 17 | } 18 | 19 | /** 20 | * 清除内部缓存 21 | *

/data/data/com.xxx.xxx/cache

22 | * 23 | * @return {@code true}: 清除成功
{@code false}: 清除失败 24 | */ 25 | public static boolean cleanInternalCache() { 26 | return FileUtils.deleteFilesInDir(Utils.getContext().getCacheDir()); 27 | } 28 | 29 | /** 30 | * 清除内部文件 31 | *

/data/data/com.xxx.xxx/files

32 | * 33 | * @return {@code true}: 清除成功
{@code false}: 清除失败 34 | */ 35 | public static boolean cleanInternalFiles() { 36 | return FileUtils.deleteFilesInDir(Utils.getContext().getFilesDir()); 37 | } 38 | 39 | /** 40 | * 清除内部数据库 41 | *

/data/data/com.xxx.xxx/databases

42 | * 43 | * @return {@code true}: 清除成功
{@code false}: 清除失败 44 | */ 45 | public static boolean cleanInternalDbs() { 46 | return FileUtils.deleteFilesInDir(Utils.getContext().getFilesDir().getParent() + File.separator + "databases"); 47 | } 48 | 49 | /** 50 | * 根据名称清除数据库 51 | *

/data/data/com.xxx.xxx/databases/dbName

52 | * 53 | * @param dbName 数据库名称 54 | * @return {@code true}: 清除成功
{@code false}: 清除失败 55 | */ 56 | public static boolean cleanInternalDbByName( String dbName) { 57 | return Utils.getContext().deleteDatabase(dbName); 58 | } 59 | 60 | /** 61 | * 清除内部SP 62 | *

/data/data/com.xxx.xxx/shared_prefs

63 | * 64 | * @return {@code true}: 清除成功
{@code false}: 清除失败 65 | */ 66 | public static boolean cleanInternalSP() { 67 | return FileUtils.deleteFilesInDir(Utils.getContext().getFilesDir().getParent() + File.separator + "shared_prefs"); 68 | } 69 | 70 | /** 71 | * 清除外部缓存 72 | *

/storage/emulated/0/android/data/com.xxx.xxx/cache

73 | * 74 | * @return {@code true}: 清除成功
{@code false}: 清除失败 75 | */ 76 | public static boolean cleanExternalCache() { 77 | return SDCardUtils.isSDCardEnable() && FileUtils.deleteFilesInDir(Utils.getContext().getExternalCacheDir()); 78 | } 79 | 80 | /** 81 | * 清除自定义目录下的文件 82 | * 83 | * @param dirPath 目录路径 84 | * @return {@code true}: 清除成功
{@code false}: 清除失败 85 | */ 86 | public static boolean cleanCustomCache(String dirPath) { 87 | return FileUtils.deleteFilesInDir(dirPath); 88 | } 89 | 90 | /** 91 | * 清除自定义目录下的文件 92 | * 93 | * @param dir 目录 94 | * @return {@code true}: 清除成功
{@code false}: 清除失败 95 | */ 96 | public static boolean cleanCustomCache(File dir) { 97 | return FileUtils.deleteFilesInDir(dir); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/ClipboardUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import android.content.ClipData; 4 | import android.content.ClipboardManager; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.net.Uri; 8 | 9 | /** 10 | *
11 |  *     author: Blankj
12 |  *     blog  : http://blankj.com
13 |  *     time  : 2016/9/25
14 |  *     desc  : 剪贴板相关工具类
15 |  * 
16 | */ 17 | public class ClipboardUtils { 18 | 19 | private ClipboardUtils() { 20 | throw new UnsupportedOperationException("u can't instantiate me..."); 21 | } 22 | 23 | /** 24 | * 复制文本到剪贴板 25 | * 26 | * @param text 文本 27 | */ 28 | public static void copyText(CharSequence text) { 29 | ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE); 30 | clipboard.setPrimaryClip(ClipData.newPlainText("text", text)); 31 | } 32 | 33 | /** 34 | * 获取剪贴板的文本 35 | * 36 | * @return 剪贴板的文本 37 | */ 38 | public static CharSequence getText() { 39 | ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE); 40 | ClipData clip = clipboard.getPrimaryClip(); 41 | if (clip != null && clip.getItemCount() > 0) { 42 | return clip.getItemAt(0).coerceToText(Utils.getContext()); 43 | } 44 | return null; 45 | } 46 | 47 | /** 48 | * 复制uri到剪贴板 49 | * 50 | * @param uri uri 51 | */ 52 | public static void copyUri(Uri uri) { 53 | ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE); 54 | clipboard.setPrimaryClip(ClipData.newUri(Utils.getContext().getContentResolver(), "uri", uri)); 55 | } 56 | 57 | /** 58 | * 获取剪贴板的uri 59 | * 60 | * @return 剪贴板的uri 61 | */ 62 | public static Uri getUri() { 63 | ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE); 64 | ClipData clip = clipboard.getPrimaryClip(); 65 | if (clip != null && clip.getItemCount() > 0) { 66 | return clip.getItemAt(0).getUri(); 67 | } 68 | return null; 69 | } 70 | 71 | /** 72 | * 复制意图到剪贴板 73 | * 74 | * @param intent 意图 75 | */ 76 | public static void copyIntent(Intent intent) { 77 | ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE); 78 | clipboard.setPrimaryClip(ClipData.newIntent("intent", intent)); 79 | } 80 | 81 | /** 82 | * 获取剪贴板的意图 83 | * 84 | * @return 剪贴板的意图 85 | */ 86 | public static Intent getIntent() { 87 | ClipboardManager clipboard = (ClipboardManager) Utils.getContext().getSystemService(Context.CLIPBOARD_SERVICE); 88 | ClipData clip = clipboard.getPrimaryClip(); 89 | if (clip != null && clip.getItemCount() > 0) { 90 | return clip.getItemAt(0).getIntent(); 91 | } 92 | return null; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/CloseUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import java.io.Closeable; 4 | import java.io.IOException; 5 | 6 | /** 7 | *
 8 |  *     author: Blankj
 9 |  *     blog  : http://blankj.com
10 |  *     time  : 2016/10/9
11 |  *     desc  : 关闭相关工具类
12 |  * 
13 | */ 14 | public class CloseUtils { 15 | 16 | private CloseUtils() { 17 | throw new UnsupportedOperationException("u can't instantiate me..."); 18 | } 19 | 20 | /** 21 | * 关闭IO 22 | * 23 | * @param closeables closeable 24 | */ 25 | public static void closeIO(Closeable... closeables) { 26 | if (closeables == null) return; 27 | for (Closeable closeable : closeables) { 28 | if (closeable != null) { 29 | try { 30 | closeable.close(); 31 | } catch (IOException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | } 36 | } 37 | 38 | /** 39 | * 安静关闭IO 40 | * 41 | * @param closeables closeable 42 | */ 43 | public static void closeIOQuietly(Closeable... closeables) { 44 | if (closeables == null) return; 45 | for (Closeable closeable : closeables) { 46 | if (closeable != null) { 47 | try { 48 | closeable.close(); 49 | } catch (IOException ignored) { 50 | } 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/EmptyUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import android.os.Build; 4 | import android.util.SparseArray; 5 | import android.util.SparseBooleanArray; 6 | import android.util.SparseIntArray; 7 | import android.util.SparseLongArray; 8 | 9 | import java.lang.reflect.Array; 10 | import java.util.Collection; 11 | import java.util.Map; 12 | 13 | /** 14 | *
15 |  *     author: Blankj
16 |  *     blog  : http://blankj.com
17 |  *     time  : 2016/9/28
18 |  *     desc  : 判空相关工具类
19 |  * 
20 | */ 21 | public class EmptyUtils { 22 | 23 | private EmptyUtils() { 24 | throw new UnsupportedOperationException("u can't instantiate me..."); 25 | } 26 | 27 | /** 28 | * 判断对象是否为空 29 | * 30 | * @param obj 对象 31 | * @return {@code true}: 为空
{@code false}: 不为空 32 | */ 33 | public static boolean isEmpty(Object obj) { 34 | if (obj == null) { 35 | return true; 36 | } 37 | if (obj instanceof String && obj.toString().length() == 0) { 38 | return true; 39 | } 40 | if (obj.getClass().isArray() && Array.getLength(obj) == 0) { 41 | return true; 42 | } 43 | if (obj instanceof Collection && ((Collection) obj).isEmpty()) { 44 | return true; 45 | } 46 | if (obj instanceof Map && ((Map) obj).isEmpty()) { 47 | return true; 48 | } 49 | if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) { 50 | return true; 51 | } 52 | if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) { 53 | return true; 54 | } 55 | if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) { 56 | return true; 57 | } 58 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { 59 | if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) { 60 | return true; 61 | } 62 | } 63 | return false; 64 | } 65 | 66 | /** 67 | * 判断对象是否非空 68 | * 69 | * @param obj 对象 70 | * @return {@code true}: 非空
{@code false}: 空 71 | */ 72 | public static boolean isNotEmpty(Object obj) { 73 | return !isEmpty(obj); 74 | } 75 | } -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/HandlerUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | import java.lang.ref.WeakReference; 7 | 8 | /** 9 | *
10 |  *     author: Blankj
11 |  *     blog  : http://blankj.com
12 |  *     time  : 16/11/01
13 |  *     desc  : Handler相关工具类
14 |  * 
15 | */ 16 | public class HandlerUtils { 17 | 18 | private HandlerUtils() { 19 | throw new UnsupportedOperationException("u can't instantiate me..."); 20 | } 21 | 22 | public static class HandlerHolder extends Handler { 23 | WeakReference mListenerWeakReference; 24 | 25 | /** 26 | * 使用必读:推荐在Activity或者Activity内部持有类中实现该接口,不要使用匿名类,可能会被GC 27 | * 28 | * @param listener 收到消息回调接口 29 | */ 30 | public HandlerHolder(OnReceiveMessageListener listener) { 31 | mListenerWeakReference = new WeakReference<>(listener); 32 | } 33 | 34 | @Override 35 | public void handleMessage(Message msg) { 36 | if (mListenerWeakReference != null && mListenerWeakReference.get() != null) { 37 | mListenerWeakReference.get().handlerMessage(msg); 38 | } 39 | } 40 | } 41 | 42 | /** 43 | * 收到消息回调接口 44 | */ 45 | public interface OnReceiveMessageListener { 46 | void handlerMessage(Message msg); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/KeyboardUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.util.Log; 6 | import android.view.View; 7 | import android.view.inputmethod.InputMethodManager; 8 | import android.widget.EditText; 9 | 10 | /** 11 | *
 12 |  *     author: Blankj
 13 |  *     blog  : http://blankj.com
 14 |  *     time  : 2016/8/2
 15 |  *     desc  : 键盘相关工具类
 16 |  * 
17 | */ 18 | public class KeyboardUtils { 19 | 20 | private KeyboardUtils() { 21 | throw new UnsupportedOperationException("u can't instantiate me..."); 22 | } 23 | 24 | /** 25 | * 避免输入法面板遮挡 26 | *

在manifest.xml中activity中设置

27 | *

android:windowSoftInputMode="adjustPan"

28 | */ 29 | 30 | /** 31 | * 动态隐藏软键盘 32 | * 33 | * @param activity activity 34 | */ 35 | public static void hideSoftInput(Activity activity) { 36 | View view = activity.getCurrentFocus(); 37 | if (view == null) view = new View(activity); 38 | InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); 39 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 40 | } 41 | 42 | /** 43 | * 点击屏幕空白区域隐藏软键盘 44 | *

根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘

45 | *

需重写dispatchTouchEvent

46 | *

参照以下注释代码

47 | */ 48 | public static void clickBlankArea2HideSoftInput() { 49 | Log.d("tips", "U should copy the following code."); 50 | /* 51 | @Override 52 | public boolean dispatchTouchEvent(MotionEvent ev) { 53 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { 54 | View v = getCurrentFocus(); 55 | if (isShouldHideKeyboard(v, ev)) { 56 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 57 | imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 58 | } 59 | } 60 | return super.dispatchTouchEvent(ev); 61 | } 62 | 63 | // 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘 64 | private boolean isShouldHideKeyboard(View v, MotionEvent event) { 65 | if (v != null && (v instanceof EditText)) { 66 | int[] l = {0, 0}; 67 | v.getLocationInWindow(l); 68 | int left = l[0], 69 | top = l[1], 70 | bottom = top + v.getHeight(), 71 | right = left + v.getWidth(); 72 | return !(event.getX() > left && event.getX() < right 73 | && event.getY() > top && event.getY() < bottom); 74 | } 75 | return false; 76 | } 77 | */ 78 | } 79 | 80 | /** 81 | * 动态显示软键盘 82 | * 83 | * @param edit 输入框 84 | */ 85 | public static void showSoftInput(EditText edit) { 86 | edit.setFocusable(true); 87 | edit.setFocusableInTouchMode(true); 88 | edit.requestFocus(); 89 | InputMethodManager imm = (InputMethodManager) Utils.getContext() 90 | .getSystemService(Context.INPUT_METHOD_SERVICE); 91 | imm.showSoftInput(edit, 0); 92 | } 93 | 94 | /** 95 | * 切换键盘显示与否状态 96 | */ 97 | public static void toggleSoftInput() { 98 | InputMethodManager imm = (InputMethodManager) Utils.getContext() 99 | .getSystemService(Context.INPUT_METHOD_SERVICE); 100 | imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); 101 | } 102 | } -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | *
 7 |  *     author: Blankj
 8 |  *     blog  : http://blankj.com
 9 |  *     time  : 16/12/08
10 |  *     desc  : Utils初始化相关
11 |  * 
12 | */ 13 | public class Utils { 14 | 15 | private static Context context; 16 | 17 | private Utils() { 18 | throw new UnsupportedOperationException("u can't instantiate me..."); 19 | } 20 | 21 | /** 22 | * 初始化工具类 23 | * 24 | * @param context 上下文 25 | */ 26 | public static void init(Context context) { 27 | Utils.context = context.getApplicationContext(); 28 | } 29 | 30 | /** 31 | * 获取ApplicationContext 32 | * 33 | * @return ApplicationContext 34 | */ 35 | public static Context getContext() { 36 | if (context != null) return context; 37 | throw new NullPointerException("u should init first"); 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/utils/VibrationUtils.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.utils; 2 | 3 | /** 4 | *
 5 |  *     author: Blankj
 6 |  *     blog  : http://blankj.com
 7 |  *     time  : 2016/9/29
 8 |  *     desc  : 震动相关工具类
 9 |  * 
10 | */ 11 | public class VibrationUtils { 12 | 13 | // private VibrationUtils() { 14 | // throw new UnsupportedOperationException("u can't instantiate me..."); 15 | // } 16 | // 17 | // /** 18 | // * 震动 19 | // *

需添加权限 {@code }

20 | // * 21 | // * @param context 上下文 22 | // * @param milliseconds 振动时长 23 | // */ 24 | // public static void vibrate(Context context, long milliseconds) { 25 | // Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); 26 | // vibrator.vibrate(milliseconds); 27 | // } 28 | // 29 | // /** 30 | // * 指定手机以pattern模式振动 31 | // * 32 | // * @param context 33 | // * @param pattern new long[]{400,800,1200,1600},就是指定在400ms、800ms、1200ms、1600ms这些时间点交替启动、关闭手机振动器 34 | // * @param repeat 指定pattern数组的索引,指定pattern数组中从repeat索引开始的振动进行循环。-1表示只振动一次,非-1表示从 pattern的指定下标开始重复振动。 35 | // */ 36 | // public static void vibrate(Context context, long[] pattern, int repeat) { 37 | // Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); 38 | // vibrator.vibrate(pattern, repeat); 39 | // } 40 | // 41 | // /** 42 | // * 取消振动 43 | // * 44 | // * @param context 上下文 45 | // */ 46 | // public static void cancel(Context context) { 47 | // ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).cancel(); 48 | // } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/web/WebActivity.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.web; 2 | 3 | import android.net.http.SslError; 4 | import android.webkit.SslErrorHandler; 5 | import android.webkit.WebChromeClient; 6 | import android.webkit.WebSettings; 7 | import android.webkit.WebView; 8 | import android.webkit.WebViewClient; 9 | import android.widget.TextView; 10 | 11 | import com.huaye.odyandroidstore.R; 12 | import com.huaye.odyandroidstore.base.BaseActivity; 13 | import com.huaye.odyandroidstore.utils.StringUtils; 14 | 15 | public class WebActivity extends BaseActivity { 16 | private WebView wv; 17 | private String url; 18 | private WebSettings ws; 19 | private TextView titleTxt; 20 | 21 | @Override 22 | protected void init() { 23 | super.init(); 24 | url = getIntent().getStringExtra("extra"); 25 | } 26 | 27 | @Override 28 | protected int bindLayout() { 29 | return R.layout.activity_web; 30 | } 31 | 32 | @Override 33 | protected void initView() { 34 | wv = (WebView) findViewById(R.id.wv); 35 | titleTxt = (TextView) findViewById(R.id.title); 36 | ws = wv.getSettings(); 37 | ws.setJavaScriptEnabled(true); 38 | wv.setWebViewClient(new WebViewClient() { 39 | @Override 40 | public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { 41 | handler.proceed(); 42 | super.onReceivedSslError(view, handler, error); 43 | } 44 | 45 | }); 46 | 47 | wv.setWebChromeClient(new WebChromeClient() { 48 | @Override 49 | public void onReceivedTitle(WebView view, String title) { 50 | super.onReceivedTitle(view, title); 51 | if (!StringUtils.isEmpty(title)) { 52 | titleTxt.setText(title); 53 | } 54 | } 55 | }); 56 | } 57 | 58 | @Override 59 | protected void initData() { 60 | super.initData(); 61 | titleTxt.setText(url); 62 | wv.loadUrl(url); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/welfare/WelfareFragment.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.welfare; 2 | 3 | 4 | import android.support.v4.app.Fragment; 5 | import android.view.View; 6 | 7 | import com.huaye.odyandroidstore.R; 8 | import com.huaye.odyandroidstore.base.BaseFragment; 9 | 10 | /** 11 | * A simple {@link Fragment} subclass. 12 | */ 13 | public class WelfareFragment extends BaseFragment { 14 | 15 | 16 | @Override 17 | protected int bindLayout() { 18 | return R.layout.fragment_welfare; 19 | } 20 | 21 | @Override 22 | protected void initView(View view) { 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/widget/DecorationSpace.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.widget; 2 | 3 | import android.graphics.Rect; 4 | import android.support.v7.widget.GridLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.support.v7.widget.StaggeredGridLayoutManager; 7 | import android.view.View; 8 | 9 | /** 10 | * Created by Samuel on 2017/3/15. 11 | */ 12 | 13 | public class DecorationSpace extends RecyclerView.ItemDecoration { 14 | 15 | int left, top, right, bottom; 16 | 17 | /** 18 | * @param left 19 | * @param top 20 | * @param right 21 | * @param bottom 22 | */ 23 | public DecorationSpace(int left, int top, int right, int bottom) { 24 | this.left = left; 25 | this.top = top; 26 | this.right = right; 27 | this.bottom = bottom; 28 | } 29 | 30 | /** 31 | * @param space 传入的值,其单位视为dp 32 | */ 33 | public DecorationSpace(int space) { 34 | this.left = space; 35 | this.top = space; 36 | this.right = space; 37 | this.bottom = space; 38 | } 39 | 40 | @Override 41 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 42 | if (parent.getLayoutManager() instanceof GridLayoutManager || parent.getLayoutManager() instanceof StaggeredGridLayoutManager) { 43 | int position = parent.getChildAdapterPosition(view); 44 | if (position % 2 == 0) { 45 | outRect.left = 0; 46 | outRect.right = right; 47 | outRect.top = top; 48 | outRect.bottom = bottom; 49 | } else { 50 | outRect.left = left; 51 | outRect.right = 0; 52 | outRect.top = top; 53 | outRect.bottom = bottom; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/huaye/odyandroidstore/widget/SquareImageView.java: -------------------------------------------------------------------------------- 1 | package com.huaye.odyandroidstore.widget; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.AppCompatImageView; 5 | import android.util.AttributeSet; 6 | import android.widget.ImageView; 7 | 8 | /** 9 | * Created by Samuel on 2017/3/13. 10 | */ 11 | 12 | public class SquareImageView extends AppCompatImageView { 13 | public SquareImageView(Context context) { 14 | super(context); 15 | } 16 | 17 | public SquareImageView(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | } 20 | 21 | public SquareImageView(Context context, AttributeSet attrs, int defStyle) { 22 | super(context, attrs, defStyle); 23 | } 24 | 25 | @Override 26 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 27 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 28 | setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth()); //Snap to width 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/constraint_ayout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sun8829/OdyAndroidStore/6b017b738dee3d625d203777820e1fcbd9c73f03/app/src/main/res/drawable-xhdpi/constraint_ayout.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/circle_menu_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sun8829/OdyAndroidStore/6b017b738dee3d625d203777820e1fcbd9c73f03/app/src/main/res/drawable/large.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sun8829/OdyAndroidStore/6b017b738dee3d625d203777820e1fcbd9c73f03/app/src/main/res/drawable/placeholder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_taobao_tab_bg.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 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_taobao_tab_txt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_baoyou_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_corner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_credit_score.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_cylinder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_dash.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_glow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_gradient0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_gradient1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_gradient2.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_gradient3.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_rec_stroke.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_ring.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_taobao_input_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_taobao_jiao_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sun8829/OdyAndroidStore/6b017b738dee3d625d203777820e1fcbd9c73f03/app/src/main/res/drawable/small.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_circle_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 21 | 22 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_con.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 21 | 22 | 27 | 28 | 33 | 34 | 35 | 39 | 40 | 46 | 47 | 52 | 53 | 58 | 59 | 60 | 61 | 67 | 68 | 73 | 74 | 79 | 80 | 85 | 86 | 91 | 92 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_expandable.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_hot_fix.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 23 | 24 |