Skip to content

Commit bb0448a

Browse files
committed
添加了关注相关 api 和界面
1 parent 8d50ce7 commit bb0448a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1422
-66
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,45 @@
2424
<activity
2525
android:name=".ui.activity.SplashActivity"
2626
android:screenOrientation="portrait"
27-
android:theme="@style/AppTheme.NoActionBar.FullScreen"
28-
>
27+
android:theme="@style/AppTheme.NoActionBar.FullScreen">
2928
<intent-filter>
3029
<action android:name="android.intent.action.MAIN" />
3130

3231
<category android:name="android.intent.category.LAUNCHER" />
3332
</intent-filter>
3433
</activity>
3534

35+
<!-- 主页面 -->
3636
<activity
3737
android:name=".ui.activity.MainActivity"
3838
android:screenOrientation="portrait" />
3939

40+
<!-- 视频播放详情页面 -->
4041
<activity
4142
android:name=".ui.activity.VideoDetailActivity"
4243
android:configChanges="orientation|keyboardHidden|screenSize" />
4344

45+
<!-- 分类详情 -->
4446
<activity
4547
android:name=".ui.activity.CategoryDetailActivity"
4648
android:screenOrientation="portrait" />
4749

50+
<!-- 搜索页面 -->
4851
<activity
4952
android:name=".ui.activity.SearchActivity"
5053
android:screenOrientation="portrait"
5154
android:windowSoftInputMode="adjustPan" />
5255

56+
<!-- 个人主页 -->
57+
<activity
58+
android:name=".ui.activity.ProfileHomePageActivity"
59+
android:screenOrientation="portrait" />
60+
61+
<!-- 关于 -->
62+
<activity
63+
android:name=".ui.activity.AboutActivity"
64+
android:screenOrientation="portrait" />
65+
5366
</application>
5467

5568
</manifest>

app/src/main/java/com/hazz/kotlinmvp/api/ApiService.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.hazz.kotlinmvp.api
22

3+
import com.hazz.kotlinmvp.mvp.model.bean.AuthorInfoBean
34
import com.hazz.kotlinmvp.mvp.model.bean.CategoryBean
45
import com.hazz.kotlinmvp.mvp.model.bean.HomeBean
56
import com.hazz.kotlinmvp.mvp.model.bean.TabInfoBean
@@ -42,7 +43,7 @@ interface ApiService{
4243
/**
4344
* 获取分类详情List
4445
*/
45-
@GET("v4/categories/videoList")
46+
@GET("v4/categories/videoList?")
4647
fun getCategoryDetailList(@Query("id") id: Long): Observable<HomeBean.Issue>
4748

4849
/**
@@ -69,6 +70,18 @@ interface ApiService{
6970
@GET("v3/queries/hot")
7071
fun getHotWord():Observable<ArrayList<String>>
7172

73+
/**
74+
* 关注
75+
*/
76+
@GET("v4/tabs/follow")
77+
fun getFollowInfo():Observable<HomeBean.Issue>
78+
79+
/**
80+
* 作者信息
81+
*/
82+
@GET("v4/pgcs/detail/tab?")
83+
fun getAuthorInfo(@Query("id") id: Long):Observable<AuthorInfoBean>
84+
7285

7386

7487
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.hazz.kotlinmvp.mvp.contract
2+
3+
import com.hazz.kotlinmvp.base.IBaseView
4+
import com.hazz.kotlinmvp.base.IPresenter
5+
import com.hazz.kotlinmvp.mvp.model.bean.HomeBean
6+
7+
/**
8+
* Created by xuhao on 2017/11/30.
9+
* desc: 契约类
10+
*/
11+
interface FollowContract {
12+
13+
interface View : IBaseView {
14+
/**
15+
* 设置关注信息数据
16+
*/
17+
fun setFollowInfo(issue: HomeBean.Issue)
18+
19+
fun showError(errorMsg: String, errorCode: Int)
20+
}
21+
22+
23+
interface Presenter : IPresenter<View> {
24+
/**
25+
* 获取List
26+
*/
27+
fun requestFollowList()
28+
29+
/**
30+
* 加载更多
31+
*/
32+
fun loadMoreData()
33+
}
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.hazz.kotlinmvp.mvp.model
2+
3+
import com.hazz.kotlinmvp.mvp.model.bean.HomeBean
4+
import com.hazz.kotlinmvp.mvp.model.bean.TabInfoBean
5+
import com.hazz.kotlinmvp.net.RetrofitManager
6+
import com.hazz.kotlinmvp.rx.scheduler.SchedulerUtils
7+
import io.reactivex.Observable
8+
9+
/**
10+
* Created by xuhao on 2017/11/30.
11+
* desc: 关注Model
12+
*/
13+
class FollowModel {
14+
15+
/**
16+
* 获取关注信息
17+
*/
18+
fun requestFollowList(): Observable<HomeBean.Issue> {
19+
20+
return RetrofitManager.service.getFollowInfo()
21+
.compose(SchedulerUtils.ioToMain())
22+
}
23+
24+
/**
25+
* 加载更多
26+
*/
27+
fun loadMoreData(url:String):Observable<HomeBean.Issue>{
28+
return RetrofitManager.service.getIssueData(url)
29+
.compose(SchedulerUtils.ioToMain())
30+
}
31+
32+
33+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.hazz.kotlinmvp.mvp.model.bean
2+
3+
import java.io.Serializable
4+
5+
data class AuthorInfoBean(val tabInfo: TabInfo,
6+
val pgcInfo: PgcInfo) : Serializable {
7+
8+
data class TabInfo(val tabList: List<TabList>,
9+
val defaultIdx: Int) : Serializable
10+
11+
data class TabList(val id: Int,
12+
val name: String,
13+
val apiUrl: String) : Serializable
14+
15+
16+
data class PgcInfo(val dataType: String,
17+
val id: Int,
18+
val icon: String,
19+
val name: String,
20+
val brief: String,
21+
val description: String,
22+
val actionUrl: String,
23+
val area: String,
24+
val gender: String,
25+
val registDate: Int,
26+
val followCount: Int,
27+
val follow: Follow,
28+
val self: Boolean,
29+
val cover: String,
30+
val videoCount: Int,
31+
val shareCount: Int,
32+
val collectCount: Int,
33+
val shield: Shield) : Serializable
34+
35+
36+
data class Follow(val itemType: String,
37+
val itemId: Int,
38+
val followed: Boolean) : Serializable
39+
40+
data class Shield(val itemType: String,
41+
val itemId: Int,
42+
val shielded: Boolean) : Serializable
43+
}
44+
45+

app/src/main/java/com/hazz/kotlinmvp/mvp/model/bean/HomeBean.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.io.Serializable
66
* Created by xuhao on 2017/11/21.
77
* desc: 首页 Bean(视频详情,相关等)
88
*/
9-
data class HomeBean(var issueList: ArrayList<Issue>, val nextPageUrl: String, val nextPublishTime: Long, val newestIssueType: String, val dialog: Any){
9+
data class HomeBean(val issueList: ArrayList<Issue>, val nextPageUrl: String, val nextPublishTime: Long, val newestIssueType: String, val dialog: Any){
1010

1111
data class Issue(val releaseTime:Long, val type:String, val date:Long, val total:Int, val publishTime:Long, val itemList:ArrayList<Item>, var count:Int, val nextPageUrl:String){
1212

@@ -57,7 +57,9 @@ data class HomeBean(var issueList: ArrayList<Issue>, val nextPageUrl: String, va
5757
val played: Boolean,
5858
val subtitles: Any,
5959
val lastViewTime: Any,
60-
val playlists: Any
60+
val playlists: Any,
61+
val header: Header,
62+
val itemList:ArrayList<HomeBean.Issue.Item>
6163
) : Serializable {
6264
data class Tag(val id: Int, val name: String, val actionUrl: String, val adTrack: Any) : Serializable
6365

@@ -80,6 +82,11 @@ data class HomeBean(var issueList: ArrayList<Issue>, val nextPageUrl: String, va
8082

8183
data class Url(val size: Long) : Serializable
8284

85+
data class Header(val id: Int,val icon: String,val iconType: String,val description: String,val title: String,val font: String,val cover: String,val label: Label,
86+
val actionUrl: String ,val subtitle:String, val labelList: ArrayList<Label>): Serializable{
87+
data class Label(val text: String,val card: String,val detial: Any,val actionUrl: Any)
88+
}
89+
8390
}
8491
}
8592

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.hazz.kotlinmvp.mvp.presenter
2+
3+
import com.hazz.kotlinmvp.base.BasePresenter
4+
import com.hazz.kotlinmvp.mvp.contract.FollowContract
5+
import com.hazz.kotlinmvp.mvp.contract.RankContract
6+
import com.hazz.kotlinmvp.mvp.model.FollowModel
7+
import com.hazz.kotlinmvp.mvp.model.RankModel
8+
import com.hazz.kotlinmvp.net.exception.ExceptionHandle
9+
10+
/**
11+
* Created by xuhao on 2017/11/30.
12+
* desc: 获取 TabInfo Presenter
13+
*/
14+
class FollowPresenter : BasePresenter<FollowContract.View>(), FollowContract.Presenter {
15+
16+
private val followModel by lazy { FollowModel() }
17+
18+
private var nextPageUrl:String?=null
19+
20+
/**
21+
* 请求排行榜数据
22+
*/
23+
override fun requestFollowList() {
24+
checkViewAttached()
25+
mRootView?.showLoading()
26+
val disposable = followModel.requestFollowList()
27+
.subscribe({ issue ->
28+
mRootView?.apply {
29+
dismissLoading()
30+
nextPageUrl = issue.nextPageUrl
31+
setFollowInfo(issue)
32+
}
33+
}, { throwable ->
34+
mRootView?.apply {
35+
dismissLoading()
36+
//处理异常
37+
showError(ExceptionHandle.handleException(throwable),ExceptionHandle.errorCode)
38+
}
39+
})
40+
addSubscription(disposable)
41+
}
42+
43+
/**
44+
* 加载更多
45+
*/
46+
override fun loadMoreData(){
47+
val disposable = nextPageUrl?.let {
48+
followModel.loadMoreData(it)
49+
.subscribe({ issue->
50+
mRootView?.apply {
51+
nextPageUrl = issue.nextPageUrl
52+
setFollowInfo(issue)
53+
}
54+
55+
},{ t ->
56+
mRootView?.apply {
57+
showError(ExceptionHandle.handleException(t),ExceptionHandle.errorCode)
58+
}
59+
})
60+
61+
62+
}
63+
if (disposable != null) {
64+
addSubscription(disposable)
65+
}
66+
}
67+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.hazz.kotlinmvp.ui.activity
2+
3+
import android.content.Intent
4+
import android.net.Uri
5+
import com.hazz.kotlinmvp.R
6+
import com.hazz.kotlinmvp.base.BaseActivity
7+
import com.hazz.kotlinmvp.utils.StatusBarUtil
8+
import kotlinx.android.synthetic.main.activity_about.*
9+
10+
/**
11+
* Created by xuhao on 2017/12/6.
12+
* desc: 关于
13+
*/
14+
class AboutActivity : BaseActivity() {
15+
override fun layoutId(): Int = R.layout.activity_about
16+
17+
override fun initData() {
18+
}
19+
20+
override fun initView() {
21+
StatusBarUtil.darkMode(this)
22+
StatusBarUtil.setPaddingSmart(this, toolbar)
23+
//返回
24+
toolbar.setNavigationOnClickListener { finish() }
25+
//访问 GitHub
26+
relayout_gitHub.setOnClickListener {
27+
val uri = Uri.parse("https://github.com/git-xuhao/KotlinMvp")
28+
val intent = Intent(Intent.ACTION_VIEW, uri)
29+
startActivity(intent)
30+
}
31+
}
32+
33+
override fun start() {
34+
35+
}
36+
}

app/src/main/java/com/hazz/kotlinmvp/ui/activity/MainActivity.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import com.hazz.kotlinmvp.R
99
import com.hazz.kotlinmvp.base.BaseActivity
1010
import com.hazz.kotlinmvp.mvp.model.bean.TabEntity
1111
import com.hazz.kotlinmvp.showToast
12-
import com.hazz.kotlinmvp.ui.fragment.CategoryFragment
13-
import com.hazz.kotlinmvp.ui.fragment.HomeFragment
14-
import com.hazz.kotlinmvp.ui.fragment.HotFragment
15-
import com.hazz.kotlinmvp.ui.fragment.MineFragment
12+
import com.hazz.kotlinmvp.ui.fragment.*
1613
import kotlinx.android.synthetic.main.activity_main.*
1714
import java.util.*
1815

@@ -37,7 +34,7 @@ class MainActivity : BaseActivity() {
3734
private val mTabEntities = ArrayList<CustomTabEntity>()
3835

3936
private var mHomeFragment: HomeFragment? = null
40-
private var mCategoryFragment: CategoryFragment? = null
37+
private var mCategoryFragment: DiscoveryFragment? = null
4138
private var mHotFragment: HotFragment? = null
4239
private var mMeiTuFragment: MineFragment?=null
4340

@@ -97,7 +94,7 @@ class MainActivity : BaseActivity() {
9794
}
9895
1 //分类
9996
-> if (mCategoryFragment == null) {
100-
mCategoryFragment = CategoryFragment.getInstance(mTitles[position])
97+
mCategoryFragment = DiscoveryFragment.getInstance(mTitles[position])
10198
transaction.add(R.id.fl_container, mCategoryFragment, "category")
10299
} else {
103100
transaction.show(mCategoryFragment)

0 commit comments

Comments
 (0)