Skip to content

Commit

Permalink
适配wanandroid 接口
Browse files Browse the repository at this point in the history
  • Loading branch information
ditclear committed Oct 7, 2019
1 parent 4226d2c commit 8096041
Show file tree
Hide file tree
Showing 41 changed files with 547 additions and 414 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# PaoNet
泡网第三方客户端(待完善)
泡网第三方客户端(WanAndroid版本)

由于泡网的api不稳定,所以适配了一下wanandroid版本的api和数据模型

技术栈 : MVVM/Kotlin/DataBinding/Rxjava2/Retrofit2/Room/Koin/AOP/Navigation

[demo下载](https://github.com/ditclear/PaoNet/releases/download/1.0/app-release.apk)
[demo下载](https://github.com/ditclear/PaoNet/releases/download/wanandroid/demo.apk)

##### 项目介绍

| Sample | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [master](https://github.com/ditclear/PaoNet) | 稳定版本 |
| [develop](https://github.com/ditclear/PaoNet/tree/develop) | 开发分支 |
| [wanandroid](https://github.com/ditclear/PaoNet/tree/wanandroid) | wanandroid 版本 |
| [modularization](https://github.com/ditclear/PaoNet/tree/modularization) | 伪·模块化(工程化)分支,基于BuildType和SourceSet进行的工程化改造 |
| [sinlge_page](https://github.com/ditclear/PaoNet/tree/single_page) | 基于[Navigation](https://developer.android.google.cn/topic/libraries/architecture/navigation/navigation-implementing)组件,对PaoNet进行了单页面(单Activity+多Fragment)改造 |
| [multi_module](https://github.com/ditclear/PaoNet/tree/multi_module) [WIP] | 基于[sinlge_page](https://github.com/ditclear/PaoNet/tree/single_page)分支进行的模块化改造 |
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ditclear/paonet/di/app_module.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import retrofit2.Retrofit

val viewModelModule = module {

viewModel { (article: Article) -> ArticleDetailViewModel(article, get(), get()) }
viewModel { (title:String)-> ArticleDetailViewModel(title) }
viewModel { (article: Article, nameDate: String) -> CodeDetailViewModel(article, nameDate, get(), get()) }
viewModel { MainViewModel(get()) }
viewModel { RecentViewModel(get()) }
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/ditclear/paonet/helper/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ package com.ditclear.paonet.helper
object Constants {

val KEY_SERIALIZABLE = "serializable"
val KEY_DATA = "data"
val KEY_OTHER = "other"

val HOST_API="http://api.jcodecraeer.com/"
val HOST_API="https://www.wanandroid.com/"

val HOST_PAO="http://jcodecraeer.com"

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/ditclear/paonet/helper/Navigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ fun navigateToArticleDetail(activity: Activity, v: View?=null, article: Article)
activity.startActivity(intent,options)
}

fun navigateToArticleDetail(activity: Activity, v: View?=null, url: String?,title:String) {
val intent = Intent(activity, ArticleDetailActivity::class.java)
val bundle = Bundle()
bundle.putSerializable(Constants.KEY_DATA, url)
bundle.putSerializable(Constants.KEY_OTHER, title)
intent.putExtras(bundle)
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity).toBundle()
activity.startActivity(intent,options)
}

//登录
fun needsLogin(@ColorRes color: Int, triggeringView: View,activity: Activity?=null,radius:Int= (triggeringView.height / 2)) {
var startActivity :Activity?=null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
package com.ditclear.paonet.helper.annotation;

import static com.ditclear.paonet.helper.annotation.ArticleType.ANDROID;
import static com.ditclear.paonet.helper.annotation.ArticleType.DAILY;
import static com.ditclear.paonet.helper.annotation.ArticleType.DB;
import static com.ditclear.paonet.helper.annotation.ArticleType.DEVLOG;
import static com.ditclear.paonet.helper.annotation.ArticleType.FRONT_END;
import static com.ditclear.paonet.helper.annotation.ArticleType.IOS;
import static com.ditclear.paonet.helper.annotation.ArticleType.PROGRAME;
import static com.ditclear.paonet.helper.annotation.ArticleType.RECOMMAND;

import androidx.annotation.IntDef;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static com.ditclear.paonet.helper.annotation.ArticleType.CXMY;
import static com.ditclear.paonet.helper.annotation.ArticleType.GITYUAN;
import static com.ditclear.paonet.helper.annotation.ArticleType.GOOGLE;
import static com.ditclear.paonet.helper.annotation.ArticleType.GUOLIN;
import static com.ditclear.paonet.helper.annotation.ArticleType.HONGYANG;
import static com.ditclear.paonet.helper.annotation.ArticleType.MEITUAN;
import static com.ditclear.paonet.helper.annotation.ArticleType.XIA;
import static com.ditclear.paonet.helper.annotation.ArticleType.YUGANG;

/**
* 页面描述:ArticleType 文章类型
*
* Created by ditclear on 2017/10/17.
*/

@IntDef({ANDROID,PROGRAME,FRONT_END,IOS,DB,DEVLOG,RECOMMAND,DAILY})
@IntDef({HONGYANG,GUOLIN,YUGANG,CXMY,XIA,GOOGLE,MEITUAN,GITYUAN})
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.FIELD)
public @interface ArticleType {
int ANDROID=16;
int PROGRAME=6;
int FRONT_END=5;
int IOS=27;
int DB=14;
int DEVLOG=15;
int RECOMMAND=32;
int DAILY=9;
int HONGYANG=408;
int GUOLIN=409;
int YUGANG=410;
int CXMY=411;
int XIA=413;
int GOOGLE=415;
int MEITUAN=417;
int GITYUAN=434;
}
104 changes: 0 additions & 104 deletions app/src/main/java/com/ditclear/paonet/helper/annotation/CodeType.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ fun <T> Flowable<T>.async(withDelay: Long = 0): Flowable<T> =
this.subscribeOn(Schedulers.io()).delay(withDelay, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())

fun <T> Single<T>.async(withDelay: Long = 0): Single<T> =
this.subscribeOn(Schedulers.io()).delay(withDelay, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())
this.subscribeOn(Schedulers.io()).apply {
if (withDelay>0){
delay(withDelay, TimeUnit.MILLISECONDS)
}
}.observeOn(AndroidSchedulers.mainThread())

fun <R : BaseResponse> Single<R>.getOriginData(): Single<R> {
return this.compose { upstream ->
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/ditclear/paonet/model/data/Banner.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ditclear.paonet.model.data

data class Banner(
val desc: String,
val id: Int,
val imagePath: String,
val isVisible: Int,
val order: Int,
val title: String,
val type: Int,
val url: String
)
20 changes: 20 additions & 0 deletions app/src/main/java/com/ditclear/paonet/model/data/BaseResponse2.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ditclear.paonet.model.data

import com.google.gson.annotations.SerializedName

/**
* 页面描述:BaseResponse
*
* Created by ditclear on 2017/10/11.
*/
open class BaseResponse2<T>{
/**
* sucess : 1
* message : 成功登录
* data :
*/

var errorCode: Int = 0
var errorMsg: String? = null
var data: T? = null
}
12 changes: 11 additions & 1 deletion app/src/main/java/com/ditclear/paonet/model/data/Category.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ data class Category(var catename: String?, var value: Int?=null, var count: Int?
"count": 0
}*/

}
}

data class WCategory(
val courseId: Int,
val id: Int,
val name: String,
val order: Int,
val parentChapterId: Int,
val userControlSetTop: Boolean,
val visible: Int
)
11 changes: 11 additions & 0 deletions app/src/main/java/com/ditclear/paonet/model/data/PageResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ditclear.paonet.model.data

data class PageResponse<T>(
val curPage: Int,
val offset: Int,
val over: Boolean,
val pageCount: Int,
val size: Int,
val total: Int,
val datas:List<T>
)
18 changes: 7 additions & 11 deletions app/src/main/java/com/ditclear/paonet/model/data/Tag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ package com.ditclear.paonet.model.data
* Created by ditclear on 2017/10/24.
*/

class Tag {
/*{
"keyword": "RecyclerView",
"count": 2,
"timeMillis": 666
}*/

var keyword: String? = null
var count: Int = 0
var timeMillis: Int = 0
}
data class Tag(
val id: Int,
val link: String,
val name: String,
val order: Int,
val visible: Int
)
33 changes: 33 additions & 0 deletions app/src/main/java/com/ditclear/paonet/model/data/WArticle.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.ditclear.paonet.model.data

data class WArticle(
val apkLink: String,
val audit: Int,
val author: String,
val chapterId: Int,
val chapterName: String,
val collect: Boolean,
val courseId: Int,
val desc: String,
val envelopePic: String,
val fresh: Boolean,
val id: Int,
val link: String,
val niceDate: String,
val niceShareDate: String,
val origin: String,
val prefix: String,
val projectLink: String,
val publishTime: Long,
val selfVisible: Int,
val shareDate: Any,
val shareUser: String,
val superChapterId: Int,
val superChapterName: String,
val tags: List<Any>,
val title: String,
val type: Int,
val userId: Int,
val visible: Int,
val zan: Int
)
Loading

0 comments on commit 8096041

Please sign in to comment.