├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── isPlay.jks ├── proguard-rules.pro ├── release │ ├── app-release.apk │ ├── output.json │ └── seven.apk └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── seven │ │ └── seven │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── DINPro-Bold.otf │ ├── java │ │ └── com │ │ │ └── seven │ │ │ └── seven │ │ │ ├── common │ │ │ ├── Model │ │ │ │ ├── BannerInfo.java │ │ │ │ ├── BannerInfos.java │ │ │ │ └── HttpErrorInfo.java │ │ │ ├── base │ │ │ │ ├── BaseModel.java │ │ │ │ ├── BaseMvpActivity.java │ │ │ │ ├── BaseMvpFragment.java │ │ │ │ ├── HttpErrorReceiver.java │ │ │ │ ├── IBaseModel.java │ │ │ │ ├── IBaseView.java │ │ │ │ ├── NetWorkStateReceiver.java │ │ │ │ └── codereview │ │ │ │ │ ├── BaseActivity.java │ │ │ │ │ ├── BaseFragment.java │ │ │ │ │ ├── BaseLazyFragment.java │ │ │ │ │ ├── BasePresenter.java │ │ │ │ │ ├── BasePresenterImpl.java │ │ │ │ │ ├── BaseRetryWhen.java │ │ │ │ │ └── BaseView.java │ │ │ ├── event │ │ │ │ ├── BaseEvent.java │ │ │ │ ├── NetWorkChangeEvent.java │ │ │ │ └── ReloginEvent.java │ │ │ ├── network │ │ │ │ ├── AddCookieInterceptor.java │ │ │ │ ├── ApiException.java │ │ │ │ ├── ApiRetrofit.java │ │ │ │ ├── ApiService.java │ │ │ │ ├── HttpCommonObserver.java │ │ │ │ ├── HttpObservable.java │ │ │ │ ├── HttpResultFunction.java │ │ │ │ ├── HttpResultObserver.java │ │ │ │ ├── HttpResultSubscriber.java │ │ │ │ ├── NetworkUrl.java │ │ │ │ ├── ResponseCustom.java │ │ │ │ ├── RxLifeManager.java │ │ │ │ ├── SaveCookieInterceptor.java │ │ │ │ ├── ServerResultFunction.java │ │ │ │ ├── ThreadSchedulersHelper.java │ │ │ │ └── gank │ │ │ │ │ ├── GankHttpObserver.java │ │ │ │ │ ├── GankIoCustom.java │ │ │ │ │ ├── GankIoObservable.java │ │ │ │ │ └── GankResultObserver.java │ │ │ ├── utils │ │ │ │ ├── AppBarStateChangeListener.java │ │ │ │ ├── AppManager.java │ │ │ │ ├── Constans.java │ │ │ │ ├── DataCleanManager.java │ │ │ │ ├── DensityUtil.java │ │ │ │ ├── FileUtils.java │ │ │ │ ├── GlideUtils.java │ │ │ │ ├── GsonTools.java │ │ │ │ ├── HTMLScript.java │ │ │ │ ├── ImageUtils.java │ │ │ │ ├── LogUtils.java │ │ │ │ ├── PermissionUtil.java │ │ │ │ ├── PreferencesUtils.java │ │ │ │ ├── RxManager.java │ │ │ │ ├── RxTool.java │ │ │ │ ├── ScaleTransformer.java │ │ │ │ ├── ShareUtils.java │ │ │ │ ├── StatusBarUtil.java │ │ │ │ ├── TimeUtils.java │ │ │ │ └── ToastUtils.java │ │ │ └── view │ │ │ │ ├── CustomCOnstantsView.java │ │ │ │ ├── ErrorLayoutView.java │ │ │ │ ├── FlowLayout.java │ │ │ │ ├── GradientView.java │ │ │ │ ├── HomeTitleView.java │ │ │ │ ├── KeyLayout.java │ │ │ │ ├── MarqueeView.java │ │ │ │ ├── NestedScrollWebView.java │ │ │ │ ├── NumberPlayTextView.java │ │ │ │ ├── RollNumberTextView.java │ │ │ │ ├── RollNumberView.java │ │ │ │ ├── dialog │ │ │ │ ├── ShareMenuPop.java │ │ │ │ └── TakePhototpop.java │ │ │ │ ├── progress │ │ │ │ ├── AnimationUtils.java │ │ │ │ ├── CircleSprite.java │ │ │ │ ├── DoubleBounce.java │ │ │ │ ├── Ease.java │ │ │ │ ├── KeyFrameInterpolator.java │ │ │ │ ├── ShapeSprite.java │ │ │ │ ├── Sprite.java │ │ │ │ ├── SpriteAnimatorBuilder.java │ │ │ │ └── SpriteContainer.java │ │ │ │ └── webview │ │ │ │ ├── H5Control.java │ │ │ │ ├── H5JSInterface.java │ │ │ │ ├── H5ToAndroidData.java │ │ │ │ ├── LookWebViewImg.java │ │ │ │ └── SevenWebView.java │ │ │ ├── gank │ │ │ ├── GankFragment.java │ │ │ ├── adapter │ │ │ │ └── GankAdapter.java │ │ │ ├── contract │ │ │ │ └── GankContract.java │ │ │ ├── events │ │ │ │ └── GankEvents.java │ │ │ ├── model │ │ │ │ └── GankIoWelfareBean.java │ │ │ └── presenter │ │ │ │ └── GankPresenter.java │ │ │ ├── home │ │ │ ├── BaseHomeTitleBar.java │ │ │ ├── BaseRecyclerFragment.java │ │ │ ├── HomeFragment.java │ │ │ ├── HomeNewsDetailActivity.java │ │ │ ├── adapter │ │ │ │ ├── BannerViewAdapter.java │ │ │ │ ├── BaseLoadMoreAdapter.java │ │ │ │ ├── HomeCommonAdapter.java │ │ │ │ └── RvLoadMoreView.java │ │ │ ├── bannerview │ │ │ │ ├── BannerLayout.java │ │ │ │ ├── RecyclerViewBannerBase.java │ │ │ │ └── layoutmanager │ │ │ │ │ ├── BannerLayoutManager.java │ │ │ │ │ ├── CenterScrollListener.java │ │ │ │ │ ├── CenterSnapHelper.java │ │ │ │ │ └── OverFlyingLayoutManager.java │ │ │ ├── contract │ │ │ │ ├── BaseWebviewContract.java │ │ │ │ └── HomeContract.java │ │ │ ├── events │ │ │ │ ├── BaseWebViewEvents.java │ │ │ │ └── HomeEvents.java │ │ │ ├── model │ │ │ │ ├── HomeBannerInfos.java │ │ │ │ ├── HomeNewsInfos.java │ │ │ │ └── HomeToWebViewInfo.java │ │ │ └── presenter │ │ │ │ ├── BaseWebviewPresenter.java │ │ │ │ └── HomePresenter.java │ │ │ ├── login │ │ │ ├── LoginActivity.java │ │ │ ├── LoginContract.java │ │ │ ├── LoginEvent.java │ │ │ ├── LoginPresenter.java │ │ │ ├── RegisterContract.java │ │ │ ├── RegisterEvent.java │ │ │ ├── RegisterInfo.java │ │ │ ├── RegisterPresenter.java │ │ │ └── RejisterActivity.java │ │ │ ├── search │ │ │ ├── LookImageActivity.java │ │ │ ├── SearchAdapter.java │ │ │ ├── SearchDetailActivity.java │ │ │ ├── SearchFragment.java │ │ │ ├── contract │ │ │ │ ├── SearchContract.java │ │ │ │ └── SearchKContract.java │ │ │ ├── events │ │ │ │ ├── HotTagEvent.java │ │ │ │ └── SearchKEvent.java │ │ │ ├── model │ │ │ │ ├── HotTagInfos.java │ │ │ │ ├── SearchListInfos.java │ │ │ │ └── UsingURLinfos.java │ │ │ └── presenter │ │ │ │ ├── HotTagPresenter.java │ │ │ │ └── SearchKPresenter.java │ │ │ ├── ui │ │ │ ├── MainActivity.java │ │ │ ├── MyApplication.java │ │ │ ├── MyPagerAdapter.java │ │ │ ├── SplashActivity.java │ │ │ ├── TestActivity.java │ │ │ ├── TestAdapter.java │ │ │ └── base │ │ │ │ ├── activity │ │ │ │ ├── ConstantsLayout.java │ │ │ │ └── ViewTestActivity.java │ │ │ │ └── fragment │ │ │ │ ├── EFragment.java │ │ │ │ ├── NoSlideViewPager.java │ │ │ │ └── TabItemInfo.java │ │ │ └── user │ │ │ ├── CollectListActivity.java │ │ │ ├── RenderscriptUtils.java │ │ │ ├── UserInfoFragment.java │ │ │ ├── adapter │ │ │ └── CollectAdapter.java │ │ │ ├── contract │ │ │ ├── CollectContract.java │ │ │ └── UserInfoContract.java │ │ │ ├── model │ │ │ ├── CollectInfo.java │ │ │ └── CollectListInfos.java │ │ │ ├── presenter │ │ │ ├── CollectPresenter.java │ │ │ └── UserInfoPresenter.java │ │ │ ├── userevent │ │ │ ├── CollectEvent.java │ │ │ └── UserInfoEvent.java │ │ │ └── view │ │ │ ├── CanleLoginDialog.java │ │ │ ├── DeleteCacheDialog.java │ │ │ ├── HeadImgView.java │ │ │ └── UserInfoItemView.java │ └── res │ │ ├── anim │ │ ├── activity_finish_trans_in.xml │ │ ├── activity_finish_trans_out.xml │ │ ├── activity_start_zoom_in.xml │ │ └── activity_start_zoom_out.xml │ │ ├── drawable-hdpi │ │ └── loading_android_1.jpg │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable-xxhdpi │ │ ├── error.jpg │ │ ├── ic_arrow_back_white.png │ │ ├── ic_check_white_48dp.png │ │ ├── ic_clear_white_48dp.png │ │ ├── ic_error_logo.png │ │ ├── ic_error_outline_white_48dp.png │ │ ├── ic_heart_follow.png │ │ ├── ic_heart_un_follow.png │ │ ├── ic_home_selector.png │ │ ├── ic_home_un_selector.png │ │ ├── ic_hot_search.png │ │ ├── ic_info_outline_white_48dp.png │ │ ├── ic_language_choose.png │ │ ├── ic_menu_black.png │ │ ├── ic_person_customer_service.png │ │ ├── ic_person_help.png │ │ ├── ic_person_integral.png │ │ ├── ic_person_right.png │ │ ├── ic_person_us.png │ │ ├── ic_return_black.png │ │ ├── ic_search.png │ │ ├── ic_share_app.png │ │ ├── icon_weixin.png │ │ ├── icon_weixin_pengyouquan.png │ │ ├── my_selector.png │ │ ├── my_un_selector.png │ │ ├── seven_logo.png │ │ ├── tab_fuli.png │ │ ├── tab_search.png │ │ ├── tab_selector_fuli.png │ │ ├── tab_selector_search.png │ │ ├── timgs.jpg │ │ └── toast_frame.9.png │ │ ├── drawable │ │ ├── bg_menu.9.png │ │ ├── btn_dialog_left_normal.xml │ │ ├── btn_dialog_left_pressed.xml │ │ ├── btn_dialog_left_selector.xml │ │ ├── dialog_background.xml │ │ ├── fuli_button_selector.xml │ │ ├── home_button_selector.xml │ │ ├── home_toolbar_bg.xml │ │ ├── ic_launcher_background.xml │ │ ├── item_touch_bg.xml │ │ ├── my_button_selector.xml │ │ ├── red_background_shape.xml │ │ ├── refresh_button_drawable.xml │ │ ├── refresh_normal_shape.xml │ │ ├── refresh_press_shape.xml │ │ ├── search_background.xml │ │ ├── search_button_selector.xml │ │ ├── tab_item_name_selector.xml │ │ ├── test.xml │ │ ├── text_background.xml │ │ ├── web_progress_bar_bg.xml │ │ └── webview_top_progress.xml │ │ ├── layout │ │ ├── activity_collect_list.xml │ │ ├── activity_home_news_detail.xml │ │ ├── activity_login.xml │ │ ├── activity_look_image.xml │ │ ├── activity_main.xml │ │ ├── activity_register.xml │ │ ├── activity_search_detail.xml │ │ ├── activity_splash.xml │ │ ├── activity_view.xml │ │ ├── banner_item.xml │ │ ├── base_home_title.xml │ │ ├── dialog_cancle.xml │ │ ├── dialog_delete.xml │ │ ├── error_layout.xml │ │ ├── fragment_gank.xml │ │ ├── fragment_home.xml │ │ ├── fragment_home_me.xml │ │ ├── fragment_search.xml │ │ ├── fragment_user_info.xml │ │ ├── home_title.xml │ │ ├── layout_constants.xml │ │ ├── layout_recycler_loadmore.xml │ │ ├── pop_share_menu.xml │ │ ├── pop_take_photo.xml │ │ ├── recycler_head_view.xml │ │ ├── recycler_item_banner.xml │ │ ├── recycler_item_collect.xml │ │ ├── recycler_item_gank.xml │ │ ├── recycler_item_home_news.xml │ │ ├── recycler_item_search.xml │ │ ├── tab_item_view.xml │ │ ├── toast_layout.xml │ │ └── user_info_item_view.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ └── seven_logo.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── arrays.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── seven │ └── seven │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── keystore.properties └── 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/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seven123456/seven_develop/e28549c65fa5f82c3691c041fe0f06e837f014fd/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.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 | # seven_develop 2 | ## 代码结构:mvp+retrofit+rxjava+eventbus 3 | ## 功能模块分为首页、搜索、干货、个人四个模块 4 | ## 效果图(七牛云在审核,暂时上传不了gif): 5 | 登录界面:![](http://p9zhrh213.bkt.clouddn.com/seven_login.jpg) 6 | 首页: ![](http://p9zhrh213.bkt.clouddn.com/seven_home.jpg) 7 | 搜索: ![](http://p9zhrh213.bkt.clouddn.com/seven_search.jpg) 8 | 干货: ![](http://p9zhrh213.bkt.clouddn.com/seven_gankio.jpg) 9 | 个人: ![](http://p9zhrh213.bkt.clouddn.com/seven_user.jpg) 10 | # 项目使用到的api: # 11 | 感谢鸿洋大神的www.wanandroid.com提供的api 12 | 还有干货集中云的api:http://gank.io/api 13 | 14 | # 感兴趣的朋友可以[下载demo](https://fir.im/mche1 "下载demo")体验一下,欢迎各位star 下载 # -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/isPlay.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seven123456/seven_develop/e28549c65fa5f82c3691c041fe0f06e837f014fd/app/isPlay.jks -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/release/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seven123456/seven_develop/e28549c65fa5f82c3691c041fe0f06e837f014fd/app/release/app-release.apk -------------------------------------------------------------------------------- /app/release/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.seven.seven","split":"","minSdkVersion":"19"}}] -------------------------------------------------------------------------------- /app/release/seven.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seven123456/seven_develop/e28549c65fa5f82c3691c041fe0f06e837f014fd/app/release/seven.apk -------------------------------------------------------------------------------- /app/src/androidTest/java/com/seven/seven/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven; 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 static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.seven.seven", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 23 | 24 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/assets/DINPro-Bold.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seven123456/seven_develop/e28549c65fa5f82c3691c041fe0f06e837f014fd/app/src/main/assets/DINPro-Bold.otf -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/Model/BannerInfo.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.Model; 2 | 3 | /** 4 | * Created on 2018-03-19. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | class BannerInfo { 10 | public String desc; 11 | public int id; 12 | public String imagePath; 13 | public int isVisible; 14 | public int order; 15 | public String title; 16 | public int type; 17 | public String url; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/Model/HttpErrorInfo.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.Model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created on 2018-03-26. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class HttpErrorInfo implements Serializable { 12 | private String msg; 13 | 14 | public HttpErrorInfo(String msg) { 15 | this.msg = msg; 16 | } 17 | 18 | public String getMsg() { 19 | return msg; 20 | } 21 | 22 | public void setMsg(String msg) { 23 | this.msg = msg; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/BaseModel.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base; 2 | 3 | /** 4 | * Created on 2018-01-05. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public abstract class BaseModel { 10 | public BaseModel() { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/BaseMvpActivity.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.seven.seven.common.base.codereview.BaseActivity; 6 | import com.seven.seven.common.base.codereview.BasePresenter; 7 | import com.seven.seven.common.utils.AppManager; 8 | import com.seven.seven.common.utils.ToastUtils; 9 | 10 | /** 11 | * Created on 2018-01-05. 12 | * author:seven 13 | * email:seven2016s@163.com 14 | */ 15 | 16 | public abstract class BaseMvpActivity

17 | extends BaseActivity implements IBaseView { 18 | /* 19 | * 这里还是属于基类,具体实例化由子类去实现 20 | * */ 21 | protected P mPresenter; 22 | protected M mModel; 23 | 24 | @Override 25 | protected void init(Bundle savedInstanceState) { 26 | super.init(savedInstanceState); 27 | } 28 | 29 | /* 30 | * 通过继承关系,p层去持有v层对象 31 | * 然后再通过p层去持有M层对象 32 | * 最后通过P持有 m层和v层对象,这里面存在一个层级关系 33 | * */ 34 | @Override 35 | protected void initData() { 36 | /* mPresenter = (P) initPresenter(); 37 | if (mPresenter != null) { 38 | // mModel = (M) mPresenter.getModel(); 39 | if (mModel != null) { 40 | // mPresenter.attachMV(mModel, this); 41 | } 42 | }*/ 43 | } 44 | 45 | /* 46 | * 通过p层里面的方法来进行解绑v 和M 层的持有关系 47 | * */ 48 | /* @Override 49 | protected void onDestroy() { 50 | super.onDestroy(); 51 | if (mPresenter != null) { 52 | mPresenter.detachMV(); 53 | } 54 | } 55 | */ 56 | /* @Override 57 | public void showToast(String msg) { 58 | ToastUtils.showToast(msg); 59 | } 60 | 61 | @Override 62 | public void back() { 63 | AppManager.getAppManager().finishActivity(this); 64 | }*/ 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/BaseMvpFragment.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.seven.seven.common.base.codereview.BaseFragment; 7 | import com.seven.seven.common.base.codereview.BasePresenter; 8 | 9 | /** 10 | * Created on 2018-03-31. 11 | * author:seven 12 | * email:seven2016s@163.com 13 | */ 14 | 15 | public abstract class BaseMvpFragment

extends BaseFragment implements IBaseView { 16 | @Override 17 | protected void initView() { 18 | super.initView(); 19 | } 20 | 21 | @Override 22 | public void startNewActivityForResult(@NonNull Class clz, Bundle bundle, int requestCode) { 23 | 24 | } 25 | 26 | @Override 27 | public void startNewActivity(@NonNull Class clz) { 28 | 29 | } 30 | 31 | @Override 32 | public void startNewActivity(@NonNull Class clz, Bundle bundle) { 33 | 34 | } 35 | 36 | /* @Override 37 | public void showToast(String msg) { 38 | 39 | } 40 | 41 | @Override 42 | public void back() { 43 | 44 | }*/ 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/HttpErrorReceiver.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.net.ConnectivityManager; 7 | import android.net.Network; 8 | import android.net.NetworkInfo; 9 | import android.widget.Toast; 10 | 11 | import com.seven.seven.common.event.NetWorkChangeEvent; 12 | import com.seven.seven.common.utils.Constans; 13 | 14 | import org.greenrobot.eventbus.EventBus; 15 | 16 | /** 17 | * Created by Carson_Ho on 16/10/31. 18 | */ 19 | public class HttpErrorReceiver extends BroadcastReceiver { 20 | @Override 21 | public void onReceive(Context context, Intent intent) { 22 | String action = intent.getAction(); 23 | if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { 24 | //获得ConnectivityManager对象 25 | ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 26 | //获取ConnectivityManager对象对应的NetworkInfo对象 27 | NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); 28 | if (networkInfo != null && networkInfo.isAvailable()) { 29 | EventBus.getDefault().post(new NetWorkChangeEvent(Constans.NET_WORK_AVAILABLE)); 30 | } else { 31 | EventBus.getDefault().post(new NetWorkChangeEvent(Constans.NET_WORK_DISABLED)); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/IBaseModel.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base; 2 | 3 | /** 4 | * Created on 2018-03-15. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public interface IBaseModel { 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/IBaseView.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.seven.seven.common.base.codereview.BaseView; 7 | 8 | /** 9 | * Created on 2018-03-15. 10 | * author:seven 11 | * email:seven2016s@163.com 12 | */ 13 | 14 | public interface IBaseView extends BaseView { 15 | /** 16 | * 跳往新的Activity 17 | * 18 | * @param clz 要跳往的Activity 19 | */ 20 | void startNewActivity(@NonNull Class clz); 21 | 22 | /** 23 | * 跳往新的Activity 24 | * 25 | * @param clz 要跳往的Activity 26 | * @param bundle 携带的bundle数据 27 | */ 28 | void startNewActivity(@NonNull Class clz, Bundle bundle); 29 | 30 | /** 31 | * 跳往新的Activity 32 | * @param clz 要跳转的Activity 33 | * @param bundle bundel数据 34 | * @param requestCode requestCode 35 | */ 36 | void startNewActivityForResult(@NonNull Class clz, Bundle bundle, int requestCode); 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/codereview/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base.codereview; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import com.seven.seven.R; 12 | import com.seven.seven.common.utils.ToastUtils; 13 | 14 | /** 15 | * Created on 2018-01-05. 16 | * author:seven 17 | * email:seven2016s@163.com 18 | */ 19 | 20 | public abstract class BaseFragment extends Fragment implements View.OnClickListener { 21 | public View rootView; 22 | 23 | @Override 24 | public void onCreate(@Nullable Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | } 27 | 28 | @Nullable 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 31 | if (rootView == null) { 32 | rootView = inflater.inflate(getLayoutId(), container, false); 33 | } 34 | 35 | initView(); 36 | setLisenter(); 37 | initData(); 38 | return rootView; 39 | } 40 | 41 | 42 | 43 | // protected abstract void initView(View rootView, Bundle savedInstanceState); 44 | 45 | /* 46 | * 带图片的toast 47 | * */ 48 | public void showSuccessToast(String msg) { 49 | ToastUtils.success(msg); 50 | } 51 | 52 | /* 53 | * error的toast 54 | * */ 55 | public void showErrorToast(String msg) { 56 | ToastUtils.error(msg); 57 | } 58 | 59 | protected abstract int getLayoutId(); 60 | 61 | protected void initView() { 62 | 63 | } 64 | 65 | 66 | protected abstract void initData(); 67 | 68 | protected abstract void setLisenter(); 69 | 70 | protected abstract void widgetClick(View v); 71 | 72 | @Override 73 | public void onClick(View v) { 74 | widgetClick(v); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/codereview/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base.codereview; 2 | 3 | /** 4 | * Created on 2018-01-05. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public interface BasePresenter { 10 | void attachView(V view); 11 | void attachActivity(T activity); 12 | void detachView(); 13 | void detachActivity(); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/codereview/BasePresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base.codereview; 2 | 3 | import com.seven.seven.common.network.ApiRetrofit; 4 | import com.seven.seven.common.network.ApiService; 5 | 6 | import java.lang.ref.Reference; 7 | import java.lang.ref.WeakReference; 8 | 9 | /** 10 | * Created by seven 11 | * on 2018/5/17 12 | * email:seven2016s@163.com 13 | */ 14 | 15 | public class BasePresenterImpl implements BasePresenter { 16 | public final ApiService apiRetrofit; 17 | private Reference viewReference; 18 | private Reference activityReference; 19 | private V mView; 20 | private T mActivity; 21 | 22 | public BasePresenterImpl(V view, T activity) { 23 | attachActivity(activity); 24 | attachView(view); 25 | apiRetrofit = ApiRetrofit.getApiRetrofit().getApiServis(); 26 | } 27 | 28 | @Override 29 | public void attachView(V view) { 30 | viewReference = new WeakReference(view); 31 | mView = viewReference.get(); 32 | } 33 | 34 | @Override 35 | public void attachActivity(T activity) { 36 | activityReference = new WeakReference(activity); 37 | mActivity = activityReference.get(); 38 | } 39 | 40 | @Override 41 | public void detachView() { 42 | if (isViewAttach()) { 43 | viewReference.clear(); 44 | viewReference = null; 45 | } 46 | } 47 | 48 | @Override 49 | public void detachActivity() { 50 | if (isActivityAttach()) { 51 | activityReference.clear(); 52 | activityReference = null; 53 | } 54 | } 55 | 56 | /* 57 | * view 是否关联 58 | * */ 59 | public boolean isViewAttach() { 60 | return viewReference != null && viewReference.get() != null; 61 | } 62 | 63 | /* 64 | * activity是否关联 65 | * */ 66 | public boolean isActivityAttach() { 67 | return activityReference != null && activityReference.get() != null; 68 | } 69 | 70 | /* 71 | * 获取view 72 | * 73 | * */ 74 | public V getView() { 75 | return viewReference == null ? null : viewReference.get(); 76 | } 77 | 78 | /* 79 | * 获取activity 80 | * */ 81 | public T getActivity() { 82 | return activityReference == null ? null : activityReference.get(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/codereview/BaseRetryWhen.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base.codereview; 2 | 3 | 4 | import android.util.Log; 5 | 6 | import java.util.concurrent.TimeUnit; 7 | 8 | import io.reactivex.Observable; 9 | import io.reactivex.ObservableSource; 10 | import io.reactivex.functions.Function; 11 | 12 | /** 13 | * Created on 2018-05-25. 14 | * author:seven 15 | * email:seven2016s@163.com 16 | */ 17 | 18 | public class BaseRetryWhen implements Function, Observable> { 19 | 20 | private final int maxRetries;//请求次数 21 | private final int retryDelayMillis;//请求间隔时间 22 | private int retryCount; 23 | 24 | public BaseRetryWhen(int maxRetries, int retryDelayMillis) { 25 | this.maxRetries = maxRetries; 26 | this.retryDelayMillis = retryDelayMillis; 27 | } 28 | 29 | @Override 30 | public Observable apply(Observable observable) throws Exception { 31 | 32 | return observable.flatMap(new Function>() { 33 | @Override 34 | public ObservableSource apply(Throwable throwable) throws Exception { 35 | 36 | Log.d("重新请求", "1111"); 37 | if (++retryCount <= maxRetries) { 38 | return Observable.timer(retryDelayMillis, TimeUnit.MILLISECONDS); 39 | } 40 | return Observable.error(throwable); 41 | } 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/base/codereview/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.base.codereview; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Created on 2018-01-05. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public interface BaseView { 12 | /* 13 | *//** 14 | * 显示toast消息 15 | * 16 | * @param msg 要显示的toast消息字符串 17 | *//* 18 | void showToast(String msg); 19 | 20 | *//** 21 | * 回退 22 | *//* 23 | void back();*/ 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/event/BaseEvent.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.event; 2 | 3 | /** 4 | * Created on 2018-03-26. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public class BaseEvent { 10 | private int what; 11 | private T data; 12 | 13 | public BaseEvent(){} 14 | 15 | public BaseEvent(int what) { 16 | this(what, null); 17 | } 18 | 19 | public BaseEvent(int what, T data) { 20 | this.what = what; 21 | this.data = data; 22 | } 23 | 24 | public int getWhat() { 25 | return what; 26 | } 27 | 28 | public void setWhat(int what) { 29 | this.what = what; 30 | } 31 | 32 | public Object getData() { 33 | return data; 34 | } 35 | 36 | public void setData(T data) { 37 | this.data = data; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/event/NetWorkChangeEvent.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.event; 2 | 3 | /** 4 | * Created on 2018-03-26. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public class NetWorkChangeEvent extends BaseEvent { 10 | 11 | public NetWorkChangeEvent() { 12 | } 13 | 14 | public NetWorkChangeEvent(int what) { 15 | super(what); 16 | } 17 | 18 | public NetWorkChangeEvent(int what, Object data) { 19 | super(what, data); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/event/ReloginEvent.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.event; 2 | 3 | /** 4 | * Created on 2018-05-30. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public class ReloginEvent extends BaseEvent { 10 | public ReloginEvent() { 11 | } 12 | 13 | public ReloginEvent(int what) { 14 | super(what); 15 | } 16 | 17 | public ReloginEvent(int what, Object data) { 18 | super(what, data); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/AddCookieInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.text.TextUtils; 6 | 7 | import com.seven.seven.common.utils.Constans; 8 | import com.seven.seven.common.utils.PreferencesUtils; 9 | import com.seven.seven.ui.MyApplication; 10 | 11 | import java.io.IOException; 12 | 13 | import okhttp3.Interceptor; 14 | import okhttp3.Request; 15 | import okhttp3.Response; 16 | 17 | import static com.seven.seven.common.utils.Constans.COOKIE_PREF; 18 | 19 | /** 20 | * Created on 2018-05-26. 21 | * author:seven 22 | * email:seven2016s@163.com 23 | */ 24 | 25 | public class AddCookieInterceptor implements Interceptor { 26 | public static String PREFERENCE_NAME = "Config"; 27 | 28 | /* private Context mContext; 29 | 30 | public AddCookieInterceptor(Context context) { 31 | this.mContext = context; 32 | } 33 | */ 34 | @Override 35 | public Response intercept(Chain chain) throws IOException { 36 | Request request = chain.request(); 37 | Request.Builder builder = request.newBuilder(); 38 | String cookie = getCookie(request.url().toString(), request.url().host()); 39 | if (!TextUtils.isEmpty(cookie)) { 40 | builder.addHeader("cookie", cookie); 41 | } 42 | return chain.proceed(builder.build()); 43 | } 44 | 45 | private String getCookie(String url, String host) { 46 | SharedPreferences sp = MyApplication.getContext().getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); 47 | /*if (!TextUtils.isEmpty(url) && sp.contains(url) && !TextUtils.isEmpty(sp.getString(url, ""))) { 48 | return sp.getString(url, ""); 49 | } 50 | if (!TextUtils.isEmpty(host) && sp.contains(host) && !TextUtils.isEmpty(sp.getString(host, ""))) { 51 | return sp.getString(host, ""); 52 | }*/ 53 | return sp.getString(Constans.COOKIE_PREF, null); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/ApiException.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | /** 4 | * Created on 2018-03-26. 5 | * author:seven 6 | * email:seven2016s@163.com 7 | */ 8 | 9 | public class ApiException extends Exception { 10 | /** 11 | * 错误码 12 | */ 13 | private int errorCode; 14 | /** 15 | * 错误信息 16 | */ 17 | private String errorMsg; 18 | 19 | public Object getData() { 20 | return data; 21 | } 22 | 23 | public void setData(Object data) { 24 | this.data = data; 25 | } 26 | 27 | private Object data; 28 | public ApiException(Throwable throwable, int code) { 29 | super(throwable); 30 | this.errorCode = code; 31 | } 32 | 33 | public ApiException(int code, String msg) { 34 | this.errorCode = code; 35 | this.errorMsg = msg; 36 | } 37 | 38 | public int getCode() { 39 | return errorCode; 40 | } 41 | 42 | public void setCode(int code) { 43 | this.errorCode = code; 44 | } 45 | 46 | public String getMsg() { 47 | return errorMsg; 48 | } 49 | 50 | public void setMsg(String msg) { 51 | this.errorMsg = msg; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/HttpCommonObserver.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import android.util.Log; 4 | 5 | import java.net.UnknownServiceException; 6 | 7 | import io.reactivex.Observer; 8 | import io.reactivex.disposables.Disposable; 9 | 10 | /** 11 | * Created on 2018-03-20. 12 | * author:seven 13 | * email:seven2016s@163.com 14 | */ 15 | 16 | public abstract class HttpCommonObserver implements Observer { 17 | private boolean flag = false;//是否切断上下游的事件传递 18 | public static final int UN_KNOWN_ERROR = 1000;//未知错误 19 | 20 | public HttpCommonObserver() { 21 | } 22 | 23 | public HttpCommonObserver(boolean isLink) { 24 | this.flag = isLink; 25 | } 26 | 27 | @Override 28 | public void onSubscribe(Disposable d) { 29 | this.onStart(d); 30 | if (flag) { 31 | RxLifeManager.getRxLifeManager().setCompositeDisposableOnStop(d); 32 | } else { 33 | RxLifeManager.getRxLifeManager().setCompositeDisposableOnDestroy(d); 34 | } 35 | } 36 | 37 | protected abstract void onStart(Disposable d); 38 | 39 | protected abstract void _onNext(T t); 40 | 41 | // protected abstract void _onError(ApiException e); 42 | protected abstract void _onError(ApiException e); 43 | 44 | /* 45 | * t==response 46 | * */ 47 | @Override 48 | public void onNext(T t) { 49 | if (t != null) { 50 | this._onNext(t); 51 | } 52 | 53 | } 54 | 55 | @Override 56 | public void onError(Throwable e) { 57 | if (e instanceof ApiException || e instanceof UnknownServiceException) { 58 | _onError((ApiException) e); 59 | Log.e("onerror", "错误编码===" + ((ApiException) e).getCode() + "错误信息===" + ((ApiException) e).getMsg()); 60 | } else { 61 | this._onError(new ApiException(e, UN_KNOWN_ERROR)); 62 | } 63 | // this._onError(e); 64 | } 65 | 66 | @Override 67 | public void onComplete() { 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/HttpObservable.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import io.reactivex.Observable; 4 | import io.reactivex.Observer; 5 | import io.reactivex.android.schedulers.AndroidSchedulers; 6 | import io.reactivex.schedulers.Schedulers; 7 | 8 | /** 9 | * Created by seven 10 | * on 2018/5/17 11 | * email:seven2016s@163.com 12 | */ 13 | 14 | public class HttpObservable { 15 | public static Observable getObservable(Observable> customObservable) { 16 | Observable observable = customObservable 17 | .map(new ServerResultFunction()) 18 | .onErrorResumeNext(new HttpResultFunction()) 19 | .subscribeOn(Schedulers.io()) 20 | .observeOn(AndroidSchedulers.mainThread()); 21 | return observable; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/HttpResultFunction.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import android.util.Log; 4 | 5 | import io.reactivex.Observable; 6 | import io.reactivex.functions.Function; 7 | 8 | /** 9 | * @author seven 10 | * @date 2017/10/31 11 | */ 12 | 13 | public class HttpResultFunction implements Function> { 14 | @Override 15 | public Observable apply(Throwable throwable) throws Exception { 16 | //打印具体错误 17 | Log.d("HttpResultFunction:", throwable.getMessage()); 18 | return Observable.error(throwable); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/HttpResultObserver.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import com.seven.seven.common.event.ReloginEvent; 4 | import com.seven.seven.common.utils.Constans; 5 | import com.seven.seven.user.userevent.UserInfoEvent; 6 | 7 | import org.greenrobot.eventbus.EventBus; 8 | 9 | import io.reactivex.disposables.Disposable; 10 | 11 | /** 12 | * Created on 2018-03-20. 13 | * author:seven 14 | * email:seven2016s@163.com 15 | */ 16 | 17 | public abstract class HttpResultObserver extends HttpCommonObserver { 18 | 19 | protected abstract void onLoading(Disposable d); 20 | 21 | protected abstract void onSuccess(T o); 22 | 23 | protected abstract void onFail(ApiException e); 24 | 25 | @Override 26 | protected void onStart(Disposable d) { 27 | onLoading(d); 28 | } 29 | 30 | @Override 31 | protected void _onNext(T responseCustom) { 32 | if (responseCustom.getErrorCode() < 0) { 33 | if (responseCustom.getErrorMsg().contains("登录")) { 34 | EventBus.getDefault().post(new ReloginEvent(Constans.RELOGIN)); 35 | // EventBus.getDefault().post(new UserInfoEvent(Constans.RELOGIN)); 36 | } else { 37 | onFail(new ApiException(responseCustom.getErrorCode(), responseCustom.getErrorMsg())); 38 | } 39 | } else { 40 | onSuccess(responseCustom); 41 | } 42 | } 43 | 44 | @Override 45 | protected void _onError(ApiException error) { 46 | onFail(error); 47 | // Log.e("网络处理异常", error.getMessage()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/HttpResultSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | 4 | import android.util.Log; 5 | 6 | import org.reactivestreams.Subscriber; 7 | import org.reactivestreams.Subscription; 8 | 9 | import io.reactivex.disposables.Disposable; 10 | 11 | import static com.seven.seven.common.network.HttpCommonObserver.UN_KNOWN_ERROR; 12 | 13 | /** 14 | * Created on 2018-03-20. 15 | * author:seven 16 | * email:seven2016s@163.com 17 | */ 18 | 19 | public abstract class HttpResultSubscriber implements Subscriber { 20 | protected abstract void onLoading(Disposable d); 21 | 22 | protected abstract void onSuccess(T o); 23 | 24 | protected abstract void onFail(ApiException e); 25 | 26 | 27 | @Override 28 | public void onNext(T tResponseCustom) { 29 | onSuccess(tResponseCustom); 30 | } 31 | 32 | @Override 33 | public void onError(Throwable e) { 34 | if (e instanceof ApiException) { 35 | onFail((ApiException) e); 36 | Log.e("onerror", "错误编码===" + ((ApiException) e).getCode() + "错误信息===" + ((ApiException) e).getMsg()); 37 | } else { 38 | this.onFail(new ApiException(e, UN_KNOWN_ERROR)); 39 | } 40 | } 41 | 42 | @Override 43 | public void onComplete() { 44 | 45 | } 46 | 47 | @Override 48 | public void onSubscribe(Subscription s) { 49 | s.request(Long.MAX_VALUE); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/NetworkUrl.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import com.seven.seven.ui.MyApplication; 4 | 5 | /** 6 | * Created on 2018-03-20. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class NetworkUrl { 12 | public static final String ANDROID_TEST_SERVICE ="http://www.wanandroid.com/"; 13 | public static final String ANDROID_BAIDU_SERVICE ="http://gank.io"; 14 | 15 | public static String getNetWorkName(){ 16 | if (MyApplication.getIsDebug()){ 17 | return ANDROID_TEST_SERVICE; 18 | }else { 19 | return ANDROID_BAIDU_SERVICE; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/ResponseCustom.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created on 2018-03-20. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class ResponseCustom implements Serializable { 12 | 13 | 14 | private int errorCode; 15 | private String errorMsg; 16 | private T data; 17 | 18 | /** 19 | * 是否成功(这里约定200) 20 | * 21 | * @return 22 | */ 23 | public boolean isSuccess() { 24 | return errorCode >= 0 ? true : false; 25 | } 26 | 27 | public int getErrorCode() { 28 | return errorCode; 29 | } 30 | 31 | public void setErrorCode(int errorCode) { 32 | this.errorCode = errorCode; 33 | } 34 | 35 | 36 | public String getErrorMsg() { 37 | return errorMsg; 38 | } 39 | 40 | public void setErrorMsg(String errorMsg) { 41 | this.errorMsg = errorMsg; 42 | } 43 | 44 | public T getData() { 45 | return data; 46 | } 47 | 48 | public void setData(T data) { 49 | this.data = data; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/RxLifeManager.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import io.reactivex.annotations.NonNull; 4 | import io.reactivex.disposables.CompositeDisposable; 5 | import io.reactivex.disposables.Disposable; 6 | 7 | /** 8 | * Created on 2018-03-20. 9 | * author:seven 10 | * email:seven2016s@163.com 11 | *

12 | * rxlifemanager用于切断上游与下游直接的联系, 13 | * 也就是说我只要执行了disposable,上游事件将无法传递给下游去接受 订阅关系结束 14 | * 集中处理在baseactivity里面就足够了,如果某一个页面需要就单独处理 15 | * 有没有效阻止rx泄露我也不知道 ,在这里统一做disposbale是为了封装observer处理onstart() 16 | */ 17 | public class RxLifeManager { 18 | 19 | private static volatile RxLifeManager rxLifeManager; 20 | private CompositeDisposable compositeDisposableOnStop = new CompositeDisposable();//在页面onstop的时候切断 21 | private CompositeDisposable compositeDisposableOnDestroy = new CompositeDisposable();//在页面ondestroy时候切断 22 | 23 | public RxLifeManager() { 24 | } 25 | 26 | public static RxLifeManager getRxLifeManager() { 27 | if (rxLifeManager == null) { 28 | synchronized (RxLifeManager.class) { 29 | if (rxLifeManager == null) { 30 | rxLifeManager = new RxLifeManager(); 31 | } 32 | } 33 | } 34 | return rxLifeManager; 35 | } 36 | 37 | public void setCompositeDisposableOnStop(@NonNull Disposable s) { 38 | if (compositeDisposableOnStop != null) { 39 | compositeDisposableOnStop.add(s); 40 | } else { 41 | compositeDisposableOnStop = new CompositeDisposable(); 42 | compositeDisposableOnStop.add(s); 43 | } 44 | } 45 | 46 | public void setCompositeDisposableOnDestroy(Disposable s) { 47 | if (compositeDisposableOnDestroy != null) { 48 | compositeDisposableOnDestroy.add(s); 49 | } else { 50 | compositeDisposableOnDestroy = new CompositeDisposable(); 51 | compositeDisposableOnDestroy.add(s); 52 | } 53 | } 54 | 55 | public void onStopDisposable() { 56 | if (compositeDisposableOnStop != null) { 57 | compositeDisposableOnStop.dispose(); 58 | compositeDisposableOnStop.clear(); 59 | compositeDisposableOnStop = null; 60 | } 61 | } 62 | 63 | public void onDestroy() { 64 | if (compositeDisposableOnDestroy != null) { 65 | compositeDisposableOnDestroy.dispose(); 66 | compositeDisposableOnDestroy.clear(); 67 | compositeDisposableOnDestroy = null; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/ServerResultFunction.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import com.seven.seven.common.utils.GsonTools; 4 | import com.seven.seven.common.utils.LogUtils; 5 | 6 | import java.util.function.Function; 7 | 8 | /** 9 | * Created by seven 10 | * on 2018/5/17 11 | * email:seven2016s@163.com 12 | */ 13 | 14 | public class ServerResultFunction implements io.reactivex.functions.Function { 15 | @Override 16 | public Object apply(ResponseCustom responseCustom) { 17 | LogUtils.jsonE("服务器返回结果===>" + GsonTools.createGsonString(responseCustom)); 18 | 19 | return responseCustom; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/ThreadSchedulersHelper.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network; 2 | 3 | import io.reactivex.Observable; 4 | import io.reactivex.ObservableSource; 5 | import io.reactivex.ObservableTransformer; 6 | import io.reactivex.android.schedulers.AndroidSchedulers; 7 | import io.reactivex.schedulers.Schedulers; 8 | 9 | /** 10 | * Created on 2018-03-20. 11 | * author:seven 12 | * email:seven2016s@163.com 13 | */ 14 | 15 | public class ThreadSchedulersHelper { 16 | /* 上游处理网络请求用io线程(发布事件) 17 | * 线程上下游切换,上游执行完以后里面切换为主线程(接收事件) 18 | * */ 19 | public static ObservableTransformer rxSchedulers() { 20 | return new ObservableTransformer() { 21 | @Override 22 | public ObservableSource apply(Observable upstream) { 23 | return upstream.subscribeOn(Schedulers.io()) 24 | .observeOn(AndroidSchedulers.mainThread()); 25 | } 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/gank/GankHttpObserver.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network.gank; 2 | 3 | import android.util.Log; 4 | 5 | import com.seven.seven.common.network.ApiException; 6 | import com.seven.seven.common.network.RxLifeManager; 7 | 8 | import java.net.UnknownServiceException; 9 | 10 | import io.reactivex.Observer; 11 | import io.reactivex.disposables.Disposable; 12 | 13 | /** 14 | * Created on 2018-03-20. 15 | * author:seven 16 | * email:seven2016s@163.com 17 | */ 18 | 19 | public abstract class GankHttpObserver implements Observer { 20 | private boolean flag = false;//是否切断上下游的事件传递 21 | public static final int UN_KNOWN_ERROR = 1000;//未知错误 22 | 23 | public GankHttpObserver() { 24 | } 25 | 26 | public GankHttpObserver(boolean isLink) { 27 | this.flag = isLink; 28 | } 29 | 30 | @Override 31 | public void onSubscribe(Disposable d) { 32 | this.onStart(d); 33 | if (flag) { 34 | RxLifeManager.getRxLifeManager().setCompositeDisposableOnStop(d); 35 | } else { 36 | RxLifeManager.getRxLifeManager().setCompositeDisposableOnDestroy(d); 37 | } 38 | } 39 | 40 | protected abstract void onStart(Disposable d); 41 | 42 | protected abstract void _onNext(T t); 43 | 44 | // protected abstract void _onError(ApiException e); 45 | protected abstract void _onError(ApiException e); 46 | 47 | /* 48 | * t==response 49 | * */ 50 | @Override 51 | public void onNext(T t) { 52 | if (t != null) { 53 | this._onNext(t); 54 | } 55 | 56 | } 57 | 58 | @Override 59 | public void onError(Throwable e) { 60 | if (e instanceof ApiException || e instanceof UnknownServiceException) { 61 | _onError((ApiException) e); 62 | Log.e("onerror", "错误编码===" + ((ApiException) e).getCode() + "错误信息===" + ((ApiException) e).getMsg()); 63 | } else { 64 | this._onError(new ApiException(e, UN_KNOWN_ERROR)); 65 | } 66 | // this._onError(e); 67 | } 68 | 69 | @Override 70 | public void onComplete() { 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/gank/GankIoCustom.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network.gank; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created on 2018-03-20. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class GankIoCustom implements Serializable { 12 | 13 | public boolean isError() { 14 | return error; 15 | } 16 | 17 | public void setError(boolean error) { 18 | this.error = error; 19 | } 20 | 21 | public T getResults() { 22 | return results; 23 | } 24 | 25 | public void setResults(T results) { 26 | this.results = results; 27 | } 28 | 29 | private boolean error; 30 | private T results; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/gank/GankIoObservable.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network.gank; 2 | 3 | import com.seven.seven.common.network.gank.GankIoCustom; 4 | 5 | import io.reactivex.Observable; 6 | import io.reactivex.android.schedulers.AndroidSchedulers; 7 | import io.reactivex.schedulers.Schedulers; 8 | 9 | /** 10 | * Created by seven 11 | * on 2018/5/17 12 | * email:seven2016s@163.com 13 | */ 14 | 15 | public class GankIoObservable { 16 | public static Observable getObservable(Observable> customObservable) { 17 | Observable observable = customObservable 18 | // .map(new ServerResultFunction()) 19 | // .onErrorResumeNext(new HttpResultFunction()) 20 | .subscribeOn(Schedulers.io()) 21 | .observeOn(AndroidSchedulers.mainThread()); 22 | return observable; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/network/gank/GankResultObserver.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.network.gank; 2 | 3 | import com.seven.seven.common.network.ApiException; 4 | import com.seven.seven.common.network.HttpCommonObserver; 5 | import com.seven.seven.common.network.gank.GankIoCustom; 6 | 7 | import io.reactivex.disposables.Disposable; 8 | 9 | /** 10 | * Created on 2018-03-20. 11 | * author:seven 12 | * email:seven2016s@163.com 13 | */ 14 | 15 | public abstract class GankResultObserver extends GankHttpObserver { 16 | 17 | protected abstract void onLoading(Disposable d); 18 | 19 | protected abstract void onSuccess(T o); 20 | 21 | protected abstract void onFail(ApiException e); 22 | 23 | @Override 24 | protected void onStart(Disposable d) { 25 | onLoading(d); 26 | } 27 | 28 | @Override 29 | protected void _onNext(T responseCustom) { 30 | onSuccess(responseCustom); 31 | } 32 | 33 | @Override 34 | protected void _onError(ApiException error) { 35 | onFail(error); 36 | // Log.e("网络处理异常", error.getMessage()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/AppBarStateChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import android.support.design.widget.AppBarLayout; 4 | 5 | public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener { 6 | 7 | public enum State { 8 | EXPANDED, 9 | COLLAPSED, 10 | IDLE 11 | } 12 | 13 | private State mCurrentState = State.IDLE; 14 | 15 | @Override 16 | public final void onOffsetChanged(AppBarLayout appBarLayout, int i) { 17 | if (i == 0) { 18 | if (mCurrentState != State.EXPANDED) { 19 | onStateChanged(appBarLayout, State.EXPANDED); 20 | } 21 | mCurrentState = State.EXPANDED; 22 | } else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) { 23 | if (mCurrentState != State.COLLAPSED) { 24 | onStateChanged(appBarLayout, State.COLLAPSED); 25 | } 26 | mCurrentState = State.COLLAPSED; 27 | } else { 28 | if (mCurrentState != State.IDLE) { 29 | onStateChanged(appBarLayout, State.IDLE); 30 | } 31 | mCurrentState = State.IDLE; 32 | } 33 | } 34 | 35 | public abstract void onStateChanged(AppBarLayout appBarLayout, State state); 36 | } -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/Constans.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | /** 4 | * Created by seven 5 | * on 2018/5/17 6 | * email:seven2016s@163.com 7 | * eventbus的what记录以及一些常量的配置 8 | */ 9 | 10 | public class Constans { 11 | /* 12 | * 网络监听 13 | * */ 14 | public static final int NET_WORK_AVAILABLE = 0;//有网络 15 | public static final int NET_WORK_DISABLED = 1;//没网络 16 | /* 17 | * home模块 100~200 18 | * */ 19 | public static final int HOMEDATA = 101;//获取首页数据成功 20 | public static final int HOMEBANNER = 102;//获取首页banner 21 | public static final int HOMEERROR = 100;//首页请求数据失败 22 | public static final int HOMEDASUCCESS = 103;//banner,homedata请求数据成功,取消loading 23 | 24 | public static final String COOKIE_PREF = "cookie_pref";//cookie保存 25 | /* 26 | * 登录注册用户相关10-20 27 | * */ 28 | public static final int REGISTER = 10;//注册成功 29 | public static final int LOGIN = 11;//登录成功 30 | public static final int RELOGIN = 13;//重新登录 31 | public static final int USERERROR = 12;//用户相关错误 32 | public static final int USERERRORS = 14;//注册相关错误 33 | public static final String USERNAME = "user_name";//存储用户名 34 | public static final int COLLECTSIZE = 41;//获取收藏size 35 | public static final int COLLECTSIZEERROR = 42;//获取收藏size失败 36 | /* 37 | * webview模块 20-40 38 | * */ 39 | public static final int COLLECT = 20;//收藏文章成功 40 | public static final int COLLECTERROR = 22;//收藏文章失败 41 | 42 | /* 43 | * 个人模块 40-60 44 | * */ 45 | public static final int COLLECTLIST = 41;//获取收藏列表成功 46 | public static final int COLLECTLISTERROR = 42;//获取收藏列表失败 47 | public static final int DELETECOLLECT = 43;//获取收藏列表失败 48 | public static final int DELETECOLLECTERROR = 44;//获取收藏列表失败 49 | 50 | /* 51 | * 搜索模块 60~80 52 | * */ 53 | public static final int HOTTAG = 60;//获取热门搜索词成功 54 | public static final int HOTTAGERROR = 61;//获取热门搜索词失败 55 | public static final int USINGURL = 62;//获取常用网址成功 56 | public static final int USINGURLERROR = 63;//获取常用网址失败 57 | public static final int SEARCHK = 64;//动态搜索成功 58 | public static final int SEARCHKERROR = 65;//动态搜索失败 59 | 60 | /* 61 | * 干货模块 80~99 62 | * 63 | * */ 64 | public static final int GANKIO = 80;//获取干货福利成功 65 | public static final int GANKIOERROR = 81;//获取干货福利失败 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/DensityUtil.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by oi on 2017/12/6. 7 | * dp和px之间进行转换 8 | */ 9 | 10 | public class DensityUtil { 11 | /** 12 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) 13 | */ 14 | public static int dip2px(Context context, float dpValue) { 15 | final float scale = context.getResources().getDisplayMetrics().density; 16 | return (int) (dpValue * scale + 0.5f); 17 | } 18 | 19 | /** 20 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp 21 | */ 22 | public static int px2dip(Context context, float pxValue) { 23 | final float scale = context.getResources().getDisplayMetrics().density; 24 | return (int) (pxValue / scale + 0.5f); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import android.content.Context; 4 | 5 | import java.io.File; 6 | import java.util.Arrays; 7 | 8 | /** 9 | * Created by Liuc on 2017-12-19. 10 | * 辅助创建文件夹和文件 11 | */ 12 | 13 | public class FileUtils { 14 | 15 | 16 | /** 17 | * 创建一个新的文件用来存储图片 18 | * 19 | * @param outputfile 输出路径 20 | * @return 是否创建成功 21 | */ 22 | public static boolean creatFile(File outputfile) { 23 | boolean flag = true; 24 | try { 25 | outputfile.deleteOnExit(); 26 | outputfile.createNewFile(); 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | } 30 | return flag; 31 | } 32 | 33 | 34 | /** 35 | * 创建一个新的文件用来存储图片 36 | * 37 | * @param outputfile 输出路径 38 | * @return 是否创建成功 39 | */ 40 | public static boolean creatDirs(File outputfile) { 41 | boolean flag = true; 42 | try { 43 | outputfile.deleteOnExit(); 44 | flag = outputfile.mkdirs(); 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | return flag; 49 | } 50 | 51 | /** 52 | * 判断assets文件夹下的文件是否存在 53 | * 54 | * @return false 不存在 true 存在 55 | */ 56 | public static boolean isFileExists(Context context, String filename) { 57 | String[] names = new File(context.getCacheDir().getAbsolutePath() + File.separator + "error_1").list(); 58 | LogUtils.e(Arrays.toString(names)); 59 | if (names != null) { 60 | for (String name : names) { 61 | if (name.contains(filename.trim())) { 62 | return true; 63 | } 64 | } 65 | } 66 | return false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/GlideUtils.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import android.graphics.Bitmap; 4 | import android.widget.ImageView; 5 | 6 | import com.bumptech.glide.Glide; 7 | import com.bumptech.glide.request.RequestOptions; 8 | import com.seven.seven.ui.MyApplication; 9 | 10 | /** 11 | * Created on 2018-05-28. 12 | * author:seven 13 | * email:seven2016s@163.com 14 | */ 15 | 16 | public class GlideUtils { 17 | /* 18 | * 正常加载 19 | * */ 20 | public static void loadImageview(ImageView imageview, String path) { 21 | Glide.with(MyApplication.getContext()).load(path).into(imageview); 22 | } 23 | 24 | /* 25 | * 26 | * 加载带有占位图的view 27 | * */ 28 | public static void loadImageViewLoading(ImageView imageView, Object path, int errorPath, int loadingPath) { 29 | RequestOptions requestOptions = new RequestOptions(); 30 | Glide.with(MyApplication.getContext()).load(path) 31 | .apply(requestOptions.placeholder(loadingPath).error(errorPath)) 32 | .into(imageView); 33 | } 34 | 35 | /* 36 | * 加载指定大小的image 37 | * */ 38 | public static void loadImageViewSize(ImageView imageView, String path, int loadingPath, int errorPath, int width, int height) { 39 | RequestOptions requestOptions = new RequestOptions(); 40 | Glide.with(MyApplication.getContext()).load(path).apply(requestOptions.override(width, height) 41 | .placeholder(loadingPath).error(errorPath)) 42 | .into(imageView); 43 | } 44 | 45 | /* 46 | * 裁剪大小,设置缓存模式,防止oom(不缓存) 47 | * 48 | * */ 49 | public static void loadImageViewOOM(ImageView imageView, int loadingPath, int errorPath, String path, int height, int width) { 50 | RequestOptions requestOptions = new RequestOptions(); 51 | Glide.with(MyApplication.getContext()).load(path) 52 | .apply(requestOptions.override(width, height).skipMemoryCache(true) 53 | .placeholder(loadingPath).error(errorPath)) 54 | .into(imageView); 55 | } 56 | 57 | /* 58 | * 加载圆形图片 59 | * */ 60 | public static void loadImageViewCircle(ImageView imageView, String path, int loadingPath, int errorPath) { 61 | RequestOptions requestOptions = new RequestOptions(); 62 | Glide.with(MyApplication.getContext()).asBitmap().load(path) 63 | .apply(requestOptions.skipMemoryCache(true).optionalCircleCrop() 64 | .placeholder(loadingPath).error(errorPath)) 65 | .into(imageView); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/GsonTools.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | 4 | import com.google.gson.Gson; 5 | import com.google.gson.reflect.TypeToken; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class GsonTools { 11 | 12 | public GsonTools() { 13 | // TODO Auto-generated constructor stub 14 | } 15 | 16 | public static String createGsonString(Object object) { 17 | Gson gson = new Gson(); 18 | String gsonString = gson.toJson(object); 19 | return gsonString; 20 | } 21 | 22 | public static T changeGsonToBean(String gsonString, Class cls) { 23 | Gson gson = new Gson(); 24 | T t = gson.fromJson(gsonString, cls); 25 | return t; 26 | } 27 | 28 | public static List changeGsonToList(String gsonString, Class cls) { 29 | Gson gson = new Gson(); 30 | List list = gson.fromJson(gsonString, new TypeToken>() { 31 | }.getType()); 32 | return list; 33 | } 34 | 35 | 36 | public static List> changeGsonToListMaps( 37 | String gsonString) { 38 | List> list = null; 39 | Gson gson = new Gson(); 40 | list = gson.fromJson(gsonString, new TypeToken>>() { 41 | }.getType()); 42 | return list; 43 | } 44 | 45 | public static Map changeGsonToMaps(String gsonString) { 46 | Map map = null; 47 | Gson gson = new Gson(); 48 | map = gson.fromJson(gsonString, new TypeToken>() { 49 | }.getType()); 50 | return map; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/HTMLScript.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | /** 7 | * Created by seven 8 | * on 2018/6/2 9 | * email:seven2016s@163.com 10 | */ 11 | 12 | public class HTMLScript { 13 | /** 14 | * 定义script的正则表达式 15 | */ 16 | private static final String REGEX_SCRIPT = "]*?>[\\s\\S]*?<\\/script>"; 17 | /** 18 | * 定义style的正则表达式 19 | */ 20 | private static final String REGEX_STYLE = "]*?>[\\s\\S]*?<\\/style>"; 21 | /** 22 | * 定义HTML标签的正则表达式 23 | */ 24 | private static final String REGEX_HTML = "<[^>]+>"; 25 | /** 26 | * 定义空格回车换行符 27 | */ 28 | private static final String REGEX_SPACE = "\\s*|\t|\r|\n"; 29 | public static String delHTMLTag(String htmlStr) { 30 | // 过滤script标签 31 | Pattern p_script = Pattern.compile(REGEX_SCRIPT, Pattern.CASE_INSENSITIVE); 32 | Matcher m_script = p_script.matcher(htmlStr); 33 | htmlStr = m_script.replaceAll(""); 34 | // 过滤style标签 35 | Pattern p_style = Pattern.compile(REGEX_STYLE, Pattern.CASE_INSENSITIVE); 36 | Matcher m_style = p_style.matcher(htmlStr); 37 | htmlStr = m_style.replaceAll(""); 38 | // 过滤html标签 39 | Pattern p_html = Pattern.compile(REGEX_HTML, Pattern.CASE_INSENSITIVE); 40 | Matcher m_html = p_html.matcher(htmlStr); 41 | htmlStr = m_html.replaceAll(""); 42 | // 过滤空格回车标签 43 | Pattern p_space = Pattern.compile(REGEX_SPACE, Pattern.CASE_INSENSITIVE); 44 | Matcher m_space = p_space.matcher(htmlStr); 45 | htmlStr = m_space.replaceAll(""); 46 | return htmlStr.trim(); // 返回文本字符串 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/RxManager.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import io.reactivex.disposables.CompositeDisposable; 4 | import io.reactivex.disposables.Disposable; 5 | 6 | /** 7 | * Created on 2018-01-05. 8 | * author:seven 9 | * email:seven2016s@163.com 10 | */ 11 | 12 | public class RxManager { 13 | protected CompositeDisposable compositeDisposable = new CompositeDisposable();//管理订阅者 14 | 15 | //注册订阅 16 | public void register(Disposable disposable) { 17 | compositeDisposable.add(disposable); 18 | } 19 | 20 | //取消订阅 21 | public void unSubscribe() { 22 | compositeDisposable.dispose(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/ScaleTransformer.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import android.support.v4.view.ViewPager; 4 | import android.util.Log; 5 | import android.view.View; 6 | 7 | public class ScaleTransformer implements ViewPager.PageTransformer { 8 | private static final float MIN_SCALE = 0.70f; 9 | private static final float MIN_ALPHA = 0.5f; 10 | 11 | @Override 12 | public void transformPage(View page, float position) { 13 | if (position < -1 || position > 1) { 14 | page.setAlpha(MIN_ALPHA); 15 | page.setScaleX(MIN_SCALE); 16 | page.setScaleY(MIN_SCALE); 17 | } else if (position <= 1) { // [-1,1] 18 | float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); 19 | if (position < 0) { 20 | float scaleX = 1 + 0.3f * position; 21 | Log.d("google_lenve_fb", "transformPage: scaleX:" + scaleX); 22 | page.setScaleX(scaleX); 23 | page.setScaleY(scaleX); 24 | } else { 25 | float scaleX = 1 - 0.3f * position; 26 | page.setScaleX(scaleX); 27 | page.setScaleY(scaleX); 28 | } 29 | page.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.utils; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | /** 8 | * Created on 2018-05-18. 9 | * author:seven 10 | * email:seven2016s@163.com 11 | */ 12 | 13 | public class TimeUtils { 14 | /* 15 | * time:时间毫秒值 16 | * inFormat:时间格式 17 | * */ 18 | public static String longToString(long time, String inFormat) { 19 | Date date = new Date(time); 20 | DateFormat format = new SimpleDateFormat(inFormat); 21 | return format.format(date); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/GradientView.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.LinearGradient; 7 | import android.graphics.Matrix; 8 | import android.graphics.Paint; 9 | import android.graphics.RadialGradient; 10 | import android.graphics.Shader; 11 | import android.graphics.SweepGradient; 12 | import android.support.annotation.Nullable; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | 16 | /** 17 | * Created on 2018-05-29. 18 | * author:seven 19 | * email:seven2016s@163.com 20 | */ 21 | 22 | public class GradientView extends View { 23 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 24 | private int[] colors = new int[]{Color.RED, Color.GREEN}; 25 | 26 | public GradientView(Context context) { 27 | super(context); 28 | } 29 | 30 | public GradientView(Context context, @Nullable AttributeSet attrs) { 31 | super(context, attrs); 32 | } 33 | 34 | public GradientView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 35 | super(context, attrs, defStyleAttr); 36 | } 37 | 38 | @Override 39 | protected void onDraw(Canvas canvas) { 40 | super.onDraw(canvas); 41 | int width = getWidth() / 2; 42 | int height = getHeight() / 2; 43 | paint.setColor(Color.WHITE); 44 | paint.setStyle(Paint.Style.STROKE); 45 | paint.setStrokeWidth(20); 46 | Matrix matrix = new Matrix(); 47 | matrix.setRotate(-90, width, height); 48 | Shader shader = new LinearGradient( width, 0, getWidth(), height, Color.RED, Color.GREEN, Shader.TileMode.CLAMP); 49 | shader.setLocalMatrix(matrix); 50 | paint.setShader(shader); 51 | canvas.drawCircle(width, height, 200, paint); 52 | } 53 | 54 | @Override 55 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 56 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 57 | // setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/HomeTitleView.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.view.animation.DecelerateInterpolator; 8 | import android.view.animation.Interpolator; 9 | import android.widget.LinearLayout; 10 | 11 | import com.seven.seven.R; 12 | 13 | /** 14 | * Created on 2018-05-24. 15 | * author:seven 16 | * email:seven2016s@163.com 17 | */ 18 | 19 | public class HomeTitleView extends LinearLayout { 20 | private Interpolator mInterpolator = new DecelerateInterpolator(3); 21 | private View view; 22 | 23 | public HomeTitleView(Context context) { 24 | super(context); 25 | } 26 | 27 | public HomeTitleView(Context context, @Nullable AttributeSet attrs) { 28 | super(context, attrs); 29 | } 30 | 31 | public HomeTitleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 32 | super(context, attrs, defStyleAttr); 33 | } 34 | 35 | @Override 36 | protected void onFinishInflate() { 37 | super.onFinishInflate(); 38 | initView(); 39 | } 40 | 41 | private void initView() { 42 | view = findViewById(R.id.lly_root); 43 | setBgAndViewAlpha(0); 44 | } 45 | 46 | public void setBgAndViewAlpha(int alpha) { 47 | float animAlpha = mInterpolator.getInterpolation(alpha); 48 | view.setAlpha(animAlpha); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/progress/AnimationUtils.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.progress; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | 6 | 7 | /** 8 | * @author vondear 9 | */ 10 | public class AnimationUtils { 11 | 12 | public static void start(Animator animator) { 13 | if (animator != null && !animator.isStarted()) { 14 | animator.start(); 15 | } 16 | } 17 | 18 | public static void stop(Animator animator) { 19 | if (animator != null && !animator.isRunning()) { 20 | animator.end(); 21 | } 22 | } 23 | 24 | public static void start(Sprite... sprites) { 25 | for (Sprite sprite : sprites) { 26 | sprite.start(); 27 | } 28 | } 29 | 30 | public static void stop(Sprite... sprites) { 31 | for (Sprite sprite : sprites) { 32 | sprite.stop(); 33 | } 34 | } 35 | 36 | public static boolean isRunning(Sprite... sprites) { 37 | for (Sprite sprite : sprites) { 38 | if (sprite.isRunning()) { 39 | return true; 40 | } 41 | } 42 | return false; 43 | } 44 | 45 | public static boolean isRunning(ValueAnimator animator) { 46 | return animator != null && animator.isRunning(); 47 | } 48 | 49 | public static boolean isStarted(ValueAnimator animator) { 50 | return animator != null && animator.isStarted(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/progress/CircleSprite.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.progress; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | 7 | /** 8 | * @author vondear 9 | */ 10 | public class CircleSprite extends ShapeSprite { 11 | 12 | @Override 13 | public ValueAnimator onCreateAnimation() { 14 | return null; 15 | } 16 | 17 | @Override 18 | public void drawShape(Canvas canvas, Paint paint) { 19 | if (getDrawBounds() != null) { 20 | int radius = Math.min(getDrawBounds().width(), getDrawBounds().height()) / 2; 21 | canvas.drawCircle(getDrawBounds().centerX(), 22 | getDrawBounds().centerY(), 23 | radius, paint); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/progress/DoubleBounce.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.progress; 2 | 3 | import android.animation.ValueAnimator; 4 | 5 | 6 | /** 7 | * @author vondear 8 | */ 9 | public class DoubleBounce extends SpriteContainer { 10 | 11 | @Override 12 | public Sprite[] onCreateChild() { 13 | return new Sprite[]{ 14 | new Bounce(), new Bounce() 15 | }; 16 | } 17 | 18 | @Override 19 | public void onChildCreated(Sprite... sprites) { 20 | super.onChildCreated(sprites); 21 | sprites[1].setAnimationDelay(-1000); 22 | } 23 | 24 | private class Bounce extends CircleSprite { 25 | 26 | Bounce() { 27 | setAlpha(153); 28 | setScale(0f); 29 | } 30 | 31 | @Override 32 | public ValueAnimator onCreateAnimation() { 33 | float fractions[] = new float[]{0f, 0.5f, 1f}; 34 | return new SpriteAnimatorBuilder(this).scale(fractions, 0f, 1f, 0f). 35 | duration(4000). 36 | easeInOut(fractions) 37 | .build(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/progress/Ease.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.progress; 2 | 3 | import android.support.v4.view.animation.PathInterpolatorCompat; 4 | import android.view.animation.Interpolator; 5 | 6 | /** 7 | * @author vondear 8 | */ 9 | public class Ease { 10 | public static Interpolator inOut() { 11 | return PathInterpolatorCompat.create(0.42f, 0f, 0.58f, 1f); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/progress/KeyFrameInterpolator.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.progress; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.support.v4.view.animation.PathInterpolatorCompat; 5 | import android.view.animation.Interpolator; 6 | 7 | /** 8 | * @author vondear 9 | */ 10 | public class KeyFrameInterpolator implements Interpolator { 11 | 12 | private TimeInterpolator interpolator; 13 | private float[] fractions; 14 | 15 | 16 | public KeyFrameInterpolator(TimeInterpolator interpolator, float... fractions) { 17 | this.interpolator = interpolator; 18 | this.fractions = fractions; 19 | } 20 | 21 | public static KeyFrameInterpolator easeInOut(float... fractions) { 22 | KeyFrameInterpolator interpolator = new KeyFrameInterpolator(Ease.inOut()); 23 | interpolator.setFractions(fractions); 24 | return interpolator; 25 | } 26 | 27 | public static KeyFrameInterpolator pathInterpolator(float controlX1, float controlY1, 28 | float controlX2, float controlY2, 29 | float... fractions) { 30 | KeyFrameInterpolator interpolator = new KeyFrameInterpolator(PathInterpolatorCompat.create(controlX1, controlY1, controlX2, controlY2)); 31 | interpolator.setFractions(fractions); 32 | return interpolator; 33 | } 34 | 35 | public void setFractions(float... fractions) { 36 | this.fractions = fractions; 37 | } 38 | 39 | @Override 40 | public synchronized float getInterpolation(float input) { 41 | if (fractions.length > 1) { 42 | for (int i = 0; i < fractions.length - 1; i++) { 43 | float start = fractions[i]; 44 | float end = fractions[i + 1]; 45 | float duration = end - start; 46 | if (input >= start && input <= end) { 47 | input = (input - start) / duration; 48 | return start + (interpolator.getInterpolation(input) 49 | * duration); 50 | } 51 | } 52 | } 53 | return interpolator.getInterpolation(input); 54 | } 55 | } -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/progress/ShapeSprite.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.progress; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Color; 5 | import android.graphics.ColorFilter; 6 | import android.graphics.Paint; 7 | 8 | /** 9 | * @author vondear 10 | */ 11 | public abstract class ShapeSprite extends Sprite { 12 | 13 | private Paint mPaint; 14 | private int mUseColor; 15 | private int mBaseColor; 16 | 17 | public ShapeSprite() { 18 | setColor(Color.WHITE); 19 | mPaint = new Paint(); 20 | mPaint.setAntiAlias(true); 21 | mPaint.setColor(mUseColor); 22 | } 23 | 24 | @Override 25 | public int getColor() { 26 | return mBaseColor; 27 | } 28 | 29 | @Override 30 | public void setColor(int color) { 31 | mBaseColor = color; 32 | updateUseColor(); 33 | } 34 | 35 | @SuppressWarnings("unused") 36 | public int getUseColor() { 37 | return mUseColor; 38 | } 39 | 40 | @Override 41 | public void setAlpha(int alpha) { 42 | super.setAlpha(alpha); 43 | updateUseColor(); 44 | } 45 | 46 | private void updateUseColor() { 47 | int alpha = getAlpha(); 48 | alpha += alpha >> 7; 49 | final int baseAlpha = mBaseColor >>> 24; 50 | final int useAlpha = baseAlpha * alpha >> 8; 51 | mUseColor = (mBaseColor << 8 >>> 8) | (useAlpha << 24); 52 | } 53 | 54 | @Override 55 | public void setColorFilter(ColorFilter colorFilter) { 56 | mPaint.setColorFilter(colorFilter); 57 | } 58 | 59 | @Override 60 | protected final void drawSelf(Canvas canvas) { 61 | mPaint.setColor(mUseColor); 62 | drawShape(canvas, mPaint); 63 | } 64 | 65 | public abstract void drawShape(Canvas canvas, Paint paint); 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/webview/H5Control.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.webview; 2 | 3 | import android.os.Bundle; 4 | 5 | /** 6 | * Created by seven 7 | * on 2018/5/28 8 | * email:seven2016s@163.com 9 | * h5控制android跳转之类的事件 10 | */ 11 | 12 | public interface H5Control { 13 | void H5ControlAndroidEvent(String url, Bundle bundle); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/webview/H5JSInterface.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.webview; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | import android.webkit.JavascriptInterface; 6 | import android.webkit.WebView; 7 | 8 | import com.seven.seven.common.network.NetworkUrl; 9 | import com.seven.seven.common.utils.Constans; 10 | import com.seven.seven.common.utils.GsonTools; 11 | import com.seven.seven.common.utils.PreferencesUtils; 12 | 13 | /** 14 | * Created by seven 15 | * on 2018/5/28 16 | * email:seven2016s@163.com 17 | */ 18 | 19 | public class H5JSInterface { 20 | private Context mContext; 21 | private H5Control control; 22 | 23 | public H5JSInterface(Context context) { 24 | this.mContext = context; 25 | } 26 | 27 | public void registerListener(H5Control control) { 28 | this.control = control; 29 | } 30 | 31 | public void unRegisterListener() { 32 | this.control = null; 33 | } 34 | 35 | /* 36 | * android发送数据到h5 37 | * */ 38 | @JavascriptInterface 39 | public String getDataFromAndroid(String datas) { 40 | final H5ToAndroidData h5ToAndroidData = GsonTools.changeGsonToBean(datas, H5ToAndroidData.class); 41 | String result = "Android:"; 42 | switch (h5ToAndroidData.type) { 43 | case 1: 44 | /*比如和h5协商type=1是传cookie,前面拼的字段为了区分android端和iOS端,字段需要明确告诉h5 他好切割数据*/ 45 | result += PreferencesUtils.getString(mContext, Constans.COOKIE_PREF); 46 | break; 47 | } 48 | return result; 49 | } 50 | 51 | /* 52 | * h5发送数据到android 53 | * */ 54 | @JavascriptInterface 55 | public void sendInfoToAndroid(String datas) { 56 | final H5ToAndroidData h5ToAndroidData = GsonTools.changeGsonToBean(datas, H5ToAndroidData.class); 57 | switch (h5ToAndroidData.type) { 58 | case 1: 59 | if (control != null) { 60 | /*比如type = 1 是跳转h5*/ 61 | H5ToH5Info h5ToH5Info = GsonTools.changeGsonToBean(GsonTools.createGsonString(h5ToAndroidData.data), H5ToH5Info.class); 62 | control.H5ControlAndroidEvent(NetworkUrl.ANDROID_TEST_SERVICE + h5ToH5Info.url, null); 63 | } 64 | break; 65 | } 66 | } 67 | 68 | /* 69 | * 打开webview里面的图片 70 | * */ 71 | @JavascriptInterface 72 | public void openImage(String img) { 73 | if (control != null) { 74 | control.H5ControlAndroidEvent(img, null); 75 | } 76 | } 77 | 78 | /* 79 | * 这个数据结构是和h5商量好的 80 | * */ 81 | private class H5ToH5Info { 82 | public String url; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/webview/H5ToAndroidData.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.webview; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by seven 7 | * on 2018/5/28 8 | * email:seven2016s@163.com 9 | * h5控制android事件时传递的数据 10 | */ 11 | 12 | public class H5ToAndroidData implements Serializable { 13 | public int type; 14 | public Object data; 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/common/view/webview/LookWebViewImg.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.common.view.webview; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by seven 7 | * on 2018/5/28 8 | * email:seven2016s@163.com 9 | * h5控制android事件时传递的数据 10 | */ 11 | 12 | public class LookWebViewImg implements Serializable { 13 | public Object data; 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/gank/adapter/GankAdapter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.gank.adapter; 2 | 3 | import android.support.annotation.Nullable; 4 | import android.widget.ImageView; 5 | 6 | import com.chad.library.adapter.base.BaseQuickAdapter; 7 | import com.chad.library.adapter.base.BaseViewHolder; 8 | import com.seven.seven.R; 9 | import com.seven.seven.common.utils.GlideUtils; 10 | import com.seven.seven.gank.model.GankIoWelfareBean; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by seven 16 | * on 2018/6/5 17 | * email:seven2016s@163.com 18 | */ 19 | 20 | public class GankAdapter extends BaseQuickAdapter { 21 | public GankAdapter(int layoutResId, @Nullable List data) { 22 | super(layoutResId, data); 23 | } 24 | 25 | public GankAdapter(int layoutResId) { 26 | super(layoutResId); 27 | } 28 | 29 | @Override 30 | protected void convert(BaseViewHolder helper, GankIoWelfareBean item) { 31 | GlideUtils.loadImageViewLoading((ImageView) helper.getView(R.id.iv_item_image), item.getUrl(), R.drawable.ic_error_logo, R.drawable.ic_error_logo); 32 | helper.addOnClickListener(R.id.iv_item_image); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/gank/contract/GankContract.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.gank.contract; 2 | 3 | import com.seven.seven.common.base.codereview.BaseView; 4 | 5 | /** 6 | * Created by seven 7 | * on 2018/6/5 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public interface GankContract { 12 | interface View extends BaseView{} 13 | interface Presenter{ 14 | void getGankList(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/gank/events/GankEvents.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.gank.events; 2 | 3 | import com.seven.seven.common.event.BaseEvent; 4 | 5 | /** 6 | * Created by seven 7 | * on 2018/6/5 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class GankEvents extends BaseEvent { 12 | public GankEvents() { 13 | } 14 | 15 | public GankEvents(int what) { 16 | super(what); 17 | } 18 | 19 | public GankEvents(int what, Object data) { 20 | super(what, data); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/gank/presenter/GankPresenter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.gank.presenter; 2 | 3 | import com.seven.seven.common.base.codereview.BasePresenterImpl; 4 | import com.seven.seven.common.network.ApiException; 5 | import com.seven.seven.common.network.gank.GankIoCustom; 6 | import com.seven.seven.common.network.gank.GankIoObservable; 7 | import com.seven.seven.common.network.gank.GankResultObserver; 8 | import com.seven.seven.common.utils.Constans; 9 | import com.seven.seven.gank.contract.GankContract; 10 | import com.seven.seven.gank.events.GankEvents; 11 | import com.seven.seven.gank.model.GankIoWelfareBean; 12 | import com.seven.seven.ui.MainActivity; 13 | 14 | import org.greenrobot.eventbus.EventBus; 15 | 16 | import java.util.List; 17 | 18 | import io.reactivex.disposables.Disposable; 19 | 20 | /** 21 | * Created by seven 22 | * on 2018/6/5 23 | * email:seven2016s@163.com 24 | */ 25 | 26 | public class GankPresenter extends BasePresenterImpl implements GankContract.Presenter { 27 | public GankPresenter(GankContract.View view, MainActivity activity) { 28 | super(view, activity); 29 | } 30 | 31 | /* 32 | * 默认每次10 33 | * */ 34 | @Override 35 | public void getGankList() { 36 | GankIoObservable.getObservable(apiRetrofit.getGankList("http://gank.io/api/data/福利/100/2")) 37 | .subscribe(new GankResultObserver>>() { 38 | @Override 39 | protected void onLoading(Disposable d) { 40 | 41 | } 42 | 43 | @Override 44 | protected void onSuccess(GankIoCustom> o) { 45 | EventBus.getDefault().post(new GankEvents(Constans.GANKIO, o.getResults())); 46 | } 47 | 48 | @Override 49 | protected void onFail(ApiException e) { 50 | EventBus.getDefault().post(new GankEvents(Constans.GANKIOERROR, e.getMsg())); 51 | } 52 | 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/BaseHomeTitleBar.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | import android.view.animation.DecelerateInterpolator; 7 | import android.view.animation.Interpolator; 8 | import android.widget.RelativeLayout; 9 | 10 | import com.seven.seven.R; 11 | import com.seven.seven.common.utils.StatusBarUtil; 12 | 13 | /** 14 | * Created by seven 15 | * on 2018/6/5 16 | * email:seven2016s@163.com 17 | */ 18 | 19 | public class BaseHomeTitleBar extends RelativeLayout { 20 | 21 | private View viespace; 22 | private RelativeLayout relativeLayout; 23 | private float bgAlpha; 24 | private Interpolator mInterpolator = new DecelerateInterpolator(3); 25 | 26 | public BaseHomeTitleBar(Context context) { 27 | super(context); 28 | } 29 | 30 | public BaseHomeTitleBar(Context context, AttributeSet attrs) { 31 | super(context, attrs); 32 | } 33 | 34 | public BaseHomeTitleBar(Context context, AttributeSet attrs, int defStyleAttr) { 35 | super(context, attrs, defStyleAttr); 36 | } 37 | 38 | @Override 39 | protected void onFinishInflate() { 40 | super.onFinishInflate(); 41 | initView(); 42 | } 43 | 44 | private void initView() { 45 | viespace = findViewById(R.id.view_space); 46 | StatusBarUtil.setFadeStatusBarHeight(getContext(), viespace); 47 | relativeLayout = findViewById(R.id.rly_home_title); 48 | setBgAlpha(0); 49 | } 50 | 51 | public void setBgAlpha(float bgAlpha) { 52 | this.bgAlpha = mInterpolator.getInterpolation(bgAlpha); 53 | viespace.setAlpha(bgAlpha); 54 | relativeLayout.setAlpha(bgAlpha); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/BaseRecyclerFragment.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.seven.seven.R; 10 | import com.seven.seven.common.base.BaseMvpFragment; 11 | import com.seven.seven.common.base.codereview.BasePresenter; 12 | import com.seven.seven.common.base.IBaseModel; 13 | 14 | /** 15 | * Created on 2018-03-31. 16 | * author:seven 17 | * email:seven2016s@163.com 18 | */ 19 | 20 | public abstract class BaseRecyclerFragment

extends BaseMvpFragment { 21 | protected View errorView; 22 | protected View loadingView; 23 | protected View emptyView; 24 | 25 | @Override 26 | public void onStart() { 27 | super.onStart(); 28 | ShowLoadingView(); 29 | } 30 | 31 | @Override 32 | public void setUserVisibleHint(boolean isVisibleToUser) { 33 | super.setUserVisibleHint(isVisibleToUser); 34 | } 35 | 36 | @Nullable 37 | @Override 38 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 39 | errorView = inflater.inflate(R.layout.error_layout, container, false); 40 | loadingView = inflater.inflate(R.layout.error_layout, container, false); 41 | emptyView = inflater.inflate(R.layout.error_layout, container, false); 42 | errorView.setOnClickListener(new View.OnClickListener() { 43 | @Override 44 | public void onClick(View v) { 45 | ShowLoadingView(); 46 | onErrorViewOnclick(v); 47 | } 48 | }); 49 | return super.onCreateView(inflater, container, savedInstanceState); 50 | } 51 | 52 | protected abstract void onErrorViewOnclick(View v); 53 | 54 | protected abstract void ShowLoadingView(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/adapter/BannerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.widget.ImageView; 6 | 7 | import com.bumptech.glide.Glide; 8 | import com.chad.library.adapter.base.BaseQuickAdapter; 9 | import com.chad.library.adapter.base.BaseViewHolder; 10 | import com.seven.seven.R; 11 | import com.seven.seven.common.utils.GlideUtils; 12 | import com.seven.seven.home.model.HomeBannerInfos; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created on 2018-05-22. 18 | * author:seven 19 | * email:seven2016s@163.com 20 | */ 21 | 22 | public class BannerViewAdapter extends BaseQuickAdapter { 23 | private Context mContext; 24 | 25 | public BannerViewAdapter(int layoutResId, @Nullable List data, Context context) { 26 | super(layoutResId, data); 27 | this.mContext = context; 28 | } 29 | 30 | public BannerViewAdapter(int layoutResId, Context mContext) { 31 | super(layoutResId); 32 | this.mContext = mContext; 33 | } 34 | 35 | @Override 36 | protected void convert(BaseViewHolder helper, HomeBannerInfos item) { 37 | if (item != null) { 38 | // Glide.with(mContext).load(item.getImagePath()).into((ImageView) helper.getView(R.id.iv_banner_image)); 39 | GlideUtils.loadImageViewLoading((ImageView) helper.getView(R.id.iv_banner_image),item.getImagePath(),R.drawable.ic_error_logo,R.drawable.ic_error_logo); 40 | helper.addOnClickListener(R.id.iv_banner_image); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/adapter/BaseLoadMoreAdapter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.adapter; 2 | 3 | import android.support.annotation.Nullable; 4 | 5 | import com.chad.library.adapter.base.BaseQuickAdapter; 6 | import com.chad.library.adapter.base.BaseViewHolder; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created on 2018-03-31. 12 | * author:seven 13 | * email:seven2016s@163.com 14 | */ 15 | 16 | public abstract class BaseLoadMoreAdapter extends BaseQuickAdapter { 17 | public BaseLoadMoreAdapter(int layoutResId, @Nullable List data) { 18 | super(layoutResId, data); 19 | init(); 20 | } 21 | 22 | public BaseLoadMoreAdapter(@Nullable List data) { 23 | super(data); 24 | init(); 25 | } 26 | 27 | public BaseLoadMoreAdapter(int layoutResId) { 28 | super(layoutResId); 29 | init(); 30 | } 31 | 32 | protected void init(){ 33 | setLoadMoreView(new RvLoadMoreView()); 34 | setEnableLoadMore(true); 35 | openLoadAnimation();//开启默认动画载入(仅开启加载新item时开启动画) 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/adapter/HomeCommonAdapter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.widget.ImageView; 6 | 7 | import com.chad.library.adapter.base.BaseQuickAdapter; 8 | import com.chad.library.adapter.base.BaseViewHolder; 9 | import com.seven.seven.R; 10 | import com.seven.seven.common.utils.GlideUtils; 11 | import com.seven.seven.common.utils.TimeUtils; 12 | import com.seven.seven.home.model.HomeNewsInfos; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Created on 2018-05-18. 18 | * author:seven 19 | * email:seven2016s@163.com 20 | */ 21 | 22 | public class HomeCommonAdapter extends BaseQuickAdapter { 23 | private Context mContext; 24 | 25 | public HomeCommonAdapter(int layoutResId, @Nullable List data, Context context) { 26 | super(layoutResId, data); 27 | this.mContext = context; 28 | } 29 | 30 | @Override 31 | public int getItemCount() { 32 | return super.getItemCount(); 33 | } 34 | 35 | @Override 36 | protected void convert(BaseViewHolder helper, HomeNewsInfos.NewsInfos item) { 37 | if (item != null) { 38 | helper.setText(R.id.tv_title, item.getTitle()) 39 | .setText(R.id.tv_author, "作者: " + item.getAuthor()) 40 | .setText(R.id.tv_time, "发布时间: " + TimeUtils.longToString(item.getPublishTime(), "yyyy-MM-dd")) 41 | .setText(R.id.tv_classify, item.getChapterName()); 42 | if (item.getEnvelopePic() != null) { 43 | /* Glide.with(mContext).load(item.getEnvelopePic() == null || item.getEnvelopePic().equals("") ? R.drawable.error_logo : item.getEnvelopePic()) 44 | .apply(requestOptions.placeholder(R.drawable.error_logo).error(R.drawable.error_logo)).into((ImageView) helper.getView(R.id.iv_right));*/ 45 | GlideUtils.loadImageViewLoading((ImageView) helper.getView(R.id.iv_right) 46 | ,item.getEnvelopePic() == null || item.getEnvelopePic().equals("") ? R.drawable.ic_error_logo : item.getEnvelopePic(),R.drawable.ic_error_logo,R.drawable.ic_error_logo); 47 | } 48 | helper.addOnClickListener(R.id.cd_item); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/adapter/RvLoadMoreView.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.adapter; 2 | 3 | import com.chad.library.adapter.base.loadmore.LoadMoreView; 4 | import com.seven.seven.R; 5 | 6 | /** 7 | * Created on 2018-03-31. 8 | * author:seven 9 | * email:seven2016s@163.com 10 | */ 11 | public class RvLoadMoreView extends LoadMoreView { 12 | @Override 13 | public int getLayoutId() { 14 | return R.layout.layout_recycler_loadmore; 15 | } 16 | 17 | @Override 18 | protected int getLoadingViewId() { 19 | return R.id.load_more_loading_view; 20 | } 21 | 22 | @Override 23 | protected int getLoadFailViewId() { 24 | return R.id.load_more_load_fail_view; 25 | } 26 | 27 | @Override 28 | protected int getLoadEndViewId() { 29 | return R.id.load_more_load_end_view; 30 | } 31 | } -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/bannerview/layoutmanager/CenterScrollListener.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.bannerview.layoutmanager; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | 6 | /** 7 | * A {@link android.support.v7.widget.RecyclerView.OnScrollListener} which helps {@link OverFlyingLayoutManager} 8 | * to center the current position 9 | */ 10 | public class CenterScrollListener extends RecyclerView.OnScrollListener { 11 | private boolean mAutoSet = false; 12 | 13 | @Override 14 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) { 15 | super.onScrollStateChanged(recyclerView, newState); 16 | final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); 17 | 18 | final OverFlyingLayoutManager.OnPageChangeListener onPageChangeListener = ((OverFlyingLayoutManager) layoutManager).onPageChangeListener; 19 | if (onPageChangeListener != null) { 20 | onPageChangeListener.onPageScrollStateChanged(newState); 21 | } 22 | 23 | if (newState == RecyclerView.SCROLL_STATE_IDLE) { 24 | if (mAutoSet) { 25 | if (onPageChangeListener != null) { 26 | onPageChangeListener.onPageSelected(((OverFlyingLayoutManager) layoutManager).getCurrentPosition()); 27 | } 28 | mAutoSet = false; 29 | } else { 30 | final int delta; 31 | delta = ((OverFlyingLayoutManager) layoutManager).getOffsetToCenter(); 32 | if (delta != 0) { 33 | if (((OverFlyingLayoutManager) layoutManager).getOrientation() == OverFlyingLayoutManager.VERTICAL) 34 | recyclerView.smoothScrollBy(0, delta); 35 | else 36 | recyclerView.smoothScrollBy(delta, 0); 37 | mAutoSet = true; 38 | } else { 39 | if (onPageChangeListener != null) { 40 | onPageChangeListener.onPageSelected(((OverFlyingLayoutManager) layoutManager).getCurrentPosition()); 41 | } 42 | mAutoSet = false; 43 | } 44 | } 45 | } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) { 46 | mAutoSet = false; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/contract/BaseWebviewContract.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.contract; 2 | 3 | import com.seven.seven.common.base.codereview.BaseView; 4 | 5 | /** 6 | * Created on 2018-05-29. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public interface BaseWebviewContract { 12 | interface Presenter { 13 | void collectBlog(int id); 14 | } 15 | 16 | interface View extends BaseView { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/contract/HomeContract.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.contract; 2 | 3 | import com.seven.seven.common.base.codereview.BasePresenter; 4 | import com.seven.seven.common.base.IBaseModel; 5 | import com.seven.seven.common.base.IBaseView; 6 | import com.seven.seven.common.base.codereview.BaseView; 7 | 8 | /** 9 | * Created on 2018-03-31. 10 | * author:seven 11 | * email:seven2016s@163.com 12 | */ 13 | 14 | public interface HomeContract { 15 | interface View extends BaseView { 16 | // void showHomeData(); 17 | } 18 | 19 | interface Presenter { 20 | void getHomeData(); 21 | 22 | void getHomeBanner(); 23 | 24 | void getMoreHomeData(int curpage); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/events/BaseWebViewEvents.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.events; 2 | 3 | import com.seven.seven.common.event.BaseEvent; 4 | 5 | /** 6 | * Created on 2018-05-29. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class BaseWebViewEvents extends BaseEvent { 12 | public BaseWebViewEvents() { 13 | } 14 | 15 | public BaseWebViewEvents(int what) { 16 | super(what); 17 | } 18 | 19 | public BaseWebViewEvents(int what, Object data) { 20 | super(what, data); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/events/HomeEvents.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.events; 2 | 3 | import com.seven.seven.common.event.BaseEvent; 4 | 5 | /** 6 | * Created by seven 7 | * on 2018/5/17 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class HomeEvents extends BaseEvent { 12 | 13 | public HomeEvents() { 14 | } 15 | 16 | public HomeEvents(int what) { 17 | super(what); 18 | } 19 | 20 | public HomeEvents(int what, T data) { 21 | super(what, data); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/model/HomeToWebViewInfo.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created on 2018-05-22. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class HomeToWebViewInfo implements Serializable { 12 | public String h5Url; 13 | public String imgUrl; 14 | public String title; 15 | public int id; 16 | public boolean collect; 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/home/presenter/BaseWebviewPresenter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.home.presenter; 2 | 3 | import com.seven.seven.common.base.codereview.BasePresenterImpl; 4 | import com.seven.seven.common.network.ApiException; 5 | import com.seven.seven.common.network.HttpObservable; 6 | import com.seven.seven.common.network.HttpResultObserver; 7 | import com.seven.seven.common.network.ResponseCustom; 8 | import com.seven.seven.common.utils.Constans; 9 | import com.seven.seven.home.HomeNewsDetailActivity; 10 | import com.seven.seven.home.contract.BaseWebviewContract; 11 | import com.seven.seven.home.events.BaseWebViewEvents; 12 | 13 | import org.greenrobot.eventbus.EventBus; 14 | 15 | import io.reactivex.disposables.Disposable; 16 | 17 | /** 18 | * Created on 2018-05-29. 19 | * author:seven 20 | * email:seven2016s@163.com 21 | */ 22 | 23 | public class BaseWebviewPresenter extends BasePresenterImpl implements BaseWebviewContract.Presenter { 24 | public BaseWebviewPresenter(BaseWebviewContract.View view, HomeNewsDetailActivity activity) { 25 | super(view, activity); 26 | } 27 | 28 | @Override 29 | public void collectBlog(int id) { 30 | HttpObservable.getObservable(apiRetrofit.collectBlog(id)) 31 | .subscribe(new HttpResultObserver>() { 32 | @Override 33 | protected void onLoading(Disposable d) { 34 | 35 | } 36 | 37 | @Override 38 | protected void onSuccess(ResponseCustom o) { 39 | EventBus.getDefault().post(new BaseWebViewEvents(Constans.COLLECT, o.getData())); 40 | } 41 | 42 | @Override 43 | protected void onFail(ApiException e) { 44 | EventBus.getDefault().post(new BaseWebViewEvents(Constans.COLLECTERROR, e.getMsg())); 45 | } 46 | }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/login/LoginContract.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.login; 2 | 3 | import com.seven.seven.common.base.codereview.BaseView; 4 | 5 | /** 6 | * Created on 2018-05-26. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public interface LoginContract { 12 | interface View extends BaseView { 13 | 14 | } 15 | 16 | interface Presenter { 17 | void login(String username, String password); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/login/LoginEvent.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.login; 2 | 3 | import com.seven.seven.common.event.BaseEvent; 4 | 5 | /** 6 | * Created on 2018-05-26. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class LoginEvent extends BaseEvent { 12 | 13 | public LoginEvent(int what) { 14 | super(what); 15 | } 16 | 17 | public LoginEvent(int what, Object data) { 18 | super(what, data); 19 | } 20 | 21 | public LoginEvent() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/login/LoginPresenter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.login; 2 | 3 | import android.util.Log; 4 | 5 | import com.seven.seven.common.base.codereview.BasePresenterImpl; 6 | import com.seven.seven.common.base.codereview.BaseRetryWhen; 7 | import com.seven.seven.common.network.ApiException; 8 | import com.seven.seven.common.network.HttpObservable; 9 | import com.seven.seven.common.network.HttpResultObserver; 10 | import com.seven.seven.common.network.ResponseCustom; 11 | import com.seven.seven.common.utils.Constans; 12 | 13 | import org.greenrobot.eventbus.EventBus; 14 | 15 | import io.reactivex.Observable; 16 | import io.reactivex.android.schedulers.AndroidSchedulers; 17 | import io.reactivex.disposables.Disposable; 18 | import io.reactivex.functions.Function; 19 | import io.reactivex.schedulers.Schedulers; 20 | 21 | /** 22 | * Created on 2018-05-26. 23 | * author:seven 24 | * email:seven2016s@163.com 25 | */ 26 | 27 | public class LoginPresenter extends BasePresenterImpl implements LoginContract.Presenter { 28 | public LoginPresenter(LoginContract.View view, LoginActivity activity) { 29 | super(view, activity); 30 | } 31 | 32 | @Override 33 | public void login(String username, String password) { 34 | 35 | HttpObservable.getObservable(apiRetrofit.login(username, password)) 36 | .subscribe(new HttpResultObserver>() { 37 | @Override 38 | protected void onLoading(Disposable d) { 39 | 40 | } 41 | 42 | @Override 43 | protected void onSuccess(ResponseCustom o) { 44 | if (getView() != null) { 45 | if (o.isSuccess()) { 46 | EventBus.getDefault().post(new LoginEvent(Constans.LOGIN, o.getData())); 47 | } else { 48 | EventBus.getDefault().post(new LoginEvent(Constans.USERERROR, o.getErrorMsg())); 49 | } 50 | } 51 | } 52 | 53 | @Override 54 | protected void onFail(ApiException e) { 55 | EventBus.getDefault().post(new LoginEvent(Constans.USERERROR, e.getMsg())); 56 | } 57 | }); 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/login/RegisterContract.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.login; 2 | 3 | import com.seven.seven.common.base.codereview.BaseView; 4 | 5 | /** 6 | * Created on 2018-05-26. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public interface RegisterContract { 12 | interface View extends BaseView { 13 | 14 | } 15 | 16 | interface Presenter { 17 | void register(String username, String password, String repassword); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/login/RegisterEvent.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.login; 2 | 3 | import com.seven.seven.common.event.BaseEvent; 4 | 5 | /** 6 | * Created on 2018-05-26. 7 | * author:seven 8 | * email:seven2016s@163.com 9 | */ 10 | 11 | public class RegisterEvent extends BaseEvent { 12 | 13 | public RegisterEvent(int what) { 14 | super(what); 15 | } 16 | 17 | public RegisterEvent(int what, Object data) { 18 | super(what, data); 19 | } 20 | 21 | public RegisterEvent() { 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/login/RegisterInfo.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.login; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * Created on 2018-05-26. 8 | * author:seven 9 | * email:seven2016s@163.com 10 | */ 11 | 12 | public class RegisterInfo implements Serializable { 13 | /** 14 | * collectIds : [] 15 | * email : 16 | * icon : 17 | * id : 6032.0 18 | * password : 1234561 19 | * type : 0.0 20 | * username : 1234561 21 | */ 22 | 23 | private String email; 24 | private String icon; 25 | private double id; 26 | private String password; 27 | private double type; 28 | private String username; 29 | private List collectIds; 30 | 31 | public String getEmail() { 32 | return email; 33 | } 34 | 35 | public void setEmail(String email) { 36 | this.email = email; 37 | } 38 | 39 | public String getIcon() { 40 | return icon; 41 | } 42 | 43 | public void setIcon(String icon) { 44 | this.icon = icon; 45 | } 46 | 47 | public double getId() { 48 | return id; 49 | } 50 | 51 | public void setId(double id) { 52 | this.id = id; 53 | } 54 | 55 | public String getPassword() { 56 | return password; 57 | } 58 | 59 | public void setPassword(String password) { 60 | this.password = password; 61 | } 62 | 63 | public double getType() { 64 | return type; 65 | } 66 | 67 | public void setType(double type) { 68 | this.type = type; 69 | } 70 | 71 | public String getUsername() { 72 | return username; 73 | } 74 | 75 | public void setUsername(String username) { 76 | this.username = username; 77 | } 78 | 79 | public List getCollectIds() { 80 | return collectIds; 81 | } 82 | 83 | public void setCollectIds(List collectIds) { 84 | this.collectIds = collectIds; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/search/LookImageActivity.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.search; 2 | 3 | import android.graphics.drawable.Drawable; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.View; 7 | import android.widget.ImageView; 8 | import android.widget.ProgressBar; 9 | 10 | import com.bm.library.PhotoView; 11 | import com.bumptech.glide.Glide; 12 | import com.bumptech.glide.request.target.DrawableImageViewTarget; 13 | import com.bumptech.glide.request.transition.Transition; 14 | import com.seven.seven.R; 15 | import com.seven.seven.common.base.codereview.BaseActivity; 16 | import com.seven.seven.common.utils.AppManager; 17 | 18 | /** 19 | * Created by seven 20 | * on 2018/6/6 21 | * email:seven2016s@163.com 22 | */ 23 | 24 | public class LookImageActivity extends BaseActivity { 25 | 26 | private PhotoView photoView; 27 | private ProgressBar loading; 28 | private ImageView ivFinsh; 29 | 30 | @Override 31 | protected void initView(Bundle savedInstanceState) { 32 | photoView = findViewById(R.id.phtotview); 33 | loading = findViewById(R.id.pb_pic_browse); 34 | ivFinsh = findViewById(R.id.iv_finsh); 35 | photoView.enable(); 36 | } 37 | 38 | @Override 39 | protected void initData() { 40 | String url = getIntent().getStringExtra("image"); 41 | Glide.with(this).load(url). 42 | into(new DrawableImageViewTarget(photoView) { 43 | @Override 44 | public void onResourceReady(Drawable resource, @Nullable Transition transition) { 45 | super.onResourceReady(resource, transition); 46 | loading.setVisibility(View.GONE); 47 | } 48 | }); 49 | 50 | } 51 | 52 | @Override 53 | protected void setLisenter() { 54 | ivFinsh.setOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | AppManager.getAppManager().finishActivity(mActivity); 58 | } 59 | }); 60 | } 61 | 62 | @Override 63 | protected void widgetClick(View v) { 64 | 65 | } 66 | 67 | @Override 68 | protected int getContentViewResId() { 69 | return R.layout.activity_look_image; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/seven/seven/search/SearchAdapter.java: -------------------------------------------------------------------------------- 1 | package com.seven.seven.search; 2 | 3 | import android.support.annotation.Nullable; 4 | 5 | import com.chad.library.adapter.base.BaseQuickAdapter; 6 | import com.chad.library.adapter.base.BaseViewHolder; 7 | import com.seven.seven.R; 8 | import com.seven.seven.common.utils.HTMLScript; 9 | import com.seven.seven.common.utils.TimeUtils; 10 | import com.seven.seven.search.model.SearchListInfos; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * Created by seven 16 | * on 2018/6/2 17 | * email:seven2016s@163.com 18 | */ 19 | 20 | public class SearchAdapter extends BaseQuickAdapter { 21 | public SearchAdapter(int layoutResId, @Nullable List data) { 22 | super(layoutResId, data); 23 | } 24 | 25 | public SearchAdapter(int layoutResId) { 26 | super(layoutResId); 27 | } 28 | 29 | @Override 30 | protected void convert(BaseViewHolder helper, SearchListInfos.DatasBean item) { 31 | if (item != null) { 32 | /*String title =item.getTitle(); 33 | title =title.replace("NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /keystore.properties: -------------------------------------------------------------------------------- 1 | storePassword=123456789 2 | keyPassword=123456789 3 | keyAlias=isPlay 4 | storeFile=isPlay.jks -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------