Commit 2f1f880fa97a1bd5ee23e8c15ff744e09d014575
1 parent
cc625bce
1.补充源码
Showing
40 changed files
with
4809 additions
and
4 deletions
Too many changes to show.
To preserve performance only 40 of 207 files are displayed.
.idea/codeStyles/Project.xml
0 → 100644
| 1 | +<component name="ProjectCodeStyleConfiguration"> | |
| 2 | + <code_scheme name="Project" version="173"> | |
| 3 | + <Objective-C-extensions> | |
| 4 | + <file> | |
| 5 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> | |
| 6 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> | |
| 7 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> | |
| 8 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> | |
| 9 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> | |
| 10 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> | |
| 11 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> | |
| 12 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> | |
| 13 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> | |
| 14 | + </file> | |
| 15 | + <class> | |
| 16 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> | |
| 17 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> | |
| 18 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> | |
| 19 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> | |
| 20 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> | |
| 21 | + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> | |
| 22 | + </class> | |
| 23 | + <extensions> | |
| 24 | + <pair source="cpp" header="h" fileNamingConvention="NONE" /> | |
| 25 | + <pair source="c" header="h" fileNamingConvention="NONE" /> | |
| 26 | + </extensions> | |
| 27 | + </Objective-C-extensions> | |
| 28 | + </code_scheme> | |
| 29 | +</component> | |
| 0 | 30 | \ No newline at end of file | ... | ... |
app/build.gradle
| ... | ... | @@ -50,7 +50,7 @@ android { |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | dependencies { |
| 53 | - implementation fileTree(dir: 'libs', include: ['*.jar']) | |
| 53 | + implementation fileTree(include: ['*.jar'], dir: 'libs') | |
| 54 | 54 | implementation "com.android.support:support-v4:$rootProject.supportV4" |
| 55 | 55 | implementation "com.android.support:appcompat-v7:$rootProject.appcompatV7" |
| 56 | 56 | implementation "com.android.support:design:$rootProject.design" |
| ... | ... | @@ -83,5 +83,10 @@ dependencies { |
| 83 | 83 | implementation "com.cnlive:app_emoj:$rootProject.libEmoj" |
| 84 | 84 | implementation "com.cnlive:menu:$rootProject.libMenu" |
| 85 | 85 | implementation "com.cnlive:app_arch:$rootProject.appArch" |
| 86 | - implementation "com.cnlive:happy_china:$rootProject.happychina" | |
| 86 | + | |
| 87 | + //Bintray module | |
| 88 | + // implementation "com.cnlive:happy_china:$rootProject.happychina" | |
| 89 | + | |
| 90 | + //Location module | |
| 91 | + implementation project(':happy_china') | |
| 87 | 92 | } | ... | ... |
build.gradle
| ... | ... | @@ -16,8 +16,9 @@ allprojects { |
| 16 | 16 | repositories { |
| 17 | 17 | google() |
| 18 | 18 | jcenter() |
| 19 | - maven{url "https://hanya.bintray.com/cnliveMaven"} | |
| 20 | - maven{url 'https://dl.bintray.com/granzon/cnliveLibs'} | |
| 19 | + maven { | |
| 20 | + url 'https://dl.bintray.com/granzon/cnliveLibs' | |
| 21 | + } | |
| 21 | 22 | } |
| 22 | 23 | } |
| 23 | 24 | |
| ... | ... | @@ -81,5 +82,6 @@ ext { |
| 81 | 82 | //阿里路由框架 |
| 82 | 83 | arouterApiVersion = '1.4.0' |
| 83 | 84 | arouterCompilerVersion = '1.2.1' |
| 85 | + | |
| 84 | 86 | happychina = '1.0.4' |
| 85 | 87 | } | ... | ... |
happy_china/.gitignore
0 → 100644
| 1 | +/build | ... | ... |
happy_china/build.gradle
0 → 100644
| 1 | +apply plugin: 'com.android.library' | |
| 2 | + | |
| 3 | +android { | |
| 4 | + compileSdkVersion 27 | |
| 5 | + | |
| 6 | + defaultConfig { | |
| 7 | + minSdkVersion 16 | |
| 8 | + targetSdkVersion 27 | |
| 9 | + versionCode 1 | |
| 10 | + versionName "1.0" | |
| 11 | + | |
| 12 | + javaCompileOptions { | |
| 13 | + annotationProcessorOptions { | |
| 14 | + arguments = [AROUTER_MODULE_NAME: project.getName(), AROUTER_GENERATE_DOC: "enable"] | |
| 15 | + } | |
| 16 | + } | |
| 17 | + } | |
| 18 | + | |
| 19 | + buildTypes { | |
| 20 | + release { | |
| 21 | + minifyEnabled false | |
| 22 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
| 23 | + } | |
| 24 | + } | |
| 25 | + | |
| 26 | + compileOptions { | |
| 27 | + sourceCompatibility JavaVersion.VERSION_1_8 | |
| 28 | + targetCompatibility JavaVersion.VERSION_1_8 | |
| 29 | + } | |
| 30 | + | |
| 31 | + dataBinding { | |
| 32 | + enabled true | |
| 33 | + } | |
| 34 | + | |
| 35 | + dexOptions { | |
| 36 | + javaMaxHeapSize '4g' | |
| 37 | + } | |
| 38 | +} | |
| 39 | + | |
| 40 | +dependencies { | |
| 41 | + implementation fileTree(include: ['*.jar'], dir: 'libs') | |
| 42 | + implementation "com.android.support:support-v4:$rootProject.supportV4" | |
| 43 | + implementation "com.android.support:appcompat-v7:$rootProject.appcompatV7" | |
| 44 | + implementation "com.android.support:design:$rootProject.design" | |
| 45 | + implementation "com.android.support:support-v13:$rootProject.supportV13" | |
| 46 | + implementation "com.android.support:recyclerview-v7:$rootProject.recyclerviewV7" | |
| 47 | + implementation "com.android.support:cardview-v7:$rootProject.cardviewV7" | |
| 48 | + | |
| 49 | + //RefreshLayout | |
| 50 | + implementation "com.scwang.smartrefresh:SmartRefreshLayout:$rootProject.SmartRefreshLayout" | |
| 51 | + implementation "com.scwang.smartrefresh:SmartRefreshHeader:$rootProject.SmartRefreshHeader" | |
| 52 | + | |
| 53 | + //QMUI | |
| 54 | + implementation "com.qmuiteam:qmui:$rootProject.qmui" | |
| 55 | + | |
| 56 | + //Glide | |
| 57 | + implementation "com.github.bumptech.glide:glide:$rootProject.glide" | |
| 58 | + implementation "jp.wasabeef:glide-transformations:$rootProject.glideTransformations" | |
| 59 | + annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.compiler" | |
| 60 | + | |
| 61 | + //RecyclerView-Animators | |
| 62 | + implementation "jp.wasabeef:recyclerview-animators:$rootProject.recyclerviewAnimators" | |
| 63 | + | |
| 64 | + //CNLiveLibs | |
| 65 | + implementation "com.cnlive:lib_base:$rootProject.libBase" | |
| 66 | + implementation "com.cnlive:lib_network:$rootProject.libNetwork" | |
| 67 | + implementation "com.cnlive:app_emoj:$rootProject.libEmoj" | |
| 68 | + implementation "com.cnlive:menu:$rootProject.libMenu" | |
| 69 | + implementation "com.cnlive:app_arch:$rootProject.appArch" | |
| 70 | + | |
| 71 | + //ARouter | |
| 72 | + implementation "com.alibaba:arouter-api:$rootProject.arouterApiVersion" | |
| 73 | + annotationProcessor "com.alibaba:arouter-compiler:$rootProject.arouterCompilerVersion" | |
| 74 | +} | |
| 0 | 75 | \ No newline at end of file | ... | ... |
happy_china/proguard-rules.pro
0 → 100644
| 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 | ... | ... |
happy_china/src/main/AndroidManifest.xml
0 → 100644
| 1 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | + package="com.cnlive.strike.happychina"> | |
| 3 | + | |
| 4 | + <application> | |
| 5 | + <activity | |
| 6 | + android:name="com.cnlive.strike.happychina.ui.activity.ClassifyActivity" | |
| 7 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | |
| 8 | + android:screenOrientation="portrait" /> | |
| 9 | + <activity | |
| 10 | + android:name="com.cnlive.strike.happychina.ui.activity.ClassifySearchActivity" | |
| 11 | + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" | |
| 12 | + android:screenOrientation="portrait" | |
| 13 | + android:windowSoftInputMode="stateVisible|adjustPan" /> | |
| 14 | + <activity | |
| 15 | + android:name="com.cnlive.strike.happychina.ui.activity.DarenActivity" | |
| 16 | + android:configChanges="keyboardHidden|screenSize|orientation|smallestScreenSize|screenLayout" | |
| 17 | + android:launchMode="singleTask" | |
| 18 | + android:screenOrientation="portrait" | |
| 19 | + android:windowSoftInputMode="stateAlwaysHidden|adjustPan" /> | |
| 20 | + <activity | |
| 21 | + android:name="com.cnlive.strike.happychina.ui.activity.FollowDarensActivity" | |
| 22 | + android:configChanges="keyboardHidden|screenSize|orientation|smallestScreenSize|screenLayout" | |
| 23 | + android:launchMode="singleTop" | |
| 24 | + android:screenOrientation="portrait" | |
| 25 | + android:windowSoftInputMode="stateHidden|adjustResize" /> | |
| 26 | + </application> | |
| 27 | +</manifest> | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/ClassifyPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.base.application.AppConfig; | |
| 6 | +import com.cnlive.libs.base.logic.Event; | |
| 7 | +import com.cnlive.libs.base.logic.Logic; | |
| 8 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 9 | +import com.cnlive.strike.happychina.R; | |
| 10 | +import com.cnlive.strike.happychina.frame.view.ClassifyView; | |
| 11 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 12 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 13 | +import com.cnlive.strike.happychina.network.model.CategoryDarensData; | |
| 14 | +import com.cnlive.strike.happychina.network.model.CategoryData; | |
| 15 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 16 | +import com.cnlive.strike.happychina.network.model.IconData; | |
| 17 | +import com.cnlive.strike.happychina.receiver.UpdatePortalReceiver; | |
| 18 | +import com.cnlive.strike.happychina.ui.moudle.RightBean; | |
| 19 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 20 | + | |
| 21 | +import java.util.ArrayList; | |
| 22 | +import java.util.HashMap; | |
| 23 | +import java.util.List; | |
| 24 | +import java.util.Map; | |
| 25 | + | |
| 26 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 27 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 28 | +import static com.cnlive.strike.happychina.router.DarenAction.addDarenAction; | |
| 29 | +import static com.cnlive.strike.happychina.router.DarenAction.cancelDarenAction; | |
| 30 | + | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * Created by Lynn on 2018/3/13. | |
| 34 | + */ | |
| 35 | + | |
| 36 | +public class ClassifyPresenter extends MvpBasePresenter<ClassifyView> { | |
| 37 | + | |
| 38 | + private Event<CategoryDarensData> getDarensByCategory; | |
| 39 | + private Event addDaren; | |
| 40 | + private Event cancelDaren; | |
| 41 | + | |
| 42 | + private void initRightData(CategoryDarensData darensData) { | |
| 43 | + if (getView() == null) return; | |
| 44 | + List<RightBean> mDatas = new ArrayList<>(); | |
| 45 | + | |
| 46 | + RightBean header = new RightBean(""); | |
| 47 | +// header.setHeaderImage("http://img1.imgtn.bdimg.com/it/u=1010984481,971733472&fm=27&gp=0.jpg"); | |
| 48 | + header.setBannerDatas(darensData.getBanners()); | |
| 49 | + header.setType(RightBean.HEADER); | |
| 50 | + header.setTag(String.valueOf(0)); | |
| 51 | + getView().fragment.showNextListener = header; | |
| 52 | +// mDatas.add(header); | |
| 53 | + | |
| 54 | + for (int i = 0; i < darensData.getList().size(); i++) { | |
| 55 | + if (darensData.getList().get(i) != null && darensData.getList().get(i).getDarens() != null && darensData.getList().get(i).getCategory().getCategoryName() != null) { | |
| 56 | + RightBean head = new RightBean(darensData.getList().get(i).getCategory().getCategoryName()); | |
| 57 | + //头部设置为true | |
| 58 | +// head.setTitle(true); | |
| 59 | + head.setType(RightBean.TITLE); | |
| 60 | + head.setTitleImage(darensData.getList().get(i).getCategory().getNewCategorySmallImage()); | |
| 61 | + head.setTitleName(darensData.getList().get(i).getCategory().getCategoryName()); | |
| 62 | + head.setTag(String.valueOf(i)); | |
| 63 | + | |
| 64 | + mDatas.add(head); | |
| 65 | + List<IconData> categoryTwoArray = darensData.getList().get(i).getDarens(); | |
| 66 | + for (int j = 0; j < categoryTwoArray.size(); j++) { | |
| 67 | + RightBean body = new RightBean(categoryTwoArray.get(j).getNickName()); | |
| 68 | + body.setType(RightBean.DETAIL); | |
| 69 | + body.setTag(String.valueOf(i)); | |
| 70 | + body.setId(categoryTwoArray.get(j).getUserId()); | |
| 71 | + body.setAvatar(categoryTwoArray.get(j).getImage()); | |
| 72 | + body.setTitleImage(darensData.getList().get(i).getCategory().getNewCategorySmallImage()); | |
| 73 | + body.setFans(categoryTwoArray.get(j).isState()); | |
| 74 | + body.setFansCount(categoryTwoArray.get(j).getFansCount()); | |
| 75 | + body.setOrderCount(categoryTwoArray.get(j).getOrderCount()); | |
| 76 | + String name = darensData.getList().get(i).getCategory().getCategoryName(); | |
| 77 | + body.setTitleName(name); | |
| 78 | + mDatas.add(body); | |
| 79 | + } | |
| 80 | + | |
| 81 | +// RightBean line = new RightBean(""); | |
| 82 | +// line.setType(RightBean.LINE); | |
| 83 | +// mDatas.add(line); | |
| 84 | + } | |
| 85 | + | |
| 86 | + } | |
| 87 | + getView().initRightView(mDatas); | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void getDarensByCategory(Context context) { | |
| 91 | + cancel(); | |
| 92 | + Map<String, String> params = new HashMap<>(); | |
| 93 | + params.put("sid", AppConfig.getSid()); | |
| 94 | + getDarensByCategory = Logic.create(params) | |
| 95 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<CategoryDarensData>> callback) -> | |
| 96 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getDarensByCategory(data)).subscribe(context, callback)) | |
| 97 | + .action((CnBaseInfo<CategoryDarensData> data, DataCallback<CategoryDarensData> callback) -> | |
| 98 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 99 | + .<CategoryDarensData>event() | |
| 100 | + .setStateCallback(state -> { | |
| 101 | + if (state == STATE_LOAD) { | |
| 102 | + if (getView() != null) getView().showLoadingView(); | |
| 103 | + } else if (state == STATE_IDLE) { | |
| 104 | + if (getView() != null) getView().hideLoadingView(); | |
| 105 | + } | |
| 106 | + }).setFailureCallback((state, message) -> { | |
| 107 | + if (getView() != null) | |
| 108 | + getView().showRetryView(state, view -> getDarensByCategory(context)); | |
| 109 | + }).setSuccessCallback(data -> { | |
| 110 | + if (getView() != null) | |
| 111 | + if (data == null) { | |
| 112 | + getView().showEmptyView(); | |
| 113 | + } else { | |
| 114 | + List<CategoryData> leftList = new ArrayList<>(); | |
| 115 | + for (int i = 0; i < data.getList().size(); i++) { | |
| 116 | + if (data.getList().get(i) != null && data.getList().get(i).getCategory() != null) | |
| 117 | + leftList.add(data.getList().get(i).getCategory()); | |
| 118 | + } | |
| 119 | + getView().initLeftView(leftList); | |
| 120 | + getView().categoryDarensDatas = data; | |
| 121 | + | |
| 122 | + initRightData(data); | |
| 123 | + } | |
| 124 | + }).start(); | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * 关注 | |
| 129 | + * | |
| 130 | + * @param context | |
| 131 | + * @param darenIds | |
| 132 | + */ | |
| 133 | + public void addDaren(Context context, String darenIds, int position) { | |
| 134 | +// cancel(); | |
| 135 | + addDaren = Logic.create() | |
| 136 | + .action(addDarenAction(context, darenIds)) | |
| 137 | + .<CnBaseInfo>event() | |
| 138 | + .setFailureCallback((state, message) -> { | |
| 139 | + if (getView() != null) | |
| 140 | + getView().showFailedToast(message); | |
| 141 | + }).setSuccessCallback(data -> { | |
| 142 | + if (getView() != null) { | |
| 143 | + getView().showSuccessToast(context.getString(R.string.add_daren_success)); | |
| 144 | +// getView().updateFollowState(true, position); | |
| 145 | + getView().updateFollowBtn(darenIds, true); | |
| 146 | + } | |
| 147 | + UpdatePortalReceiver.post(new UpdatePortalReceiver.UpdatePortalResult()); | |
| 148 | + }).start(); | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * 取消关注 | |
| 153 | + * | |
| 154 | + * @param context | |
| 155 | + * @param darenIds | |
| 156 | + */ | |
| 157 | + public void cancelDaren(Context context, String darenIds, int position) { | |
| 158 | +// cancel(); | |
| 159 | + cancelDaren = Logic.create() | |
| 160 | + .action(cancelDarenAction(context, darenIds)) | |
| 161 | + .<CnBaseInfo>event() | |
| 162 | + .setFailureCallback((state, message) -> { | |
| 163 | + if (getView() != null) | |
| 164 | + getView().showFailedToast(message); | |
| 165 | + }).setSuccessCallback(data -> { | |
| 166 | + if (getView() != null) { | |
| 167 | + getView().showSuccessToast(context.getString(R.string.cancel_daren_success)); | |
| 168 | +// getView().updateFollowState(false, position); | |
| 169 | + getView().updateFollowBtn(darenIds, false); | |
| 170 | + } | |
| 171 | + UpdatePortalReceiver.post(new UpdatePortalReceiver.UpdatePortalResult()); | |
| 172 | + }).start(); | |
| 173 | + } | |
| 174 | + | |
| 175 | + | |
| 176 | + public void cancel() { | |
| 177 | + if (getDarensByCategory != null) | |
| 178 | + getDarensByCategory.cencel(); | |
| 179 | + if (addDaren != null) addDaren.cencel(); | |
| 180 | + if (cancelDaren != null) cancelDaren.cencel(); | |
| 181 | + } | |
| 182 | + | |
| 183 | + | |
| 184 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/ClassifySearchPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.base.application.AppConfig; | |
| 6 | +import com.cnlive.libs.base.logic.Event; | |
| 7 | +import com.cnlive.libs.base.logic.Logic; | |
| 8 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 9 | +import com.cnlive.libs.base.util.SharedPreferencesHelper; | |
| 10 | +import com.cnlive.strike.happychina.frame.view.ClassifySearchView; | |
| 11 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 12 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 13 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 14 | +import com.cnlive.strike.happychina.network.model.SearchDarenData; | |
| 15 | +import com.google.gson.Gson; | |
| 16 | +import com.google.gson.reflect.TypeToken; | |
| 17 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 18 | + | |
| 19 | +import java.lang.reflect.Type; | |
| 20 | +import java.util.ArrayList; | |
| 21 | +import java.util.Collections; | |
| 22 | +import java.util.HashMap; | |
| 23 | +import java.util.List; | |
| 24 | +import java.util.Map; | |
| 25 | + | |
| 26 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 27 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 28 | + | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * Created by cnlive201803 on 2018/5/30. | |
| 32 | + */ | |
| 33 | + | |
| 34 | +public class ClassifySearchPresenter extends MvpBasePresenter<ClassifySearchView> { | |
| 35 | + | |
| 36 | + public static final String SEARCH_SP_KEY = "search_"; | |
| 37 | + private Event<List<SearchDarenData>> searchDarenEvent; | |
| 38 | + | |
| 39 | + public void searchDaren(Context context, String type, String shopName) { | |
| 40 | + cancel(); | |
| 41 | + Map<String, String> requestData = new HashMap<>(); | |
| 42 | + requestData.put("shopName", shopName); | |
| 43 | + requestData.put("type", type); | |
| 44 | + requestData.put("sid", AppConfig.getSid()); | |
| 45 | + searchDarenEvent = Logic.create(requestData) | |
| 46 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<List<SearchDarenData>>> callback) -> | |
| 47 | + CnApiRequest.service(CnApiDarenService.class, service -> service.searchDaren(data)).subscribe(context, callback)) | |
| 48 | + .action((CnBaseInfo<List<SearchDarenData>> data, DataCallback<List<SearchDarenData>> callback) -> | |
| 49 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 50 | + .<List<SearchDarenData>>event() | |
| 51 | + .setStateCallback(state -> { | |
| 52 | + if (state == STATE_LOAD) { | |
| 53 | + if (getView() != null) | |
| 54 | + getView().showLoadingView(); | |
| 55 | + } else if (state == STATE_IDLE) { | |
| 56 | + if (getView() != null) { | |
| 57 | + if (insertHistory(context, shopName)) { | |
| 58 | + getView().addItemToFloatLayout(shopName, true); | |
| 59 | + } else { | |
| 60 | + getView().moveItemToFirst(); | |
| 61 | + } | |
| 62 | + | |
| 63 | + getView().hideLoadingView(); | |
| 64 | +// if (SearchHistoryAPI.insertData(context, shopName)) | |
| 65 | +// getView().addItemToFloatLayout(shopName, true); | |
| 66 | +// else | |
| 67 | +// getView().moveItemToFirst(); | |
| 68 | +// getView().hideLoadingView(); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + }).setSuccessCallback(data -> { | |
| 72 | + if (getView() != null) { | |
| 73 | + getView().hideHistoryView(); | |
| 74 | + | |
| 75 | + if (data.size() > 0 && data != null) { | |
| 76 | + getView().refreshItem(data); | |
| 77 | + } else { | |
| 78 | + getView().showEmptyView(); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + }).setFailureCallback((state, message) -> { | |
| 82 | + if (getView() != null) { | |
| 83 | + getView().showEmptyView(); | |
| 84 | + getView().hideHistoryView(); | |
| 85 | + } | |
| 86 | + }).start(); | |
| 87 | + | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void cancel() { | |
| 91 | + if (searchDarenEvent != null) searchDarenEvent.cencel(); | |
| 92 | + } | |
| 93 | + | |
| 94 | + private boolean insertHistory(Context context, String shopName) { | |
| 95 | + List<String> searchHistorys = loadHistorys(context); | |
| 96 | + if (searchHistorys != null && searchHistorys.size() > 0) { | |
| 97 | + if (searchHistorys.contains(shopName)) { | |
| 98 | + searchHistorys.remove(shopName); | |
| 99 | + searchHistorys.add(shopName); | |
| 100 | + Collections.reverse(searchHistorys); | |
| 101 | + SharedPreferencesHelper.getInstance(context).setValue(SEARCH_SP_KEY + AppConfig.getSid(), new Gson().toJson(searchHistorys)); | |
| 102 | + return false; | |
| 103 | + } else { | |
| 104 | + searchHistorys.add(shopName); | |
| 105 | + SharedPreferencesHelper.getInstance(context).setValue(SEARCH_SP_KEY + AppConfig.getSid(), new Gson().toJson(searchHistorys)); | |
| 106 | + return true; | |
| 107 | + } | |
| 108 | + | |
| 109 | + } else { | |
| 110 | + searchHistorys.add(shopName); | |
| 111 | + SharedPreferencesHelper.getInstance(context).setValue(SEARCH_SP_KEY + AppConfig.getSid(), new Gson().toJson(searchHistorys)); | |
| 112 | + return true; | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + public List<String> loadHistorys(Context context) { | |
| 117 | + List<String> searchHistorys; | |
| 118 | + String searchHistoryString = SharedPreferencesHelper.getInstance(context).getValue(SEARCH_SP_KEY + AppConfig.getSid()); | |
| 119 | + Type searchHistoryType = new TypeToken<ArrayList<String>>() { | |
| 120 | + }.getType(); | |
| 121 | + searchHistorys = new Gson().fromJson(searchHistoryString, searchHistoryType); | |
| 122 | + return searchHistorys == null ? new ArrayList<>() : searchHistorys; | |
| 123 | + } | |
| 124 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/DarenCommentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.base.application.AppConfig; | |
| 6 | +import com.cnlive.libs.base.logic.Event; | |
| 7 | +import com.cnlive.libs.base.logic.Logic; | |
| 8 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 9 | +import com.cnlive.strike.happychina.frame.view.DarenCommentView; | |
| 10 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 11 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 12 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 13 | +import com.cnlive.strike.happychina.network.model.GetDarenComment; | |
| 14 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 15 | + | |
| 16 | +import java.util.HashMap; | |
| 17 | +import java.util.Map; | |
| 18 | + | |
| 19 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 20 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 21 | + | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * Created by Lynn on 2018/2/28. | |
| 25 | + */ | |
| 26 | + | |
| 27 | +public class DarenCommentPresenter extends MvpBasePresenter<DarenCommentView> { | |
| 28 | + private Event<GetDarenComment> getComments; | |
| 29 | + private Event<GetDarenComment> getCommentsMore; | |
| 30 | + | |
| 31 | + public void getComments(Context context, String darenId, int pageNo) { | |
| 32 | + cancel(); | |
| 33 | + Map<String, String> requestData = new HashMap<>(); | |
| 34 | + requestData.put("appId", AppConfig.getAppId()); | |
| 35 | + requestData.put("plat", "a"); | |
| 36 | + requestData.put("darenId", darenId); | |
| 37 | + requestData.put("pageNo", pageNo + ""); | |
| 38 | + getComments = Logic.create(requestData) | |
| 39 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarenComment>> callback) -> | |
| 40 | + CnApiRequest.service(CnApiDarenService.class, api -> api.getDarenComment(requestData)).subscribe(context, callback)) | |
| 41 | + .action((Logic.Action<CnBaseInfo<GetDarenComment>, GetDarenComment>) (data, callback) -> Logic.process(() -> | |
| 42 | + data == null ? null : data.getData(), callback)) | |
| 43 | + .<GetDarenComment>event() | |
| 44 | + .setStateCallback(state -> { | |
| 45 | + if (state == STATE_LOAD) { | |
| 46 | + if (getView() != null) getView().showLoadingView(); | |
| 47 | + } else if (state == STATE_IDLE) { | |
| 48 | + if (getView() != null) getView().hideLoadingView(); | |
| 49 | + } | |
| 50 | + }) | |
| 51 | + .setFailureCallback((state, message) -> { | |
| 52 | + if (getView() == null) return; | |
| 53 | + if (getView().pageData().getAdapter().getList().size() == 0) | |
| 54 | + getView().showRetryView(state, view -> getComments(context, darenId, pageNo)); | |
| 55 | + else getView().showFailedToast(message); | |
| 56 | + }) | |
| 57 | + .setSuccessCallback(data -> { | |
| 58 | + if (data != null && data.getCommentItems() != null && data.getCommentItems().size() > 0) { | |
| 59 | + if (getView() != null) getView().refreshItem(context, data); | |
| 60 | + } else { | |
| 61 | + if (getView() != null) getView().showEmptyView(); | |
| 62 | + } | |
| 63 | + }) | |
| 64 | + .start(); | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void getCommentsMore(Context context, String darenId, int pageNo) { | |
| 68 | + cancel(); | |
| 69 | + Map<String, String> requestData = new HashMap<>(); | |
| 70 | + requestData.put("appId", AppConfig.getAppId()); | |
| 71 | + requestData.put("plat", "a"); | |
| 72 | + requestData.put("darenId", darenId); | |
| 73 | + requestData.put("pageNo", pageNo + ""); | |
| 74 | + getCommentsMore = Logic.create(requestData) | |
| 75 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarenComment>> callback) -> | |
| 76 | + CnApiRequest.service(CnApiDarenService.class, api -> api.getDarenComment(requestData)).subscribe(context, callback)) | |
| 77 | + .action((Logic.Action<CnBaseInfo<GetDarenComment>, GetDarenComment>) (data, callback) -> Logic.process(() -> | |
| 78 | + data == null ? null : data.getData(), callback)) | |
| 79 | + .<GetDarenComment>event() | |
| 80 | + .setStateCallback(state -> { | |
| 81 | + if (state == STATE_LOAD) { | |
| 82 | + if (getView() != null) getView().showLoadingView(); | |
| 83 | + } else if (state == STATE_IDLE) { | |
| 84 | + if (getView() != null) getView().hideLoadingView(); | |
| 85 | + } | |
| 86 | + }) | |
| 87 | + .setSuccessCallback(data -> { | |
| 88 | + if (getView() == null) return; | |
| 89 | + if (data != null && data.getCommentItems() != null && data.getCommentItems().size() > 0) | |
| 90 | + getView().addItems(context, data); | |
| 91 | + }) | |
| 92 | + .start(); | |
| 93 | + } | |
| 94 | + | |
| 95 | + public void cancel() { | |
| 96 | + if (getComments != null) getComments.cencel(); | |
| 97 | + if (getCommentsMore != null) getCommentsMore.cencel(); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/DarenDetailPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.View; | |
| 5 | + | |
| 6 | +import com.cnlive.libs.base.application.AppConfig; | |
| 7 | +import com.cnlive.libs.base.logic.Event; | |
| 8 | +import com.cnlive.libs.base.logic.Logic; | |
| 9 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 10 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 11 | +import com.cnlive.strike.happychina.R; | |
| 12 | +import com.cnlive.strike.happychina.frame.view.DarenDetailView; | |
| 13 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 14 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 15 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 16 | +import com.cnlive.strike.happychina.network.model.GetDarenHomeData; | |
| 17 | +import com.cnlive.strike.happychina.network.model.ShareDarenInfo; | |
| 18 | +import com.cnlive.strike.happychina.receiver.UpdatePortalReceiver; | |
| 19 | +import com.cnlive.strike.happychina.router.DarenLogic; | |
| 20 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 21 | + | |
| 22 | +import java.util.HashMap; | |
| 23 | +import java.util.Map; | |
| 24 | + | |
| 25 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 26 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 27 | +import static com.cnlive.strike.happychina.router.DarenAction.addDarenAction; | |
| 28 | +import static com.cnlive.strike.happychina.router.DarenAction.cancelDarenAction; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * Created by xiansong on 2018/1/26. | |
| 32 | + */ | |
| 33 | + | |
| 34 | +public class DarenDetailPresenter extends MvpBasePresenter<DarenDetailView> { | |
| 35 | + | |
| 36 | + private Event addDaren; | |
| 37 | + private Event cancelDaren; | |
| 38 | + private com.cnlive.libs.base.logic.Event shareEvent; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获取达人号列表 | |
| 42 | + */ | |
| 43 | + private Event<GetDarenHomeData> loadDarenDisposable; | |
| 44 | + private Event<GetDarenHomeData> loadDarenMore; | |
| 45 | + | |
| 46 | + public void getDarenHome(Context context, String homeId, String darenId) { | |
| 47 | + cancel(); | |
| 48 | + String userId = AppConfig.getSid(); | |
| 49 | + | |
| 50 | + DarenLogic.loadDarenContent(context, userId, homeId, darenId, 1, loadDarenDisposable = new Event<GetDarenHomeData>() | |
| 51 | + .setStateCallback(state -> { | |
| 52 | + if (state == STATE_LOAD) { | |
| 53 | + if (getView() != null) | |
| 54 | + getView().showLoadingView(); | |
| 55 | + } else if (state == STATE_IDLE) { | |
| 56 | + if (getView() != null) | |
| 57 | + getView().hideLoadingView(); | |
| 58 | + } | |
| 59 | + }) | |
| 60 | + .setFailureCallback((code, message) -> { | |
| 61 | + if (getView() != null) | |
| 62 | + if (getView().pageData().getAdapter().getList().size() == 0 || getView().pageData() == null || getView().pageData().getAdapter().getList() == null) { | |
| 63 | + getView().showRetryView(code, view -> getDarenHome(context, homeId, darenId)); | |
| 64 | + } else { | |
| 65 | + getView().showFailedToast(message); | |
| 66 | + } | |
| 67 | + }) | |
| 68 | + .setSuccessCallback(data -> { | |
| 69 | + if (getView() != null) getView().showShareBtn(); | |
| 70 | + if (data.getContent().size() > 0) { | |
| 71 | + if (getView() != null) getView().loadList = data; | |
| 72 | + if (getView() != null) getView().shouldItemUpdate = true; | |
| 73 | + if (getView() != null) getView().refreshItems(context, data); | |
| 74 | + } else { | |
| 75 | + if (getView() != null) getView().initPageInfo(data); | |
| 76 | + if (getView() != null) getView().showEmptyView(); | |
| 77 | + } | |
| 78 | + })); | |
| 79 | + } | |
| 80 | + | |
| 81 | + | |
| 82 | + public void loadMoreContent(Context context, String homeId, String darenId, int pageNo) { | |
| 83 | + cancel(); | |
| 84 | + String userId = AppConfig.getSid(); | |
| 85 | + DarenLogic.loadDarenContent(context, userId, homeId, darenId, pageNo, loadDarenMore = new Event<GetDarenHomeData>() | |
| 86 | + .setStateCallback(state -> { | |
| 87 | + if (state == STATE_LOAD) { | |
| 88 | + if (getView() != null) | |
| 89 | + getView().showLoadingView(); | |
| 90 | + } else if (state == STATE_IDLE) { | |
| 91 | + if (getView() != null) | |
| 92 | + getView().hideLoadingView(); | |
| 93 | + } | |
| 94 | + }) | |
| 95 | + .setFailureCallback((code, message) -> { | |
| 96 | + AlertUtil.showDeftToast(context, String.format("数据加载失败 code=%s message=%s", code, message)); | |
| 97 | + }) | |
| 98 | + .setSuccessCallback(data -> { | |
| 99 | + if (data.getContent().size() > 0) | |
| 100 | + if (getView() != null) | |
| 101 | + getView().addItems(context, data); | |
| 102 | + })); | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void follow(String darenIds) { | |
| 106 | + if (getView().isFollowed) { | |
| 107 | + cancelDaren(getView().getContext(), darenIds); | |
| 108 | + } else { | |
| 109 | + addDaren(getView().getContext(), darenIds); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * 关注达人 | |
| 115 | + * | |
| 116 | + * @param context | |
| 117 | + */ | |
| 118 | + private void addDaren(Context context, String darenIds) { | |
| 119 | + cancel(); | |
| 120 | + addDaren = Logic.create() | |
| 121 | + .action(addDarenAction(context, darenIds)) | |
| 122 | + .<CnBaseInfo>event() | |
| 123 | + .setStateCallback(state -> { | |
| 124 | + if (getView() == null) return; | |
| 125 | + if (state == STATE_LOAD) | |
| 126 | + getView().showLoading(); | |
| 127 | + else getView().hideLoading(); | |
| 128 | + }).setFailureCallback((state, message) -> { | |
| 129 | + if (getView() != null) | |
| 130 | + getView().showErrorToast(message); | |
| 131 | + }).setSuccessCallback(data -> { | |
| 132 | + if (getView() != null) { | |
| 133 | + getView().isFollowed = true; | |
| 134 | + getView().showSuccess(context.getString(R.string.add_daren_success)); | |
| 135 | + getView().changeFollowBtn(getView().isFollowed); | |
| 136 | + getView().updateFansNum(true); | |
| 137 | + } | |
| 138 | + UpdatePortalReceiver.UpdatePortalResult updatePortalResult = new UpdatePortalReceiver.UpdatePortalResult(); | |
| 139 | + updatePortalResult.setDarenId(darenIds); | |
| 140 | + updatePortalResult.setAddDaren(true); | |
| 141 | + UpdatePortalReceiver.post(updatePortalResult); | |
| 142 | + }).start(); | |
| 143 | + } | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * 取消关注 | |
| 147 | + * | |
| 148 | + * @param context | |
| 149 | + */ | |
| 150 | + private void cancelDaren(Context context, String darenIds) { | |
| 151 | + cancel(); | |
| 152 | + cancelDaren = Logic.create() | |
| 153 | + .action(cancelDarenAction(context, darenIds)) | |
| 154 | + .<CnBaseInfo>event() | |
| 155 | + .setStateCallback(state -> { | |
| 156 | + if (getView() == null) return; | |
| 157 | + if (state == STATE_LOAD) | |
| 158 | + getView().showLoading(); | |
| 159 | + else getView().hideLoading(); | |
| 160 | + }).setFailureCallback((state, message) -> { | |
| 161 | + if (getView() != null) | |
| 162 | + getView().showErrorToast(message); | |
| 163 | + }).setSuccessCallback(data -> { | |
| 164 | + if (getView() != null) { | |
| 165 | + getView().isFollowed = false; | |
| 166 | + getView().showSuccess(context.getString(R.string.cancel_daren_success)); | |
| 167 | + getView().changeFollowBtn(getView().isFollowed); | |
| 168 | + getView().updateFansNum(false); | |
| 169 | + } | |
| 170 | + UpdatePortalReceiver.UpdatePortalResult updatePortalResult = new UpdatePortalReceiver.UpdatePortalResult(); | |
| 171 | + updatePortalResult.setDarenId(darenIds); | |
| 172 | + updatePortalResult.setAddDaren(false); | |
| 173 | + UpdatePortalReceiver.post(updatePortalResult); | |
| 174 | + }).start(); | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void cancel() { | |
| 178 | + if (addDaren != null) addDaren.cencel(); | |
| 179 | + if (cancelDaren != null) cancelDaren.cencel(); | |
| 180 | + if (loadDarenMore != null) loadDarenMore.cencel(); | |
| 181 | + if (loadDarenDisposable != null) loadDarenDisposable.cencel(); | |
| 182 | + if (shareEvent != null) shareEvent.cencel(); | |
| 183 | + } | |
| 184 | + | |
| 185 | + | |
| 186 | + public void shareDaren(Context context, View v, String sid, String darenId) { | |
| 187 | + if (shareEvent != null) shareEvent.cencel(); | |
| 188 | + Map<String, String> map = new HashMap<>(); | |
| 189 | + map.put("sid", sid); | |
| 190 | + map.put("darenId", darenId); | |
| 191 | + shareEvent = Logic.create(map) | |
| 192 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<ShareDarenInfo>> callback) -> | |
| 193 | + CnApiRequest.service(CnApiDarenService.class, api -> api.getDarenShare(data)).subscribe(context, callback)) | |
| 194 | + .action((Logic.Action<CnBaseInfo<ShareDarenInfo>, ShareDarenInfo>) (data, callback) -> | |
| 195 | + Logic.process(data::getData, callback)) | |
| 196 | + .<ShareDarenInfo>event() | |
| 197 | + .setStateCallback(state -> { | |
| 198 | + if (getView() == null) return; | |
| 199 | + if (v != null) | |
| 200 | + v.setClickable(state == STATE_IDLE); | |
| 201 | + }) | |
| 202 | + .setFailureCallback((state, message) -> { | |
| 203 | + if (getView() == null) return; | |
| 204 | +// getView().onShareFailure(state == -3 ? "分享失败 网络出错啦." : "分享失败 不要灰心在试一次."); | |
| 205 | + getView().showShareView(""); | |
| 206 | + }) | |
| 207 | + .setSuccessCallback(data -> { | |
| 208 | + if (getView() == null) return; | |
| 209 | + getView().showShareView(data.getcDownLoadUrl()); | |
| 210 | + }) | |
| 211 | + .start(); | |
| 212 | + } | |
| 213 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/DarenFansPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.base.logic.Event; | |
| 6 | +import com.cnlive.libs.base.logic.Logic; | |
| 7 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 8 | +import com.cnlive.strike.happychina.frame.view.DarenFansView; | |
| 9 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 10 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 11 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 12 | +import com.cnlive.strike.happychina.network.model.GetDarensData; | |
| 13 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 14 | + | |
| 15 | +import java.util.HashMap; | |
| 16 | +import java.util.Map; | |
| 17 | + | |
| 18 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 19 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Created by Lynn on 2018/2/28. | |
| 23 | + */ | |
| 24 | + | |
| 25 | +public class DarenFansPresenter extends MvpBasePresenter<DarenFansView> { | |
| 26 | + private Event<GetDarensData> getFans; | |
| 27 | + private Event<GetDarensData> getFansMore; | |
| 28 | + | |
| 29 | + public void getFansList(Context context, String darenId) { | |
| 30 | + cancel(); | |
| 31 | + Map<String, String> map = new HashMap<>(); | |
| 32 | + map.put("darenId", darenId); | |
| 33 | + map.put("pageNo", "1"); | |
| 34 | +// map.put("pageSize", Integer.MAX_VALUE + ""); | |
| 35 | + getFans = Logic.create(map) | |
| 36 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarensData>> callback) -> | |
| 37 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getFans(data)).subscribe(context, callback)) | |
| 38 | + .action((CnBaseInfo<GetDarensData> data, DataCallback<GetDarensData> callback) -> | |
| 39 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 40 | + .<GetDarensData>event() | |
| 41 | + .setStateCallback(state -> { | |
| 42 | + if (state == STATE_LOAD) { | |
| 43 | + if (getView() != null) | |
| 44 | + getView().showLoadingView(); | |
| 45 | + } else if (state == STATE_IDLE) { | |
| 46 | + if (getView() != null) | |
| 47 | + getView().hideLoadingView(); | |
| 48 | + } | |
| 49 | + }).setFailureCallback((state, message) -> { | |
| 50 | + if (getView().pageData().getAdapter().getList().size() == 0) | |
| 51 | + getView().showRetryView(state, view -> getFansList(context, darenId)); | |
| 52 | + else getView().showFailedToast(message); | |
| 53 | + }).setSuccessCallback(data -> { | |
| 54 | + if (data.getFans().size() > 0) { | |
| 55 | + if (getView() != null) getView().refreshItem(context, data); | |
| 56 | + } else { | |
| 57 | + if (getView() != null) getView().showEmptyView(); | |
| 58 | + } | |
| 59 | + }).start(); | |
| 60 | + } | |
| 61 | + | |
| 62 | + public void getFansListMore(Context context, String darenId, int pageNo) { | |
| 63 | + cancel(); | |
| 64 | + Map<String, String> map = new HashMap<>(); | |
| 65 | + map.put("darenId", darenId); | |
| 66 | + map.put("pageNo", pageNo + ""); | |
| 67 | +// map.put("pageSize", Integer.MAX_VALUE + ""); | |
| 68 | + getFansMore = Logic.create(map) | |
| 69 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarensData>> callback) -> | |
| 70 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getFans(data)).subscribe(context, callback) | |
| 71 | + ) | |
| 72 | + .action((CnBaseInfo<GetDarensData> data, DataCallback<GetDarensData> callback) -> | |
| 73 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 74 | + .<GetDarensData>event() | |
| 75 | + .setStateCallback(state -> { | |
| 76 | + if (state == STATE_LOAD) { | |
| 77 | + if (getView() != null) | |
| 78 | + getView().showLoadingView(); | |
| 79 | + } else if (state == STATE_IDLE) { | |
| 80 | + if (getView() != null) | |
| 81 | + getView().hideLoadingView(); | |
| 82 | + } | |
| 83 | + }).setSuccessCallback(data -> { | |
| 84 | + if (data.getFans().size() > 0) | |
| 85 | + if (getView() != null) | |
| 86 | + getView().addItems(context, data); | |
| 87 | + }).start(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void cancel() { | |
| 91 | + if (getFans != null) getFans.cencel(); | |
| 92 | + if (getFansMore != null) getFansMore.cencel(); | |
| 93 | + } | |
| 94 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/FollowDarensPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.base.application.AppConfig; | |
| 6 | +import com.cnlive.libs.base.logic.Event; | |
| 7 | +import com.cnlive.libs.base.logic.Logic; | |
| 8 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 9 | +import com.cnlive.strike.happychina.R; | |
| 10 | +import com.cnlive.strike.happychina.frame.view.FollowDarensView; | |
| 11 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 12 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 13 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 14 | +import com.cnlive.strike.happychina.network.model.GetDarensData; | |
| 15 | +import com.cnlive.strike.happychina.receiver.UpdatePortalReceiver; | |
| 16 | +import com.cnlive.strike.happychina.ui.moudle.FollowDarensItem; | |
| 17 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 18 | + | |
| 19 | +import java.util.HashMap; | |
| 20 | +import java.util.Map; | |
| 21 | + | |
| 22 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 23 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 24 | +import static com.cnlive.strike.happychina.router.DarenAction.addDarenAction; | |
| 25 | +import static com.cnlive.strike.happychina.router.DarenAction.cancelDarenAction; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * Created by cnlive201803 on 2018/5/17. | |
| 29 | + */ | |
| 30 | + | |
| 31 | +public class FollowDarensPresenter extends MvpBasePresenter<FollowDarensView> { | |
| 32 | + | |
| 33 | + private Event<GetDarensData> getFollowedDarensEvent; | |
| 34 | + private Event<GetDarensData> getUnFollowedDarensEvent; | |
| 35 | + private Event addDaren; | |
| 36 | + private Event cancelDaren; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获取已关注达人列表 | |
| 40 | + * | |
| 41 | + * @param context | |
| 42 | + */ | |
| 43 | + public void getFollowedDarens(Context context) { | |
| 44 | + | |
| 45 | + Map<String, String> requestData = new HashMap<>(); | |
| 46 | + String userId = AppConfig.getSid(); | |
| 47 | + requestData.put("appId", AppConfig.getAppId()); | |
| 48 | + requestData.put("sid", userId); | |
| 49 | + requestData.put("pageSize", "" + Integer.MAX_VALUE); | |
| 50 | + requestData.put("type", "follow"); | |
| 51 | + | |
| 52 | + getFollowedDarensEvent = Logic.create(requestData) | |
| 53 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarensData>> callback) -> | |
| 54 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getDarenList(data)).subscribe(context, callback)) | |
| 55 | + .action((CnBaseInfo<GetDarensData> data, DataCallback<GetDarensData> callback) -> | |
| 56 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 57 | + .<GetDarensData>event() | |
| 58 | + .setStateCallback(state -> { | |
| 59 | + if (state == STATE_LOAD) { | |
| 60 | + if (getView() != null) | |
| 61 | + getView().showLoadingView(); | |
| 62 | + } else if (state == STATE_IDLE) { | |
| 63 | + if (getView() != null) | |
| 64 | + getView().hideLoadingView(); | |
| 65 | + } | |
| 66 | + }).setFailureCallback((state, message) -> { | |
| 67 | + if (getView() == null) return; | |
| 68 | + if (getView().pageData().getAdapter().getList().size() == 0) | |
| 69 | + getView().showRetryView(state, view -> getFollowedDarens(context)); | |
| 70 | + else getView().showFailedToast(message); | |
| 71 | + }).setSuccessCallback(data -> { | |
| 72 | + if (data.getFans().size() > 0) { | |
| 73 | + if (getView() != null) | |
| 74 | + getView().refreshItem(data); | |
| 75 | + } else { | |
| 76 | + if (getView() != null) | |
| 77 | + getView().showEmptyView(); | |
| 78 | + } | |
| 79 | + }).start(); | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 获取未关注达人列表 | |
| 84 | + * | |
| 85 | + * @param context | |
| 86 | + */ | |
| 87 | + public void getUnFollowedDarens(Context context, int pageNo) { | |
| 88 | + Map<String, String> requestData = new HashMap<>(); | |
| 89 | + String userId = AppConfig.getSid(); | |
| 90 | + requestData.put("appId", AppConfig.getAppId()); | |
| 91 | + requestData.put("sid", userId); | |
| 92 | + requestData.put("pageNo", pageNo + ""); | |
| 93 | + requestData.put("type", "unFollow"); | |
| 94 | + | |
| 95 | + getUnFollowedDarensEvent = Logic.create(requestData) | |
| 96 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarensData>> callback) -> | |
| 97 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getUnFollowDarens(data)).subscribe(context, callback)) | |
| 98 | + .action((CnBaseInfo<GetDarensData> data, DataCallback<GetDarensData> callback) -> | |
| 99 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 100 | + .<GetDarensData>event() | |
| 101 | + .setStateCallback(state -> { | |
| 102 | + if (state == STATE_LOAD) { | |
| 103 | + if (getView() != null) | |
| 104 | + getView().showLoadingView(); | |
| 105 | + } else if (state == STATE_IDLE) { | |
| 106 | + if (getView() != null) | |
| 107 | + getView().hideLoadingView(); | |
| 108 | + } | |
| 109 | + }).setFailureCallback((state, message) -> { | |
| 110 | + if (getView() == null) return; | |
| 111 | + if (getView().pageData().getAdapter().getList().size() == 0) | |
| 112 | + getView().showRetryView(state, view -> getFollowedDarens(context)); | |
| 113 | + else getView().showFailedToast(message); | |
| 114 | + }).setSuccessCallback(data -> { | |
| 115 | + if (data.getFans().size() > 0) { | |
| 116 | + if (getView() != null) | |
| 117 | + getView().refreshItem(data); | |
| 118 | + } else { | |
| 119 | + if (getView() != null) | |
| 120 | + getView().showEmptyView(); | |
| 121 | + } | |
| 122 | + }).start(); | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void getMoreUnFollowedDarens(Context context, int pageNo) { | |
| 126 | + Map<String, String> requestData = new HashMap<>(); | |
| 127 | + String userId = AppConfig.getSid(); | |
| 128 | + requestData.put("appId", AppConfig.getAppId()); | |
| 129 | + requestData.put("sid", userId); | |
| 130 | + requestData.put("pageNo", pageNo + ""); | |
| 131 | + requestData.put("type", "unFollow"); | |
| 132 | + | |
| 133 | + getUnFollowedDarensEvent = Logic.create(requestData) | |
| 134 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<GetDarensData>> callback) -> | |
| 135 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getUnFollowDarens(data)).subscribe(context, callback)) | |
| 136 | + .action((CnBaseInfo<GetDarensData> data, DataCallback<GetDarensData> callback) -> | |
| 137 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 138 | + .<GetDarensData>event() | |
| 139 | + .setStateCallback(state -> { | |
| 140 | + if (state == STATE_LOAD) { | |
| 141 | + if (getView() != null) | |
| 142 | + getView().showLoadingView(); | |
| 143 | + } else if (state == STATE_IDLE) { | |
| 144 | + if (getView() != null) | |
| 145 | + getView().hideLoadingView(); | |
| 146 | + } | |
| 147 | + }).setFailureCallback((state, message) -> { | |
| 148 | + if (getView() == null) return; | |
| 149 | + if (getView().pageData().getAdapter().getList().size() == 0) | |
| 150 | + getView().showRetryView(state, view -> getFollowedDarens(context)); | |
| 151 | + else getView().showFailedToast(message); | |
| 152 | + }).setSuccessCallback(data -> { | |
| 153 | + if (data.getFans().size() > 0) | |
| 154 | + if (getView() != null) | |
| 155 | + getView().addItems(data); | |
| 156 | + }).start(); | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 160 | + * 关注 | |
| 161 | + * | |
| 162 | + * @param context | |
| 163 | + * @param darenIds | |
| 164 | + */ | |
| 165 | + public void addDaren(Context context, String darenIds, FollowDarensItem item) { | |
| 166 | +// cancel(); | |
| 167 | + addDaren = Logic.create() | |
| 168 | + .action(addDarenAction(context, darenIds)) | |
| 169 | + .<CnBaseInfo>event() | |
| 170 | + .setFailureCallback((state, message) -> { | |
| 171 | + if (getView() != null) | |
| 172 | + getView().showFailedToast(message); | |
| 173 | + }).setSuccessCallback(data -> { | |
| 174 | + if (getView() != null) { | |
| 175 | + getView().showSuccessToast(context.getString(R.string.add_daren_success)); | |
| 176 | + getView().removeItem(item); | |
| 177 | + } | |
| 178 | + UpdatePortalReceiver.post(new UpdatePortalReceiver.UpdatePortalResult()); | |
| 179 | + }).start(); | |
| 180 | + } | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * 取消关注 | |
| 184 | + * | |
| 185 | + * @param context | |
| 186 | + * @param darenIds | |
| 187 | + */ | |
| 188 | + public void cancelDaren(Context context, String darenIds, FollowDarensItem item) { | |
| 189 | +// cancel(); | |
| 190 | + cancelDaren = Logic.create() | |
| 191 | + .action(cancelDarenAction(context, darenIds)) | |
| 192 | + .<CnBaseInfo>event() | |
| 193 | + .setFailureCallback((state, message) -> { | |
| 194 | + if (getView() != null) | |
| 195 | + getView().showFailedToast(message); | |
| 196 | + }).setSuccessCallback(data -> { | |
| 197 | + if (getView() != null) { | |
| 198 | + getView().showSuccessToast(context.getString(R.string.cancel_daren_success)); | |
| 199 | + getView().removeItem(item); | |
| 200 | + } | |
| 201 | + UpdatePortalReceiver.post(new UpdatePortalReceiver.UpdatePortalResult()); | |
| 202 | + }).start(); | |
| 203 | + } | |
| 204 | + | |
| 205 | + public void cancel() { | |
| 206 | + if (getFollowedDarensEvent != null) getFollowedDarensEvent.cencel(); | |
| 207 | + if (getUnFollowedDarensEvent != null) getUnFollowedDarensEvent.cencel(); | |
| 208 | + if (addDaren != null) addDaren.cencel(); | |
| 209 | + if (cancelDaren != null) cancelDaren.cencel(); | |
| 210 | + } | |
| 211 | + | |
| 212 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/presenter/PortalPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.text.TextUtils; | |
| 5 | + | |
| 6 | +import com.cnlive.libs.base.application.AppConfig; | |
| 7 | +import com.cnlive.libs.base.logic.Event; | |
| 8 | +import com.cnlive.libs.base.logic.Logic; | |
| 9 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 10 | +import com.cnlive.strike.happychina.R; | |
| 11 | +import com.cnlive.strike.happychina.frame.view.PortalView; | |
| 12 | +import com.cnlive.strike.happychina.network.CnApiDarenService; | |
| 13 | +import com.cnlive.strike.happychina.network.CnApiRequest; | |
| 14 | +import com.cnlive.strike.happychina.network.model.CategoryListData; | |
| 15 | +import com.cnlive.strike.happychina.network.model.CenterPageData; | |
| 16 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 17 | +import com.cnlive.strike.happychina.network.model.HotList; | |
| 18 | +import com.cnlive.strike.happychina.network.model.UnFollowDarensData; | |
| 19 | +import com.cnlive.strike.happychina.network.model.UnFollowList; | |
| 20 | +import com.cnlive.strike.happychina.ui.moudle.BasePortalItem; | |
| 21 | +import com.cnlive.strike.happychina.ui.moudle.MomentsContentItem; | |
| 22 | +import com.cnlive.strike.happychina.ui.moudle.PortalBanner; | |
| 23 | +import com.cnlive.strike.happychina.ui.moudle.PortalCategory; | |
| 24 | +import com.cnlive.strike.happychina.ui.moudle.PortalMoment; | |
| 25 | +import com.cnlive.strike.happychina.ui.moudle.PortalNotFollow; | |
| 26 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 27 | + | |
| 28 | +import java.util.ArrayList; | |
| 29 | +import java.util.Collections; | |
| 30 | +import java.util.Comparator; | |
| 31 | +import java.util.HashMap; | |
| 32 | +import java.util.List; | |
| 33 | +import java.util.Map; | |
| 34 | + | |
| 35 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 36 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 37 | +import static com.cnlive.strike.happychina.router.DarenAction.addDarenAction; | |
| 38 | +import static com.cnlive.strike.happychina.router.DarenAction.cancelDarenAction; | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * Created by Lynn on 2018/3/6. | |
| 42 | + */ | |
| 43 | + | |
| 44 | +public class PortalPresenter extends MvpBasePresenter<PortalView> { | |
| 45 | + private Event<CenterPageData> getCenterPage; | |
| 46 | + private Event addDaren; | |
| 47 | + private Event cancelDaren; | |
| 48 | + | |
| 49 | + public void loadData(Context context, String city) { | |
| 50 | + if (city == null) { | |
| 51 | + city = ""; | |
| 52 | + } | |
| 53 | + getCenterPage(context, city, false); | |
| 54 | + } | |
| 55 | + | |
| 56 | + private void getCenterPage(Context context, String city, boolean isFollowClick) { | |
| 57 | + cancel(); | |
| 58 | + | |
| 59 | + Map<String, String> requestMap = new HashMap<>(); | |
| 60 | + requestMap.put("sid", AppConfig.getSid()); | |
| 61 | + requestMap.put("city", city); | |
| 62 | + | |
| 63 | + getCenterPage = Logic.create(requestMap) | |
| 64 | + .action((Map<String, String> data, DataCallback<CnBaseInfo<CenterPageData>> callback) -> | |
| 65 | + CnApiRequest.service(CnApiDarenService.class, service -> service.getCenterPage(data)).subscribe(context, callback)) | |
| 66 | + .action((CnBaseInfo<CenterPageData> data, DataCallback<CenterPageData> callback) -> | |
| 67 | + Logic.process(() -> data == null ? null : data.getData(), callback)) | |
| 68 | + .<CenterPageData>event() | |
| 69 | + .setStateCallback(state -> { | |
| 70 | + if (state == STATE_LOAD) { | |
| 71 | + if (getView() != null) | |
| 72 | + getView().showLoadingView(); | |
| 73 | + } else if (state == STATE_IDLE) { | |
| 74 | + if (getView() != null) { | |
| 75 | + getView().hideLoadingView(); | |
| 76 | + getView().finishRefresh(); | |
| 77 | + } | |
| 78 | + } | |
| 79 | + }).setFailureCallback((state, message) -> { | |
| 80 | + if (getView() != null) | |
| 81 | + if (getView().portalListAdapter().getList().size() == 0) | |
| 82 | + getView().showRetryPage(state, view -> getCenterPage(context, city, isFollowClick)); | |
| 83 | + else getView().showFailedToast(message); | |
| 84 | + }).setSuccessCallback(data -> { | |
| 85 | + if (data == null) { | |
| 86 | + if (getView() != null) | |
| 87 | + getView().showEmptyPage(); | |
| 88 | + } else { | |
| 89 | + if (getView() != null) | |
| 90 | + if (!isFollowClick) { | |
| 91 | + getView().loadList = toPortalItemList(data); | |
| 92 | + getView().shouldItemUpdate = true; | |
| 93 | + getView().updateItems(toPortalItemList(data)); | |
| 94 | + } else { | |
| 95 | + getView().updateNotFollowList(updateDarensList(data)); | |
| 96 | + } | |
| 97 | + } | |
| 98 | + }).start(); | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * 关注 | |
| 103 | + * | |
| 104 | + * @param context | |
| 105 | + * @param darenIds | |
| 106 | + */ | |
| 107 | + public void addDaren(Context context, String darenIds, UnFollowList item, String type) { | |
| 108 | +// cancel(); | |
| 109 | + addDaren = Logic.create() | |
| 110 | + .action(addDarenAction(context, darenIds)) | |
| 111 | + .<CnBaseInfo>event() | |
| 112 | + .setFailureCallback((state, message) -> { | |
| 113 | + if (getView() != null) | |
| 114 | + getView().showFollowFailedToast(message); | |
| 115 | + }).setSuccessCallback(data -> { | |
| 116 | +// if (getView() != null) | |
| 117 | +// getCenterPage(context, getView().fragment.city, true); | |
| 118 | + if (getView() != null) { | |
| 119 | + getView().updateFollowState(darenIds, true); | |
| 120 | +// getView().updateNotFollowList(updateTest(darenIds, item, true)); | |
| 121 | + getView().showFollowSuccessToast(context.getString(R.string.add_daren_success)); | |
| 122 | + updateFollowList(darenIds, item, true); | |
| 123 | + } | |
| 124 | + }).start(); | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * 取消关注 | |
| 129 | + * | |
| 130 | + * @param context | |
| 131 | + * @param darenIds | |
| 132 | + */ | |
| 133 | + public void cancelDaren(Context context, String darenIds, UnFollowList item, String type) { | |
| 134 | +// cancel(); | |
| 135 | + cancelDaren = Logic.create() | |
| 136 | + .action(cancelDarenAction(context, darenIds)) | |
| 137 | + .<CnBaseInfo>event() | |
| 138 | + .setFailureCallback((state, message) -> { | |
| 139 | + if (getView() != null) | |
| 140 | + getView().showFailedToast(message); | |
| 141 | + }).setSuccessCallback(data -> { | |
| 142 | +// if (getView() != null) | |
| 143 | +// getCenterPage(context, getView().fragment.city, true); | |
| 144 | + if (getView() != null) { | |
| 145 | + getView().updateFollowState(darenIds, false); | |
| 146 | +// getView().updateNotFollowList(updateTest(darenIds, item, false)); | |
| 147 | + getView().showFollowSuccessToast(context.getString(R.string.cancel_daren_success)); | |
| 148 | + updateFollowList(darenIds, item, false); | |
| 149 | + } | |
| 150 | + }).start(); | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * 转换数据,填充adapter | |
| 155 | + * | |
| 156 | + * @param centerPageData | |
| 157 | + * @return | |
| 158 | + */ | |
| 159 | + List<BasePortalItem> portalItemList; | |
| 160 | + private PortalMoment portalMoment; | |
| 161 | + private List<BasePortalItem> follows; | |
| 162 | + | |
| 163 | + private List<BasePortalItem> toPortalItemList(CenterPageData centerPageData) { | |
| 164 | + if (portalItemList != null) | |
| 165 | + portalItemList = null; | |
| 166 | + portalItemList = new ArrayList<>(); | |
| 167 | + | |
| 168 | + //banner | |
| 169 | + if (centerPageData.getBannerList() != null && centerPageData.getBannerList().size() > 0) { | |
| 170 | + PortalBanner portalBanner = new PortalBanner(); | |
| 171 | + portalBanner.setBanners(centerPageData.getBannerList()); | |
| 172 | + portalBanner.setType(BasePortalItem.TYPE_BANNER); | |
| 173 | + getView().fragment.showNextListener = portalBanner; | |
| 174 | + portalItemList.add(portalBanner); | |
| 175 | + } | |
| 176 | + | |
| 177 | + //未关注与已关注达人或订阅号 | |
| 178 | + if (centerPageData.getList() != null) { | |
| 179 | + List<UnFollowDarensData> notFollowList = centerPageData.getList(); | |
| 180 | + Collections.sort(notFollowList, new Comparator<UnFollowDarensData>() { | |
| 181 | + @Override | |
| 182 | + public int compare(UnFollowDarensData unFollowDarensData, UnFollowDarensData t1) { | |
| 183 | + if (unFollowDarensData.getSort() > t1.getSort()) { | |
| 184 | + return 1; | |
| 185 | + } | |
| 186 | + return -1; | |
| 187 | + } | |
| 188 | + }); | |
| 189 | + | |
| 190 | + follows = new ArrayList<>(); | |
| 191 | + for (int i = 0; i < notFollowList.size(); i++) { | |
| 192 | + PortalNotFollow portalNotFollow = new PortalNotFollow(); | |
| 193 | + portalNotFollow.setName(centerPageData.getList().get(i).getName()); | |
| 194 | + portalNotFollow.setIcon(centerPageData.getList().get(i).getIcon()); | |
| 195 | + portalNotFollow.setOpenUrl(centerPageData.getList().get(i).getOpenUrl()); | |
| 196 | + portalNotFollow.setSort(centerPageData.getList().get(i).getSort()); | |
| 197 | + portalNotFollow.setType(BasePortalItem.TYPE_UNFOLLOW_DAREN); | |
| 198 | + if (notFollowList.get(i).getDarenList() != null && notFollowList.get(i).getDarenList().size() > 0) { | |
| 199 | + portalNotFollow.setNotFollowList(centerPageData.getList().get(i).getDarenList()); | |
| 200 | + portalItemList.add(portalNotFollow); | |
| 201 | + } | |
| 202 | + follows.add(portalNotFollow); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + //达人广场 | |
| 207 | + if (centerPageData.getDarenSquare() != null && centerPageData.getDarenSquare().getList() != null && centerPageData.getDarenSquare().getList().size() > 0) { | |
| 208 | + PortalCategory portalCategory = new PortalCategory(); | |
| 209 | + List<CategoryListData> categoryListDataList = new ArrayList<>(); | |
| 210 | + for (int i = 0; i < centerPageData.getDarenSquare().getList().size(); i++) { | |
| 211 | + | |
| 212 | + if (centerPageData.getDarenSquare().getList().get(i).getList() != null && centerPageData.getDarenSquare().getList().get(i).getList().size() > 0) { | |
| 213 | + CategoryListData categoryListData = new CategoryListData(); | |
| 214 | + categoryListData.setList(centerPageData.getDarenSquare().getList().get(i).getList()); | |
| 215 | + categoryListData.setCategoryIconBean(centerPageData.getDarenSquare().getList().get(i).getCategoryIconBean()); | |
| 216 | + categoryListDataList.add(categoryListData); | |
| 217 | + } | |
| 218 | + } | |
| 219 | + portalCategory.setCategories(categoryListDataList); | |
| 220 | +// portalCategory.setCategories(centerPageData.getAtegories().getList()); | |
| 221 | + portalCategory.setIcon(centerPageData.getDarenSquare().getIcon()); | |
| 222 | + portalCategory.setName(centerPageData.getDarenSquare().getName()); | |
| 223 | + portalCategory.setType(BasePortalItem.TYPE_DAREN_SQUARE); | |
| 224 | + portalItemList.add(portalCategory); | |
| 225 | + } | |
| 226 | + | |
| 227 | + //热点 | |
| 228 | + if (centerPageData.getHotMsg().getHotList() != null && centerPageData.getHotMsg().getHotList().size() > 0) { | |
| 229 | + portalMoment = new PortalMoment(); | |
| 230 | + portalMoment.setType(BasePortalItem.TYPE_MOMENT); | |
| 231 | + portalMoment.setName(centerPageData.getHotMsg().getName()); | |
| 232 | + portalMoment.setIcon(centerPageData.getHotMsg().getIcon()); | |
| 233 | + portalMoment.setOpenUrl(centerPageData.getHotMsg().getOpenUrl()); | |
| 234 | + portalMoment.setSort(centerPageData.getHotMsg().getSort()); | |
| 235 | + List<HotList> lists = centerPageData.getHotMsg().getHotList(); | |
| 236 | + List<PortalMoment.Hot> hotList = new ArrayList<>(); | |
| 237 | + for (int i = 0; i < lists.size(); i++) { | |
| 238 | + PortalMoment.Hot hot = new PortalMoment.Hot(); | |
| 239 | + hot.setAddress(lists.get(i).getItem().getAddress()); | |
| 240 | + hot.setCategory(lists.get(i).getItem().getCategory()); | |
| 241 | + hot.setCategoryName(lists.get(i).getItem().getCategoryName()); | |
| 242 | + String od = lists.get(i).getItem().getOptionDesc(); | |
| 243 | + hot.setOptionDesc(TextUtils.isEmpty(od) ? "" : String.format("配送方式: %s", od)); | |
| 244 | + hot.setOptionId(lists.get(i).getItem().getOptionId()); | |
| 245 | + hot.setDarenId(lists.get(i).getItem().getDarenId()); | |
| 246 | + hot.setFan(lists.get(i).getFan()); | |
| 247 | + hot.setIcon(lists.get(i).getIcon()); | |
| 248 | + hot.setItemId(lists.get(i).getItem().getItemId()); | |
| 249 | + hot.setCategories(lists.get(i).getCategories()); | |
| 250 | + List<MomentsContentItem> list2 = new ArrayList<>(); | |
| 251 | + if (lists.get(i).getItem().getType() == 1) { | |
| 252 | + for (HotList.HotItem.Image image : lists.get(i).getItem().getImages()) { | |
| 253 | + MomentsContentItem item2 = new MomentsContentItem(); | |
| 254 | + item2.setImage(image.getImagePath()); | |
| 255 | + item2.setImageThumbnail(image.getThumbnailPath()); | |
| 256 | + item2.setImageThumbnailsFirst(image.getThumbnailsFirstPic()); | |
| 257 | + item2.setHeight(image.getHeight()); | |
| 258 | + item2.setWidth(image.getWidth()); | |
| 259 | + item2.setVideo(false); | |
| 260 | + list2.add(item2); | |
| 261 | + } | |
| 262 | + } else if (lists.get(i).getItem().getType() == 2) { | |
| 263 | + MomentsContentItem item2 = new MomentsContentItem(); | |
| 264 | + item2.setImage(lists.get(i).getItem().getVideo().getImageUrl()); | |
| 265 | + item2.setImageThumbnail(lists.get(i).getItem().getVideo().getImageUrl()); | |
| 266 | + item2.setVideo(lists.get(i).getItem().getVideo().getVideoId()); | |
| 267 | + item2.setVideoPath(lists.get(i).getItem().getVideo().getVideoPlayUrl()); | |
| 268 | + item2.setVideo(true); | |
| 269 | + item2.setWidth(lists.get(i).getItem().getVideo().getWidth()); | |
| 270 | + item2.setHeight(lists.get(i).getItem().getVideo().getHeight()); | |
| 271 | + item2.setImageThumbnailsFirst(lists.get(i).getItem().getVideo().getImageUrl()); | |
| 272 | + list2.add(item2); | |
| 273 | + } | |
| 274 | + hot.setMomentsContentItems(list2); | |
| 275 | + hot.setStatus(lists.get(i).getItem().getStatus()); | |
| 276 | + hot.setText(lists.get(i).getItem().getText()); | |
| 277 | + hot.setTs(lists.get(i).getItem().getTs()); | |
| 278 | + hot.setType(lists.get(i).getItem().getType()); | |
| 279 | + hotList.add(hot); | |
| 280 | + } | |
| 281 | + | |
| 282 | + portalMoment.setMomentList(hotList); | |
| 283 | + portalItemList.add(portalMoment); | |
| 284 | + } | |
| 285 | + return portalItemList; | |
| 286 | + } | |
| 287 | + | |
| 288 | + /** | |
| 289 | + * 更新已关注/未关注列表 | |
| 290 | + * | |
| 291 | + * @param centerPageData | |
| 292 | + * @return | |
| 293 | + */ | |
| 294 | + private List<BasePortalItem> updateDarensList(CenterPageData centerPageData) { | |
| 295 | + List<BasePortalItem> portalItemList = new ArrayList<>(); | |
| 296 | + //未关注与已关注达人或订阅号 | |
| 297 | + if (centerPageData.getList() != null) { | |
| 298 | + List<UnFollowDarensData> notFollowList = centerPageData.getList(); | |
| 299 | + Collections.sort(notFollowList, new Comparator<UnFollowDarensData>() { | |
| 300 | + @Override | |
| 301 | + public int compare(UnFollowDarensData unFollowDarensData, UnFollowDarensData t1) { | |
| 302 | + if (unFollowDarensData.getSort() > t1.getSort()) { | |
| 303 | + return 1; | |
| 304 | + } | |
| 305 | + return -1; | |
| 306 | + } | |
| 307 | + }); | |
| 308 | + | |
| 309 | + for (int i = 0; i < notFollowList.size(); i++) { | |
| 310 | + if (notFollowList.get(i).getDarenList() != null && notFollowList.get(i).getDarenList().size() > 0) { | |
| 311 | + PortalNotFollow portalNotFollow = new PortalNotFollow(); | |
| 312 | + portalNotFollow.setNotFollowList(centerPageData.getList().get(i).getDarenList()); | |
| 313 | + portalNotFollow.setName(centerPageData.getList().get(i).getName()); | |
| 314 | + portalNotFollow.setIcon(centerPageData.getList().get(i).getIcon()); | |
| 315 | + portalNotFollow.setOpenUrl(centerPageData.getList().get(i).getOpenUrl()); | |
| 316 | + portalNotFollow.setSort(centerPageData.getList().get(i).getSort()); | |
| 317 | + portalNotFollow.setType(BasePortalItem.TYPE_UNFOLLOW_DAREN); | |
| 318 | + portalItemList.add(portalNotFollow); | |
| 319 | + } else { | |
| 320 | + if (getView() != null) | |
| 321 | + getView().removeItem(notFollowList.get(i).getSort() + 1); | |
| 322 | + } | |
| 323 | + } | |
| 324 | + } | |
| 325 | + return portalItemList; | |
| 326 | + } | |
| 327 | + | |
| 328 | + | |
| 329 | + private void updateFollowList(String darenId, UnFollowList item, boolean isFollow) { | |
| 330 | + | |
| 331 | + List<BasePortalItem> followList = follows; | |
| 332 | + | |
| 333 | + if (followList != null && followList.size() > 0) { | |
| 334 | + PortalNotFollow unFollows = null; | |
| 335 | + PortalNotFollow follows = null; | |
| 336 | + | |
| 337 | + if (followList.size() < 2) { | |
| 338 | + | |
| 339 | + if (((PortalNotFollow) followList.get(0)).getSort() == 1) { | |
| 340 | + unFollows = (PortalNotFollow) followList.get(0); | |
| 341 | + follows = new PortalNotFollow(); | |
| 342 | + follows.setType(BasePortalItem.TYPE_UNFOLLOW_DAREN); | |
| 343 | + follows.setNotFollowList(new ArrayList<>()); | |
| 344 | + follows.setIcon(""); | |
| 345 | + follows.setName("已关注达人"); | |
| 346 | + follows.setSort(unFollows.getSort() - 1); | |
| 347 | + followList.add(unFollows.getSort() - 1, follows); | |
| 348 | + } else { | |
| 349 | + follows = (PortalNotFollow) followList.get(0); | |
| 350 | + unFollows = new PortalNotFollow(); | |
| 351 | + unFollows.setType(BasePortalItem.TYPE_UNFOLLOW_DAREN); | |
| 352 | + unFollows.setNotFollowList(new ArrayList<>()); | |
| 353 | + unFollows.setIcon(""); | |
| 354 | + unFollows.setName("未关注达人"); | |
| 355 | + unFollows.setSort(follows.getSort() + 1); | |
| 356 | + followList.add(follows.getSort() + 1, unFollows); | |
| 357 | + } | |
| 358 | + } else if (followList.size() >= 2) { | |
| 359 | + follows = (PortalNotFollow) followList.get(0); | |
| 360 | + if (follows.getNotFollowList() == null) { | |
| 361 | + follows.setNotFollowList(new ArrayList<>()); | |
| 362 | + } | |
| 363 | + unFollows = (PortalNotFollow) followList.get(1); | |
| 364 | + } | |
| 365 | + | |
| 366 | + if (isFollow) { | |
| 367 | + if (follows.getNotFollowList().size() == 0) { | |
| 368 | + getView().portalListAdapter().addItem(follows.getSort() + 1, follows); | |
| 369 | + } | |
| 370 | + follows.getNotFollowList().add(0, item); | |
| 371 | + getView().portalListAdapter().updateDarensList(follows); | |
| 372 | + for (int j = 0; j < unFollows.getNotFollowList().size(); j++) { | |
| 373 | + if (unFollows.getNotFollowList().get(j).getIcon().getUserId().equals(darenId)) { | |
| 374 | + unFollows.getNotFollowList().remove(j); | |
| 375 | + if (unFollows.getNotFollowList().size() <= 0) | |
| 376 | + getView().portalListAdapter().removeItem(unFollows.getSort() + 1); | |
| 377 | + else | |
| 378 | + getView().portalListAdapter().updateDarensList(unFollows); | |
| 379 | + | |
| 380 | + } | |
| 381 | + } | |
| 382 | + | |
| 383 | + } else { | |
| 384 | + List<UnFollowList> list = unFollows.getNotFollowList(); | |
| 385 | + if (list == null) { | |
| 386 | + list = new ArrayList<>(); | |
| 387 | + } | |
| 388 | + if (list.size() == 0) { | |
| 389 | + getView().portalListAdapter().addItem(unFollows.getSort() + 1, unFollows); | |
| 390 | + } | |
| 391 | + list.add(0, item); | |
| 392 | + unFollows.setNotFollowList(list); | |
| 393 | + getView().portalListAdapter().updateDarensList(unFollows); | |
| 394 | + for (int j = 0; j < follows.getNotFollowList().size(); j++) { | |
| 395 | + if (follows.getNotFollowList().get(j).getIcon().getUserId().equals(darenId)) { | |
| 396 | + follows.getNotFollowList().remove(j); | |
| 397 | + if (follows.getNotFollowList().size() <= 0) | |
| 398 | + getView().portalListAdapter().removeItem(follows.getSort() + 1); | |
| 399 | + else getView().portalListAdapter().updateDarensList(follows); | |
| 400 | + | |
| 401 | + } | |
| 402 | + } | |
| 403 | + | |
| 404 | + } | |
| 405 | +// updateItem(follows); | |
| 406 | +// updateItem(unFollows); | |
| 407 | + } | |
| 408 | + } | |
| 409 | + | |
| 410 | + private void updateItem(PortalNotFollow data) { | |
| 411 | + if (data == null) | |
| 412 | + return; | |
| 413 | + if (data.getNotFollowList() == null || data.getNotFollowList().size() <= 0) { | |
| 414 | + getView().portalListAdapter().removeItem(data.getSort() + 1); | |
| 415 | + } else { | |
| 416 | + getView().portalListAdapter().updateItem(data, data.getSort() + 1); | |
| 417 | + } | |
| 418 | + } | |
| 419 | + | |
| 420 | + public void cancel() { | |
| 421 | + if (getCenterPage != null) getCenterPage.cencel(); | |
| 422 | + if (addDaren != null) addDaren.cencel(); | |
| 423 | + if (cancelDaren != null) cancelDaren.cencel(); | |
| 424 | + } | |
| 425 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/ClassifySearchView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.support.v4.content.ContextCompat; | |
| 5 | +import android.text.TextUtils; | |
| 6 | +import android.util.TypedValue; | |
| 7 | +import android.view.Gravity; | |
| 8 | +import android.view.KeyEvent; | |
| 9 | +import android.view.View; | |
| 10 | +import android.view.ViewGroup; | |
| 11 | +import android.view.inputmethod.EditorInfo; | |
| 12 | +import android.widget.TextView; | |
| 13 | + | |
| 14 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 15 | +import com.cnlive.strike.happychina.R; | |
| 16 | +import com.cnlive.strike.happychina.network.model.SearchDarenData; | |
| 17 | +import com.cnlive.strike.happychina.ui.fragment.ClassifySearchFragment; | |
| 18 | +import com.cnlive.strike.happychina.ui.moudle.SearchDarenItem; | |
| 19 | +import com.cnlive.strike.happychina.ui.moudle.SearchDarenPage; | |
| 20 | +import com.cnlive.strike.happychina.utils.KeyboardUtils; | |
| 21 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 22 | +import com.qmuiteam.qmui.util.QMUIDisplayHelper; | |
| 23 | + | |
| 24 | +import java.util.ArrayList; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * Created by cnlive201803 on 2018/5/30. | |
| 29 | + */ | |
| 30 | + | |
| 31 | +public class ClassifySearchView implements MvpView { | |
| 32 | + | |
| 33 | + private ClassifySearchFragment fragment; | |
| 34 | + | |
| 35 | + public ClassifySearchView(ClassifySearchFragment fragment) { | |
| 36 | + this.fragment = fragment; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public Context getContext() { | |
| 40 | + return fragment == null ? null : fragment.getActivity(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void initView() { | |
| 44 | + fragment.binding.searchList.setNestedScrollingEnabled(false); | |
| 45 | + fragment.binding.editText.setOnEditorActionListener(editorActionListener); | |
| 46 | + | |
| 47 | + fragment.binding.editText.clearFocus(); | |
| 48 | + for (String history : fragment.getPresenter().loadHistorys(getContext())) { | |
| 49 | + if (!TextUtils.isEmpty(history)) { | |
| 50 | + addItemToFloatLayout(history, false); | |
| 51 | + fragment.binding.clear.setVisibility(View.VISIBLE); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | + fragment.binding.close.setOnClickListener(new View.OnClickListener() { | |
| 56 | + @Override | |
| 57 | + public void onClick(View v) { | |
| 58 | + fragment.binding.editText.setText(""); | |
| 59 | + pageData().getAdapter().removeAllItems(); | |
| 60 | + hideEmptyView(); | |
| 61 | + fragment.binding.searchList.setVisibility(View.GONE); | |
| 62 | + fragment.binding.searchHistoryLayout.setVisibility(View.VISIBLE); | |
| 63 | + } | |
| 64 | + }); | |
| 65 | + | |
| 66 | + fragment.binding.cancel.setOnClickListener(new View.OnClickListener() { | |
| 67 | + @Override | |
| 68 | + public void onClick(View v) { | |
| 69 | + KeyboardUtils.hideSoftInput(fragment.getActivity()); | |
| 70 | + fragment.getActivity().finish(); | |
| 71 | + } | |
| 72 | + }); | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void addItems(List<SearchDarenData> searchDarenDataList) { | |
| 76 | + for (SearchDarenItem item : changeItem(searchDarenDataList)) | |
| 77 | + fragment.pageData.getAdapter().addItem(item); | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void refreshItem(List<SearchDarenData> searchDarenDataList) { | |
| 81 | + fragment.binding.searchList.setVisibility(View.VISIBLE); | |
| 82 | + fragment.pageData.getAdapter().updateItems(changeItem(searchDarenDataList)); | |
| 83 | + } | |
| 84 | + | |
| 85 | + private List<SearchDarenItem> changeItem(List<SearchDarenData> searchDarenDatas) { | |
| 86 | + List<SearchDarenItem> list = new ArrayList<>(); | |
| 87 | + for (SearchDarenData searchDaren : searchDarenDatas) { | |
| 88 | + SearchDarenItem item = new SearchDarenItem(); | |
| 89 | + item.setId(searchDaren.getId()); | |
| 90 | + item.setImg(searchDaren.getImg()); | |
| 91 | + item.setShopName(searchDaren.getShopName()); | |
| 92 | + list.add(item); | |
| 93 | + } | |
| 94 | + return list; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public SearchDarenPage pageData() { | |
| 98 | + return fragment.pageData; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public void showLoadingView() { | |
| 102 | + fragment.binding.emptyView.show(true); | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void hideLoadingView() { | |
| 106 | + fragment.binding.emptyView.hide(); | |
| 107 | + } | |
| 108 | + | |
| 109 | + public void hideHistoryView() { | |
| 110 | + fragment.binding.searchHistoryLayout.setVisibility(View.GONE); | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void showEmptyView() { | |
| 114 | + fragment.pageData.getAdapter().removeAllItems(); | |
| 115 | + if (fragment.binding.emptyView != null) { | |
| 116 | + fragment.binding.emptyView.show(getContext().getResources().getString(R.string.search_empty), "", R.drawable.dd_quanbumeiyou); | |
| 117 | + } | |
| 118 | + } | |
| 119 | + | |
| 120 | + public void hideEmptyView() { | |
| 121 | + fragment.binding.emptyView.setVisibility(View.GONE); | |
| 122 | + } | |
| 123 | + | |
| 124 | + public void addItemToFloatLayout(String history, boolean first) { | |
| 125 | + | |
| 126 | + final TextView textView = new TextView(getContext()); | |
| 127 | + int textViewPadding = QMUIDisplayHelper.dp2px(getContext(), 7); | |
| 128 | + int textViewRightPadding = QMUIDisplayHelper.dp2px(getContext(), 14); | |
| 129 | + textView.setPadding(textViewRightPadding, textViewPadding, textViewRightPadding, textViewPadding); | |
| 130 | + textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); | |
| 131 | + textView.setTextColor(ContextCompat.getColor(getContext(), R.color.color_363637)); | |
| 132 | + textView.setText(history); | |
| 133 | + textView.setGravity(Gravity.CENTER); | |
| 134 | + textView.setMaxEms(21); | |
| 135 | + textView.setSingleLine(); | |
| 136 | + textView.setEllipsize(TextUtils.TruncateAt.MIDDLE); | |
| 137 | + textView.setMinWidth(QMUIDisplayHelper.dp2px(getContext(), 50)); | |
| 138 | + textView.setBackgroundResource(R.drawable.item_search_history); | |
| 139 | + | |
| 140 | + ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
| 141 | + if (first) { | |
| 142 | + fragment.binding.floatLayout.addView(textView, 0, lp); | |
| 143 | + } else { | |
| 144 | + fragment.binding.floatLayout.addView(textView, lp); | |
| 145 | + } | |
| 146 | + | |
| 147 | + textView.setOnClickListener(new View.OnClickListener() { | |
| 148 | + @Override | |
| 149 | + public void onClick(View v) { | |
| 150 | + fragment.binding.editText.setText(history); | |
| 151 | + fragment.searchDaren(history); | |
| 152 | + } | |
| 153 | + }); | |
| 154 | + | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void moveItemToFirst() { | |
| 158 | + | |
| 159 | + fragment.binding.floatLayout.removeAllViews(); | |
| 160 | + | |
| 161 | + for (String history : fragment.getPresenter().loadHistorys(getContext())) { | |
| 162 | + if (!TextUtils.isEmpty(history)) { | |
| 163 | + addItemToFloatLayout(history, false); | |
| 164 | + fragment.binding.clear.setVisibility(View.VISIBLE); | |
| 165 | + } | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + private TextView.OnEditorActionListener editorActionListener = new TextView.OnEditorActionListener() { | |
| 170 | + @Override | |
| 171 | + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { | |
| 172 | + if (actionId == EditorInfo.IME_ACTION_SEARCH) { | |
| 173 | + | |
| 174 | + String s = fragment.binding.editText.getText().toString().trim(); | |
| 175 | + if (!TextUtils.isEmpty(s)) { | |
| 176 | + fragment.searchDaren(s.trim()); | |
| 177 | + } else { | |
| 178 | + AlertUtil.showDeftToast(getContext(), getContext().getResources().getString(R.string.search_content_empty_toast)); | |
| 179 | + } | |
| 180 | + return true; | |
| 181 | + } | |
| 182 | + | |
| 183 | + return false; | |
| 184 | + } | |
| 185 | + }; | |
| 186 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/ClassifyView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.support.v7.widget.GridLayoutManager; | |
| 5 | +import android.support.v7.widget.LinearLayoutManager; | |
| 6 | +import android.support.v7.widget.RecyclerView; | |
| 7 | +import android.text.TextUtils; | |
| 8 | +import android.util.Log; | |
| 9 | +import android.view.View; | |
| 10 | +import android.widget.Button; | |
| 11 | +import android.widget.TextView; | |
| 12 | + | |
| 13 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 14 | +import com.cnlive.strike.happychina.R; | |
| 15 | +import com.cnlive.strike.happychina.listener.CheckListener; | |
| 16 | +import com.cnlive.strike.happychina.network.model.CategoryDarensData; | |
| 17 | +import com.cnlive.strike.happychina.network.model.CategoryData; | |
| 18 | +import com.cnlive.strike.happychina.ui.adapter.ClassifyDetailAdapter; | |
| 19 | +import com.cnlive.strike.happychina.ui.adapter.SortAdapter; | |
| 20 | +import com.cnlive.strike.happychina.ui.fragment.ClassifyFragment; | |
| 21 | +import com.cnlive.strike.happychina.ui.moudle.RightBean; | |
| 22 | +import com.cnlive.strike.happychina.ui.widget.ItemHeaderDecoration; | |
| 23 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 24 | + | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * Created by Lynn on 2018/3/13. | |
| 29 | + */ | |
| 30 | + | |
| 31 | +public class ClassifyView implements MvpView, CheckListener { | |
| 32 | + public ClassifyFragment fragment; | |
| 33 | + public SortAdapter sortAdapter; | |
| 34 | + private ClassifyDetailAdapter detailAdapter; | |
| 35 | + private LinearLayoutManager linearLayoutManager; | |
| 36 | + private GridLayoutManager gridLayoutManager; | |
| 37 | + private int targetPosition;//点击左边某一个具体的item的位置 | |
| 38 | + private boolean isMoved; | |
| 39 | + // public SortBean mSortBean; | |
| 40 | + public CategoryDarensData categoryDarensDatas; | |
| 41 | + private ItemHeaderDecoration mDecoration; | |
| 42 | + private int mIndex = 0; | |
| 43 | + private boolean move = false; | |
| 44 | + | |
| 45 | + | |
| 46 | + public ClassifyView(ClassifyFragment fragment) { | |
| 47 | + this.fragment = fragment; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public Context getContext() { | |
| 51 | + return fragment == null ? null : fragment.getActivity(); | |
| 52 | + } | |
| 53 | + | |
| 54 | + public void showEmptyView() { | |
| 55 | + if (fragment.binding.emptyView != null) | |
| 56 | + fragment.binding.emptyView.show(getContext().getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong); | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void showLoadingView() { | |
| 60 | + if (fragment.binding.emptyView != null) | |
| 61 | + fragment.binding.emptyView.show(true); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void hideLoadingView() { | |
| 65 | + if (fragment.binding.emptyView != null) | |
| 66 | + fragment.binding.emptyView.hide(); | |
| 67 | + } | |
| 68 | + | |
| 69 | + public void hideEmptyView() { | |
| 70 | + if (fragment.binding.emptyView != null) | |
| 71 | + fragment.binding.emptyView.hide(); | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void showRetryView(int state, View.OnClickListener listener) { | |
| 75 | + String titleText = ""; | |
| 76 | + String detailText = ""; | |
| 77 | + if (state == -3) { | |
| 78 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 79 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 80 | + } else { | |
| 81 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 82 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 83 | + } | |
| 84 | + if (fragment.binding.emptyView != null) { | |
| 85 | + fragment.binding.emptyView.show(false, titleText, detailText, "重试", R.drawable.wufalianjie, listener); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void showFailedToast(String message) { | |
| 90 | + if (getContext() == null) | |
| 91 | + return; | |
| 92 | + AlertUtil.showFailedToast(getContext(), message); | |
| 93 | + | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void showSuccessToast(String message) { | |
| 97 | + if (getContext() == null) | |
| 98 | + return; | |
| 99 | + AlertUtil.showSuccessToast(getContext(), message); | |
| 100 | + } | |
| 101 | + | |
| 102 | + public void updateFollowState(boolean isFollow, int position) { | |
| 103 | + RecyclerView.ViewHolder viewHolder = fragment.binding.detaiRv.getChildViewHolder(fragment.binding.detaiRv.getLayoutManager().findViewByPosition(position)); | |
| 104 | + Button textView = viewHolder.itemView.findViewById(R.id.follow); | |
| 105 | + TextView fansTextView = viewHolder.itemView.findViewById(R.id.fansNum); | |
| 106 | + detailAdapter.setFollowed(isFollow, position); | |
| 107 | + int fansCount = Integer.parseInt(fansTextView.getText().toString().substring(0, fansTextView.getText().toString().length() - 2)); | |
| 108 | + if (isFollow) { | |
| 109 | + textView.setBackgroundResource(R.drawable.drawable_drgc_gz_sel); | |
| 110 | + textView.setText(R.string.btn_follow_already); | |
| 111 | + fansCount += 1; | |
| 112 | + fansTextView.setText(fansCount + "粉丝"); | |
| 113 | + } else { | |
| 114 | + textView.setBackgroundResource(R.drawable.drawable_drgc_gz); | |
| 115 | + textView.setText(""); | |
| 116 | + fansCount -= 1; | |
| 117 | + fansTextView.setText(fansCount + "粉丝"); | |
| 118 | + } | |
| 119 | + } | |
| 120 | + | |
| 121 | + | |
| 122 | + public void initLeftView(List<CategoryData> sortList) { | |
| 123 | + fragment.binding.sortRv.setLayoutManager(linearLayoutManager = new LinearLayoutManager(getContext())); | |
| 124 | + fragment.binding.sortRv.setAdapter(sortAdapter = new SortAdapter(getContext())); | |
| 125 | +// fragment.binding.sortRv.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayout.VERTICAL, QMUIDisplayHelper.dpToPx(1), R.color.white)); | |
| 126 | + sortAdapter.updateItems(sortList); | |
| 127 | + sortAdapter.setOnItemListener((viewId, position) -> { | |
| 128 | + isMoved = true; | |
| 129 | + targetPosition = position; | |
| 130 | + setChecked(position, true); | |
| 131 | + }); | |
| 132 | + } | |
| 133 | + | |
| 134 | + public void initRightView(List<RightBean> rightList) { | |
| 135 | + gridLayoutManager = new GridLayoutManager(getContext(), 1); | |
| 136 | + //通过isTitle的标志来判断是否是title | |
| 137 | + gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { | |
| 138 | + @Override | |
| 139 | + public int getSpanSize(int position) { | |
| 140 | +// return rightList.get(position).isTitle() ? 3 : 1; | |
| 141 | +// return rightList.get(position).getType() == 1 ? 1 : 3; | |
| 142 | + return 1; | |
| 143 | + } | |
| 144 | + }); | |
| 145 | + | |
| 146 | + fragment.binding.detaiRv.addOnScrollListener(new RecyclerViewListener()); | |
| 147 | + fragment.binding.detaiRv.setLayoutManager(gridLayoutManager); | |
| 148 | + int width = fragment.binding.detaiRv.getWidth() - fragment.binding.detaiRv.getPaddingLeft() - fragment.binding.detaiRv.getPaddingRight(); | |
| 149 | + detailAdapter = new ClassifyDetailAdapter(getContext(), width); | |
| 150 | + fragment.binding.detaiRv.setAdapter(detailAdapter); | |
| 151 | + mDecoration = new ItemHeaderDecoration(getContext(), rightList); | |
| 152 | + fragment.binding.detaiRv.addItemDecoration(mDecoration); | |
| 153 | + detailAdapter.updateItems(rightList); | |
| 154 | + | |
| 155 | + | |
| 156 | + detailAdapter.notifyDataSetChanged(); | |
| 157 | + mDecoration.setCheckListener(this); | |
| 158 | + mDecoration.setData(rightList); | |
| 159 | + | |
| 160 | + | |
| 161 | + smoothTo(); | |
| 162 | + } | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * 根据上一页的categoryId滚动到对应的达人类型 | |
| 166 | + */ | |
| 167 | + public void smoothTo() { | |
| 168 | + if (sortAdapter.getList() != null && sortAdapter.getList().size() > 0) | |
| 169 | + for (int i = 0; i < sortAdapter.getList().size(); i++) { | |
| 170 | + if (sortAdapter.getItem(i).getCategoryId().equals(fragment.categoryId)) { | |
| 171 | + targetPosition = i; | |
| 172 | + } else if (TextUtils.isEmpty(fragment.categoryId)) { | |
| 173 | + targetPosition = 0; | |
| 174 | + } | |
| 175 | + isMoved = true; | |
| 176 | + setChecked(targetPosition, true); | |
| 177 | + } | |
| 178 | + } | |
| 179 | + | |
| 180 | + public void setChecked(int position, boolean isLeft) { | |
| 181 | + if (isLeft) { | |
| 182 | + sortAdapter.setCheckedPosition(position); | |
| 183 | + //此处的位置需要根据每个分类的集合来进行计算 | |
| 184 | + | |
| 185 | +// int count = 1; | |
| 186 | +// if (position == 0) { | |
| 187 | +// count = 0; | |
| 188 | +// } | |
| 189 | + //如果没有顶部的图片可以设置count = 0 | |
| 190 | + int count = 0; | |
| 191 | + for (int i = 0; i < position; i++) { | |
| 192 | +// count += mSortBean.getCategoryOneArray().get(i).getCategoryTwoArray().size(); | |
| 193 | + if (categoryDarensDatas.getList().get(i).getDarens() != null && categoryDarensDatas.getList().get(i) != null) { | |
| 194 | + count += categoryDarensDatas.getList().get(i).getDarens().size(); | |
| 195 | + | |
| 196 | + } else { | |
| 197 | + count += 0; | |
| 198 | + | |
| 199 | + } | |
| 200 | + } | |
| 201 | + | |
| 202 | + count += position; | |
| 203 | + mIndex = count; | |
| 204 | + fragment.binding.detaiRv.stopScroll(); | |
| 205 | + smoothMoveToPosition(count); | |
| 206 | + | |
| 207 | + ItemHeaderDecoration.setCurrentTag(String.valueOf(targetPosition));//凡是点击左边,将左边点击的位置作为当前的tag | |
| 208 | + } else { | |
| 209 | + if (isMoved) { | |
| 210 | + isMoved = false; | |
| 211 | + } else | |
| 212 | + sortAdapter.setCheckedPosition(position); | |
| 213 | + ItemHeaderDecoration.setCurrentTag(String.valueOf(position));//如果是滑动右边联动左边,则按照右边传过来的位置作为tag | |
| 214 | + | |
| 215 | + } | |
| 216 | + moveToCenter(position); | |
| 217 | + } | |
| 218 | + | |
| 219 | + //将当前选中的item居中 | |
| 220 | + private void moveToCenter(int position) { | |
| 221 | + //将点击的position转换为当前屏幕上可见的item的位置以便于计算距离顶部的高度,从而进行移动居中 | |
| 222 | + View childAt = fragment.binding.sortRv.getChildAt(position - linearLayoutManager.findFirstVisibleItemPosition()); | |
| 223 | + if (childAt != null) { | |
| 224 | + int y = (childAt.getTop() - fragment.binding.sortRv.getHeight() / 2); | |
| 225 | + fragment.binding.sortRv.smoothScrollBy(0, y); | |
| 226 | + } | |
| 227 | + | |
| 228 | + } | |
| 229 | + | |
| 230 | + @Override | |
| 231 | + public void check(int position, boolean isScroll) { | |
| 232 | + setChecked(position, isScroll); | |
| 233 | + } | |
| 234 | + | |
| 235 | + private void smoothMoveToPosition(int n) { | |
| 236 | + int firstItem = gridLayoutManager.findFirstVisibleItemPosition(); | |
| 237 | + int lastItem = gridLayoutManager.findLastVisibleItemPosition(); | |
| 238 | + Log.d("first--->", String.valueOf(firstItem)); | |
| 239 | + Log.d("last--->", String.valueOf(lastItem)); | |
| 240 | + if (n <= firstItem) { | |
| 241 | + fragment.binding.detaiRv.scrollToPosition(n); | |
| 242 | + } else if (n <= lastItem) { | |
| 243 | + Log.d("pos---->", String.valueOf(n) + "VS" + firstItem); | |
| 244 | + int top = fragment.binding.detaiRv.getChildAt(n - firstItem).getTop(); | |
| 245 | + Log.d("top---->", String.valueOf(top)); | |
| 246 | + fragment.binding.detaiRv.scrollBy(0, top); | |
| 247 | + } else { | |
| 248 | + fragment.binding.detaiRv.scrollToPosition(n); | |
| 249 | + move = true; | |
| 250 | + } | |
| 251 | + } | |
| 252 | + | |
| 253 | + | |
| 254 | + private class RecyclerViewListener extends RecyclerView.OnScrollListener { | |
| 255 | + @Override | |
| 256 | + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { | |
| 257 | + super.onScrollStateChanged(recyclerView, newState); | |
| 258 | + if (move && newState == RecyclerView.SCROLL_STATE_IDLE) { | |
| 259 | + move = false; | |
| 260 | + int n = mIndex - gridLayoutManager.findFirstVisibleItemPosition(); | |
| 261 | + Log.d("n---->", String.valueOf(n)); | |
| 262 | + if (0 <= n && n < fragment.binding.detaiRv.getChildCount()) { | |
| 263 | + int top = fragment.binding.detaiRv.getChildAt(n).getTop(); | |
| 264 | + Log.d("top--->", String.valueOf(top)); | |
| 265 | + fragment.binding.detaiRv.smoothScrollBy(0, top); | |
| 266 | + } | |
| 267 | + } | |
| 268 | + } | |
| 269 | + | |
| 270 | + @Override | |
| 271 | + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
| 272 | + super.onScrolled(recyclerView, dx, dy); | |
| 273 | + if (move) { | |
| 274 | + move = false; | |
| 275 | + int n = mIndex - gridLayoutManager.findFirstVisibleItemPosition(); | |
| 276 | + if (0 <= n && n < fragment.binding.detaiRv.getChildCount()) { | |
| 277 | + int top = fragment.binding.detaiRv.getChildAt(n).getTop(); | |
| 278 | + fragment.binding.detaiRv.scrollBy(0, top); | |
| 279 | + } | |
| 280 | + } | |
| 281 | + } | |
| 282 | + } | |
| 283 | + | |
| 284 | + public void updateFollowBtn(String darenId, boolean addDaren) { | |
| 285 | + if (detailAdapter != null && detailAdapter.getList() != null && detailAdapter.getList().size() > 0) { | |
| 286 | + for (RightBean rightBean : detailAdapter.getList()) { | |
| 287 | + if (!TextUtils.isEmpty(rightBean.getId()) && rightBean.getId().equals(darenId)) { | |
| 288 | + RightBean item = new RightBean(TextUtils.isEmpty(rightBean.getName()) ? "" : rightBean.getName()); | |
| 289 | + item.setFans(addDaren); | |
| 290 | + item.setFansCount(addDaren ? rightBean.getFansCount() + 1 : rightBean.getFansCount() - 1); | |
| 291 | + item.setOrderCount(rightBean.getOrderCount()); | |
| 292 | + item.setTitleImage(TextUtils.isEmpty(rightBean.getTitleName()) ? "" : rightBean.getTitleName()); | |
| 293 | + item.setAvatar(TextUtils.isEmpty(rightBean.getAvatar()) ? "" : rightBean.getAvatar()); | |
| 294 | + item.setHeaderImage(TextUtils.isEmpty(rightBean.getHeaderImage()) ? "" : rightBean.getHeaderImage()); | |
| 295 | + item.setId(TextUtils.isEmpty(rightBean.getId()) ? "" : rightBean.getId()); | |
| 296 | + item.setName(TextUtils.isEmpty(rightBean.getName()) ? "" : rightBean.getName()); | |
| 297 | + item.setTag(TextUtils.isEmpty(rightBean.getTag()) ? "" : rightBean.getTag()); | |
| 298 | + item.setTitleName(TextUtils.isEmpty(rightBean.getTitleName()) ? "" : rightBean.getTitleName()); | |
| 299 | + item.setType(rightBean.getType()); | |
| 300 | + detailAdapter.updateItem(item, detailAdapter.getList().indexOf(rightBean)); | |
| 301 | + } | |
| 302 | + } | |
| 303 | + } | |
| 304 | + } | |
| 305 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/DarenCommentView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.View; | |
| 5 | + | |
| 6 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 7 | +import com.cnlive.libs.base.frame.adapter.DataBindingRecyclerAdapter; | |
| 8 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 9 | +import com.cnlive.strike.happychina.R; | |
| 10 | +import com.cnlive.strike.happychina.network.model.GetDarenComment; | |
| 11 | +import com.cnlive.strike.happychina.ui.fragment.CommentsFragment; | |
| 12 | +import com.cnlive.strike.happychina.ui.moudle.CommentsItem; | |
| 13 | +import com.cnlive.strike.happychina.ui.moudle.CommentsPage; | |
| 14 | +import com.cnlive.strike.happychina.ui.moudle.MomentsContentItem; | |
| 15 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 16 | + | |
| 17 | +import java.util.ArrayList; | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * Created by Lynn on 2018/2/28. | |
| 22 | + */ | |
| 23 | + | |
| 24 | +public class DarenCommentView implements MvpView { | |
| 25 | + private CommentsFragment fragment; | |
| 26 | + | |
| 27 | + public DarenCommentView(CommentsFragment fragment) { | |
| 28 | + this.fragment = fragment; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public Context getContext() { | |
| 32 | + return fragment == null ? null : fragment.getActivity(); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void addItems(Context context, GetDarenComment list) { | |
| 36 | + fragment.pageData.setNextPage(list.getNextPage() + ""); | |
| 37 | + fragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 38 | + for (CommentsItem item : changeItem(list)) | |
| 39 | + fragment.pageData.getAdapter().addItem(item); | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void refreshItem(Context context, GetDarenComment list) { | |
| 43 | + fragment.pageData.setNextPage(list.getNextPage() + ""); | |
| 44 | + fragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 45 | + fragment.pageData.getAdapter().updateItems(changeItem(list)); | |
| 46 | + } | |
| 47 | + | |
| 48 | + public CommentsPage pageData() { | |
| 49 | + return fragment.pageData; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public List<CommentsItem> changeItem(GetDarenComment data) { | |
| 53 | + List<CommentsItem> list = new ArrayList<>(); | |
| 54 | + | |
| 55 | + for (GetDarenComment.CommentItem commentItem : data.getCommentItems()) { | |
| 56 | + CommentsItem item = new CommentsItem(); | |
| 57 | + item.setSid(commentItem.getSid()); | |
| 58 | + item.setCommentText(commentItem.getCommentText()); | |
| 59 | + item.setRemarkName(commentItem.getNickName()); | |
| 60 | + item.setImage(commentItem.getImage()); | |
| 61 | + item.setNickName(commentItem.getNickName()); | |
| 62 | + item.setTime(commentItem.getTime()); | |
| 63 | + List<MomentsContentItem> contentItemList = new ArrayList<>(); | |
| 64 | + for (GetDarenComment.CommentItem.Path image : commentItem.getPaths()) { | |
| 65 | + MomentsContentItem item1 = new MomentsContentItem(); | |
| 66 | + item1.setImage(image.getImagePath()); | |
| 67 | + item1.setImageThumbnail(image.getThumbnailPath()); | |
| 68 | + item1.setVideo(false); | |
| 69 | + contentItemList.add(item1); | |
| 70 | + } | |
| 71 | + item.setContents(contentItemList); | |
| 72 | + list.add(item); | |
| 73 | + } | |
| 74 | + return list; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public void showLoadingView() { | |
| 78 | + fragment.binding.emptyView.show(true); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void hideLoadingView() { | |
| 82 | + fragment.binding.emptyView.hide(); | |
| 83 | + fragment.binding.refreshLayout.finishRefresh(); | |
| 84 | + fragment.binding.refreshLayout.finishLoadMore(); | |
| 85 | + } | |
| 86 | + | |
| 87 | + public void init() { | |
| 88 | + fragment.binding.refreshLayout.setEnableLoadMore(false); | |
| 89 | + fragment.binding.refreshLayout.setEnableOverScrollDrag(true); | |
| 90 | + fragment.binding.refreshLayout.setEnableOverScrollBounce(false); | |
| 91 | + fragment.binding.refreshLayout.setEnableAutoLoadMore(false); | |
| 92 | + | |
| 93 | + fragment.pageData.getAdapter().setItemClickListener(new DataBindingRecyclerAdapter.OnItemClickListener<CommentsItem>() { | |
| 94 | + @Override | |
| 95 | + public void onItemClick(int id, CommentsItem item) { | |
| 96 | + ARouter.getInstance().build("/chat/UserInfoActivity") | |
| 97 | + .withString("rNickName", item.getNickName()) | |
| 98 | + .withString("rImage", item.getImage()) | |
| 99 | + .withString("rUserId", item.getSid()) | |
| 100 | + .navigation(); | |
| 101 | + } | |
| 102 | + }); | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void showEmptyView() { | |
| 106 | + fragment.pageData.getAdapter().removeAllItems(); | |
| 107 | + if (fragment.binding.emptyView != null) | |
| 108 | + fragment.binding.emptyView.show(getContext().getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong); | |
| 109 | + } | |
| 110 | + | |
| 111 | + public void showRetryView(int state, View.OnClickListener listener) { | |
| 112 | + String titleText = ""; | |
| 113 | + String detailText = ""; | |
| 114 | + if (state == -3) { | |
| 115 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 116 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 117 | + } else { | |
| 118 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 119 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 120 | + } | |
| 121 | + if (fragment.binding.emptyView != null) | |
| 122 | + fragment.binding.emptyView.show(false, titleText, detailText, "重试", R.drawable.wufalianjie, listener); | |
| 123 | + } | |
| 124 | + | |
| 125 | +// public void showFailedToast(int state) { | |
| 126 | +// String msg = ""; | |
| 127 | +// if (state == -3) { | |
| 128 | +// msg = getContext().getString(R.string.msg_failed_network_toast); | |
| 129 | +// } else { | |
| 130 | +// msg = getContext().getString(R.string.msg_failed_other_toast); | |
| 131 | +// } | |
| 132 | +// if (getContext() != null) | |
| 133 | +// AlertUtil.showFailedToast(getContext(), msg); | |
| 134 | +// } | |
| 135 | + | |
| 136 | + public void showFailedToast(String message) { | |
| 137 | + if (getContext() != null) | |
| 138 | + AlertUtil.showFailedToast(getContext(), message); | |
| 139 | + } | |
| 140 | + | |
| 141 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/DarenDetailView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Context; | |
| 5 | +import android.content.Intent; | |
| 6 | +import android.os.Handler; | |
| 7 | +import android.support.v7.widget.LinearLayoutManager; | |
| 8 | +import android.text.TextUtils; | |
| 9 | +import android.view.View; | |
| 10 | +import android.view.ViewTreeObserver; | |
| 11 | +import android.widget.FrameLayout; | |
| 12 | +import android.widget.RelativeLayout; | |
| 13 | + | |
| 14 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 15 | +import com.bumptech.glide.request.RequestOptions; | |
| 16 | +import com.cnlive.libs.base.application.AppConfig; | |
| 17 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 18 | +import com.cnlive.libs.base.util.NetworkUtil; | |
| 19 | +import com.cnlive.strike.happychina.R; | |
| 20 | +import com.cnlive.strike.happychina.network.model.GetDarenHomeData; | |
| 21 | +import com.cnlive.strike.happychina.receiver.DarenDetailReceiver; | |
| 22 | +import com.cnlive.strike.happychina.ui.adapter.PropagandaItemAdapter; | |
| 23 | +import com.cnlive.strike.happychina.ui.fragment.DarenDetailFragment; | |
| 24 | +import com.cnlive.strike.happychina.ui.moudle.DarenDetailPage; | |
| 25 | +import com.cnlive.strike.happychina.ui.moudle.MomentsContentItem; | |
| 26 | +import com.cnlive.strike.happychina.ui.moudle.MomentsItem; | |
| 27 | +import com.cnlive.strike.happychina.ui.widget.ScrollListenerNestedScrollView; | |
| 28 | +import com.cnlive.strike.happychina.ui.widget.ViewPagerIndicator; | |
| 29 | +import com.cnlive.strike.happychina.utils.DateUtils; | |
| 30 | +import com.cnlive.strike.happychina.utils.DeviceUtils; | |
| 31 | +import com.cnlive.strike.happychina.utils.ScreenUtils; | |
| 32 | +import com.cnlive.strike.util.GlideUtil; | |
| 33 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 34 | + | |
| 35 | +import java.text.DecimalFormat; | |
| 36 | +import java.util.ArrayList; | |
| 37 | +import java.util.List; | |
| 38 | + | |
| 39 | +import jp.wasabeef.glide.transformations.BlurTransformation; | |
| 40 | + | |
| 41 | +/** | |
| 42 | + * Created by xiansong on 2018/1/26. | |
| 43 | + */ | |
| 44 | + | |
| 45 | +public class DarenDetailView implements MvpView { | |
| 46 | + | |
| 47 | + private DarenDetailFragment fragment; | |
| 48 | + private boolean isExpanded; | |
| 49 | + public boolean isFollowed; | |
| 50 | + public boolean isFirst; | |
| 51 | + private ViewPagerIndicator viewPagerIndicator; | |
| 52 | + private GetDarenHomeData tempData;//更新关注数量用 | |
| 53 | + | |
| 54 | + public GetDarenHomeData loadList; | |
| 55 | + public boolean shouldItemUpdate = false; | |
| 56 | + | |
| 57 | + public DarenDetailView(DarenDetailFragment fragment) { | |
| 58 | + this.fragment = fragment; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public Activity getContext() { | |
| 62 | + return fragment == null ? null : fragment.getActivity(); | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void init(View.OnClickListener listener) { | |
| 66 | + fragment.binding.setOnSendView(v -> { | |
| 67 | + ARouter.getInstance().build("/chat/ChatActivity") | |
| 68 | + .withString("targetId", fragment.pageData.getDarenId()) | |
| 69 | + .withString("chatType", "private") | |
| 70 | + .withString("conversationName", fragment.pageData.getName()) | |
| 71 | + .withFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | |
| 72 | + .navigation(); | |
| 73 | + }); | |
| 74 | + fragment.binding.setOnAddFriends(v -> { | |
| 75 | +// if (fragment.pageData != null && fragment.pageData.getSid() != null) | |
| 76 | +// FriendVerificationActivity.startActivity(getContext(), fragment.pageData.getSid()); | |
| 77 | + }); | |
| 78 | + | |
| 79 | + fragment.binding.setOnAddFollow(listener); | |
| 80 | + fragment.binding.collapsingTopbarLayout.setTitleEnabled(false); | |
| 81 | + fragment.binding.expand.setOnClickListener(view -> onExpandClick()); | |
| 82 | + | |
| 83 | + fragment.binding.refreshLayout.setEnableLoadMore(false); | |
| 84 | + fragment.binding.refreshLayout.setEnableOverScrollDrag(true); | |
| 85 | + fragment.binding.refreshLayout.setEnableOverScrollBounce(false); | |
| 86 | + fragment.binding.refreshLayout.setEnableAutoLoadMore(false); | |
| 87 | + if (NetworkUtil.isConnectInternet(getContext())) { | |
| 88 | + fragment.binding.refreshLayout.autoRefresh(); | |
| 89 | + } | |
| 90 | + fragment.binding.refreshLayout.setEnableFooterFollowWhenLoadFinished(true); | |
| 91 | + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); | |
| 92 | + layoutManager.setSmoothScrollbarEnabled(false); | |
| 93 | + layoutManager.setAutoMeasureEnabled(true); | |
| 94 | + | |
| 95 | + fragment.binding.recyclerView.setNestedScrollingEnabled(false); | |
| 96 | +// fragment.binding.recyclerView.setHasFixedSize(true); | |
| 97 | + fragment.binding.recyclerView.setLayoutManager(layoutManager); | |
| 98 | + | |
| 99 | + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); | |
| 100 | + | |
| 101 | + fragment.binding.scrollView.setTestY(fragment.binding.scrollView.getTop()); | |
| 102 | + fragment.binding.scrollView.setOnScrollStateChangedListener(new ScrollListenerNestedScrollView.ScrollViewListener() { | |
| 103 | + @Override | |
| 104 | + public void onScrollChanged(ScrollListenerNestedScrollView.ScrollType scrollType) { | |
| 105 | + if (shouldItemUpdate && scrollType.equals(ScrollListenerNestedScrollView.ScrollType.IDLE)) { | |
| 106 | + refreshItems(getContext(), loadList); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + }); | |
| 110 | + | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void changeFollowBtn(boolean isFollowed) { | |
| 114 | + if (!isFollowed) { | |
| 115 | + fragment.binding.addFollowImage.setImageResource(R.drawable.drd_fuceng_yiguanzhu); | |
| 116 | + fragment.binding.addFollow.setText("关注"); | |
| 117 | + fragment.binding.addFollow.setTextColor(getContext().getResources().getColor(R.color.white)); | |
| 118 | + } else { | |
| 119 | + fragment.binding.addFollowImage.setImageResource(R.drawable.drd_fuceng_jiaguanzhu); | |
| 120 | + fragment.binding.addFollow.setText("已关注"); | |
| 121 | + fragment.binding.addFollow.setTextColor(getContext().getResources().getColor(R.color.color_00d636)); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void showLoading() { | |
| 126 | + fragment.tipDialog.show(); | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void hideLoading() { | |
| 130 | + if (fragment.tipDialog != null) | |
| 131 | + fragment.tipDialog.dismiss(); | |
| 132 | + } | |
| 133 | + | |
| 134 | +// public void showErrorToast(int state) { | |
| 135 | +// String msg = ""; | |
| 136 | +// if (state == -3) | |
| 137 | +// msg = getContext().getString(R.string.msg_failed_network_toast); | |
| 138 | +// else if (state == 402) { | |
| 139 | +// msg = getContext().getString(R.string.msg_failed_self_toast); | |
| 140 | +// } else msg = getContext().getString(R.string.msg_failed_other_toast); | |
| 141 | +// if (getContext() != null) | |
| 142 | +// AlertUtil.showFailedToast(getContext(), msg); | |
| 143 | +// } | |
| 144 | + | |
| 145 | + public void showErrorToast(String message) { | |
| 146 | + if (getContext() != null) | |
| 147 | + AlertUtil.showFailedToast(getContext(), message); | |
| 148 | + } | |
| 149 | + | |
| 150 | + public void showSuccess(String msg) { | |
| 151 | + if (getContext() != null) | |
| 152 | + AlertUtil.showSuccessToast(getContext(), msg); | |
| 153 | + } | |
| 154 | + | |
| 155 | + //显示与隐藏展开按钮 | |
| 156 | + public void showExpandBtn(int categoryItemSize) { | |
| 157 | + ViewTreeObserver vto = fragment.binding.categoryTagItemLayout.getViewTreeObserver(); | |
| 158 | + vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | |
| 159 | + @Override | |
| 160 | + public void onGlobalLayout() { | |
| 161 | + if (fragment.binding.categoryTagItemLayout.getMeasuredChildCount() > 0) { | |
| 162 | + fragment.binding.categoryTagItemLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); | |
| 163 | + } | |
| 164 | + if (categoryItemSize > fragment.binding.categoryTagItemLayout.getMeasuredChildCount()) | |
| 165 | + fragment.binding.expand.setVisibility(View.VISIBLE); | |
| 166 | + } | |
| 167 | + }); | |
| 168 | + } | |
| 169 | + | |
| 170 | + private void onExpandClick() { | |
| 171 | + if (isExpanded) { | |
| 172 | + fragment.binding.categoryTagItemLayout.setMaxLines(1); | |
| 173 | + fragment.binding.expand.setImageResource(R.drawable.ic_expand); | |
| 174 | + isExpanded = false; | |
| 175 | + } else { | |
| 176 | + fragment.binding.categoryTagItemLayout.setMaxLines(Integer.MAX_VALUE); | |
| 177 | + fragment.binding.expand.setImageResource(R.drawable.ic_pullback); | |
| 178 | + isExpanded = true; | |
| 179 | + } | |
| 180 | + } | |
| 181 | + | |
| 182 | + public void initPageInfo(GetDarenHomeData data) { | |
| 183 | + if (data == null) | |
| 184 | + return; | |
| 185 | + tempData = data; | |
| 186 | + DarenDetailPage pageData = fragment.pageData; | |
| 187 | + pageData.setDarenId(data.getDarenId()); | |
| 188 | + pageData.setSid(data.getSid()); | |
| 189 | + pageData.setImage(data.getImage()); | |
| 190 | + pageData.setName(data.getShopName()); | |
| 191 | + pageData.setGrade(data.getGrade()); | |
| 192 | + pageData.setCategory(data.getCategory()); | |
| 193 | + pageData.setFan(data.isFan()); | |
| 194 | + pageData.setOnline(data.isOnline()); | |
| 195 | + List<GetDarenHomeData.CategoryContent.CategoryItemContent> itemList = new ArrayList<>(); | |
| 196 | + for (GetDarenHomeData.CategoryContent item : data.getCategory()) | |
| 197 | + itemList.addAll(item.getCategoryItems()); | |
| 198 | + pageData.setCategoryItem(itemList); | |
| 199 | + pageData.setFans(data.getFansNum()); | |
| 200 | + pageData.setFocusCount("1");//关注人数 | |
| 201 | + pageData.setLocation(data.getAddress()); | |
| 202 | + pageData.setOrderCount(data.getOrderCount()); | |
| 203 | + pageData.setCommentCount(data.getCommentCount()); | |
| 204 | + | |
| 205 | + List<GetDarenHomeData.Propaganda> propagandaList = new ArrayList<>(); | |
| 206 | + propagandaList.addAll(data.getPropagandas()); | |
| 207 | + pageData.setPropagandaList(propagandaList); | |
| 208 | + | |
| 209 | + for (GetDarenHomeData.DarenContent item : data.getContent()) | |
| 210 | + item.setTags(data.getCategory()); | |
| 211 | + DarenDetailReceiver.post(new DarenDetailReceiver.DarenDetailResult(pageData.getCategoryItem().size(), pageData.getFans(), pageData.isFan())); | |
| 212 | + | |
| 213 | + if (!isFirst) { | |
| 214 | + RequestOptions options = new RequestOptions(); | |
| 215 | + options.transform(new BlurTransformation(25, 4)); | |
| 216 | + GlideUtil.into(fragment.binding.blurBackground, pageData.getImage(), options); | |
| 217 | + isFirst = true; | |
| 218 | + } | |
| 219 | + | |
| 220 | + initPropagandaItemAdapter(); | |
| 221 | + } | |
| 222 | + | |
| 223 | + PropagandaItemAdapter propagandaItemAdapter; | |
| 224 | + | |
| 225 | + private void initPropagandaItemAdapter() { | |
| 226 | + | |
| 227 | + int width = DeviceUtils.getScreenWidth(getContext()); | |
| 228 | + | |
| 229 | + float num = (float) 90 / 368; | |
| 230 | + DecimalFormat decimalFormat = new DecimalFormat("0.0000"); | |
| 231 | + int height = (int) (Float.parseFloat(decimalFormat.format(num)) * width); | |
| 232 | + if (pageData().getPropagandaList().size() > 0) { | |
| 233 | + fragment.binding.viewpager.setAdapter(propagandaItemAdapter = new PropagandaItemAdapter(getContext(), pageData().getPropagandaList())); | |
| 234 | + RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); | |
| 235 | + params.bottomMargin = ScreenUtils.dp2px(getContext(), 5); | |
| 236 | + params.topMargin = ScreenUtils.dp2px(getContext(), 5); | |
| 237 | + params.leftMargin = ScreenUtils.dp2px(getContext(), 5); | |
| 238 | + params.rightMargin = ScreenUtils.dp2px(getContext(), 5); | |
| 239 | + fragment.binding.viewpager.setLayoutParams(params); | |
| 240 | + if (pageData().getPropagandaList().size() > 1) { | |
| 241 | + fragment.binding.viewpager.setCurrentItem(500 - 500 % pageData().getPropagandaList().size()); | |
| 242 | + } | |
| 243 | + if (viewPagerIndicator == null && pageData().getPropagandaList().size() > 1) | |
| 244 | + fragment.binding.viewpager.addOnPageChangeListener(viewPagerIndicator = new ViewPagerIndicator(getContext(), fragment.binding.indicatorLayout, pageData().getPropagandaList().size())); | |
| 245 | + } | |
| 246 | + } | |
| 247 | + | |
| 248 | + public void addItems(Context context, GetDarenHomeData list) { | |
| 249 | + fragment.pageData.setNextPage(list.getNextPage()); | |
| 250 | + fragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 251 | + for (MomentsItem item : changeList(context, list)) | |
| 252 | + fragment.pageData.getAdapter().addItem(item); | |
| 253 | + } | |
| 254 | + | |
| 255 | + public void refreshItems(Context context, GetDarenHomeData list) { | |
| 256 | + | |
| 257 | + if (list == null || fragment.pageData == null) | |
| 258 | + return; | |
| 259 | + | |
| 260 | + if (fragment.binding.scrollView.getScrollType().equals(ScrollListenerNestedScrollView.ScrollType.IDLE)) { | |
| 261 | + | |
| 262 | + initPageInfo(list); | |
| 263 | + fragment.pageData.setNextPage(list.getNextPage()); | |
| 264 | + fragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 265 | + fragment.pageData.getAdapter().removeAllItems(); | |
| 266 | + for (MomentsItem item : changeList(context, list)) | |
| 267 | + fragment.pageData.getAdapter().addItem(item); | |
| 268 | + shouldItemUpdate = false; | |
| 269 | + } | |
| 270 | + } | |
| 271 | + | |
| 272 | + private List<MomentsItem> changeList(Context context, GetDarenHomeData data) { | |
| 273 | + List<MomentsItem> list = new ArrayList<>(); | |
| 274 | + for (GetDarenHomeData.DarenContent content : data.getContent()) { | |
| 275 | + MomentsItem item = new MomentsItem(); | |
| 276 | + item.setDarenId(content.getDarenId()); | |
| 277 | + item.setItemId(content.getItemId()); | |
| 278 | + item.setName(data.getShopName()); | |
| 279 | + item.setSid(data.getSid()); | |
| 280 | + item.setImage(data.getImage()); | |
| 281 | + String od = content.getOptionDesc(); | |
| 282 | + item.setOptionDesc(TextUtils.isEmpty(od) ? "" : String.format("配送方式: %s", od)); | |
| 283 | + item.setOptionId(content.getOptionId()); | |
| 284 | + item.setMessage(content.getText()); | |
| 285 | + item.setLocation(content.getAddress()); | |
| 286 | + item.setShowTime(DateUtils.getDateDiff(content.getTs())); | |
| 287 | + item.setCategory(content.getTags()); | |
| 288 | + List<MomentsContentItem> list2 = new ArrayList<>(); | |
| 289 | + if (content.getType() == 1) | |
| 290 | + for (GetDarenHomeData.DarenContent.Image image : content.getImages()) { | |
| 291 | + MomentsContentItem item2 = new MomentsContentItem(); | |
| 292 | + item2.setImage(image.getImagePath()); | |
| 293 | + item2.setImageThumbnail(image.getThumbnailPath()); | |
| 294 | + item2.setImageThumbnailsFirst(image.getThumbnailsFirstPic()); | |
| 295 | + item2.setHeight(image.getHeight()); | |
| 296 | + item2.setWidth(image.getWidth()); | |
| 297 | + item2.setVideo(false); | |
| 298 | + list2.add(item2); | |
| 299 | + } | |
| 300 | + else if (content.getType() == 2) { | |
| 301 | + MomentsContentItem item2 = new MomentsContentItem(); | |
| 302 | + if (content != null && content.getVideo() != null) { | |
| 303 | + item2.setImage(content.getVideo().getImageUrl()); | |
| 304 | + item2.setImageThumbnail(content.getVideo().getImageUrl()); | |
| 305 | + item2.setImageThumbnailsFirst(content.getVideo().getImageUrl()); | |
| 306 | + item2.setWidth(content.getVideo().getWidth()); | |
| 307 | + item2.setHeight(content.getVideo().getHeight()); | |
| 308 | + item2.setVideo(content.getVideo().getVideoId()); | |
| 309 | + item2.setVideoPath(content.getVideo().getVideoPlayUrl()); | |
| 310 | + } | |
| 311 | + item2.setVideo(true); | |
| 312 | + list2.add(item2); | |
| 313 | + } | |
| 314 | + | |
| 315 | + item.setContents(list2); | |
| 316 | + | |
| 317 | + list.add(item); | |
| 318 | + } | |
| 319 | + return list; | |
| 320 | + } | |
| 321 | + | |
| 322 | + public DarenDetailPage pageData() { | |
| 323 | + return fragment.pageData; | |
| 324 | + } | |
| 325 | + | |
| 326 | + public void showLoadingView() { | |
| 327 | + fragment.binding.emptyView.show(true); | |
| 328 | + } | |
| 329 | + | |
| 330 | + public void hideLoadingView() { | |
| 331 | + fragment.binding.emptyView.hide(); | |
| 332 | + fragment.binding.refreshLayout.finishLoadMore(); | |
| 333 | + fragment.binding.refreshLayout.finishRefresh(); | |
| 334 | + } | |
| 335 | + | |
| 336 | + public void showEmptyView() { | |
| 337 | + fragment.pageData.getAdapter().removeAllItems(); | |
| 338 | + if (fragment.binding.emptyView != null) | |
| 339 | + fragment.binding.emptyView.show(getContext().getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong); | |
| 340 | + } | |
| 341 | + | |
| 342 | + public void showRetryView(int state, View.OnClickListener listener) { | |
| 343 | + String titleText = ""; | |
| 344 | + String detailText = ""; | |
| 345 | + if (state == -3) { | |
| 346 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 347 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 348 | + } else if (state == 402) { | |
| 349 | + titleText = getContext().getString(R.string.msg_failed_noresponse); | |
| 350 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 351 | + } else { | |
| 352 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 353 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 354 | + } | |
| 355 | + if (fragment.binding.emptyView != null) | |
| 356 | + fragment.binding.emptyView.show(false, titleText, detailText, "重试", R.drawable.wufalianjie, listener); | |
| 357 | + } | |
| 358 | + | |
| 359 | + | |
| 360 | + public void showFailedToast(String message) { | |
| 361 | + if (getContext() != null) | |
| 362 | + AlertUtil.showFailedToast(getContext(), message); | |
| 363 | + } | |
| 364 | + | |
| 365 | + private boolean isAutoPlay = true; | |
| 366 | + // 默认自动滚动任务延时两秒执行 | |
| 367 | + private int delayTime = 2000; | |
| 368 | + // 定义处理自动滚动的handler | |
| 369 | + private Handler handler = new Handler(); | |
| 370 | + // 当前ViewPager展示页 | |
| 371 | + private int currentItem; | |
| 372 | + private final Runnable task = new Runnable() { | |
| 373 | + @Override | |
| 374 | + public void run() { | |
| 375 | + if (isAutoPlay) { | |
| 376 | + // 自动滚动逻辑处理 | |
| 377 | + currentItem = fragment.binding.viewpager.getCurrentItem(); | |
| 378 | + currentItem++; | |
| 379 | + if (propagandaItemAdapter != null && currentItem == propagandaItemAdapter.getCount() - 1) { | |
| 380 | + currentItem = 0; | |
| 381 | + fragment.binding.viewpager.setCurrentItem(currentItem); | |
| 382 | + handler.postDelayed(this, delayTime); | |
| 383 | + } else { | |
| 384 | + fragment.binding.viewpager.setCurrentItem(currentItem); | |
| 385 | + handler.postDelayed(this, delayTime); | |
| 386 | + } | |
| 387 | + } else { | |
| 388 | + handler.postDelayed(this, delayTime); | |
| 389 | + } | |
| 390 | + } | |
| 391 | + }; | |
| 392 | + | |
| 393 | + /** | |
| 394 | + * 开启自动滚动的方法 | |
| 395 | + */ | |
| 396 | + public void startAutoPlay() { | |
| 397 | + isAutoPlay = true; | |
| 398 | + handler.removeCallbacks(task); | |
| 399 | + handler.postDelayed(task, delayTime); | |
| 400 | + } | |
| 401 | + | |
| 402 | + /** | |
| 403 | + * 暂停自动滚动 | |
| 404 | + */ | |
| 405 | + public void pauseAutoPlay() { | |
| 406 | + isAutoPlay = false; | |
| 407 | + handler.removeCallbacks(task); | |
| 408 | + } | |
| 409 | + | |
| 410 | + public void updateFansNum(boolean add) { | |
| 411 | + pageData().setFans(tempData.getUpdateFansNum(add)); | |
| 412 | + } | |
| 413 | + | |
| 414 | + public void showShareBtn() { | |
| 415 | + fragment.binding.share.setVisibility(View.VISIBLE); | |
| 416 | + } | |
| 417 | + | |
| 418 | + public void onShareFailure(String s) { | |
| 419 | + if (getContext() != null) AlertUtil.showDeftToast(getContext(), s); | |
| 420 | + } | |
| 421 | + | |
| 422 | + public void showShareView(String link) { | |
| 423 | + String url = TextUtils.isEmpty(link) ? AppConfig.getShareDownload() : link.concat("?appId=" + AppConfig.getAppId()).concat("&darenId=" + fragment.darenId).concat("&sid=" + AppConfig.getSid()); | |
| 424 | + String name = fragment == null || fragment.pageData == null ? "" : fragment.pageData.getName(); | |
| 425 | + String subTitle = TextUtils.isEmpty(name) ? "中国网++ 让生活更美好!" : "推荐\"" + fragment.pageData.getName() + "\"的主页"; | |
| 426 | + | |
| 427 | + ARouter.getInstance().build("/share/ShareActivity") | |
| 428 | + .withString("title", "快来加入中国网++,优享美好生活!") | |
| 429 | + .withString("subTitle", subTitle) | |
| 430 | + .withString("shareUrl", url) | |
| 431 | + .withString("shareUrlImg", AppConfig.getShareIcon()) | |
| 432 | + .withBoolean("isShowWjjLife", true) | |
| 433 | + .withBoolean("isShowWjjFriend", false) | |
| 434 | + .withBoolean("isShowOther", true) | |
| 435 | + .navigation(); | |
| 436 | + } | |
| 437 | + | |
| 438 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/DarenFansView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.View; | |
| 5 | + | |
| 6 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 7 | +import com.cnlive.libs.base.frame.adapter.DataBindingRecyclerAdapter; | |
| 8 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 9 | +import com.cnlive.strike.happychina.R; | |
| 10 | +import com.cnlive.strike.happychina.network.model.GetDarensData; | |
| 11 | +import com.cnlive.strike.happychina.ui.fragment.DarenFansFragment; | |
| 12 | +import com.cnlive.strike.happychina.ui.moudle.DarenFansItem; | |
| 13 | +import com.cnlive.strike.happychina.ui.moudle.DarenFansPage; | |
| 14 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 15 | + | |
| 16 | +import java.util.ArrayList; | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * Created by Lynn on 2018/2/28. | |
| 21 | + */ | |
| 22 | + | |
| 23 | +public class DarenFansView implements MvpView { | |
| 24 | + | |
| 25 | + DarenFansFragment fansFragment; | |
| 26 | + | |
| 27 | + public DarenFansView(DarenFansFragment fansFragment) { | |
| 28 | + this.fansFragment = fansFragment; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public Context getContext() { | |
| 32 | + return fansFragment == null ? null : fansFragment.getActivity(); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void init() { | |
| 36 | + fansFragment.binding.refreshLayout.setEnableLoadMore(false); | |
| 37 | + fansFragment.binding.refreshLayout.setEnableOverScrollDrag(true); | |
| 38 | + fansFragment.binding.refreshLayout.setEnableOverScrollBounce(false); | |
| 39 | + fansFragment.binding.refreshLayout.setEnableAutoLoadMore(false); | |
| 40 | + | |
| 41 | + fansFragment.pageData.getAdapter().setItemClickListener(new DataBindingRecyclerAdapter.OnItemClickListener<DarenFansItem>() { | |
| 42 | + @Override | |
| 43 | + public void onItemClick(int id, DarenFansItem item) { | |
| 44 | + if (id == R.id.item_fans_layout){ | |
| 45 | + ARouter.getInstance().build("/chat/UserInfoActivity") | |
| 46 | + .withString("rNickName", item.getNickName()) | |
| 47 | + .withString("rImage", item.getImage()) | |
| 48 | + .withString("rUserId", item.getUserId()) | |
| 49 | + .navigation(); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + }); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void addItems(Context context, GetDarensData list) { | |
| 56 | + fansFragment.pageData.setNextPage(list.getNextPage() + ""); | |
| 57 | + fansFragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 58 | + for (DarenFansItem item : changeItem(list)) | |
| 59 | + fansFragment.pageData.getAdapter().addItem(item); | |
| 60 | + fansFragment.binding.fansCount.setText(fansFragment.pageData.getAdapter().getList().size() + "位粉丝"); | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void refreshItem(Context context, GetDarensData list) { | |
| 64 | + fansFragment.pageData.setNextPage(list.getNextPage() + ""); | |
| 65 | + fansFragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 66 | + fansFragment.pageData.getAdapter().updateItems(changeItem(list)); | |
| 67 | + fansFragment.binding.fansCount.setText(fansFragment.pageData.getAdapter().getList().size() + "位粉丝"); | |
| 68 | + } | |
| 69 | + | |
| 70 | + public DarenFansPage pageData() { | |
| 71 | + return fansFragment.pageData; | |
| 72 | + } | |
| 73 | + | |
| 74 | + private List<DarenFansItem> changeItem(GetDarensData data) { | |
| 75 | + List<DarenFansItem> list = new ArrayList<>(); | |
| 76 | + for (GetDarensData.DarensFans fansItem : data.getFans()) { | |
| 77 | + DarenFansItem item = new DarenFansItem(); | |
| 78 | + item.setUserId(fansItem.getUserId()); | |
| 79 | + item.setImage(fansItem.getImage()); | |
| 80 | + item.setNickName(fansItem.getNickName()); | |
| 81 | + item.setRemarkName(fansItem.getNickName()); | |
| 82 | + list.add(item); | |
| 83 | + } | |
| 84 | + return list; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public void showLoadingView() { | |
| 88 | + fansFragment.binding.emptyView.show(true); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void hideLoadingView() { | |
| 92 | + fansFragment.binding.emptyView.hide(); | |
| 93 | + fansFragment.binding.refreshLayout.finishRefresh(); | |
| 94 | + fansFragment.binding.refreshLayout.finishLoadMore(); | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void showEmptyView() { | |
| 98 | + fansFragment.pageData.getAdapter().removeAllItems(); | |
| 99 | + if (fansFragment.binding.emptyView != null) | |
| 100 | + fansFragment.binding.emptyView.show(getContext().getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong); | |
| 101 | + } | |
| 102 | + | |
| 103 | + public void showRetryView(int state, View.OnClickListener listener) { | |
| 104 | + String titleText = ""; | |
| 105 | + String detailText = ""; | |
| 106 | + if (state == -3) { | |
| 107 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 108 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 109 | + } else { | |
| 110 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 111 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 112 | + } | |
| 113 | + if (fansFragment.binding.emptyView != null) | |
| 114 | + fansFragment.binding.emptyView.show(false, titleText, detailText, "重试", R.drawable.wufalianjie, listener); | |
| 115 | + | |
| 116 | + } | |
| 117 | + | |
| 118 | +// public void showFailedToast(int state) { | |
| 119 | +// String msg = ""; | |
| 120 | +// if (state == -3) | |
| 121 | +// msg = getContext().getString(R.string.msg_failed_network_toast); | |
| 122 | +// else msg = getContext().getString(R.string.msg_failed_other_toast); | |
| 123 | +// AlertUtil.showDeftToast(getContext(), msg); | |
| 124 | +// } | |
| 125 | + | |
| 126 | + public void showFailedToast(String message) { | |
| 127 | + if (getContext() != null) | |
| 128 | + AlertUtil.showFailedToast(getContext(), message); | |
| 129 | + } | |
| 130 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/FollowDarensView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.View; | |
| 5 | + | |
| 6 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 7 | +import com.cnlive.strike.happychina.R; | |
| 8 | +import com.cnlive.strike.happychina.network.model.GetDarensData; | |
| 9 | +import com.cnlive.strike.happychina.ui.fragment.FollowDarensFragment; | |
| 10 | +import com.cnlive.strike.happychina.ui.moudle.FollowDarensItem; | |
| 11 | +import com.cnlive.strike.happychina.ui.moudle.FollowDarensPage; | |
| 12 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 13 | + | |
| 14 | +import java.util.ArrayList; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * Created by cnlive201803 on 2018/5/17. | |
| 19 | + */ | |
| 20 | + | |
| 21 | +public class FollowDarensView implements MvpView { | |
| 22 | + | |
| 23 | + private FollowDarensFragment fragment; | |
| 24 | + | |
| 25 | + public FollowDarensView(FollowDarensFragment followDarensFragment) { | |
| 26 | + this.fragment = followDarensFragment; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public Context getContext() { | |
| 30 | + return fragment == null ? null : fragment.getActivity(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + public void initView() { | |
| 34 | + fragment.binding.refreshLayout.setEnableLoadMore(false); | |
| 35 | + fragment.binding.refreshLayout.setEnableOverScrollDrag(true); | |
| 36 | + fragment.binding.refreshLayout.setEnableOverScrollBounce(false); | |
| 37 | + fragment.binding.refreshLayout.setEnableAutoLoadMore(false); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void addItems(GetDarensData darensData) { | |
| 41 | + fragment.pageData.setNextPage(darensData.getNextPage() + ""); | |
| 42 | + fragment.binding.refreshLayout.setEnableLoadMore(darensData.getNextPage() > 1); | |
| 43 | + for (FollowDarensItem item : changeItem(darensData)) | |
| 44 | + fragment.pageData.getAdapter().addItem(item); | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void refreshItem(GetDarensData list) { | |
| 48 | + fragment.pageData.setNextPage(list.getNextPage() + ""); | |
| 49 | + fragment.binding.refreshLayout.setEnableLoadMore(list.getNextPage() > 1); | |
| 50 | + fragment.pageData.getAdapter().updateItems(changeItem(list)); | |
| 51 | + } | |
| 52 | + | |
| 53 | + public List<FollowDarensItem> changeItem(GetDarensData darensData) { | |
| 54 | + List<FollowDarensItem> list = new ArrayList<>(); | |
| 55 | + for (GetDarensData.DarensFans darensFans : darensData.getFans()) { | |
| 56 | + FollowDarensItem item = new FollowDarensItem(); | |
| 57 | + item.setDarenAvatar(darensFans.getImage()); | |
| 58 | + item.setDarenId(darensFans.getUserId()); | |
| 59 | + item.setDarenName(darensFans.getNickName()); | |
| 60 | + item.setFollowed(fragment.isFollowed); | |
| 61 | + list.add(item); | |
| 62 | + } | |
| 63 | + return list; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void removeItem(FollowDarensItem item) { | |
| 67 | + fragment.pageData.getAdapter().getList().remove(item); | |
| 68 | + fragment.pageData.getAdapter().notifyDataSetChanged(); | |
| 69 | + | |
| 70 | + if (fragment.pageData.getAdapter().getList().size() == 0 || fragment.pageData.getAdapter().getList() == null) { | |
| 71 | + showEmptyView(); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + public FollowDarensPage pageData() { | |
| 76 | + return fragment.pageData; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public void showLoadingView() { | |
| 80 | + fragment.binding.emptyView.show(true); | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void hideLoadingView() { | |
| 84 | + fragment.binding.emptyView.hide(); | |
| 85 | + fragment.binding.refreshLayout.finishRefresh(); | |
| 86 | + fragment.binding.refreshLayout.finishLoadMore(); | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void showEmptyView() { | |
| 90 | + fragment.pageData.getAdapter().removeAllItems(); | |
| 91 | + if (fragment.binding.emptyView != null) { | |
| 92 | + fragment.binding.emptyView.show(getContext().getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void showRetryView(int state, View.OnClickListener listener) { | |
| 97 | + String titleText = ""; | |
| 98 | + String detailText = ""; | |
| 99 | + if (state == -3) { | |
| 100 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 101 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 102 | + } else { | |
| 103 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 104 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 105 | + } | |
| 106 | + if (fragment.binding.emptyView != null) | |
| 107 | + fragment.binding.emptyView.show(false, titleText, detailText, "重试", R.drawable.wufalianjie, listener); | |
| 108 | + | |
| 109 | + } | |
| 110 | + | |
| 111 | + public void showFailedToast(String message) { | |
| 112 | + if (getContext() != null) | |
| 113 | + AlertUtil.showFailedToast(getContext(), message); | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void showSuccessToast(String message) { | |
| 117 | + if (getContext() != null) | |
| 118 | + AlertUtil.showSuccessToast(getContext(), message); | |
| 119 | + } | |
| 120 | + | |
| 121 | + | |
| 122 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/frame/view/PortalView.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.graphics.Color; | |
| 5 | +import android.support.v7.widget.LinearLayoutManager; | |
| 6 | +import android.support.v7.widget.RecyclerView; | |
| 7 | +import android.view.View; | |
| 8 | + | |
| 9 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 10 | +import com.cnlive.strike.happychina.R; | |
| 11 | +import com.cnlive.strike.happychina.network.model.UnFollowList; | |
| 12 | +import com.cnlive.strike.happychina.ui.adapter.PortalListAdapter; | |
| 13 | +import com.cnlive.strike.happychina.ui.fragment.PortalFragment; | |
| 14 | +import com.cnlive.strike.happychina.ui.moudle.BasePortalItem; | |
| 15 | +import com.cnlive.strike.happychina.ui.moudle.PortalNotFollow; | |
| 16 | +import com.cnlive.strike.happychina.ui.widget.ScrollListenerNestedScrollView; | |
| 17 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 18 | +import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener; | |
| 19 | + | |
| 20 | +import java.util.List; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * Created by Lynn on 2018/3/6. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +public class PortalView implements MvpView { | |
| 27 | + public PortalFragment fragment; | |
| 28 | + private int headerViewHeight = 300; | |
| 29 | + private int h = 0; | |
| 30 | + private PortalListAdapter adapter; | |
| 31 | + private boolean followed; | |
| 32 | + public boolean shouldItemUpdate = false; | |
| 33 | + public List<BasePortalItem> loadList; | |
| 34 | + | |
| 35 | + | |
| 36 | + public PortalView(PortalFragment fragment) { | |
| 37 | + this.fragment = fragment; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public Context getContext() { | |
| 41 | + return fragment == null ? null : fragment.getActivity(); | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void initView() { | |
| 45 | + fragment.binding.refreshLayout.clearDisappearingChildren(); | |
| 46 | + fragment.binding.refreshLayout.setEnableLoadMore(false); | |
| 47 | + fragment.binding.refreshLayout.setEnableOverScrollDrag(true); | |
| 48 | + fragment.binding.refreshLayout.setEnableOverScrollBounce(false); | |
| 49 | + fragment.binding.refreshLayout.setOnRefreshListener(fragment.onRefreshListener); | |
| 50 | + fragment.binding.refreshLayout.setOnLoadMoreListener(onLoadMoreListener); | |
| 51 | + setAdapter(); | |
| 52 | + | |
| 53 | + fragment.binding.scrollView.setOnScrollStateChangedListener(scrollType -> { | |
| 54 | + if (shouldItemUpdate && scrollType == ScrollListenerNestedScrollView.ScrollType.IDLE) { | |
| 55 | + updateItems(loadList); | |
| 56 | + } | |
| 57 | + }); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setAdapter() { | |
| 61 | + LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); | |
| 62 | + layoutManager.setSmoothScrollbarEnabled(false); | |
| 63 | + fragment.binding.recyclerView.setNestedScrollingEnabled(false); | |
| 64 | + fragment.binding.recyclerView.setLayoutManager(layoutManager); | |
| 65 | + fragment.binding.recyclerView.setHasFixedSize(true); | |
| 66 | + | |
| 67 | + | |
| 68 | + fragment.binding.recyclerView.addOnScrollListener(onScrollListener); | |
| 69 | + fragment.binding.recyclerView.setItemAnimator(null); | |
| 70 | + fragment.binding.recyclerView.setAdapter(adapter = new PortalListAdapter(getContext())); | |
| 71 | + | |
| 72 | + fragment.binding.recyclerView.post(() -> fragment.binding.recyclerView.setMinimumHeight( | |
| 73 | + fragment.binding.refreshLayout.getHeight() | |
| 74 | + - fragment.binding.titleBar.getHeight() | |
| 75 | + )); | |
| 76 | + | |
| 77 | + | |
| 78 | + adapter.setFollowClickListener(onFollowClickListener); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public PortalListAdapter portalListAdapter() { | |
| 82 | + return adapter; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public void updateItems(List<BasePortalItem> list) { | |
| 86 | + if (fragment.binding.scrollView.getScrollType().equals(ScrollListenerNestedScrollView.ScrollType.IDLE)) { | |
| 87 | + adapter.updateItems(list); | |
| 88 | + shouldItemUpdate = false; | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | + | |
| 93 | + public void updateNotFollowList(List<BasePortalItem> list) { | |
| 94 | + for (int i = 0; i < list.size(); i++) { | |
| 95 | + if (list.get(i).getType() == BasePortalItem.TYPE_UNFOLLOW_DAREN) { | |
| 96 | + adapter.updateDarensList((PortalNotFollow) list.get(i)); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + public void removeItem(int position) { | |
| 102 | + adapter.removeItem(position); | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void updateFollowState(String darenId, boolean isFollow) { | |
| 106 | + adapter.updateFollowState(darenId, isFollow); | |
| 107 | + } | |
| 108 | + | |
| 109 | + public void addItem(BasePortalItem basePortalItem, int position) { | |
| 110 | + adapter.addItem(position, basePortalItem); | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void finishRefresh() { | |
| 114 | + fragment.binding.refreshLayout.finishRefresh(); | |
| 115 | + } | |
| 116 | + | |
| 117 | + public void showLoadingView() { | |
| 118 | + if (fragment.binding.emptyView != null) | |
| 119 | + fragment.binding.emptyView.show(true); | |
| 120 | + } | |
| 121 | + | |
| 122 | + public void hideLoadingView() { | |
| 123 | + if (fragment.binding.emptyView != null) | |
| 124 | + fragment.binding.emptyView.hide(); | |
| 125 | + } | |
| 126 | + | |
| 127 | + public void showEmptyPage() { | |
| 128 | + setUpToolbar(); | |
| 129 | + fragment.binding.refreshLayout.setEnableRefresh(false); | |
| 130 | + if (adapter != null) adapter.removeAllItems(); | |
| 131 | + if (fragment.binding.emptyView != null) | |
| 132 | + fragment.binding.emptyView.show(getContext().getString(R.string.msg_empty_page), "", R.drawable.zhuangtai_kong); | |
| 133 | + } | |
| 134 | + | |
| 135 | + public void hideEmptyPage() { | |
| 136 | + if (fragment.binding.emptyView != null) | |
| 137 | + fragment.binding.emptyView.hide(); | |
| 138 | + } | |
| 139 | + | |
| 140 | + public void showRetryPage(int state, View.OnClickListener listener) { | |
| 141 | + String titleText = ""; | |
| 142 | + String detailText = ""; | |
| 143 | + if (state == -3) { | |
| 144 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 145 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 146 | + } else { | |
| 147 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 148 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 149 | + } | |
| 150 | + if (fragment.binding.emptyView != null) | |
| 151 | + fragment.binding.emptyView.show(false, titleText, detailText, "重试", R.drawable.wufalianjie, listener); | |
| 152 | + } | |
| 153 | + | |
| 154 | + | |
| 155 | + public void showFollowFailedToast(String message) { | |
| 156 | + if (getContext() != null) | |
| 157 | + AlertUtil.showFailedToast(getContext(), message); | |
| 158 | + } | |
| 159 | + | |
| 160 | + public void showFollowSuccessToast(String message) { | |
| 161 | + if (getContext() != null) | |
| 162 | + AlertUtil.showSuccessToast(getContext(), message); | |
| 163 | + } | |
| 164 | + | |
| 165 | + public void showFailedToast(String message) { | |
| 166 | + if (getContext() != null) | |
| 167 | + AlertUtil.showFailedToast(getContext(), message); | |
| 168 | + } | |
| 169 | + | |
| 170 | + public void setUpToolbar() { | |
| 171 | + fragment.binding.titleBar.setBackgroundColor(getContext().getResources().getColor(R.color.app_color_blue)); | |
| 172 | + } | |
| 173 | + | |
| 174 | + OnLoadMoreListener onLoadMoreListener = refreshLayout -> { | |
| 175 | +// Toast.makeText(getContext(), "触发加载更多事件", Toast.LENGTH_SHORT).show(); | |
| 176 | + refreshLayout.finishLoadMore(2000); | |
| 177 | + }; | |
| 178 | + | |
| 179 | + //recyclerView滚动监听 | |
| 180 | + private RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() { | |
| 181 | + @Override | |
| 182 | + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
| 183 | + super.onScrolled(recyclerView, dx, dy); | |
| 184 | + | |
| 185 | + //设置搜索布局的背景颜色透明度 | |
| 186 | + int color = getContext().getResources().getColor(R.color.white); | |
| 187 | + | |
| 188 | + int red = Color.red(color); | |
| 189 | + int green = Color.green(color); | |
| 190 | + int blue = Color.blue(color); | |
| 191 | + if (headerViewHeight > 0) { | |
| 192 | + int lHeight = headerViewHeight; | |
| 193 | + h += dy; | |
| 194 | + if (h < 0) { | |
| 195 | + fragment.binding.titleBar.setBackgroundColor(Color.argb((int) 0, red, green, blue)); | |
| 196 | + } else { | |
| 197 | + if (h < lHeight) { | |
| 198 | + float scale = (float) h / lHeight; | |
| 199 | + float progress = (255 * scale); | |
| 200 | + fragment.binding.titleBar.setBackgroundColor(Color.argb((int) progress, red, green, blue)); | |
| 201 | + } else { | |
| 202 | + fragment.binding.titleBar.setBackgroundColor(Color.argb((int) 255, red, green, blue)); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + } | |
| 207 | + }; | |
| 208 | + | |
| 209 | + private PortalListAdapter.OnFollowClickListener onFollowClickListener = new PortalListAdapter.OnFollowClickListener() { | |
| 210 | + @Override | |
| 211 | + public void followClick(String darenIds, UnFollowList item, boolean isFollowed, View view, String type) { | |
| 212 | + followed = isFollowed; | |
| 213 | + fragment.follow(isFollowed, darenIds, item, type); | |
| 214 | + } | |
| 215 | + }; | |
| 216 | + | |
| 217 | + | |
| 218 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/listener/CheckListener.java
0 → 100644
happy_china/src/main/java/com/cnlive/strike/happychina/listener/OnItemListener.java
0 → 100644
happy_china/src/main/java/com/cnlive/strike/happychina/listener/ShowNextListener.java
0 → 100644
happy_china/src/main/java/com/cnlive/strike/happychina/network/CnApiDarenService.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network; | |
| 2 | + | |
| 3 | +import com.cnlive.strike.happychina.network.model.CategoryDarensData; | |
| 4 | +import com.cnlive.strike.happychina.network.model.CenterPageData; | |
| 5 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 6 | +import com.cnlive.strike.happychina.network.model.GetDarenComment; | |
| 7 | +import com.cnlive.strike.happychina.network.model.GetDarenHomeData; | |
| 8 | +import com.cnlive.strike.happychina.network.model.GetDarensData; | |
| 9 | +import com.cnlive.strike.happychina.network.model.SearchDarenData; | |
| 10 | +import com.cnlive.strike.happychina.network.model.ShareDarenInfo; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | +import java.util.Map; | |
| 14 | + | |
| 15 | +import io.reactivex.Observable; | |
| 16 | +import retrofit2.adapter.rxjava2.Result; | |
| 17 | +import retrofit2.http.FieldMap; | |
| 18 | +import retrofit2.http.FormUrlEncoded; | |
| 19 | +import retrofit2.http.Headers; | |
| 20 | +import retrofit2.http.POST; | |
| 21 | +import retrofit2.http.QueryMap; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * Created by Lynn on 2018/11/28. | |
| 25 | + */ | |
| 26 | + | |
| 27 | +public interface CnApiDarenService { | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 分类首页 | |
| 31 | + * | |
| 32 | + * @return | |
| 33 | + */ | |
| 34 | + @Headers("cache:5") | |
| 35 | + @POST("Daren/classify/getNewCenterPage.action") | |
| 36 | + Observable<Result<CnBaseInfo<CenterPageData>>> getCenterPage(@QueryMap() Map<String, String> map); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 分类二级页面达人列表 | |
| 40 | + * | |
| 41 | + * @return | |
| 42 | + */ | |
| 43 | + @Headers("cache:5") | |
| 44 | + @POST("Daren/classify/getNewDarensByCategory.action") | |
| 45 | + Observable<Result<CnBaseInfo<CategoryDarensData>>> getDarensByCategory(@QueryMap() Map<String, String> map); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 获取未关注列表接口 | |
| 49 | + * | |
| 50 | + * @param maps | |
| 51 | + * @return | |
| 52 | + */ | |
| 53 | + @POST("Daren/classify/getUnFansOrDarenBean.action") | |
| 54 | + Observable<Result<CnBaseInfo<GetDarensData>>> getUnFollowDarens(@QueryMap() Map<String, String> maps); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 获取关注列表接口(分类页面) | |
| 58 | + * | |
| 59 | + * @param maps | |
| 60 | + * @return | |
| 61 | + */ | |
| 62 | + @POST("Daren/classify/getDarenList.action") | |
| 63 | + Observable<Result<CnBaseInfo<GetDarensData>>> getDarenList(@QueryMap() Map<String, String> maps); | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 关注 | |
| 67 | + * | |
| 68 | + * @param map appId 应用Id | |
| 69 | + * sid 用户Id | |
| 70 | + * darenIds 达人Id,多个用逗号分隔 | |
| 71 | + * @return | |
| 72 | + */ | |
| 73 | + @POST("Daren/sub/addDarenSub.action") | |
| 74 | + Observable<Result<CnBaseInfo>> addDaren(@QueryMap() Map<String, String> map); | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 取消关注 | |
| 78 | + * | |
| 79 | + * @param map appId 应用Id | |
| 80 | + * sid 用户Id | |
| 81 | + * darenIds 达人Id,多个用逗号分隔 | |
| 82 | + * @return | |
| 83 | + */ | |
| 84 | + @POST("Daren/sub/cancelDarenSub.action") | |
| 85 | + Observable<Result<CnBaseInfo>> cancelDaren(@QueryMap() Map<String, String> map); | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * 分类页面--搜索 | |
| 89 | + * | |
| 90 | + * @param maps | |
| 91 | + * @return | |
| 92 | + */ | |
| 93 | + @FormUrlEncoded | |
| 94 | + @POST("Daren/search/searchDaren.action") | |
| 95 | + Observable<Result<CnBaseInfo<List<SearchDarenData>>>> searchDaren(@FieldMap() Map<String, String> maps); | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * 获取达人主页 | |
| 99 | + * | |
| 100 | + * @param maps | |
| 101 | + * @return | |
| 102 | + */ | |
| 103 | + @Headers("cache:5") | |
| 104 | + @POST("Daren/sub/getDarenHome.action") | |
| 105 | + Observable<Result<CnBaseInfo<GetDarenHomeData>>> getDarenHome(@QueryMap() Map<String, String> maps); | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * 粉丝列表 | |
| 109 | + */ | |
| 110 | + @Headers("cache:5") | |
| 111 | + @POST("Daren/sub/getFans.action") | |
| 112 | + Observable<Result<CnBaseInfo<GetDarensData>>> getFans(@QueryMap() Map<String, String> map); | |
| 113 | + | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * 获取达人主页分享地址 | |
| 117 | + * | |
| 118 | + * @return | |
| 119 | + */ | |
| 120 | + @POST("Daren/common/shareDarenHomePage.action") | |
| 121 | + Observable<Result<CnBaseInfo<ShareDarenInfo>>> getDarenShare(@QueryMap() Map<String, String> map); | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * 获取获得评论列表 | |
| 125 | + * | |
| 126 | + * @param maps darenId 达人ID | |
| 127 | + * plat 客户端平台 | |
| 128 | + * pageNo 页码 | |
| 129 | + * @return | |
| 130 | + */ | |
| 131 | + @Headers("cache:5") | |
| 132 | + @POST("Daren/hudong/getDarenComment.action") | |
| 133 | + Observable<Result<CnBaseInfo<GetDarenComment>>> getDarenComment(@QueryMap() Map<String, String> maps); | |
| 134 | + | |
| 135 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/CnApiRequest.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.cnlive.libs.base.application.AppConfig; | |
| 6 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 7 | +import com.cnlive.libs.data.network.ApiBuild; | |
| 8 | +import com.cnlive.libs.data.network.Subscriber; | |
| 9 | +import com.cnlive.libs.data.network.interceptor.SignEncryptInterceptor; | |
| 10 | +import com.cnlive.strike.happychina.network.model.CnBaseInfo; | |
| 11 | + | |
| 12 | +import io.reactivex.android.schedulers.AndroidSchedulers; | |
| 13 | +import io.reactivex.disposables.Disposable; | |
| 14 | +import io.reactivex.schedulers.Schedulers; | |
| 15 | +import okhttp3.Interceptor; | |
| 16 | +import retrofit2.adapter.rxjava2.Result; | |
| 17 | + | |
| 18 | +import static com.cnlive.libs.base.logic.Config.SUCCESS; | |
| 19 | + | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Created by xiansong on 2017/9/8. | |
| 23 | + */ | |
| 24 | + | |
| 25 | +public class CnApiRequest<Observable extends io.reactivex.Observable<Result<BaseData>>, BaseData extends CnBaseInfo> { | |
| 26 | + | |
| 27 | + //网++ 接口域名 | |
| 28 | + public static final String BASE_URL = "https://apiwjj.cnlive.com/"; | |
| 29 | + //网++ 测试环境 接口域名 | |
| 30 | + public static final String DEBUG_URL = "http://apiwjjtest.cnlive.com/"; | |
| 31 | + | |
| 32 | + public static <T> String baseEndpoint() { | |
| 33 | + return AppConfig.isDebug() ? DEBUG_URL : BASE_URL; | |
| 34 | + } | |
| 35 | + | |
| 36 | + private static <T> String serviceEndpoint(Class<T> clazz) { | |
| 37 | + return baseEndpoint(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + | |
| 41 | + public static <Service> Service service(Class<Service> clazz) { | |
| 42 | + return service(clazz, new SignEncryptInterceptor()); | |
| 43 | + } | |
| 44 | + | |
| 45 | + private static <Service> Service service(Class<Service> clazz, Interceptor... interceptor) { | |
| 46 | + return service(clazz, false, interceptor); | |
| 47 | + } | |
| 48 | + | |
| 49 | + private static <Service> Service service(Class<Service> clazz, boolean decode, Interceptor... interceptor) { | |
| 50 | + return ApiBuild.service(clazz, null) | |
| 51 | + .setEndpoint(serviceEndpoint(clazz)) | |
| 52 | + .addInterceptor(interceptor) | |
| 53 | + .service(decode); | |
| 54 | + } | |
| 55 | + | |
| 56 | + | |
| 57 | + public static <Service, Observable extends io.reactivex.Observable<Result<BaseData>>, BaseData extends CnBaseInfo> | |
| 58 | + CnApiRequest<Observable, BaseData> service(Class<Service> clazz, ApiBuild.Api<Service, Observable, BaseData> api) { | |
| 59 | + return service(clazz, api, new SignEncryptInterceptor()); | |
| 60 | + } | |
| 61 | + | |
| 62 | + private static <Service, Observable extends io.reactivex.Observable<Result<BaseData>>, BaseData extends CnBaseInfo> | |
| 63 | + CnApiRequest<Observable, BaseData> service(Class<Service> clazz, ApiBuild.Api<Service, Observable, BaseData> api, Interceptor... interceptor) { | |
| 64 | + return service(clazz, false, api, interceptor); | |
| 65 | + } | |
| 66 | + | |
| 67 | + private static <Service, Observable extends io.reactivex.Observable<Result<BaseData>>, BaseData extends CnBaseInfo> | |
| 68 | + CnApiRequest<Observable, BaseData> service(Class<Service> clazz, boolean decode, ApiBuild.Api<Service, Observable, BaseData> api, Interceptor... interceptor) { | |
| 69 | + | |
| 70 | + CnApiRequest<Observable, BaseData> request = new CnApiRequest<>(); | |
| 71 | + | |
| 72 | + request.observable = ApiBuild.service(clazz, api) | |
| 73 | + .setEndpoint(serviceEndpoint(clazz)) | |
| 74 | + .addInterceptor(interceptor) | |
| 75 | + .build(decode); | |
| 76 | + | |
| 77 | + return request; | |
| 78 | + } | |
| 79 | + | |
| 80 | + private Observable observable; | |
| 81 | + | |
| 82 | + private CnApiRequest() { | |
| 83 | + } | |
| 84 | + | |
| 85 | + public static <Observable extends io.reactivex.Observable<Result<BaseData>>, BaseData extends CnBaseInfo> | |
| 86 | + Disposable subscribe(Observable observable, Subscriber<BaseData> subscriber) { | |
| 87 | + return observable.take(1) | |
| 88 | + .subscribeOn(Schedulers.io()) | |
| 89 | + .observeOn(AndroidSchedulers.mainThread()) | |
| 90 | + .subscribe(subscriber.next, subscriber.error, subscriber.complete, subscriber.subscribe); | |
| 91 | + } | |
| 92 | + | |
| 93 | + public Disposable subscribe(Context context, DataCallback<BaseData> callback) { | |
| 94 | + Subscriber<BaseData> subscriber = new Subscriber<BaseData>(context) { | |
| 95 | + @Override | |
| 96 | + public void onCompleted(String s, String s1, BaseData data) { | |
| 97 | + if (callback == null) return; | |
| 98 | + callback.callback(SUCCESS, "", data); | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Override | |
| 102 | + public void onError(String code, String message) { | |
| 103 | + if (callback == null) return; | |
| 104 | + int errorCode = -1; | |
| 105 | + try { | |
| 106 | + errorCode = Integer.valueOf(code); | |
| 107 | + } catch (Exception ignored) { | |
| 108 | + } | |
| 109 | + callback.callback(errorCode, message, null); | |
| 110 | + } | |
| 111 | + }; | |
| 112 | + | |
| 113 | + return observable.take(1) | |
| 114 | + .subscribeOn(Schedulers.io()) | |
| 115 | + .observeOn(AndroidSchedulers.mainThread()) | |
| 116 | + .subscribe(subscriber.next, subscriber.error, subscriber.complete, subscriber.subscribe); | |
| 117 | + } | |
| 118 | + | |
| 119 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/CnApiSubscriber.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.cnlive.libs.data.network.Subscriber; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * Created by xiansong on 2017/9/8. | |
| 8 | + */ | |
| 9 | + | |
| 10 | +public class CnApiSubscriber { | |
| 11 | + | |
| 12 | + private static final String success_code = "0"; | |
| 13 | + private static final String success_message = "数据加载成功"; | |
| 14 | + | |
| 15 | + public static final Subscriber.Config subscriberBuild = Subscriber.newConfig() | |
| 16 | + .putInfo(Subscriber.Config.response_success, success_code, success_message) ; | |
| 17 | + | |
| 18 | + public static String getSuccessCode(){ | |
| 19 | + return success_code; | |
| 20 | + } | |
| 21 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/BannerData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by Lynn on 2018/3/14. | |
| 5 | + */ | |
| 6 | + | |
| 7 | +public class BannerData { | |
| 8 | + private String image; | |
| 9 | + private String itemId; | |
| 10 | + private String darenId; | |
| 11 | + private String h5Path; | |
| 12 | + private String type; | |
| 13 | + | |
| 14 | + public String getImage() { | |
| 15 | + return image; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public void setImage(String image) { | |
| 19 | + this.image = image; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public String getItemId() { | |
| 23 | + return itemId; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void setItemId(String itemId) { | |
| 27 | + this.itemId = itemId; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public String getDarenId() { | |
| 31 | + return darenId; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setDarenId(String darenId) { | |
| 35 | + this.darenId = darenId; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getH5Path() { | |
| 39 | + return h5Path; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setH5Path(String h5Path) { | |
| 43 | + this.h5Path = h5Path; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public String getType() { | |
| 47 | + return type; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setType(String type) { | |
| 51 | + this.type = type; | |
| 52 | + } | |
| 53 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/CategoryDarensData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by Lynn on 2018/3/14. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class CategoryDarensData { | |
| 10 | + | |
| 11 | + private List<CategoryList> list; | |
| 12 | + private List<BannerData> banners; | |
| 13 | + | |
| 14 | + public List<CategoryList> getList() { | |
| 15 | + return list; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public void setList(List<CategoryList> list) { | |
| 19 | + this.list = list; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public List<BannerData> getBanners() { | |
| 23 | + return banners; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void setBanners(List<BannerData> banners) { | |
| 27 | + this.banners = banners; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public static class CategoryList { | |
| 31 | + private List<IconData> darens; | |
| 32 | + private CategoryData category; | |
| 33 | + | |
| 34 | + public List<IconData> getDarens() { | |
| 35 | + return darens; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setDarens(List<IconData> darens) { | |
| 39 | + this.darens = darens; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public CategoryData getCategory() { | |
| 43 | + return category; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setCategory(CategoryData category) { | |
| 47 | + this.category = category; | |
| 48 | + } | |
| 49 | + | |
| 50 | + } | |
| 51 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/CategoryData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by Lynn on 2018/3/14. | |
| 5 | + */ | |
| 6 | + | |
| 7 | +public class CategoryData { | |
| 8 | + private String categoryImage; | |
| 9 | + private String categoryName; | |
| 10 | + private String categoryId; | |
| 11 | + //分类页面达人广场达人类型背景图片 | |
| 12 | + private String newCategoryImage; | |
| 13 | + //分类二级页面达人类型图片 | |
| 14 | + private String newCategorySmallImage; | |
| 15 | + | |
| 16 | + public String getCategoryImage() { | |
| 17 | + return categoryImage; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setCategoryImage(String categoryImage) { | |
| 21 | + this.categoryImage = categoryImage; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getCategoryName() { | |
| 25 | + return categoryName; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setCategoryName(String categoryName) { | |
| 29 | + this.categoryName = categoryName; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public String getCategoryId() { | |
| 33 | + return categoryId; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setCategoryId(String categoryId) { | |
| 37 | + this.categoryId = categoryId; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public String getNewCategoryImage() { | |
| 41 | + return newCategoryImage; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setNewCategoryImage(String newCategoryImage) { | |
| 45 | + this.newCategoryImage = newCategoryImage; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public String getNewCategorySmallImage() { | |
| 49 | + return newCategorySmallImage; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setNewCategorySmallImage(String newCategorySmallImage) { | |
| 53 | + this.newCategorySmallImage = newCategorySmallImage; | |
| 54 | + } | |
| 55 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/CategoryListData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by cnlive201803 on 2018/5/24. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class CategoryListData { | |
| 10 | + private List<IconData> list; | |
| 11 | + private CategoryData categoryIconBean; | |
| 12 | + | |
| 13 | + public List<IconData> getList() { | |
| 14 | + return list; | |
| 15 | + } | |
| 16 | + | |
| 17 | + public void setList(List<IconData> list) { | |
| 18 | + this.list = list; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public CategoryData getCategoryIconBean() { | |
| 22 | + return categoryIconBean; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public void setCategoryIconBean(CategoryData categoryIconBean) { | |
| 26 | + this.categoryIconBean = categoryIconBean; | |
| 27 | + } | |
| 28 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/CenterPageData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by Lynn on 2018/3/14. | |
| 7 | + * 分类首页 | |
| 8 | + */ | |
| 9 | + | |
| 10 | +public class CenterPageData { | |
| 11 | + | |
| 12 | + private List<UnFollowDarensData> list; | |
| 13 | + private List<BannerData> bannerList; | |
| 14 | + private DarenSquareData darenSquare; | |
| 15 | + private HotMsgData hotMsg; | |
| 16 | + | |
| 17 | + public List<UnFollowDarensData> getList() { | |
| 18 | + return list; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public void setList(List<UnFollowDarensData> list) { | |
| 22 | + this.list = list; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public List<BannerData> getBannerList() { | |
| 26 | + return bannerList; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setBannerList(List<BannerData> bannerList) { | |
| 30 | + this.bannerList = bannerList; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public DarenSquareData getDarenSquare() { | |
| 34 | + return darenSquare; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public void setDarenSquare(DarenSquareData darenSquare) { | |
| 38 | + this.darenSquare = darenSquare; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public HotMsgData getHotMsg() { | |
| 42 | + return hotMsg; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public void setHotMsg(HotMsgData hotMsg) { | |
| 46 | + this.hotMsg = hotMsg; | |
| 47 | + } | |
| 48 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/CnBaseInfo.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import com.cnlive.libs.data.network.model.IBaseInfo; | |
| 4 | +import com.cnlive.strike.happychina.network.CnApiSubscriber; | |
| 5 | + | |
| 6 | + | |
| 7 | +public class CnBaseInfo<T> implements IBaseInfo { | |
| 8 | + //TODO 接口错误信息 需要自定义 | |
| 9 | + private String errorCode = CnApiSubscriber.getSuccessCode(); | |
| 10 | + private String errorMessage = ""; | |
| 11 | + | |
| 12 | + //TODO 接口内容数据 需要自定义 | |
| 13 | + private T data; | |
| 14 | + | |
| 15 | + public void setCode(String status_code) { | |
| 16 | + this.errorCode = status_code; | |
| 17 | + } | |
| 18 | + | |
| 19 | + @Override | |
| 20 | + public String getCode() { | |
| 21 | + return errorCode; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public void setMessage(String errorMessage) { | |
| 25 | + this.errorMessage = errorMessage; | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public String getMessage() { | |
| 30 | + return errorMessage; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public void setData(T data) { | |
| 34 | + this.data = data; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public T getData() { | |
| 38 | + return data; | |
| 39 | + } | |
| 40 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/DarenSquareData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by cnlive201803 on 2018/5/24. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class DarenSquareData { | |
| 10 | + private String name; | |
| 11 | + private String icon; | |
| 12 | + private String openUrl; | |
| 13 | + private int sort; | |
| 14 | + private List<CategoryListData> list; | |
| 15 | + | |
| 16 | + public String getName() { | |
| 17 | + return name; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setName(String name) { | |
| 21 | + this.name = name; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getIcon() { | |
| 25 | + return icon; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setIcon(String icon) { | |
| 29 | + this.icon = icon; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public List<CategoryListData> getList() { | |
| 33 | + return list; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setList(List<CategoryListData> list) { | |
| 37 | + this.list = list; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public String getOpenUrl() { | |
| 41 | + return openUrl; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setOpenUrl(String openUrl) { | |
| 45 | + this.openUrl = openUrl; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public int getSort() { | |
| 49 | + return sort; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setSort(int sort) { | |
| 53 | + this.sort = sort; | |
| 54 | + } | |
| 55 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/GetDarenComment.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by xiansong on 2018/2/28. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class GetDarenComment { | |
| 10 | + private int pageNo; | |
| 11 | + private int nextPage; | |
| 12 | + private int pageSize; | |
| 13 | + | |
| 14 | + private List<CommentItem> commentItems; | |
| 15 | + | |
| 16 | + public static class CommentItem { | |
| 17 | + | |
| 18 | + public static class Path{ | |
| 19 | + private String imagePath; | |
| 20 | + private String thumbnailPath; | |
| 21 | + | |
| 22 | + public String getImagePath() { | |
| 23 | + return imagePath; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void setImagePath(String imagePath) { | |
| 27 | + this.imagePath = imagePath; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public String getThumbnailPath() { | |
| 31 | + return thumbnailPath; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setThumbnailPath(String thumbnailPath) { | |
| 35 | + this.thumbnailPath = thumbnailPath; | |
| 36 | + } | |
| 37 | + } | |
| 38 | + private String image; | |
| 39 | + private String nickName; | |
| 40 | + private String commentId; | |
| 41 | + private String time; | |
| 42 | + private String commentText; | |
| 43 | + private String sid; | |
| 44 | + private List<Path> paths; | |
| 45 | + private String plat; | |
| 46 | + private String grade; | |
| 47 | + | |
| 48 | + public String getImage() { | |
| 49 | + return image; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setImage(String image) { | |
| 53 | + this.image = image; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public String getNickName() { | |
| 57 | + return nickName; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setNickName(String nickName) { | |
| 61 | + this.nickName = nickName; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getCommentId() { | |
| 65 | + return commentId; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setCommentId(String commentId) { | |
| 69 | + this.commentId = commentId; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public String getTime() { | |
| 73 | + return time; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setTime(String time) { | |
| 77 | + this.time = time; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public String getCommentText() { | |
| 81 | + return commentText; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public void setCommentText(String commentText) { | |
| 85 | + this.commentText = commentText; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public String getSid() { | |
| 89 | + return sid; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setSid(String sid) { | |
| 93 | + this.sid = sid; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public List<Path> getPaths() { | |
| 97 | + return paths; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public void setPaths(List<Path> paths) { | |
| 101 | + this.paths = paths; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public String getPlat() { | |
| 105 | + return plat; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public void setPlat(String plat) { | |
| 109 | + this.plat = plat; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public String getGrade() { | |
| 113 | + return grade; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void setGrade(String grade) { | |
| 117 | + this.grade = grade; | |
| 118 | + } | |
| 119 | + } | |
| 120 | + | |
| 121 | + public int getPageNo() { | |
| 122 | + return pageNo; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void setPageNo(int pageNo) { | |
| 126 | + this.pageNo = pageNo; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public int getNextPage() { | |
| 130 | + return nextPage; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setNextPage(int nextPage) { | |
| 134 | + this.nextPage = nextPage; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public int getPageSize() { | |
| 138 | + return pageSize; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setPageSize(int pageSize) { | |
| 142 | + this.pageSize = pageSize; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public List<CommentItem> getCommentItems() { | |
| 146 | + return commentItems; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setCommentItems(List<CommentItem> commentItems) { | |
| 150 | + this.commentItems = commentItems; | |
| 151 | + } | |
| 152 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/GetDarenHomeData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import android.text.TextUtils; | |
| 4 | + | |
| 5 | +import java.io.Serializable; | |
| 6 | +import java.text.DecimalFormat; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Created by xiansong on 2018/1/27. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +public class GetDarenHomeData { | |
| 14 | + private int pageNo; | |
| 15 | + private int nextPage; | |
| 16 | + private int pageSize; | |
| 17 | + private String image; | |
| 18 | + private String custSign; | |
| 19 | + private String fansNum; | |
| 20 | + private int updateFansNumber; | |
| 21 | + private boolean fan; | |
| 22 | + private String sid; | |
| 23 | + private String darenId; | |
| 24 | + private String address; | |
| 25 | + private String shopName; | |
| 26 | + private float grade; | |
| 27 | + private boolean online; | |
| 28 | + private String orderCount; | |
| 29 | + private String commentCount; | |
| 30 | + private List<Propaganda> propagandas; | |
| 31 | + | |
| 32 | + private List<DarenContent> content; | |
| 33 | + private List<CategoryContent> category; | |
| 34 | + | |
| 35 | + | |
| 36 | + public static class CategoryContent implements Serializable { | |
| 37 | + | |
| 38 | + private CategoryIcon categoryIcon; | |
| 39 | + private List<CategoryItemContent> categoryItems; | |
| 40 | + | |
| 41 | + public static class CategoryIcon { | |
| 42 | + private String categoryName; | |
| 43 | + private String categoryId; | |
| 44 | + private String categoryImage; | |
| 45 | + | |
| 46 | + public String getCategoryName() { | |
| 47 | + return categoryName; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setCategoryName(String categoryName) { | |
| 51 | + this.categoryName = categoryName; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public String getCategoryId() { | |
| 55 | + return categoryId; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void setCategoryId(String categoryId) { | |
| 59 | + this.categoryId = categoryId; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public String getCategoryImage() { | |
| 63 | + return categoryImage; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setCategoryImage(String categoryImage) { | |
| 67 | + this.categoryImage = categoryImage; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 71 | + public static class CategoryItemContent { | |
| 72 | + private String typeName; | |
| 73 | + private String color; | |
| 74 | + private String type; | |
| 75 | + | |
| 76 | + public String getTypeName() { | |
| 77 | + return typeName; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void setTypeName(String typeName) { | |
| 81 | + this.typeName = typeName; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public String getColor() { | |
| 85 | + return color; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void setColor(String color) { | |
| 89 | + this.color = color; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public String getType() { | |
| 93 | + return type; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setType(String type) { | |
| 97 | + this.type = type; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + public List<CategoryItemContent> getCategoryItems() { | |
| 102 | + return categoryItems; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setCategoryItems(List<CategoryItemContent> categoryItems) { | |
| 106 | + this.categoryItems = categoryItems; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public CategoryIcon getCategoryIcon() { | |
| 110 | + return categoryIcon; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setCategoryIcon(CategoryIcon categoryIcon) { | |
| 114 | + this.categoryIcon = categoryIcon; | |
| 115 | + } | |
| 116 | + | |
| 117 | + } | |
| 118 | + | |
| 119 | + public static class DarenContent { | |
| 120 | + | |
| 121 | + public static class Video { | |
| 122 | + private int time; | |
| 123 | + private String imageUrl; | |
| 124 | + private String videoId; | |
| 125 | + private String videoPlayUrl; | |
| 126 | + private int height; | |
| 127 | + private int width; | |
| 128 | + | |
| 129 | + public int getTime() { | |
| 130 | + return time; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setTime(int time) { | |
| 134 | + this.time = time; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public String getImageUrl() { | |
| 138 | + return imageUrl; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setImageUrl(String imageUrl) { | |
| 142 | + this.imageUrl = imageUrl; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public String getVideoId() { | |
| 146 | + return videoId; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public String getVideoPlayUrl() { | |
| 150 | + return videoPlayUrl; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public void setVideoPlayUrl(String videoPlayUrl) { | |
| 154 | + this.videoPlayUrl = videoPlayUrl; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void setVideoId(String videoId) { | |
| 158 | + this.videoId = videoId; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public int getHeight() { | |
| 162 | + return height; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public void setHeight(int height) { | |
| 166 | + this.height = height; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public int getWidth() { | |
| 170 | + return width; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public void setWidth(int width) { | |
| 174 | + this.width = width; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + public static class Image { | |
| 179 | + private String imagePath; | |
| 180 | + private String thumbnailPath; | |
| 181 | + //单张图片没有裁剪的压缩图 | |
| 182 | + private String thumbnailsFirstPic; | |
| 183 | + private int height; | |
| 184 | + private int width; | |
| 185 | + | |
| 186 | + public String getImagePath() { | |
| 187 | + return imagePath; | |
| 188 | + } | |
| 189 | + | |
| 190 | + public void setImagePath(String imagePath) { | |
| 191 | + this.imagePath = imagePath; | |
| 192 | + } | |
| 193 | + | |
| 194 | + public String getThumbnailPath() { | |
| 195 | + return thumbnailPath; | |
| 196 | + } | |
| 197 | + | |
| 198 | + public void setThumbnailPath(String thumbnailPath) { | |
| 199 | + this.thumbnailPath = thumbnailPath; | |
| 200 | + } | |
| 201 | + | |
| 202 | + public String getThumbnailsFirstPic() { | |
| 203 | + return thumbnailsFirstPic; | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setThumbnailsFirstPic(String thumbnailsFirstPic) { | |
| 207 | + this.thumbnailsFirstPic = thumbnailsFirstPic; | |
| 208 | + } | |
| 209 | + | |
| 210 | + public int getHeight() { | |
| 211 | + return height; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public void setHeight(int height) { | |
| 215 | + this.height = height; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public int getWidth() { | |
| 219 | + return width; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setWidth(int width) { | |
| 223 | + this.width = width; | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + private String darenId; | |
| 228 | + private String address; | |
| 229 | + private String itemId; | |
| 230 | + private String optionId; | |
| 231 | + private String optionDesc; | |
| 232 | + private int type; | |
| 233 | + private List<Image> images; | |
| 234 | + private String text; | |
| 235 | + private long ts; | |
| 236 | + private String category; | |
| 237 | + private Video video; | |
| 238 | + private List<CategoryContent> tags; | |
| 239 | + | |
| 240 | + public String getOptionId() { | |
| 241 | + return optionId; | |
| 242 | + } | |
| 243 | + | |
| 244 | + public void setOptionId(String optionId) { | |
| 245 | + this.optionId = optionId; | |
| 246 | + } | |
| 247 | + | |
| 248 | + public String getOptionDesc() { | |
| 249 | + return optionDesc; | |
| 250 | + } | |
| 251 | + | |
| 252 | + public void setOptionDesc(String optionDesc) { | |
| 253 | + this.optionDesc = optionDesc; | |
| 254 | + } | |
| 255 | + | |
| 256 | + public String getDarenId() { | |
| 257 | + return darenId; | |
| 258 | + } | |
| 259 | + | |
| 260 | + public void setDarenId(String darenId) { | |
| 261 | + this.darenId = darenId; | |
| 262 | + } | |
| 263 | + | |
| 264 | + public String getAddress() { | |
| 265 | + return address; | |
| 266 | + } | |
| 267 | + | |
| 268 | + public void setAddress(String address) { | |
| 269 | + this.address = address; | |
| 270 | + } | |
| 271 | + | |
| 272 | + public List<Image> getImages() { | |
| 273 | + return images; | |
| 274 | + } | |
| 275 | + | |
| 276 | + public void setImages(List<Image> images) { | |
| 277 | + this.images = images; | |
| 278 | + } | |
| 279 | + | |
| 280 | + public String getText() { | |
| 281 | + return text; | |
| 282 | + } | |
| 283 | + | |
| 284 | + public void setText(String text) { | |
| 285 | + this.text = text; | |
| 286 | + } | |
| 287 | + | |
| 288 | + public long getTs() { | |
| 289 | + return ts; | |
| 290 | + } | |
| 291 | + | |
| 292 | + public void setTs(long ts) { | |
| 293 | + this.ts = ts; | |
| 294 | + } | |
| 295 | + | |
| 296 | + public String getItemId() { | |
| 297 | + return itemId; | |
| 298 | + } | |
| 299 | + | |
| 300 | + public void setItemId(String itemId) { | |
| 301 | + this.itemId = itemId; | |
| 302 | + } | |
| 303 | + | |
| 304 | + public int getType() { | |
| 305 | + return type; | |
| 306 | + } | |
| 307 | + | |
| 308 | + public void setType(int type) { | |
| 309 | + this.type = type; | |
| 310 | + } | |
| 311 | + | |
| 312 | + public String getCategory() { | |
| 313 | + return category; | |
| 314 | + } | |
| 315 | + | |
| 316 | + public void setCategory(String category) { | |
| 317 | + this.category = category; | |
| 318 | + } | |
| 319 | + | |
| 320 | + public Video getVideo() { | |
| 321 | + return video; | |
| 322 | + } | |
| 323 | + | |
| 324 | + public void setVideo(Video video) { | |
| 325 | + this.video = video; | |
| 326 | + } | |
| 327 | + | |
| 328 | + public List<CategoryContent> getTags() { | |
| 329 | + return tags; | |
| 330 | + } | |
| 331 | + | |
| 332 | + public void setTags(List<CategoryContent> tags) { | |
| 333 | + this.tags = tags; | |
| 334 | + } | |
| 335 | + } | |
| 336 | + | |
| 337 | + public static class Propaganda { | |
| 338 | + private String id; | |
| 339 | + private String img; | |
| 340 | + private String playUrl; | |
| 341 | + private String type; | |
| 342 | + | |
| 343 | + public String getImg() { | |
| 344 | + return img; | |
| 345 | + } | |
| 346 | + | |
| 347 | + public void setImg(String img) { | |
| 348 | + this.img = img; | |
| 349 | + } | |
| 350 | + | |
| 351 | + public String getId() { | |
| 352 | + return id; | |
| 353 | + } | |
| 354 | + | |
| 355 | + public void setId(String id) { | |
| 356 | + this.id = id; | |
| 357 | + } | |
| 358 | + | |
| 359 | + public String getPlayUrl() { | |
| 360 | + return playUrl; | |
| 361 | + } | |
| 362 | + | |
| 363 | + public void setPlayUrl(String playUrl) { | |
| 364 | + this.playUrl = playUrl; | |
| 365 | + } | |
| 366 | + | |
| 367 | + public String getType() { | |
| 368 | + return type; | |
| 369 | + } | |
| 370 | + | |
| 371 | + public void setType(String type) { | |
| 372 | + this.type = type; | |
| 373 | + } | |
| 374 | + } | |
| 375 | + | |
| 376 | + public String getSid() { | |
| 377 | + return sid; | |
| 378 | + } | |
| 379 | + | |
| 380 | + public void setSid(String sid) { | |
| 381 | + this.sid = sid; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public int getPageNo() { | |
| 385 | + return pageNo; | |
| 386 | + } | |
| 387 | + | |
| 388 | + public void setPageNo(int pageNo) { | |
| 389 | + this.pageNo = pageNo; | |
| 390 | + } | |
| 391 | + | |
| 392 | + public int getNextPage() { | |
| 393 | + return nextPage; | |
| 394 | + } | |
| 395 | + | |
| 396 | + public void setNextPage(int nextPage) { | |
| 397 | + this.nextPage = nextPage; | |
| 398 | + } | |
| 399 | + | |
| 400 | + public int getPageSize() { | |
| 401 | + return pageSize; | |
| 402 | + } | |
| 403 | + | |
| 404 | + public void setPageSize(int pageSize) { | |
| 405 | + this.pageSize = pageSize; | |
| 406 | + } | |
| 407 | + | |
| 408 | + public String getImage() { | |
| 409 | + return image; | |
| 410 | + } | |
| 411 | + | |
| 412 | + public void setImage(String image) { | |
| 413 | + this.image = image; | |
| 414 | + } | |
| 415 | + | |
| 416 | + public String getCustSign() { | |
| 417 | + return custSign; | |
| 418 | + } | |
| 419 | + | |
| 420 | + public void setCustSign(String custSign) { | |
| 421 | + this.custSign = custSign; | |
| 422 | + } | |
| 423 | + | |
| 424 | + public String getFansNum() { | |
| 425 | + if (!TextUtils.isEmpty(fansNum)) | |
| 426 | + updateFansNumber = Integer.parseInt(fansNum); | |
| 427 | + else updateFansNumber = 0; | |
| 428 | + return getNumDiff(Integer.parseInt(fansNum)); | |
| 429 | + } | |
| 430 | + | |
| 431 | + public void setFansNum(String fansNum) { | |
| 432 | + this.fansNum = fansNum; | |
| 433 | + } | |
| 434 | + | |
| 435 | + public String getUpdateFansNum(boolean add) { | |
| 436 | + if (add) { | |
| 437 | + updateFansNumber = updateFansNumber + 1; | |
| 438 | + } else { | |
| 439 | + updateFansNumber = updateFansNumber - 1; | |
| 440 | + } | |
| 441 | + return getNumDiff(updateFansNumber); | |
| 442 | + } | |
| 443 | + | |
| 444 | + public boolean isFan() { | |
| 445 | + return fan; | |
| 446 | + } | |
| 447 | + | |
| 448 | + public void setFan(boolean fan) { | |
| 449 | + this.fan = fan; | |
| 450 | + } | |
| 451 | + | |
| 452 | + public String getDarenId() { | |
| 453 | + return darenId; | |
| 454 | + } | |
| 455 | + | |
| 456 | + public void setDarenId(String darenId) { | |
| 457 | + this.darenId = darenId; | |
| 458 | + } | |
| 459 | + | |
| 460 | + public String getAddress() { | |
| 461 | + return address; | |
| 462 | + } | |
| 463 | + | |
| 464 | + public void setAddress(String address) { | |
| 465 | + this.address = address; | |
| 466 | + } | |
| 467 | + | |
| 468 | + public String getShopName() { | |
| 469 | + return shopName; | |
| 470 | + } | |
| 471 | + | |
| 472 | + public void setShopName(String shopName) { | |
| 473 | + this.shopName = shopName; | |
| 474 | + } | |
| 475 | + | |
| 476 | + public float getGrade() { | |
| 477 | + return grade; | |
| 478 | + } | |
| 479 | + | |
| 480 | + public void setGrade(float grade) { | |
| 481 | + this.grade = grade; | |
| 482 | + } | |
| 483 | + | |
| 484 | + public boolean isOnline() { | |
| 485 | + return online; | |
| 486 | + } | |
| 487 | + | |
| 488 | + public void setOnline(boolean online) { | |
| 489 | + this.online = online; | |
| 490 | + } | |
| 491 | + | |
| 492 | + public List<DarenContent> getContent() { | |
| 493 | + return content; | |
| 494 | + } | |
| 495 | + | |
| 496 | + public void setContent(List<DarenContent> content) { | |
| 497 | + this.content = content; | |
| 498 | + } | |
| 499 | + | |
| 500 | + public List<CategoryContent> getCategory() { | |
| 501 | + return category; | |
| 502 | + } | |
| 503 | + | |
| 504 | + public void setCategory(List<CategoryContent> category) { | |
| 505 | + this.category = category; | |
| 506 | + } | |
| 507 | + | |
| 508 | + public String getOrderCount() { | |
| 509 | + return getNumDiff(Integer.parseInt(orderCount)); | |
| 510 | + } | |
| 511 | + | |
| 512 | + public void setOrderCount(String orderCount) { | |
| 513 | + this.orderCount = orderCount; | |
| 514 | + } | |
| 515 | + | |
| 516 | + public String getCommentCount() { | |
| 517 | + return getNumDiff(Integer.parseInt(commentCount)); | |
| 518 | + } | |
| 519 | + | |
| 520 | + public void setCommentCount(String commentCount) { | |
| 521 | + this.commentCount = commentCount; | |
| 522 | + } | |
| 523 | + | |
| 524 | + public List<Propaganda> getPropagandas() { | |
| 525 | + return propagandas; | |
| 526 | + } | |
| 527 | + | |
| 528 | + public void setPropagandas(List<Propaganda> propagandas) { | |
| 529 | + this.propagandas = propagandas; | |
| 530 | + } | |
| 531 | + | |
| 532 | + /** | |
| 533 | + * 数量转换 | |
| 534 | + */ | |
| 535 | + public String getNumDiff(int count) { | |
| 536 | + String fansNum = ""; | |
| 537 | + if (count >= 0 && count < 10000) { | |
| 538 | + fansNum = count + ""; | |
| 539 | + } else if (count >= 10000 && count < 10000000) { | |
| 540 | + if (count / 1000 % 10 != 0) { | |
| 541 | + float num = (float) count / 10000; | |
| 542 | + DecimalFormat decimalFormat = new DecimalFormat("0.0"); | |
| 543 | + fansNum = decimalFormat.format(num).concat("万"); | |
| 544 | + } else { | |
| 545 | + fansNum = (count / 10000) + "万"; | |
| 546 | + } | |
| 547 | + } else if (count >= 10000000) { | |
| 548 | + fansNum = "1000万"; | |
| 549 | + } | |
| 550 | + return fansNum; | |
| 551 | + } | |
| 552 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/GetDarensData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by gujun on 2018/1/24. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class GetDarensData { | |
| 10 | + private int pageNo; | |
| 11 | + private int nextPage; | |
| 12 | + private int pageSize; | |
| 13 | + private List<DarensFans> fans; | |
| 14 | + | |
| 15 | + public static class DarensFans { | |
| 16 | + private String userId; | |
| 17 | + private String nickName; | |
| 18 | + private String image; | |
| 19 | + | |
| 20 | + public String getUserId() { | |
| 21 | + return userId; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public void setUserId(String userId) { | |
| 25 | + this.userId = userId; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public String getNickName() { | |
| 29 | + return nickName; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public void setNickName(String nickName) { | |
| 33 | + this.nickName = nickName; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public String getImage() { | |
| 37 | + return image; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public void setImage(String image) { | |
| 41 | + this.image = image; | |
| 42 | + } | |
| 43 | + } | |
| 44 | + | |
| 45 | + public int getPageNo() { | |
| 46 | + return pageNo; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void setPageNo(int pageNo) { | |
| 50 | + this.pageNo = pageNo; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public int getNextPage() { | |
| 54 | + return nextPage; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public void setNextPage(int nextPage) { | |
| 58 | + this.nextPage = nextPage; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public int getPageSize() { | |
| 62 | + return pageSize; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setPageSize(int pageSize) { | |
| 66 | + this.pageSize = pageSize; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public List<DarensFans> getFans() { | |
| 70 | + return fans; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setFans(List<DarensFans> fans) { | |
| 74 | + this.fans = fans; | |
| 75 | + } | |
| 76 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/HotList.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by Lynn on 2018/3/14. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class HotList { | |
| 10 | + private boolean fan; | |
| 11 | + private IconData icon; | |
| 12 | + private HotItem item; | |
| 13 | + private List<CategoryData> categories; | |
| 14 | + | |
| 15 | + public boolean getFan() { | |
| 16 | + return fan; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public void setFan(boolean fan) { | |
| 20 | + this.fan = fan; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public IconData getIcon() { | |
| 24 | + return icon; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public void setIcon(IconData icon) { | |
| 28 | + this.icon = icon; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public HotItem getItem() { | |
| 32 | + return item; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setItem(HotItem item) { | |
| 36 | + this.item = item; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public List<CategoryData> getCategories() { | |
| 40 | + return categories; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setCategories(List<CategoryData> categories) { | |
| 44 | + this.categories = categories; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public static class HotItem { | |
| 48 | + | |
| 49 | + public static class Image { | |
| 50 | + private String imagePath; | |
| 51 | + private String thumbnailPath; | |
| 52 | + private String thumbnailsFirstPic; | |
| 53 | + private int height; | |
| 54 | + private int width; | |
| 55 | + | |
| 56 | + public String getImagePath() { | |
| 57 | + return imagePath; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setImagePath(String imagePath) { | |
| 61 | + this.imagePath = imagePath; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getThumbnailPath() { | |
| 65 | + return thumbnailPath; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setThumbnailPath(String thumbnailPath) { | |
| 69 | + this.thumbnailPath = thumbnailPath; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public String getThumbnailsFirstPic() { | |
| 73 | + return thumbnailsFirstPic; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setThumbnailsFirstPic(String thumbnailsFirstPic) { | |
| 77 | + this.thumbnailsFirstPic = thumbnailsFirstPic; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public int getHeight() { | |
| 81 | + return height; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public void setHeight(int height) { | |
| 85 | + this.height = height; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public int getWidth() { | |
| 89 | + return width; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setWidth(int width) { | |
| 93 | + this.width = width; | |
| 94 | + } | |
| 95 | + } | |
| 96 | + | |
| 97 | + private String darenId; | |
| 98 | + private String categoryName; | |
| 99 | + private String category; | |
| 100 | + private String text; | |
| 101 | + private long ts; | |
| 102 | + private String address; | |
| 103 | + private String status; | |
| 104 | + private List<Image> images; | |
| 105 | + private String itemId; | |
| 106 | + private String optionId; | |
| 107 | + private String optionDesc; | |
| 108 | + private int type; | |
| 109 | + private MomentData.MomentVideo video; | |
| 110 | + | |
| 111 | + public String getOptionId() { | |
| 112 | + return optionId; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public void setOptionId(String optionId) { | |
| 116 | + this.optionId = optionId; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public String getOptionDesc() { | |
| 120 | + return optionDesc; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setOptionDesc(String optionDesc) { | |
| 124 | + this.optionDesc = optionDesc; | |
| 125 | + } | |
| 126 | + | |
| 127 | + | |
| 128 | + public String getDarenId() { | |
| 129 | + return darenId; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public void setDarenId(String darenId) { | |
| 133 | + this.darenId = darenId; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public String getCategoryName() { | |
| 137 | + return categoryName; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public void setCategoryName(String categoryName) { | |
| 141 | + this.categoryName = categoryName; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public String getCategory() { | |
| 145 | + return category; | |
| 146 | + } | |
| 147 | + | |
| 148 | + public void setCategory(String category) { | |
| 149 | + this.category = category; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public String getText() { | |
| 153 | + return text; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public void setText(String text) { | |
| 157 | + this.text = text; | |
| 158 | + } | |
| 159 | + | |
| 160 | + public long getTs() { | |
| 161 | + return ts; | |
| 162 | + } | |
| 163 | + | |
| 164 | + public void setTs(long ts) { | |
| 165 | + this.ts = ts; | |
| 166 | + } | |
| 167 | + | |
| 168 | + public String getAddress() { | |
| 169 | + return address; | |
| 170 | + } | |
| 171 | + | |
| 172 | + public void setAddress(String address) { | |
| 173 | + this.address = address; | |
| 174 | + } | |
| 175 | + | |
| 176 | + public String getStatus() { | |
| 177 | + return status; | |
| 178 | + } | |
| 179 | + | |
| 180 | + public void setStatus(String status) { | |
| 181 | + this.status = status; | |
| 182 | + } | |
| 183 | + | |
| 184 | + public List<Image> getImages() { | |
| 185 | + return images; | |
| 186 | + } | |
| 187 | + | |
| 188 | + public void setImages(List<Image> images) { | |
| 189 | + this.images = images; | |
| 190 | + } | |
| 191 | + | |
| 192 | + public String getItemId() { | |
| 193 | + return itemId; | |
| 194 | + } | |
| 195 | + | |
| 196 | + public void setItemId(String itemId) { | |
| 197 | + this.itemId = itemId; | |
| 198 | + } | |
| 199 | + | |
| 200 | + public int getType() { | |
| 201 | + return type; | |
| 202 | + } | |
| 203 | + | |
| 204 | + public void setType(int type) { | |
| 205 | + this.type = type; | |
| 206 | + } | |
| 207 | + | |
| 208 | + public MomentData.MomentVideo getVideo() { | |
| 209 | + return video; | |
| 210 | + } | |
| 211 | + | |
| 212 | + public void setVideo(MomentData.MomentVideo video) { | |
| 213 | + this.video = video; | |
| 214 | + } | |
| 215 | + } | |
| 216 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/HotMsgData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by Lynn on 2018/3/15. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class HotMsgData { | |
| 10 | + private String openUrl; | |
| 11 | + private String name; | |
| 12 | + private int sort; | |
| 13 | + private String icon; | |
| 14 | + private List<HotList> hotList; | |
| 15 | + | |
| 16 | + public String getOpenUrl() { | |
| 17 | + return openUrl; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setOpenUrl(String openUrl) { | |
| 21 | + this.openUrl = openUrl; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getName() { | |
| 25 | + return name; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setName(String name) { | |
| 29 | + this.name = name; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public int getSort() { | |
| 33 | + return sort; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setSort(int sort) { | |
| 37 | + this.sort = sort; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public String getIcon() { | |
| 41 | + return icon; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setIcon(String icon) { | |
| 45 | + this.icon = icon; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public List<HotList> getHotList() { | |
| 49 | + return hotList; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setHotList(List<HotList> hotList) { | |
| 53 | + this.hotList = hotList; | |
| 54 | + } | |
| 55 | +} | ... | ... |
happy_china/src/main/java/com/cnlive/strike/happychina/network/model/IconData.java
0 → 100644
| 1 | +package com.cnlive.strike.happychina.network.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by Lynn on 2018/3/14. | |
| 5 | + */ | |
| 6 | + | |
| 7 | +public class IconData { | |
| 8 | + private String image; | |
| 9 | + private String nickName; | |
| 10 | + private String userId; | |
| 11 | + private int fansCount; | |
| 12 | + private int orderCount; | |
| 13 | + private boolean state; | |
| 14 | + private String extInfo; | |
| 15 | + | |
| 16 | + public String getImage() { | |
| 17 | + return image; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setImage(String image) { | |
| 21 | + this.image = image; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getNickName() { | |
| 25 | + return nickName; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setNickName(String nickName) { | |
| 29 | + this.nickName = nickName; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public String getUserId() { | |
| 33 | + return userId; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setUserId(String userId) { | |
| 37 | + this.userId = userId; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public int getFansCount() { | |
| 41 | + return fansCount; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setFansCount(int fansCount) { | |
| 45 | + this.fansCount = fansCount; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public int getOrderCount() { | |
| 49 | + return orderCount; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setOrderCount(int orderCount) { | |
| 53 | + this.orderCount = orderCount; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public boolean isState() { | |
| 57 | + return state; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setState(boolean state) { | |
| 61 | + this.state = state; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getExtInfo() { | |
| 65 | + return extInfo; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setExtInfo(String extInfo) { | |
| 69 | + this.extInfo = extInfo; | |
| 70 | + } | |
| 71 | +} | ... | ... |