Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改后的提交 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ dependencies {
//状态栏
api 'com.gyf.immersionbar:immersionbar:2.3.1'





//时间获取
api 'com.github.ArdWang:dateutil:1.0.1'


}
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.clw">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>

<application
android:allowBackup="true"
Expand All @@ -16,16 +18,19 @@
android:theme="@style/AppTheme"
android:name=".common.MainApplication"
>
<activity android:name=".ui.activity.MainActivity">
<activity android:name=".ui.activity.MainActivity"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.activity.PhotoViewActivity"/>
<activity android:name=".ui.activity.NewsViewActivity"/>
<activity android:name=".ui.activity.LeftMainActivity"/>
<activity android:name=".ui.activity.DemoActivity"/>
<activity android:name=".ui.activity.NewsConActivity"/>
</application>

</manifest>
2 changes: 2 additions & 0 deletions app/src/main/java/com/clw/base/data/net/RetrofitFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class RetrofitFactory private constructor(){
"weather" -> HttpUrl.parse(BaseConstant.APP_WEATHER_SERVICE_ADDRE)
"gank"-> HttpUrl.parse(BaseConstant.APP_GANK_SERVICE_ADDRE)
"comic"-> HttpUrl.parse(BaseConstant.APP_SERVICE_ADDRE)
"news"-> HttpUrl.parse(BaseConstant.APP_NEWS_ADDRE)
"latest" -> HttpUrl.parse(BaseConstant.APP_ZHIHUNEWS_ADDRE)
else -> oldUrl
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class BaseMvpActivity<T:BasePresenter<*>>:BaseActivity(),BaseView {

lateinit var mPresenter: T

lateinit var progressLoading: ProgressLoading
private lateinit var progressLoading: ProgressLoading

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class BaseMvpFragment<T: BasePresenter<*>> :BaseFragment(), BaseView{

lateinit var mPresenter: T

lateinit var progressLoading: ProgressLoading
private lateinit var progressLoading: ProgressLoading

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
init()
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/clw/common/AppManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class AppManager private constructor(){
}

@SuppressLint("MissingPermission")
/*

/**
退出应用程序
*/
fun exitApp(context:Context){
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/clw/common/BaseConstant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ class BaseConstant {
const val APP_SERVICE_ADDRE = "http://192.168.1.164:8080/"
//const val APP_SERVICE_ADDRE = "http://192.168.0.101:8080/"

//新闻天气接口
const val APP_NEWS_ADDRE = "http://api01.bitspaceman.com:8000/"

//获取知乎新闻接口
const val APP_ZHIHUNEWS_ADDRE = "https://news-at.zhihu.com/"

//和风天气的Key
const val WEATHER_HEFENG_KEY = "c0d50dd43adb4a62aff5f3f728941082"

//新闻的Key
const val NEWS_KEY = "erXw8Wg6dREAERFoa7RVG9a0v95zx1DrCzyuuJ2RwHOOGFeqRpH7d3ryYjRZrxgD"


}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/clw/common/ProviderConstant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ class ProviderConstant {
const val LEFT_SPACE = 2
const val LEFT_BACK = 3
const val LEFT_EXIT = 4

//夜间模式
const val DAY_THEME = "DAY_THEME"
const val NIGHT_THEME = "NIGHT_THEME"
}
}
2 changes: 0 additions & 2 deletions app/src/main/java/com/clw/data/api/ComicApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.clw.data.api

import com.clw.data.protocol.comic.banner.BannerResp
import com.clw.data.protocol.comic.daycomic.DayComicResp
import com.clw.data.protocol.comic.japancomic.JapanComic
import com.clw.data.protocol.comic.japancomic.JapanComicResp
import com.clw.data.protocol.comic.newcomic.NewComicResp
import com.clw.data.protocol.comic.recommend.RecommendResp
Expand All @@ -13,7 +12,6 @@ import retrofit2.http.Headers

interface ComicApi {


/**
* 获取动漫Banner的接口
*/
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/java/com/clw/data/api/NewsApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.clw.data.api

import com.clw.data.protocol.news.LatestResp
import com.clw.data.protocol.news.NewsConResp
import com.clw.data.protocol.news.NewsResp
import io.reactivex.Observable
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Path
import retrofit2.http.QueryMap

interface NewsApi {
/**
* 获取新闻A接口
*/
@Headers("UrlName:news")
@GET("news/qihoo")
fun getNews(@QueryMap params:MutableMap<String,String>):Observable<NewsResp>


/**
* 获取最新的新闻接口
*/
@Headers("UrlName:latest")
@GET("api/4/news/latest")
fun getLatest():Observable<LatestResp>


/**
* 获取新闻内容接口
*/
@Headers("UrlName:latest")
@GET("api/4/news/{newsId}")
fun getNewsCon(@Path("newsId") newsId:Long):Observable<NewsConResp>


}
22 changes: 22 additions & 0 deletions app/src/main/java/com/clw/data/protocol/news/Data.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.clw.data.protocol.news

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize


@Parcelize
data class Data(
val id:String,
val likeCount:String,
val url:String,
val posterScreenName:String,
val shareCount:String,
val content:String,
val imageUrls:MutableList<String>,
val posterId:String,
val tags:String,
val commentCount:String,
val publishDate:Long,
val publishDateStr:String,
val title:String
): Parcelable
7 changes: 7 additions & 0 deletions app/src/main/java/com/clw/data/protocol/news/LatestResp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.clw.data.protocol.news

data class LatestResp(
val date:String,
val stories:MutableList<Stories>,
val top_stories:MutableList<TopStories>
)
13 changes: 13 additions & 0 deletions app/src/main/java/com/clw/data/protocol/news/NewsConResp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.clw.data.protocol.news

data class NewsConResp(
val body:String,
val image_source:String,
val title:String,
val image:String,
val share_url:String,
val ga_prefix:String,
val images:MutableList<String>,
val type:Int,
val id:Long
)
10 changes: 10 additions & 0 deletions app/src/main/java/com/clw/data/protocol/news/NewsResp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.clw.data.protocol.news

data class NewsResp(
val dataType:String,
val pageToken:String,
val retcode:String,
val hasNext:Boolean,
val appCode:String,
val data:MutableList<Data>
)
9 changes: 9 additions & 0 deletions app/src/main/java/com/clw/data/protocol/news/Stories.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.clw.data.protocol.news

data class Stories(
val images: MutableList<String>,
val type:Int,
val id:Long,
val ga_prefix:String,
val title:String
)
9 changes: 9 additions & 0 deletions app/src/main/java/com/clw/data/protocol/news/TopStories.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.clw.data.protocol.news

data class TopStories(
val image:String,
val type:Int,
val id:Long,
val ga_prefix:String,
val title:String
)
28 changes: 28 additions & 0 deletions app/src/main/java/com/clw/data/respository/NewsRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.clw.data.respository

import com.clw.base.data.net.RetrofitFactory
import com.clw.data.api.NewsApi
import com.clw.data.protocol.news.LatestResp
import com.clw.data.protocol.news.NewsConResp
import com.clw.data.protocol.news.NewsResp
import io.reactivex.Observable
import retrofit2.http.Path


class NewsRepository {

//获取新闻
fun getNews(params:MutableMap<String,String>): Observable<NewsResp>{
return RetrofitFactory.instance.create(NewsApi::class.java).getNews(params)
}

//获取最新闻
fun getLatest():Observable<LatestResp>{
return RetrofitFactory.instance.create(NewsApi::class.java).getLatest()
}

//获取新闻内容
fun getNewsCon(newsId:Long):Observable<NewsConResp>{
return RetrofitFactory.instance.create(NewsApi::class.java).getNewsCon(newsId)
}
}
3 changes: 0 additions & 3 deletions app/src/main/java/com/clw/db/City.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.clw.db




class City{
var id: Int = 0
var cityName: String? = null
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/clw/db/County.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.clw.db



class County {
var id: Int = 0
var countyName: String? = null
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/com/clw/db/DBSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,4 @@ class DBSupport {
db.close()
return list
}





}
1 change: 0 additions & 1 deletion app/src/main/java/com/clw/db/Province.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ class Province {
var id: Int = 0
var provinceName: String? = null
var provinceCode: Int = 0

}

9 changes: 8 additions & 1 deletion app/src/main/java/com/clw/ext/CommonExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,20 @@ fun <T> Observable<T>.convert(): Observable<T> {
return this.map(BaseFunction())
}

/*
/**
ImageView加载网络图片
*/
fun ImageView.loadUrl(url: String) {
GlideUtils.loadUrlImage(context, url, this)
}

/**
扩展视图可见性
*/
fun View.setVisible(visible:Boolean){
this.visibility = if (visible) View.VISIBLE else View.GONE
}




Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/com/clw/presenter/LatestPresenter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.clw.presenter

import com.clw.base.presenter.BasePresenter
import com.clw.base.rx.BaseObserver
import com.clw.data.protocol.news.LatestResp
import com.clw.ext.excute
import com.clw.presenter.view.LatestView
import com.clw.service.impl.NewsServiceImpl

class LatestPresenter:BasePresenter<LatestView>() {

private var newsService = NewsServiceImpl()

/**
* 获取当前的新闻值
*/
fun getLatest(){
if(!checkNetWork()){
return
}

mView.showLoading()

newsService.getLatest().excute(object :BaseObserver<LatestResp>(mView){
override fun onNext(t: LatestResp) {
mView.getLatest(t)
}
},lifeProvider)
}
}
Loading