Skip to content

Commit

Permalink
🐛 💄
Browse files Browse the repository at this point in the history
[Update]
- 优化了过场动画

[Fix]
- 阅读界面依然能打开侧边栏的 BUG
  • Loading branch information
rosuH committed Mar 6, 2019
1 parent 0563a72 commit ccc5611
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "me.rosuh.android.jianews"
minSdkVersion 22
targetSdkVersion 28
versionCode 10
versionName "0.8.6"
versionCode 11
versionName "0.8.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
// signingConfigs {
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/me/rosuh/jianews/util/DrawerLocker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package me.rosuh.jianews.util

/**
*
* @author rosuh
* @date 2019/3/7
*/
interface DrawerLocker {
fun setDrawerLocked(shouldLock:Boolean)
}
11 changes: 10 additions & 1 deletion app/src/main/java/me/rosuh/jianews/view/ArticleReadingFrag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.coroutines.Dispatchers
import me.rosuh.android.jianews.R
import me.rosuh.jianews.bean.ArticleBean
import me.rosuh.jianews.util.Const
import me.rosuh.jianews.util.DrawerLocker

/**
* 这个类是文章阅读页面的 AppCompatActivity 类
Expand Down Expand Up @@ -61,6 +62,11 @@ class ArticleReadingFrag : BaseFragment(), CoroutineScope {
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as DrawerLocker).setDrawerLocked(true)
}

private fun initWebView(view: View) {
webView = view.findViewById(R.id.wv_reading)
with(webView.settings) {
Expand Down Expand Up @@ -140,17 +146,20 @@ class ArticleReadingFrag : BaseFragment(), CoroutineScope {
override fun onHiddenChanged(hidden: Boolean) {
if (hidden) {
reset()
(activity as DrawerLocker).setDrawerLocked(false)
}else{
(activity as DrawerLocker).setDrawerLocked(true)
}
super.onHiddenChanged(hidden)
}

fun updateBean(newBean: ArticleBean) {
this.articleBean = newBean
webView.loadUrl("")
webViewLoad(newBean.content)
}

private fun reset(){
webView.loadUrl("")
fontItemView = null
mFontPopupMenu = null
}
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/me/rosuh/jianews/view/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import me.rosuh.jianews.util.GlideApp
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import me.rosuh.jianews.bean.ArticleBean
import me.rosuh.jianews.util.DrawerLocker
import me.rosuh.jianews.view.ArticleReadingFrag.Companion.READING_FRAGMENT_TAG

/**
* 首页 Activity
* @author rosu
*/
class HomeActivity : AppCompatActivity() {
class HomeActivity : AppCompatActivity(), DrawerLocker{

private var isExit = false

Expand Down Expand Up @@ -147,6 +148,14 @@ class HomeActivity : AppCompatActivity() {
}
}

override fun setDrawerLocked(shouldLock: Boolean) {
if (shouldLock){
dl_home.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
}else{
dl_home.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
}
}

/**
* 判断 Fragment 是否已经实例化
*/
Expand All @@ -170,8 +179,8 @@ class HomeActivity : AppCompatActivity() {
setCustomAnimations(
R.anim.push_left_in, R.anim.push_right_out
)
hide(readingFrag)
show(homeFragment)
hide(readingFrag)
commit()
}
}
Expand Down

0 comments on commit ccc5611

Please sign in to comment.