├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.MD
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── src
│ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── liuzhi
│ │ │ └── one
│ │ │ └── ExampleInstrumentedTest.java
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── liuzh
│ │ │ │ └── one
│ │ │ │ ├── activity
│ │ │ │ ├── AuthorActivity.java
│ │ │ │ ├── BaseActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── MovieActivity.java
│ │ │ │ ├── MusicActivity.java
│ │ │ │ ├── QuestionActivity.java
│ │ │ │ ├── ReadActivity.java
│ │ │ │ ├── SplashActivity.java
│ │ │ │ └── VideoActivity.java
│ │ │ │ ├── adapter
│ │ │ │ ├── CommentRvAdapter.java
│ │ │ │ ├── ListRvAdapter.java
│ │ │ │ └── ViewsPagerAdapter.java
│ │ │ │ ├── application
│ │ │ │ └── App.java
│ │ │ │ ├── bean
│ │ │ │ ├── Author.java
│ │ │ │ ├── ContentList.java
│ │ │ │ ├── DataList.java
│ │ │ │ ├── Qq.java
│ │ │ │ ├── ShareList.java
│ │ │ │ ├── Tag.java
│ │ │ │ ├── Weibo.java
│ │ │ │ ├── Wx.java
│ │ │ │ ├── comment
│ │ │ │ │ ├── Comment.java
│ │ │ │ │ ├── CommentData.java
│ │ │ │ │ ├── Datum.java
│ │ │ │ │ └── User.java
│ │ │ │ ├── list
│ │ │ │ │ ├── Data.java
│ │ │ │ │ ├── Icons.java
│ │ │ │ │ ├── OneDay.java
│ │ │ │ │ ├── OneListId.java
│ │ │ │ │ ├── ShareInfo.java
│ │ │ │ │ └── Weather.java
│ │ │ │ ├── movie
│ │ │ │ │ ├── Movie.java
│ │ │ │ │ └── MovieData.java
│ │ │ │ ├── music
│ │ │ │ │ ├── Music.java
│ │ │ │ │ └── MusicData.java
│ │ │ │ ├── question
│ │ │ │ │ ├── Question.java
│ │ │ │ │ └── QuestionData.java
│ │ │ │ └── read
│ │ │ │ │ ├── Read.java
│ │ │ │ │ └── ReadData.java
│ │ │ │ ├── dialog
│ │ │ │ ├── MovieProfilePopupWindow.java
│ │ │ │ ├── OneImgPopupWindow.java
│ │ │ │ └── SharePopupWindow.java
│ │ │ │ ├── fragment
│ │ │ │ ├── BaseFragment.java
│ │ │ │ ├── HomeFragment.java
│ │ │ │ ├── ListFragment.java
│ │ │ │ └── OneContentFragment.java
│ │ │ │ ├── utils
│ │ │ │ ├── BitmapUtil.java
│ │ │ │ ├── CircleTransform.java
│ │ │ │ ├── Constant.java
│ │ │ │ ├── DateUtil.java
│ │ │ │ ├── DensityUtil.java
│ │ │ │ ├── FileUtil.java
│ │ │ │ ├── HtmlFmtUtil.java
│ │ │ │ ├── RetrofitUtil.java
│ │ │ │ └── SPUtil.java
│ │ │ │ └── view
│ │ │ │ ├── AppToolbar.java
│ │ │ │ ├── AuthorsView.java
│ │ │ │ ├── CDView.java
│ │ │ │ └── ScrollRecyclerView.java
│ │ └── res
│ │ │ ├── anim
│ │ │ ├── pop_enter_b2t.xml
│ │ │ ├── pop_enter_r2l.xml
│ │ │ ├── pop_exit_l2r.xml
│ │ │ └── pop_exit_t2b.xml
│ │ │ ├── drawable-v21
│ │ │ └── click_bg.xml
│ │ │ ├── drawable
│ │ │ ├── back.png
│ │ │ ├── click_bg.xml
│ │ │ ├── click_default.xml
│ │ │ ├── click_pressed.xml
│ │ │ ├── collect.png
│ │ │ ├── collect_high_light.png
│ │ │ ├── comment.png
│ │ │ ├── comment_laud.png
│ │ │ ├── comment_laud_selected.png
│ │ │ ├── decoration.xml
│ │ │ ├── edit.png
│ │ │ ├── feeds_music.png
│ │ │ ├── feeds_music_story.png
│ │ │ ├── follow_bg.xml
│ │ │ ├── frame_loading.xml
│ │ │ ├── like.png
│ │ │ ├── like_high_light.png
│ │ │ ├── listen.png
│ │ │ ├── loading_1.png
│ │ │ ├── loading_10.png
│ │ │ ├── loading_11.png
│ │ │ ├── loading_12.png
│ │ │ ├── loading_2.png
│ │ │ ├── loading_3.png
│ │ │ ├── loading_4.png
│ │ │ ├── loading_5.png
│ │ │ ├── loading_6.png
│ │ │ ├── loading_7.png
│ │ │ ├── loading_8.png
│ │ │ ├── loading_9.png
│ │ │ ├── movie_bottom_bg.xml
│ │ │ ├── movie_info.png
│ │ │ ├── one_icon.png
│ │ │ ├── one_placeholder.png
│ │ │ ├── pause.png
│ │ │ ├── placeholder.png
│ │ │ ├── play.png
│ │ │ ├── qq.png
│ │ │ ├── search.png
│ │ │ ├── share.png
│ │ │ ├── tab_home_checked.png
│ │ │ ├── tab_home_unchecked.png
│ │ │ ├── tab_movie_checked.png
│ │ │ ├── tab_movie_unchecked.png
│ │ │ ├── tab_music_checked.png
│ │ │ ├── tab_music_unchecked.png
│ │ │ ├── tab_read_checked.png
│ │ │ ├── tab_read_unchecked.png
│ │ │ ├── url.png
│ │ │ ├── user.png
│ │ │ ├── weibo.png
│ │ │ ├── weichat.png
│ │ │ ├── weichat_friendes.png
│ │ │ └── xiami.png
│ │ │ ├── layout
│ │ │ ├── activity_author.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── activity_movie.xml
│ │ │ ├── activity_music.xml
│ │ │ ├── activity_play_video.xml
│ │ │ ├── activity_question.xml
│ │ │ ├── activity_read.xml
│ │ │ ├── activity_splash.xml
│ │ │ ├── fragment_content.xml
│ │ │ ├── fragment_home.xml
│ │ │ ├── item_rv_commet.xml
│ │ │ ├── item_rv_day_one.xml
│ │ │ ├── item_rv_movie.xml
│ │ │ ├── item_rv_music.xml
│ │ │ ├── item_rv_read.xml
│ │ │ ├── layout_author.xml
│ │ │ ├── layout_detail_authors.xml
│ │ │ ├── layout_detail_bottombar.xml
│ │ │ ├── layout_detail_comments.xml
│ │ │ ├── layout_detail_content.xml
│ │ │ ├── layout_detail_head.xml
│ │ │ ├── layout_hot_decoration.xml
│ │ │ ├── layout_loading.xml
│ │ │ ├── layout_main_content.xml
│ │ │ ├── layout_main_head.xml
│ │ │ ├── layout_play_movie.xml
│ │ │ ├── layout_popup_movie_profile.xml
│ │ │ ├── layout_popup_one_img.xml
│ │ │ ├── layout_popup_share.xml
│ │ │ ├── layout_rv_item_bottom.xml
│ │ │ └── layout_toolbar_content.xml
│ │ │ ├── menu
│ │ │ └── menu.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── attrs.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── liuzhi
│ │ └── one
│ │ └── ExampleUnitTest.java
└── 《ONE一个》.apk
├── build.gradle
├── gif
├── home.gif
├── movie.gif
├── music.gif
└── read.gif
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.MD:
--------------------------------------------------------------------------------
1 |
2 | # 说高仿,其实做成了个山寨...
3 |
4 | - **目前完成度看图:**
5 |
6 | 
7 |
8 | ## 关于我
9 | 1. 最近火力全开正在实现中,感兴趣的朋友可以**Star**一下,关注我的后续动作
10 | 2. 虽是火力全开,但学生党目前还有课,有进度但效率可能不太高
11 | 3. 联系我:qq354295878@gmail.com(一个邮箱暴露两个联系方式,完美)
12 | 4. 另:大三狗一枚,求安卓开发实习岗位中
13 |
14 |
15 | ## 开发相关
16 |
17 | ### 更新:
18 | ```
19 | -2017-4-14 :
20 | 1. 发现Picasso的Target工作在主线程,遂用AsyncTask装一下
21 | 2. 解决在电影详情页按back程序挂掉的bug
22 |
23 | -2017-4-12 :
24 | 1. 所有圆形图片的ImageView换成CircleImageView:新增依赖CircleImageView
25 | 2. API请求APP版本更换成4.1.0
26 |
27 | -2017-4-9 :
28 | 1. 删除电影简介activity,替换成popupWindow展示
29 | 2. 每日一图的popupWindow长按图片实现通过Picasso保存图片到制定路径
30 |
31 | -2017-4-8 :
32 | 1. 自定义RecyclerView实现滚动实时监听,彻底解决RecyclerView滚动时toolbar显示bug
33 | 2. 添加水波纹点击效果
34 | 3. 添加分享按钮弹出popupWindow,包含弹出动画/退出动画
35 | 4. OneList的每日一图点击弹出popupWindow,长按pop图片,弹出Snackbar提示是否保存图片
36 |
37 | -2017-4-7 :
38 | 1. 更换部分图片
39 | 2. 添加各详情页的评论列表
40 | 3. 优化部分代码
41 | 注:后期更新频率会减少
42 |
43 | -2017-4-6 :
44 | 1. 添加BaseFragment、优化fragment代码/逻辑
45 | 2. 自定义RecyclerView实现滚动实时监听(未完成)
46 | 3. 添加作者信息Activity(未完成/无法完成:无作者文章API)
47 |
48 | -2017-4-5 :
49 | 1. 解决tab切换时toolbar显示异常的bug
50 | 2. 优化fragment代码/逻辑
51 |
52 | -2017-4-2 :
53 | 1. 添加页面加载动画(帧动画)
54 |
55 | -2017-3-30:
56 | 1. 优化代码结构:baseActivity&adapter&布局
57 |
58 | -2017-3-27:
59 | 1. 实现底部tab点击,主界面所有tab均有内容展现
60 |
61 | -2017-3-25:
62 | 1. 增加音乐详情页(所有详情页均无显示评论列表,后续加)
63 |
64 | -2017-3-24:
65 | 1. 增加电影详情页以及部分细节调整/实现
66 |
67 | -...再早没写。一次性出来的...
68 | ```
69 |
70 | ### 大致内容:
71 |
72 | 1. Retrofit进行网络请求
73 | 2. Picasso图片加载;Picasso保存图片到SD卡
74 | 3. RecycleView显示不同类型item
75 | 4. ViewPager切换动画+Fragment
76 | 5. WebView的JS交互(一丢丢,在MovieActivity);WebView加载HTML
77 | 6. 等等...细节说不了那么多,也不好表述,都在项目里
78 |
79 | ### ONE的API:[ONE-API](https://github.com/jokermonn/-Api/blob/master/ONEv3.5.0~.md)
80 |
81 | API来自网络,若侵犯《ONE一个》权利,本人将及时停止使用并删除相关内容
82 |
83 | **PS**:感谢分享的哥们儿;也提示各位朋友不要用于商业用途
84 |
85 | **废话**:《ONE》这个APP的API和JSON不忍直视,原APP卡顿明显,体验差强人意。
86 |
87 | ### 使用到的库:
88 | ```
89 | - compile 'com.squareup.retrofit2:retrofit:2.2.0'//Retrofit
90 | - compile 'com.squareup.retrofit2:converter-gson:2.0.2'//Gson
91 | - compile 'com.squareup.picasso:picasso:2.5.2'//picasso
92 | - compile 'com.android.support:design:25.3.1'//MD
93 | - compile 'com.android.support:recyclerview-v7:25.3.1'//recyclerView
94 | - compile 'de.hdodenhof:circleimageview:2.1.0'//CircleIV
95 | ```
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion '25.0.2'
6 | defaultConfig {
7 | applicationId "com.liuzh.one"
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 |
28 | compile 'com.android.support:appcompat-v7:25.3.1'
29 |
30 | testCompile 'junit:junit:4.12'
31 | //noinspection GradleCompatible
32 |
33 | compile 'com.android.support:recyclerview-v7:25.3.1'//recyclerView
34 | compile 'com.squareup.retrofit2:retrofit:2.2.0'//Retrofit
35 | compile 'com.squareup.retrofit2:converter-gson:2.0.2'//GSon
36 | compile 'com.squareup.picasso:picasso:2.5.2'//picasso
37 | compile 'com.android.support:design:25.3.1'//MaterialDesign
38 | compile 'de.hdodenhof:circleimageview:2.1.0'//CircleImageView
39 | }
40 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\AndroidDevelopment\android-sdk-windows/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/liuzhi/one/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.liuzhi.one;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.liuzhi.one", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/activity/AuthorActivity.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 |
9 | import com.liuzh.one.R;
10 | import com.liuzh.one.bean.Author;
11 | import com.liuzh.one.utils.Constant;
12 | import com.squareup.picasso.Picasso;
13 |
14 | import de.hdodenhof.circleimageview.CircleImageView;
15 |
16 | /**
17 | * 作者信息activity
18 | * Created by 刘晓彬 on 2017/4/6.
19 | */
20 |
21 | public class AuthorActivity extends BaseActivity {
22 |
23 | private ImageView mIvBack;
24 | private CircleImageView mCivHead;
25 | private TextView mTvName;
26 | private TextView mTvSummary;
27 | private TextView mTvDesc;
28 | private TextView mTvFansNum;
29 | private TextView mTvTitle;
30 |
31 |
32 | public static void start(Context context, Author author) {
33 | Intent starter = new Intent(context, AuthorActivity.class);
34 | starter.putExtra(Constant.INTENT_KEY_AUTHOR, author);
35 | context.startActivity(starter);
36 | }
37 |
38 | @Override
39 | protected int getContentId() {
40 | return R.layout.activity_author;
41 | }
42 |
43 | @Override
44 | protected void findViews() {
45 | mCivHead = (CircleImageView) findViewById(R.id.iv_head);
46 | mTvName = (TextView) findViewById(R.id.tv_author_name);
47 | mTvSummary = (TextView) findViewById(R.id.tv_summary);
48 | mTvDesc = (TextView) findViewById(R.id.tv_desc);
49 | mTvFansNum = (TextView) findViewById(R.id.tv_fans_num);
50 | mIvBack = (ImageView) findViewById(R.id.iv_back);
51 | mTvTitle = (TextView) findViewById(R.id.tv_title);
52 | }
53 |
54 | @Override
55 | protected void initViewData() {
56 | Author author = (Author) getIntent().getSerializableExtra(Constant.INTENT_KEY_AUTHOR);
57 | Picasso.with(mContext)
58 | .load(author.web_url)
59 | .placeholder(R.mipmap.ic_launcher)
60 | .into(mCivHead);
61 | mTvName.setText(author.user_name);
62 | mTvSummary.setText(author.summary);
63 | mTvDesc.setText(author.desc);
64 | mTvFansNum.setText(author.fans_total + "关注");
65 | mIvBack.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View view) {
68 | finish();
69 | }
70 | });
71 | mTvTitle.setText(author.user_name);
72 | mTvTitle.setAlpha(0);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.activity;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.AnimationDrawable;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.View;
10 | import android.widget.ImageView;
11 |
12 | import com.liuzh.one.R;
13 |
14 | /**
15 | * base activity
16 | * Created by 刘晓彬 on 2017/3/26.
17 | */
18 |
19 | public abstract class BaseActivity extends AppCompatActivity {
20 |
21 | protected Context mContext;
22 | private ImageView mIvLoading;
23 |
24 | @Override
25 | protected void onCreate(@Nullable Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | mContext = this;
28 | setContentView(getContentId());
29 | findViews();
30 | initViewData();
31 | fetchData();
32 | setDarkStatusIcon(true);
33 | }
34 |
35 | public void setDarkStatusIcon(boolean bDark) {
36 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
37 | View decorView = getWindow().getDecorView();
38 | if (decorView != null) {
39 | int vis = decorView.getSystemUiVisibility();
40 | if (bDark) {
41 | vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
42 | } else {
43 | vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
44 | }
45 | decorView.setSystemUiVisibility(vis);
46 | }
47 | }
48 | }
49 |
50 | protected abstract int getContentId();
51 |
52 | protected void fetchData() {
53 | }
54 |
55 | protected abstract void findViews();
56 |
57 | protected abstract void initViewData();
58 |
59 | protected void hiddenLoadingView() {
60 | mIvLoading.setVisibility(View.GONE);
61 | }
62 |
63 | protected void showLoadingView() {
64 | if (mIvLoading == null) {
65 | mIvLoading = (ImageView) findViewById(R.id.iv_loading);
66 | }
67 | ((AnimationDrawable) mIvLoading.getDrawable()).start();
68 | mIvLoading.setVisibility(View.VISIBLE);
69 | }
70 |
71 | @Override
72 | public void onBackPressed() {
73 | super.onBackPressed();
74 | }
75 |
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/activity/MusicActivity.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.v7.widget.DividerItemDecoration;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.View;
9 | import android.webkit.WebView;
10 | import android.widget.TextView;
11 |
12 | import com.liuzh.one.R;
13 | import com.liuzh.one.adapter.CommentRvAdapter;
14 | import com.liuzh.one.application.App;
15 | import com.liuzh.one.bean.Tag;
16 | import com.liuzh.one.bean.comment.Comment;
17 | import com.liuzh.one.bean.comment.CommentData;
18 | import com.liuzh.one.bean.music.Music;
19 | import com.liuzh.one.bean.music.MusicData;
20 | import com.liuzh.one.utils.Constant;
21 | import com.liuzh.one.utils.HtmlFmtUtil;
22 | import com.liuzh.one.utils.RetrofitUtil;
23 | import com.liuzh.one.view.AppToolbar;
24 | import com.liuzh.one.view.AuthorsView;
25 | import com.liuzh.one.view.CDView;
26 | import com.squareup.picasso.Picasso;
27 |
28 | import java.util.List;
29 |
30 | import retrofit2.Call;
31 | import retrofit2.Callback;
32 | import retrofit2.Response;
33 |
34 | /**
35 | * music activity
36 | * Created by 刘晓彬 on 2017/3/23.
37 | */
38 |
39 | public class MusicActivity extends BaseActivity {
40 |
41 |
42 | private AppToolbar mToolbar;
43 | private CDView mCdvMusic;
44 | private TextView mTvMusicAuthor;
45 | private TextView mTvTitle;
46 | private TextView mTvAuthorName;
47 | private WebView mWvContent;
48 | private TextView mTvEditorInfo;
49 | private TextView mTvCopyright;
50 | private TextView mTvLikeComment;
51 | private AuthorsView mAvAuthors;
52 | private Call mMusicCall;
53 | private Call mCommentCall;
54 | private RecyclerView mRvComments;
55 |
56 | public static void start(Context context, int id) {
57 | Intent intent = new Intent(context, MusicActivity.class);
58 | intent.putExtra(Constant.INTENT_KEY_ID, id);
59 | context.startActivity(intent);
60 | }
61 |
62 | @Override
63 | protected int getContentId() {
64 | return R.layout.activity_music;
65 | }
66 |
67 | @Override
68 | protected void findViews() {
69 | mToolbar = (AppToolbar) findViewById(R.id.toolbar);
70 | mCdvMusic = (CDView) findViewById(R.id.cdv_music);
71 | mTvMusicAuthor = (TextView) findViewById(R.id.tv_music_author);
72 | mTvTitle = (TextView) findViewById(R.id.tv_title);
73 | mTvAuthorName = (TextView) findViewById(R.id.tv_author_name);
74 | mWvContent = (WebView) findViewById(R.id.webView);
75 | mTvEditorInfo = (TextView) findViewById(R.id.tv_info);
76 | mTvCopyright = (TextView) findViewById(R.id.tv_copyright);
77 | mTvLikeComment = (TextView) findViewById(R.id.tv_like_comment);
78 | mAvAuthors = (AuthorsView) findViewById(R.id.av_authors);
79 | mRvComments = (RecyclerView) findViewById(R.id.rv_comments);
80 | }
81 |
82 | @Override
83 | protected void initViewData() {
84 | showLoadingView();
85 | // init toolbar
86 | mToolbar.setLBtnDrawable(R.drawable.back);
87 | mToolbar.setLBtnClickListener(new View.OnClickListener() {
88 | @Override
89 | public void onClick(View view) {
90 | finish();
91 | }
92 | });
93 | mToolbar.setRRDrawable(R.drawable.share);
94 | mToolbar.initShareListener(findViewById(R.id.main));
95 | setSupportActionBar(mToolbar);
96 | LinearLayoutManager layoutManager = new LinearLayoutManager(mContext) {
97 | @Override
98 | public boolean canScrollVertically() {
99 | return false;
100 | }
101 | };
102 | mRvComments.setLayoutManager(layoutManager);
103 | mRvComments.addItemDecoration(new DividerItemDecoration(
104 | mContext, DividerItemDecoration.VERTICAL));
105 | }
106 |
107 | private void setData(MusicData data) {
108 | String toolbarTitle = getString(R.string.one_music);
109 | List tags = data.tag_list;
110 | if (tags.size() != 0) {
111 | toolbarTitle = tags.get(0).title;
112 | }
113 | mToolbar.setToolbarTitle(toolbarTitle);
114 | Picasso.with(mContext)
115 | .load(data.cover)
116 | .into(mCdvMusic);
117 | mTvMusicAuthor.setText(" · " + data.title + " · \n" +
118 | data.author.user_name + " | " + data.album);
119 | mTvTitle.setText(data.story_title);
120 | mTvAuthorName.setText("文 / " + data.story_author.user_name);
121 | mWvContent.loadDataWithBaseURL("about:blank",
122 | HtmlFmtUtil.fmt(data.story), "text/html", "utf-8", null);
123 | mTvEditorInfo.setText(data.charge_edt + " " + data.editor_email);
124 | mTvCopyright.setText(data.copyright);
125 | mTvLikeComment.setText(data.praisenum + " 喜欢 · " + data.commentnum + " 评论");
126 | mAvAuthors.setAuthors(data.author_list);
127 | }
128 |
129 | @Override
130 | protected void fetchData() {
131 | int id = getIntent().getIntExtra(Constant.INTENT_KEY_ID, -1);
132 | if (id == -1) {
133 | App.showToast("id=-1");
134 | return;
135 | }
136 | fetchMusic(id);
137 | fetchComment(id);
138 | }
139 |
140 | private void fetchComment(final int id) {
141 | mCommentCall = RetrofitUtil.getMusicCommentCall(id);
142 | mCommentCall.enqueue(new Callback() {
143 | @Override
144 | public void onResponse(Call call, Response response) {
145 | setComment(response.body().data);
146 | }
147 |
148 | @Override
149 | public void onFailure(Call call, Throwable t) {
150 | fetchComment(id);
151 | }
152 | });
153 | }
154 |
155 | public void setComment(CommentData comment) {
156 | mRvComments.setAdapter(new CommentRvAdapter(mContext, comment));
157 | }
158 |
159 | private void fetchMusic(final int id) {
160 | mMusicCall = RetrofitUtil.getMusicCall(id);
161 | mMusicCall.enqueue(new Callback() {
162 | @Override
163 | public void onResponse(Call call, Response response) {
164 | setData(response.body().data);
165 | hiddenLoadingView();
166 | }
167 |
168 | @Override
169 | public void onFailure(Call call, Throwable t) {
170 | App.showToast("失败-再次请求");
171 | fetchMusic(id);
172 | }
173 | });
174 | }
175 |
176 | @Override
177 | protected void onDestroy() {
178 | super.onDestroy();
179 | mMusicCall.cancel();
180 | mCommentCall.cancel();
181 | }
182 |
183 | @Override
184 | public void onBackPressed() {
185 | if (mToolbar.popIsShowing()) {
186 | mToolbar.dismissPop();
187 | } else {
188 | finish();
189 | }
190 | }
191 | }
192 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/activity/QuestionActivity.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.v7.widget.DividerItemDecoration;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.text.TextUtils;
9 | import android.view.View;
10 | import android.webkit.WebView;
11 | import android.webkit.WebViewClient;
12 | import android.widget.TextView;
13 |
14 | import com.liuzh.one.R;
15 | import com.liuzh.one.adapter.CommentRvAdapter;
16 | import com.liuzh.one.application.App;
17 | import com.liuzh.one.bean.Tag;
18 | import com.liuzh.one.bean.comment.Comment;
19 | import com.liuzh.one.bean.comment.CommentData;
20 | import com.liuzh.one.bean.question.Question;
21 | import com.liuzh.one.bean.question.QuestionData;
22 | import com.liuzh.one.utils.Constant;
23 | import com.liuzh.one.utils.HtmlFmtUtil;
24 | import com.liuzh.one.utils.RetrofitUtil;
25 | import com.liuzh.one.view.AppToolbar;
26 |
27 | import java.util.List;
28 |
29 | import retrofit2.Call;
30 | import retrofit2.Callback;
31 | import retrofit2.Response;
32 |
33 | /**
34 | * Created by 刘晓彬 on 2017/3/28.
35 | */
36 |
37 | public class QuestionActivity extends BaseActivity {
38 |
39 | private AppToolbar mToolbar;
40 | private TextView mTvQuestionTitle;
41 | private TextView mTvQuestionContent;
42 | private TextView mTvQuestionAsker;
43 | private TextView mTvAnswerer;
44 | private TextView mTvEditorInfo;
45 | private TextView mTvCopyright;
46 | private WebView mWvContent;
47 | private Call mQuestionCall;
48 | private Call mCommentCall;
49 | private RecyclerView mRvComments;
50 |
51 | public static void start(Context context, int id) {
52 | Intent intent = new Intent(context, QuestionActivity.class);
53 | intent.putExtra(Constant.INTENT_KEY_ID, id);
54 | context.startActivity(intent);
55 | }
56 |
57 | @Override
58 | protected int getContentId() {
59 | return R.layout.activity_question;
60 | }
61 |
62 |
63 | @Override
64 | protected void findViews() {
65 | mToolbar = (AppToolbar) findViewById(R.id.toolbar);
66 | mTvQuestionTitle = (TextView) findViewById(R.id.tv_question_title);
67 | mTvQuestionContent = (TextView) findViewById(R.id.tv_question_content);
68 | mTvQuestionAsker = (TextView) findViewById(R.id.tv_question_asker);
69 | mTvAnswerer = (TextView) findViewById(R.id.tv_answerer);
70 | mWvContent = (WebView) findViewById(R.id.webView);
71 | mTvEditorInfo = (TextView) findViewById(R.id.tv_info);
72 | mTvCopyright = (TextView) findViewById(R.id.tv_copyright);
73 | mRvComments = (RecyclerView) findViewById(R.id.rv_comments);
74 | }
75 |
76 | @Override
77 | protected void initViewData() {
78 | showLoadingView();
79 | // init toolbar
80 | mToolbar.setLBtnDrawable(R.drawable.back);
81 | mToolbar.setLBtnClickListener(new View.OnClickListener() {
82 | @Override
83 | public void onClick(View view) {
84 | finish();
85 | }
86 | });
87 | mToolbar.setRRDrawable(R.drawable.share);
88 | mToolbar.initShareListener(findViewById(R.id.main));
89 | setSupportActionBar(mToolbar);
90 | mWvContent.setWebViewClient(new WebViewClient() {
91 | @Override
92 | public void onPageFinished(WebView view, String url) {
93 | super.onPageFinished(view, url);
94 | hiddenLoadingView();
95 | }
96 | });
97 | LinearLayoutManager layoutManager = new LinearLayoutManager(mContext) {
98 | @Override
99 | public boolean canScrollVertically() {
100 | return false;
101 | }
102 | };
103 | mRvComments.setLayoutManager(layoutManager);
104 | mRvComments.addItemDecoration(new DividerItemDecoration(
105 | mContext, DividerItemDecoration.VERTICAL));
106 | }
107 |
108 |
109 |
110 | private void setData(QuestionData data) {
111 | List tags = data.tag_list;
112 | String toolbarTitle = getString(R.string.one_question);
113 | if (tags.size() != 0) {
114 | toolbarTitle = tags.get(0).title;
115 | }
116 | mToolbar.setToolbarTitle(toolbarTitle);
117 | mTvQuestionTitle.setText(data.question_title);
118 | mTvQuestionContent.setText(data.question_content);
119 | mTvQuestionAsker.setText("————" + data.asker.user_name + "问道");
120 | mTvAnswerer.setText(data.answerer.user_name + "答:");
121 | mWvContent.loadDataWithBaseURL("about:blank",
122 | HtmlFmtUtil.fmt(data.answer_content), "text/html", "utf-8", null);
123 | mTvEditorInfo.setText(data.charge_edt + " " + data.charge_email);
124 | if (TextUtils.isEmpty(data.copyright)) {
125 | mTvCopyright.setVisibility(View.GONE);
126 | } else {
127 | mTvCopyright.setText(data.copyright + "");
128 | }
129 | }
130 |
131 | @Override
132 | protected void fetchData() {
133 | int id = getIntent().getIntExtra(Constant.INTENT_KEY_ID, -1);
134 | if (id == -1) {
135 | App.showToast("ID = -1");
136 | return;
137 | }
138 | fetchQuestion(id);
139 | fetchComment(id);
140 |
141 | }
142 |
143 | private void fetchComment(final int id) {
144 | mCommentCall = RetrofitUtil.getQuestionCommentCall(id);
145 | mCommentCall.enqueue(new Callback() {
146 | @Override
147 | public void onResponse(Call call, Response response) {
148 | setComment(response.body().data);
149 | }
150 |
151 | @Override
152 | public void onFailure(Call call, Throwable t) {
153 | fetchComment(id);
154 | }
155 | });
156 | }
157 |
158 |
159 | private void setComment(CommentData comment) {
160 | mRvComments.setAdapter(new CommentRvAdapter(mContext, comment));
161 | }
162 |
163 | private void fetchQuestion(final int id) {
164 | mQuestionCall = RetrofitUtil.getQuestionCall(id);
165 | mQuestionCall.enqueue(new Callback() {
166 | @Override
167 | public void onResponse(Call call, Response response) {
168 | setData(response.body().data);
169 | hiddenLoadingView();
170 | }
171 |
172 | @Override
173 | public void onFailure(Call call, Throwable t) {
174 | App.showToast("失败,再次尝试");
175 | fetchQuestion(id);
176 | }
177 | });
178 | }
179 |
180 | @Override
181 | protected void onDestroy() {
182 | super.onDestroy();
183 | mQuestionCall.cancel();
184 | }
185 |
186 | @Override
187 | public void onBackPressed() {
188 | if (mToolbar.popIsShowing()) {
189 | mToolbar.dismissPop();
190 | } else {
191 | finish();
192 | }
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/activity/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 |
7 | import com.liuzh.one.R;
8 | import com.liuzh.one.application.App;
9 | import com.liuzh.one.bean.list.OneListId;
10 | import com.liuzh.one.utils.DateUtil;
11 | import com.liuzh.one.utils.RetrofitUtil;
12 | import com.liuzh.one.utils.SPUtil;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Collections;
16 |
17 | import retrofit2.Call;
18 | import retrofit2.Callback;
19 | import retrofit2.Response;
20 |
21 | /**
22 | * 首屏页
23 | * Created by 刘晓彬 on 2017/3/19.
24 | */
25 |
26 | public class SplashActivity extends AppCompatActivity {
27 | private static final String TAG = "SplashActivity";
28 |
29 | @Override
30 | protected void onCreate(@Nullable Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_splash);
33 | fetchOneListId();
34 | }
35 |
36 | /**
37 | * 获取oneListId
38 | */
39 | public void fetchOneListId() {
40 | String nowDate = DateUtil.getFmtYMD();
41 | String lastOpenDate = SPUtil.getString(SPUtil.SP_KEY_OPEN_DATE, "");
42 | //根据SP存储的年月日信息,如果当天打开过应用即当天获取过oneListId,
43 | // 则不再获取直接从SP中读取IDs然后进入MainActivity
44 | if (lastOpenDate.equals(nowDate)) {
45 | String listIdStr = SPUtil.getString(SPUtil.SP_KEY_ONE_LIST_ID, "");
46 | ArrayList listId = new ArrayList<>();
47 | Collections.addAll(listId, listIdStr.split(","));
48 | startMainActivity(listId);
49 | return;
50 | }
51 | //如果当天第一次打开应用,则获取oneListId数据
52 | RetrofitUtil.getOneListIdCall()
53 | .enqueue(new Callback() {
54 | @Override
55 | public void onResponse(Call call, Response response) {
56 | //向SP写入打开应用的日期
57 | SPUtil.putString(SPUtil.SP_KEY_OPEN_DATE, DateUtil.getFmtYMD());
58 | OneListId listId = response.body();
59 | //将oneListId全部存入SP
60 | String content = listId.data.get(0);
61 | for (int i = 1; i < listId.data.size(); i++) {
62 | content = content + "," + listId.data.get(i);
63 | }
64 | SPUtil.putString(SPUtil.SP_KEY_ONE_LIST_ID, content);
65 |
66 | startMainActivity(listId.data);
67 | }
68 |
69 | @Override
70 | public void onFailure(Call call, Throwable t) {
71 | App.showToast("失败,再次尝试");
72 | fetchOneListId();
73 | }
74 | });
75 | }
76 |
77 | /**
78 | * 进入MainActivity
79 | */
80 | private void startMainActivity(ArrayList listId) {
81 | MainActivity.start(this, listId);
82 | finish();
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/activity/VideoActivity.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.widget.MediaController;
10 | import android.widget.VideoView;
11 |
12 | import com.liuzh.one.R;
13 | import com.liuzh.one.utils.Constant;
14 |
15 | /**
16 | * 播放视频 activity
17 | * Created by 刘晓彬 on 2017/4/2.
18 | */
19 |
20 | public class VideoActivity extends AppCompatActivity {
21 |
22 |
23 | private VideoView mVideoView;
24 |
25 | public static void start(Context context, String url) {
26 | Intent starter = new Intent(context, VideoActivity.class);
27 | starter.putExtra(Constant.INTENT_KEY_URL, url);
28 | context.startActivity(starter);
29 | }
30 |
31 | @Override
32 | protected void onCreate(@Nullable Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_play_video);
35 | mVideoView = (VideoView) findViewById(R.id.webView);
36 | String url = getIntent().getStringExtra(Constant.INTENT_KEY_URL);
37 | mVideoView.setVideoURI(Uri.parse(url));
38 | mVideoView.setMediaController(new MediaController(this));
39 | mVideoView.start();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/adapter/CommentRvAdapter.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.text.TextUtils;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.LinearLayout;
11 | import android.widget.TextView;
12 |
13 | import com.liuzh.one.R;
14 | import com.liuzh.one.bean.comment.CommentData;
15 | import com.liuzh.one.bean.comment.Datum;
16 | import com.squareup.picasso.Picasso;
17 |
18 | import java.util.List;
19 |
20 | import de.hdodenhof.circleimageview.CircleImageView;
21 |
22 | /**
23 | * Created by 刘晓彬 on 2017/4/7.
24 | */
25 |
26 | public class CommentRvAdapter extends RecyclerView.Adapter {
27 | private CommentData mCommentData;
28 | private Context mContext;
29 |
30 | public CommentRvAdapter(Context context, CommentData data) {
31 | mContext = context;
32 | mCommentData = data;
33 | boolean added = false;
34 | boolean hasHot = false;
35 | List datums = mCommentData.data;
36 | for (int i = 0; i < datums.size(); i++) {
37 | Datum datum = datums.get(i);
38 | if (datum.type == 0) {
39 | hasHot = true;
40 | } else if (datum.type == 1 && !added && hasHot) {
41 | Datum d = new Datum();
42 | d.type = 3;
43 | datums.add(i, d);
44 | added = true;
45 | }
46 | }
47 | }
48 |
49 |
50 | @Override
51 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
52 | LayoutInflater inflater = LayoutInflater.from(mContext);
53 | RecyclerView.ViewHolder holder;
54 | switch (viewType) {
55 | case 3:
56 | holder = new DecorHolder(inflater.inflate(
57 | R.layout.layout_hot_decoration, parent, false));
58 | break;
59 | default:
60 | holder = new CommentHolder(inflater.inflate(
61 | R.layout.item_rv_commet, parent, false));
62 | }
63 | return holder;
64 | }
65 |
66 | @Override
67 | public int getItemViewType(int position) {
68 | return mCommentData.data.get(position).type;
69 | }
70 |
71 | @Override
72 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
73 | if (holder instanceof CommentHolder) {
74 | Datum datum = mCommentData.data.get(position);
75 | if (!TextUtils.isEmpty(datum.user.web_url)) {
76 | Picasso.with(mContext)
77 | .load(datum.user.web_url)
78 | .into(((CommentHolder) holder).civHead);
79 | }
80 | ((CommentHolder) holder).tvUserName.setText(datum.user.user_name);
81 | ((CommentHolder) holder).tvTime.setText(datum.created_at);
82 | ((CommentHolder) holder).tvContent.setText(datum.content);
83 | ((CommentHolder) holder).tvLaudNum.setText(datum.praisenum + "");
84 | if (datum.touser != null) {
85 | ((CommentHolder) holder).llToUser.setVisibility(View.VISIBLE);
86 | ((CommentHolder) holder).tvToUserName.setText(datum.touser.user_name + ":");
87 | ((CommentHolder) holder).tvToUserContent.setText(datum.quote);
88 | } else {
89 | ((CommentHolder) holder).llToUser.setVisibility(View.GONE);
90 | }
91 | }
92 | }
93 |
94 | @Override
95 | public int getItemCount() {
96 | return mCommentData.data.size();
97 | }
98 |
99 |
100 | class CommentHolder extends RecyclerView.ViewHolder {
101 |
102 | CircleImageView civHead;
103 | ImageView ivComment;
104 | ImageView ivLaud;
105 | TextView tvUserName;
106 | TextView tvTime;
107 | TextView tvContent;
108 | TextView tvLaudNum;
109 | LinearLayout llToUser;
110 | TextView tvToUserName;
111 | TextView tvToUserContent;
112 |
113 | public CommentHolder(View itemView) {
114 | super(itemView);
115 | civHead = (CircleImageView) itemView.findViewById(R.id.iv_head);
116 | ivComment = (ImageView) itemView.findViewById(R.id.iv_comment);
117 | ivLaud = (ImageView) itemView.findViewById(R.id.iv_laud);
118 | tvUserName = (TextView) itemView.findViewById(R.id.tv_username);
119 | tvTime = (TextView) itemView.findViewById(R.id.tv_time);
120 | tvContent = (TextView) itemView.findViewById(R.id.tv_content);
121 | tvLaudNum = (TextView) itemView.findViewById(R.id.tv_laud_num);
122 | llToUser = (LinearLayout) itemView.findViewById(R.id.ll_to_user);
123 | tvToUserName = (TextView) itemView.findViewById(R.id.tv_to_user_username);
124 | tvToUserContent = (TextView) itemView.findViewById(R.id.tv_to_user_content);
125 | }
126 | }
127 |
128 | class DecorHolder extends RecyclerView.ViewHolder {
129 |
130 | public DecorHolder(View itemView) {
131 | super(itemView);
132 | }
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/adapter/ViewsPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.text.TextUtils;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.liuzh.one.R;
10 | import com.liuzh.one.activity.VideoActivity;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * images view pager adapter
16 | * Created by 刘晓彬 on 2017/3/30.
17 | */
18 |
19 | public class ViewsPagerAdapter extends PagerAdapter {
20 | private static final String TAG = "ViewsPagerAdapter";
21 | private List mViews;
22 |
23 | public ViewsPagerAdapter(final Context context, List views) {
24 | mViews = views;
25 | View v = mViews.get(0);
26 | final String videoUrl = (String) v.getTag();
27 | if (!TextUtils.isEmpty(videoUrl)) {
28 | v.findViewById(R.id.iv_play).setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View view) {
31 | VideoActivity.start(context, videoUrl);
32 | }
33 | });
34 | }
35 | }
36 |
37 | @Override
38 | public int getCount() {
39 | return mViews.size();
40 | }
41 |
42 | @Override
43 | public boolean isViewFromObject(View view, Object object) {
44 | return view == object;
45 | }
46 |
47 | @Override
48 | public void destroyItem(ViewGroup container, int position, Object object) {
49 | // container.removeView(mIVList.get(position % mIVList.size()));
50 | }
51 |
52 | @Override
53 | public Object instantiateItem(ViewGroup container, int position) {
54 | View view = mViews.get(position);
55 | ViewGroup parent = (ViewGroup) view.getParent();
56 | //如果当前要显示的view有父布局先将父布局移除(view只能有一个父布局)
57 | if (parent != null) {
58 | parent.removeView(view);
59 | }
60 | container.addView(view);
61 | return view;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/application/App.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.application;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.content.Context;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.widget.Toast;
9 |
10 | import java.lang.ref.Reference;
11 | import java.lang.ref.WeakReference;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * application
17 | * Created by 刘晓彬 on 2017/3/16.
18 | */
19 |
20 | public class App extends Application {
21 | private static final String TAG = "ActivityLC";
22 |
23 | private static Context mContext;
24 | private static Toast toast;
25 |
26 | @Override
27 | public void onCreate() {
28 | super.onCreate();
29 | mContext = this;
30 | }
31 |
32 | public static Context getContext() {
33 | return mContext;
34 | }
35 |
36 | public static void showToast(String msg) {
37 | if (toast == null) {
38 | toast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT);
39 | } else {
40 | toast.setText(msg);
41 | }
42 | toast.show();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/Author.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | import java.io.Serializable;
5 |
6 | public class Author implements Serializable{
7 |
8 | public String user_id;
9 | public String user_name;
10 | public String desc;
11 | public String wb_name;
12 | public String is_settled;
13 | public String settled_type;
14 | public String summary;
15 | public String fans_total;
16 | public String web_url;
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/ContentList.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | import com.liuzh.one.bean.list.ShareInfo;
5 |
6 | import java.util.List;
7 |
8 | public class ContentList {
9 |
10 | public String id;
11 | public String category;
12 | public Integer display_category;
13 | public String item_id;
14 | public String title;
15 | public String forward;
16 | public String img_url;
17 | public Integer like_count;
18 | public String post_date;
19 | public String last_update_date;
20 | public Author author;
21 | public String video_url;
22 | public String audio_url;
23 | public Integer audio_platform;
24 | public String start_video;
25 | public String volume;
26 | public String pic_info;
27 | public String words_info;
28 | public String subtitle;
29 | public Integer number;
30 | public Integer serial_id;
31 | public List serial_list = null;
32 | public String movie_story_id;
33 | public Integer ad_id;
34 | public Integer ad_type;
35 | public String ad_pvurl;
36 | public String ad_linkurl;
37 | public String ad_makettime;
38 | public String ad_closetime;
39 | public String ad_shareCnt;
40 | public String ad_pvurl_vendor;
41 | public String content_id;
42 | public String content_type;
43 | public String content_bgcolor;
44 | public String share_url;
45 | public ShareInfo share_info;
46 | public ShareList share_list;
47 | public List tag_list = null;
48 | public String orientation;
49 | public String music_name;
50 | public String audio_author;
51 | public String audio_album;
52 | public Author answerer;
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/DataList.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.bean;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by 刘晓彬 on 2017/3/27.
7 | */
8 |
9 | public class DataList {
10 | public Integer res;
11 | public List data = null;
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/Qq.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | public class Qq {
5 |
6 | public String title;
7 | public String desc;
8 | public String link;
9 | public String img_url;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/ShareList.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | public class ShareList {
5 |
6 | public Wx wx;
7 | public Weibo weibo;
8 | public Qq qq;
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/Tag.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | public class Tag {
5 |
6 | public String id;
7 | public String title;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/Weibo.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | public class Weibo {
5 |
6 | public String title;
7 | public String desc;
8 | public String link;
9 | public String img_url;
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/Wx.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean;
3 |
4 | public class Wx {
5 |
6 | public String title;
7 | public String desc;
8 | public String link;
9 | public String img_url;
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/comment/Comment.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.comment;
3 |
4 | public class Comment {
5 |
6 | public Integer res;
7 | public CommentData data;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/comment/CommentData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.comment;
3 |
4 | import java.util.List;
5 |
6 | public class CommentData {
7 |
8 | public Integer count;
9 | public List data = null;
10 |
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/comment/Datum.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.comment;
3 |
4 | public class Datum {
5 |
6 | public String id;
7 | public String quote;
8 | public String content;
9 | public Integer praisenum;
10 | public String device_token;
11 | public String del_flag;
12 | public String reviewed;
13 | public String user_info_id;
14 | public String input_date;
15 | public String created_at;
16 | public String updated_at;
17 | public User user;
18 | public User touser;
19 | public Integer type;
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/comment/User.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.comment;
3 |
4 | public class User {
5 |
6 | public String user_id;
7 | public String user_name;
8 | public String web_url;
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/list/Data.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.list;
3 |
4 | import com.liuzh.one.bean.ContentList;
5 |
6 | import java.util.List;
7 |
8 | public class Data {
9 |
10 | public String id;
11 | public Weather weather;
12 | public String date;
13 | public List content_list = null;
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/list/Icons.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.list;
3 |
4 | public class Icons {
5 |
6 | public String day;
7 | public String night;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/list/OneDay.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.list;
3 |
4 | public class OneDay {
5 |
6 | public Integer res;
7 | public Data data;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/list/OneListId.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.bean.list;
2 |
3 | /**
4 | * Created by 刘晓彬 on 2017/3/19.
5 | */
6 |
7 | import java.util.ArrayList;
8 |
9 | public class OneListId {
10 |
11 | public Integer res;
12 | public ArrayList data = null;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/list/ShareInfo.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.list;
3 |
4 | public class ShareInfo {
5 |
6 | public String url;
7 | public String image;
8 | public String title;
9 | public String content;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/list/Weather.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.list;
3 |
4 | public class Weather {
5 |
6 | public String city_name;
7 | public String date;
8 | public String temperature;
9 | public String humidity;
10 | public String climate;
11 | public String wind_direction;
12 | public String hurricane;
13 | public Icons icons;
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/movie/Movie.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.movie;
3 |
4 | public class Movie {
5 |
6 | public Integer res;
7 | public MovieData data;
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/movie/MovieData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.movie;
3 |
4 | import com.liuzh.one.bean.ShareList;
5 | import com.liuzh.one.bean.Tag;
6 |
7 | import java.util.List;
8 |
9 | public class MovieData {
10 |
11 | public String id;
12 | public String title;
13 | public String indexcover;
14 | public String detailcover;
15 | public String video;
16 | public String verse;
17 | public String verse_en;
18 | public Object score;
19 | public String revisedscore;
20 | public String review;
21 | public String keywords;
22 | public String movie_id;
23 | public String info;
24 | public String officialstory;
25 | public String hide_flag;
26 | public String charge_edt;
27 | public String web_url;
28 | public Integer praisenum;
29 | public String sort;
30 | public String releasetime;
31 | public String scoretime;
32 | public String maketime;
33 | public String last_update_date;
34 | public String read_num;
35 | public String directors;
36 | public String editor_email;
37 | public String related;
38 | public String directors_id;
39 | public String start_video;
40 | public String media_type;
41 | public String poster;
42 | public List photo = null;
43 | public String next_id;
44 | public String previous_id;
45 | public List tag_list = null;
46 | public ShareList share_list;
47 | public Integer sharenum;
48 | public Integer commentnum;
49 | public Integer servertime;
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/music/Music.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.music;
3 |
4 | public class Music {
5 |
6 | public Integer res;
7 | public MusicData data;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/music/MusicData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.music;
3 |
4 | import com.liuzh.one.bean.Author;
5 | import com.liuzh.one.bean.ShareList;
6 | import com.liuzh.one.bean.Tag;
7 |
8 | import java.util.List;
9 |
10 | public class MusicData {
11 |
12 | public String id;
13 | public String title;
14 | public String cover;
15 | public String isfirst;
16 | public String story_title;
17 | public String story;
18 | public String lyric;
19 | public String info;
20 | public String platform;
21 | public String music_id;
22 | public String charge_edt;
23 | public String related_to;
24 | public String web_url;
25 | public Integer praisenum;
26 | public String hide_flag;
27 | public String sort;
28 | public String maketime;
29 | public String last_update_date;
30 | public String read_num;
31 | public String story_summary;
32 | public String audio;
33 | public String anchor;
34 | public String editor_email;
35 | public String related_musics;
36 | public String album;
37 | public String start_video;
38 | public String media_type;
39 | public String copyright;
40 | public Author author;
41 | public Author story_author;
42 | public List author_list = null;
43 | public String next_id;
44 | public String previous_id;
45 | public List tag_list = null;
46 | public ShareList share_list;
47 | public Integer sharenum;
48 | public Integer commentnum;
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/question/Question.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.question;
3 |
4 | public class Question {
5 |
6 | public Integer res;
7 | public QuestionData data;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/question/QuestionData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.question;
3 |
4 | import com.liuzh.one.bean.Author;
5 | import com.liuzh.one.bean.ShareList;
6 | import com.liuzh.one.bean.Tag;
7 |
8 | import java.util.List;
9 |
10 | public class QuestionData {
11 |
12 | public String question_id;
13 | public String question_title;
14 | public String question_content;
15 | public String answer_title;
16 | public String answer_content;
17 | public String question_makettime;
18 | public String recommend_flag;
19 | public String charge_edt;
20 | public String charge_email;
21 | public String last_update_date;
22 | public String web_url;
23 | public String read_num;
24 | public String guide_word;
25 | public String audio;
26 | public String anchor;
27 | public String cover;
28 | public String content_bgcolor;
29 | public String cover_media_type;
30 | public String cover_media_file;
31 | public String start_video;
32 | public String copyright;
33 | public Author answerer;
34 | public Author asker;
35 | public List author_list = null;
36 | public List asker_list = null;
37 | public Integer next_id;
38 | public String previous_id;
39 | public List tag_list = null;
40 | public ShareList share_list;
41 | public Integer praisenum;
42 | public Integer sharenum;
43 | public Integer commentnum;
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/read/Read.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.read;
3 |
4 | public class Read {
5 |
6 | public Integer res;
7 | public ReadData data;
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/bean/read/ReadData.java:
--------------------------------------------------------------------------------
1 |
2 | package com.liuzh.one.bean.read;
3 |
4 | import com.liuzh.one.bean.Author;
5 | import com.liuzh.one.bean.ShareList;
6 | import com.liuzh.one.bean.Tag;
7 |
8 | import java.util.List;
9 |
10 | public class ReadData {
11 |
12 | public String content_id;
13 | public String hp_title;
14 | public String sub_title;
15 | public String hp_author;
16 | public String auth_it;
17 | public String hp_author_introduce;
18 | public String hp_content;
19 | public String hp_makettime;
20 | public String hide_flag;
21 | public String wb_name;
22 | public String wb_img_url;
23 | public String last_update_date;
24 | public String web_url;
25 | public String guide_word;
26 | public String audio;
27 | public String anchor;
28 | public String editor_email;
29 | public String top_media_type;
30 | public String top_media_file;
31 | public String top_media_image;
32 | public String start_video;
33 | public String copyright;
34 | public List author = null;
35 | public String maketime;
36 | public List author_list = null;
37 | public String next_id;
38 | public String previous_id;
39 | public List tag_list = null;
40 | public ShareList share_list;
41 | public Integer praisenum;
42 | public Integer sharenum;
43 | public Integer commentnum;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/dialog/MovieProfilePopupWindow.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.dialog;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.ImageView;
7 | import android.widget.LinearLayout;
8 | import android.widget.PopupWindow;
9 | import android.widget.TextView;
10 |
11 | import com.liuzh.one.R;
12 | import com.squareup.picasso.Picasso;
13 |
14 | /**
15 | * Created by 刘晓彬 on 2017/4/9.
16 | */
17 |
18 | public class MovieProfilePopupWindow extends PopupWindow {
19 | private ImageView mIvPoster;
20 | private TextView mTvMovieName;
21 | private TextView mTvDesc;
22 | private TextView mTvInfo;
23 | private TextView mTvOfficialStory;
24 | private LinearLayout mLlContent;
25 |
26 | public MovieProfilePopupWindow(View contentView) {
27 | super(contentView, ViewGroup.LayoutParams.MATCH_PARENT,
28 | ViewGroup.LayoutParams.MATCH_PARENT);
29 | mTvMovieName = ((TextView) contentView.findViewById(R.id.tv_movie_name));
30 | mIvPoster = (ImageView) contentView.findViewById(R.id.iv_poster);
31 | mTvDesc = ((TextView) contentView.findViewById(R.id.tv_desc));
32 | mTvInfo = ((TextView) contentView.findViewById(R.id.tv_info));
33 | mTvOfficialStory = ((TextView) contentView.findViewById(R.id.tv_official_story));
34 | mLlContent = (LinearLayout) contentView.findViewById(R.id.ll_content);
35 | this.setAnimationStyle(R.style.PopupWindowAnimationRight);
36 | }
37 |
38 | public void initData(Context context, String name, String url,
39 | String desc, String info, String official_story) {
40 | mTvMovieName.setText(name);
41 | mTvDesc.setText(desc);
42 | mTvInfo.setText(info);
43 | mTvOfficialStory.setText(official_story);
44 | mLlContent.setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View view) {
47 | dismiss();
48 | }
49 | });
50 | Picasso.with(context)
51 | .load(url)
52 | .into(mIvPoster);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/dialog/OneImgPopupWindow.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.dialog;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.design.widget.Snackbar;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.PopupWindow;
10 | import android.widget.TextView;
11 |
12 | import com.liuzh.one.R;
13 | import com.liuzh.one.utils.DensityUtil;
14 | import com.liuzh.one.utils.FileUtil;
15 | import com.squareup.picasso.Picasso;
16 |
17 | /**
18 | * Created by 刘晓彬 on 2017/4/8.
19 | */
20 |
21 | public class OneImgPopupWindow extends PopupWindow implements View.OnClickListener {
22 |
23 | private TextView mTvVolume;
24 | private TextView mTvInfo;
25 | private ImageView mIvImg;
26 |
27 | public OneImgPopupWindow(View contentView) {
28 | super(contentView, ViewGroup.LayoutParams.MATCH_PARENT,
29 | ViewGroup.LayoutParams.MATCH_PARENT);
30 | mTvVolume = (TextView) contentView.findViewById(R.id.tv_volume);
31 | mTvInfo = (TextView) contentView.findViewById(R.id.tv_info);
32 | mIvImg = (ImageView) contentView.findViewById(R.id.iv_img);
33 | mIvImg.setOnClickListener(this);
34 |
35 | contentView.setOnClickListener(this);
36 |
37 | this.setAnimationStyle(R.style.PopupWindowAnimationRight);
38 |
39 | }
40 |
41 | public void setData(final Context context, String volume, String info, final String url) {
42 | mTvVolume.setText(volume);
43 | mTvInfo.setText(info);
44 | Picasso.with(context)
45 | .load(url)
46 | .placeholder(R.drawable.one_placeholder)
47 | .into(mIvImg);
48 | int maxWidth = DensityUtil.getWinWidth((Activity) context) - DensityUtil.dip2px(30);
49 | mIvImg.setMaxWidth(maxWidth);
50 | mIvImg.setMinimumWidth(maxWidth);
51 | mIvImg.setMaxHeight(maxWidth * 5);
52 | mIvImg.setOnLongClickListener(new View.OnLongClickListener() {
53 | @Override
54 | public boolean onLongClick(View view) {
55 | Snackbar.make(view.getRootView(), "要保存图片吗", 2000)
56 | .setAction("保存", new View.OnClickListener() {
57 | @Override
58 | public void onClick(View view) {
59 | FileUtil.savePic(context, url);
60 | }
61 | })
62 | .show();
63 | return true;
64 | }
65 | });
66 | }
67 |
68 | @Override
69 | public void onClick(View view) {
70 | if (view == getContentView()) {
71 | dismiss();
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/dialog/SharePopupWindow.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.dialog;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 | import android.widget.PopupWindow;
6 |
7 | import com.liuzh.one.R;
8 | import com.liuzh.one.application.App;
9 |
10 | /**
11 | * Created by 刘晓彬 on 2017/4/8.
12 | */
13 |
14 | public class SharePopupWindow extends PopupWindow implements View.OnClickListener {
15 |
16 | private View mContentView;
17 | private View mShareWeichatFriends;
18 | private View mShareWeichat;
19 | private View mShareQQ;
20 | private View mShareWeibo;
21 | private View mShareUrl;
22 |
23 | public SharePopupWindow(View contentView) {
24 | super(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
25 | mContentView = contentView;
26 | mShareWeichatFriends = mContentView.findViewById(R.id.iv_share_friends);
27 | mShareWeichat = mContentView.findViewById(R.id.iv_share_weichat);
28 | mShareQQ = mContentView.findViewById(R.id.iv_share_qq);
29 | mShareWeibo = mContentView.findViewById(R.id.iv_share_weibo);
30 | mShareUrl = mContentView.findViewById(R.id.iv_share_url);
31 |
32 | mShareWeichatFriends.setOnClickListener(this);
33 | mShareWeichat.setOnClickListener(this);
34 | mShareQQ.setOnClickListener(this);
35 | mShareWeibo.setOnClickListener(this);
36 | mShareUrl.setOnClickListener(this);
37 | mContentView.setOnClickListener(this);
38 |
39 |
40 | this.setAnimationStyle(R.style.PopupWindowAnimationBottom);
41 | }
42 |
43 |
44 | @Override
45 | public void onClick(View view) {
46 | if (view != mContentView) {
47 | App.showToast("分享");
48 | }
49 | dismiss();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.liuzh.one.utils.DensityUtil;
11 |
12 | /**
13 | * base fragment
14 | * Created by 刘晓彬 on 2017/4/6.
15 | */
16 |
17 | public abstract class BaseFragment extends Fragment {
18 |
19 | private View mRootView;
20 |
21 | @Nullable
22 | @Override
23 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
24 | @Nullable Bundle savedInstanceState) {
25 | if (mRootView == null) {
26 | mRootView = inflater.inflate(getRootViewId(), null);
27 | initView(mRootView);
28 | initData();
29 | }
30 | return mRootView;
31 | }
32 |
33 | protected abstract void initData();
34 |
35 | protected abstract void initView(View rootView);
36 |
37 | protected abstract int getRootViewId();
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/fragment/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 | import android.support.v4.view.ViewPager;
7 | import android.view.View;
8 |
9 | import com.liuzh.one.R;
10 | import com.liuzh.one.activity.MainActivity;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * homeFragment
17 | * Created by 刘晓彬 on 2017/3/16.
18 | */
19 |
20 | public class HomeFragment extends BaseFragment {
21 | private ViewPager mViewPager;//viewpager
22 | private ArrayList mFragments;//all fragment
23 | private FragmentPagerAdapter mPagerAdapter;//adapter
24 | private List mIdList;//one ids
25 | private MainActivity mMainActivity;
26 | private String[] mDayArr;
27 |
28 | @Override
29 | protected int getRootViewId() {
30 | return R.layout.fragment_home;
31 | }
32 |
33 | @Override
34 | public void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | mMainActivity = (MainActivity) getActivity();
37 | mDayArr = getResources().getStringArray(R.array.day);
38 | initFragments();
39 | }
40 |
41 | /**
42 | * init fragments
43 | */
44 | private void initFragments() {
45 | //从依附的activity的intent中取一天的list id
46 | mIdList = mMainActivity.getListId();
47 | //创建2个fragment,其余fragment通过view pager滑动监听来动态创建
48 | mFragments = new ArrayList<>();
49 | for (int i = 0; i < 2; i++) {
50 | int id = Integer.valueOf(mIdList.get(i));
51 | OneContentFragment fragment = new OneContentFragment(id);
52 | mFragments.add(fragment);
53 | }
54 | }
55 |
56 | /**
57 | * 当前fragment:
58 | * 被隐藏的时候:停止当前ContentFragment中的RecycleView的滚动(防止toolbar的显示异常)
59 | * 被显示的时候:设置toolbar显示状态、设置toolbar的title
60 | *
61 | * @param hidden 是否隐藏
62 | */
63 | @Override
64 | public void onHiddenChanged(boolean hidden) {
65 | super.onHiddenChanged(hidden);
66 | int pos = mViewPager.getCurrentItem();
67 | if (hidden) {
68 | mFragments.get(pos).stopRvScroll();
69 | } else {
70 | mFragments.get(pos).controlToolbarVisibility();
71 | mMainActivity.setToolbarTitle(mDayArr[pos]);
72 | }
73 | }
74 |
75 | @Override
76 | protected void initView(View rootView) {
77 | mViewPager = (ViewPager) rootView.findViewById(R.id.viewPager);
78 | }
79 |
80 | @Override
81 | protected void initData() {
82 | mPagerAdapter = new FragmentPagerAdapter(getChildFragmentManager()) {
83 | @Override
84 | public int getCount() {
85 | return mFragments.size();
86 | }
87 |
88 | @Override
89 | public Fragment getItem(int position) {
90 | return mFragments.get(position);
91 | }
92 | };
93 | mViewPager.setAdapter(mPagerAdapter);
94 | /*设置pager切换动画后,在4.1.2有奇怪的问题
95 | * 滑动当前页,实际滑动的是下一页*/
96 | mViewPager.setPageTransformer(true, new DepthPageTransformer());
97 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
98 | @Override
99 | public void onPageScrolled(int position, float positionOffset,
100 | int positionOffsetPixels) {
101 | }
102 |
103 | @Override
104 | public void onPageSelected(int position) {
105 | mMainActivity.setToolbarTitle(mDayArr[position]);
106 | //如果当前页是最后一页则新建下一页的fragment
107 | if (position == mFragments.size() - 1
108 | && position != mIdList.size() - 1) {
109 | int id = Integer.valueOf(mIdList.get(position + 1));
110 | OneContentFragment fragment = new OneContentFragment(id);
111 | mFragments.add(fragment);
112 | mPagerAdapter.notifyDataSetChanged();
113 | }
114 | mFragments.get(position).controlToolbarVisibility();
115 | }
116 |
117 | @Override
118 | public void onPageScrollStateChanged(int state) {
119 | }
120 | });
121 | }
122 |
123 | /**
124 | * viewpager切换动画
125 | * 4.1上有神奇的bug
126 | */
127 | private class DepthPageTransformer implements ViewPager.PageTransformer {
128 |
129 | public void transformPage(View view, float position) {
130 | if (position <= -1) { // [-Infinity,-1)
131 | view.setAlpha(0);
132 | } else if (position <= 0) { // [-1,0]
133 | view.setAlpha(1);
134 | view.setTranslationX(0);
135 | } else if (position <= 1) { // (0,1]
136 | view.setAlpha(1 - position);
137 | view.setTranslationX(view.getMeasuredWidth() * -position);
138 | } else { // (1,+Infinity]
139 | view.setAlpha(0);
140 | }
141 | }
142 | }
143 |
144 | public boolean currentPagePopIsShowing() {
145 | return mFragments.get(mViewPager.getCurrentItem()).getAdapter().popIsShowing();
146 | }
147 | public void dismissPop(){
148 | mFragments.get(mViewPager.getCurrentItem()).getAdapter().dismissPop();
149 | }
150 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/liuzh/one/fragment/ListFragment.java:
--------------------------------------------------------------------------------
1 | package com.liuzh.one.fragment;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.graphics.drawable.AnimationDrawable;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.widget.DividerItemDecoration;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.View;
11 | import android.widget.ImageView;
12 |
13 | import com.liuzh.one.R;
14 | import com.liuzh.one.adapter.ListRvAdapter;
15 | import com.liuzh.one.application.App;
16 | import com.liuzh.one.bean.DataList;
17 | import com.liuzh.one.bean.list.Data;
18 | import com.liuzh.one.utils.DensityUtil;
19 | import com.liuzh.one.utils.RetrofitUtil;
20 |
21 | import retrofit2.Call;
22 | import retrofit2.Callback;
23 | import retrofit2.Response;
24 |
25 | /**
26 | * 展现内容list的fragment,可创建类型:Read、Music、movie
27 | * Created by 刘晓彬 on 2017/3/27.
28 | */
29 |
30 | public class ListFragment extends BaseFragment {
31 | public static final int TYPE_READ = 0;
32 | public static final int TYPE_MUSIC = 1;
33 | public static final int TYPE_MOVIE = 2;
34 |
35 | private int mType;
36 |
37 | private RecyclerView mRecyclerView;
38 | private ImageView mIvLoading;
39 |
40 | public ListFragment() {
41 | }
42 |
43 | @SuppressLint("ValidFragment")
44 | public ListFragment(int type) {
45 | mType = type;
46 | }
47 |
48 | @Override
49 | protected int getRootViewId() {
50 | return R.layout.fragment_content;
51 | }
52 |
53 | @Override
54 | public void onCreate(@Nullable Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | fetchData();
57 | }
58 |
59 | @Override
60 | protected void initData() {
61 | mIvLoading.setVisibility(View.VISIBLE);
62 | ((AnimationDrawable) mIvLoading.getDrawable()).start();
63 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
64 | mRecyclerView.addItemDecoration(new DividerItemDecoration(
65 | getActivity(), DividerItemDecoration.VERTICAL));
66 | }
67 |
68 | @Override
69 | protected void initView(View rootView) {
70 | rootView.setPadding(0, DensityUtil.dip2px(50), 0, 0);
71 | mIvLoading = (ImageView) rootView.findViewById(R.id.iv_loading);
72 | mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
73 | }
74 |
75 | private void fetchData() {
76 | Callback