Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
VIPyinzhiwei committed Aug 4, 2022
2 parents 3f136ca + eeb03af commit 1e7bfe1
Show file tree
Hide file tree
Showing 82 changed files with 370 additions and 587 deletions.
45 changes: 22 additions & 23 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 32
buildToolsVersion "32.0.0"

defaultConfig {
applicationId "com.eyepetizer.android"
minSdkVersion 21
targetSdkVersion 29
versionCode 6
versionName "1.0.5"
targetSdkVersion 32
versionCode 7
versionName "1.0.6"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
Expand Down Expand Up @@ -74,19 +74,18 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

//常用依赖库
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.github.bumptech.glide:glide:4.13.2'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.9.0'
implementation 'jp.wasabeef:glide-transformations:4.1.0'
Expand All @@ -96,16 +95,16 @@ dependencies {

//Android Jetpack 组件
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.work:work-runtime:2.5.0'
implementation "androidx.startup:startup-runtime:1.0.0"
implementation "androidx.datastore:datastore-preferences:1.0.0-beta01"
implementation "androidx.paging:paging-runtime:3.0.0"
implementation 'androidx.work:work-runtime:2.7.1'
implementation "androidx.startup:startup-runtime:1.1.1"
implementation "androidx.datastore:datastore-preferences:1.0.0"
implementation "androidx.paging:paging-runtime:3.1.1"

//Android KTX
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation "androidx.fragment:fragment-ktx:1.3.1"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation "androidx.fragment:fragment-ktx:1.5.1"

//特定功能依赖库
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
Expand All @@ -123,6 +122,6 @@ dependencies {
implementation 'com.umeng.umsdk:asms:1.2.2'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<queries>
<package android:name="com.tencent.mobileqq" />
<package android:name="com.tencent.mm" />
<package android:name="com.sina.weibo" />
</queries>

<application
android:name=".EyepetizerApplication"
android:allowBackup="false"
Expand Down Expand Up @@ -40,6 +46,7 @@

<activity
android:name=".ui.SplashActivity"
android:exported="true"
android:theme="@style/Eyepetizer.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.eyepetizer.android.util.GlobalUtil
import com.scwang.smart.refresh.header.MaterialHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
import com.umeng.commonsdk.UMConfigure
import tv.danmaku.ijk.media.player.IjkMediaPlayer

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ package com.eyepetizer.android.event
* @author vipyinzhiwei
* @since 2020/4/29
*/
open class MessageEvent
open class MessageEvent
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ package com.eyepetizer.android.event
* @author vipyinzhiwei
* @since 2020/5/19
*/
open class RefreshEvent(var activityClass: Class<*>? = null) : MessageEvent()
class RefreshEvent(val activityClass: Class<*>? = null) : MessageEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ package com.eyepetizer.android.event
* @author vipyinzhiwei
* @since 2020/5/19
*/
open class SwitchPagesEvent(var activityClass: Class<*>? = null) : MessageEvent()
class SwitchPagesEvent(val activityClass: Class<*>? = null) : MessageEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@ fun CharSequence.preCreateSession(): Boolean {
}
val sessionConfigBuilder = SonicSessionConfig.Builder().apply { setSupportLocalServer(true) }
val preloadSuccess = SonicEngine.getInstance().preCreateSession(this.toString(), sessionConfigBuilder.build())
logD("preCreateSession()", "${this}\t:${if (preloadSuccess) "Preload start up success!" else "Preload start up fail!"}")
return preloadSuccess
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ fun TextView.setDrawable(drawable: Drawable?, iconWidth: Float? = null, iconHeig
*
* @param lDrawable 左边图标
* @param rDrawable 右边图标
* @param lIconWidth 图标宽dp:默认自动根据图标大小
* @param lIconHeight 图标高dp:默认自动根据图标大小
* @param rIconWidth 图标宽dp:默认自动根据图标大小
* @param rIconHeight 图标高dp:默认自动根据图标大小
* @param lIconWidth 左边图标宽dp:默认自动根据图标大小
* @param lIconHeight 左边图标高dp:默认自动根据图标大小
* @param rIconWidth 右边图标宽dp:默认自动根据图标大小
* @param rIconHeight 右边图标高dp:默认自动根据图标大小
*/
fun TextView.setDrawables(lDrawable: Drawable?, rDrawable: Drawable?, lIconWidth: Float? = null, lIconHeight: Float? = null, rIconWidth: Float? = null, rIconHeight: Float? = null) {
if (lIconWidth != null && lIconHeight != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,11 @@ class MainPageRepository private constructor(private val mainPageDao: MainPageDa

companion object {

private var repository: MainPageRepository? = null
@Volatile
private var INSTANCE: MainPageRepository? = null

fun getInstance(dao: MainPageDao, network: EyepetizerNetwork): MainPageRepository {
if (repository == null) {
synchronized(MainPageRepository::class.java) {
if (repository == null) {
repository = MainPageRepository(dao, network)
}
}
}

return repository!!
fun getInstance(dao: MainPageDao, network: EyepetizerNetwork): MainPageRepository = INSTANCE ?: synchronized(this) {
INSTANCE ?: MainPageRepository(dao, network)
}
}
}
61 changes: 22 additions & 39 deletions app/src/main/java/com/eyepetizer/android/logic/VideoRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.eyepetizer.android.logic.model.VideoDetail
import com.eyepetizer.android.logic.network.EyepetizerNetwork
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.withContext

/**
Expand All @@ -39,55 +38,39 @@ class VideoRepository(private val dao: VideoDao, private val network: Eyepetizer
suspend fun refreshVideoDetail(videoId: Long, repliesUrl: String) = requestVideoDetail(videoId, repliesUrl)

private suspend fun requestVideoReplies(url: String) = withContext(Dispatchers.IO) {
coroutineScope {
val deferredVideoReplies = async { network.fetchVideoReplies(url) }
val videoReplies = deferredVideoReplies.await()
videoReplies
}
val deferredVideoReplies = async { network.fetchVideoReplies(url) }
val videoReplies = deferredVideoReplies.await()
videoReplies
}

private suspend fun requestVideoRelatedAndVideoReplies(videoId: Long, repliesUrl: String) = withContext(Dispatchers.IO) {
coroutineScope {
val deferredVideoRelated = async { network.fetchVideoRelated(videoId) }
val deferredVideoReplies = async { network.fetchVideoReplies(repliesUrl) }
val videoRelated = deferredVideoRelated.await()
val videoReplies = deferredVideoReplies.await()
val videoDetail = VideoDetail(null, videoRelated, videoReplies)
videoDetail
}
val deferredVideoRelated = async { network.fetchVideoRelated(videoId) }
val deferredVideoReplies = async { network.fetchVideoReplies(repliesUrl) }
val videoRelated = deferredVideoRelated.await()
val videoReplies = deferredVideoReplies.await()
val videoDetail = VideoDetail(null, videoRelated, videoReplies)
videoDetail
}

private suspend fun requestVideoDetail(videoId: Long, repliesUrl: String) = withContext(Dispatchers.IO) {
coroutineScope {
val deferredVideoRelated = async { network.fetchVideoRelated(videoId) }
val deferredVideoReplies = async { network.fetchVideoReplies(repliesUrl) }
val deferredVideoBeanForClient = async { network.fetchVideoBeanForClient(videoId) }
val videoBeanForClient = deferredVideoBeanForClient.await()
val videoRelated = deferredVideoRelated.await()
val videoReplies = deferredVideoReplies.await()
val videoDetail = VideoDetail(videoBeanForClient, videoRelated, videoReplies)

if (videoDetail.videoBeanForClient != null && videoDetail.videoRelated?.count ?: 0 > 0 && videoDetail.videoReplies.count > 0) {
dao.cacheVideoDetail(videoDetail)
}
videoDetail
}
val deferredVideoRelated = async { network.fetchVideoRelated(videoId) }
val deferredVideoReplies = async { network.fetchVideoReplies(repliesUrl) }
val deferredVideoBeanForClient = async { network.fetchVideoBeanForClient(videoId) }
val videoBeanForClient = deferredVideoBeanForClient.await()
val videoRelated = deferredVideoRelated.await()
val videoReplies = deferredVideoReplies.await()
val videoDetail = VideoDetail(videoBeanForClient, videoRelated, videoReplies)
dao.cacheVideoDetail(videoDetail)
videoDetail
}

companion object {

private var repository: VideoRepository? = null

fun getInstance(dao: VideoDao, network: EyepetizerNetwork): VideoRepository {
if (repository == null) {
synchronized(VideoRepository::class.java) {
if (repository == null) {
repository = VideoRepository(dao, network)
}
}
}
@Volatile
private var INSTANCE: VideoRepository? = null

return repository!!
fun getInstance(dao: VideoDao, network: EyepetizerNetwork): VideoRepository = INSTANCE ?: synchronized(this) {
INSTANCE ?: VideoRepository(dao, network)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,11 @@ package com.eyepetizer.android.logic.dao
*/
object EyepetizerDatabase {

private var mainPageDao: MainPageDao? = null
private lateinit var mainPageDao: MainPageDao

private var videoDao: VideoDao? = null
private lateinit var videoDao: VideoDao

fun getMainPageDao(): MainPageDao {
if (mainPageDao == null) {
mainPageDao = MainPageDao()
}
return mainPageDao!!
}
fun getMainPageDao() = if (this::mainPageDao.isInitialized) mainPageDao else MainPageDao()

fun getVideoDao(): VideoDao {
if (videoDao == null) {
videoDao = VideoDao()
}
return videoDao!!
}
fun getVideoDao() = if (this::videoDao.isInitialized) videoDao else VideoDao()
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ data class HomePageRecommend(val itemList: List<Item>, val count: Int, val total
val nickname: String,
val resourceType: String,
val url: String,
val urls: List<String>,
val urls: List<String>?,
val userCover: String
)
}
14 changes: 4 additions & 10 deletions app/src/main/java/com/eyepetizer/android/logic/model/TabEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ import com.flyco.tablayout.listener.CustomTabEntity
* @author vipyinzhiwei
* @since 2020/5/10
*/
class TabEntity(private var title: String, private var selectedIcon: Int = 0, private var unSelectedIcon: Int = 0) : CustomTabEntity {
class TabEntity(private val title: String, private val selectedIcon: Int = 0, private val unSelectedIcon: Int = 0) : CustomTabEntity {

override fun getTabTitle(): String {
return title
}
override fun getTabTitle() = title

override fun getTabSelectedIcon(): Int {
return selectedIcon
}
override fun getTabSelectedIcon() = selectedIcon

override fun getTabUnselectedIcon(): Int {
return unSelectedIcon
}
override fun getTabUnselectedIcon() = unSelectedIcon

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ class EyepetizerNetwork {

companion object {

private var network: EyepetizerNetwork? = null

fun getInstance(): EyepetizerNetwork {
if (network == null) {
synchronized(EyepetizerNetwork::class.java) {
if (network == null) {
network = EyepetizerNetwork()
}
}
}
return network!!
@Volatile
private var INSTANCE: EyepetizerNetwork? = null

fun getInstance(): EyepetizerNetwork = INSTANCE ?: synchronized(this) {
INSTANCE ?: EyepetizerNetwork()
}
}
}
Loading

0 comments on commit 1e7bfe1

Please sign in to comment.