Skip to content

Commit

Permalink
scheme action
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed Jul 5, 2020
1 parent e763a9f commit bf44683
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 20 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
21 changes: 7 additions & 14 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,18 @@
android:name=".ui.subject.SubjectActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:supportsPictureInPicture="true">
</activity>
<activity
android:name=".ui.action.ActionActivity"
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
android:theme="@style/AppTheme.Transparent">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<data
android:host="subject"
android:scheme="bangumi"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>

<data
android:host="playersubject"
android:pathPrefix="/bangumi"
android:host="bangumi"
android:scheme="ekibun"/>
</intent-filter>
</activity>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package soko.ekibun.bangumi.ui.action

import soko.ekibun.bangumi.ui.view.BaseActivity

class ActionActivity : BaseActivity()
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.ViewGroup
import androidx.annotation.Keep
import androidx.appcompat.widget.PopupMenu
import androidx.core.view.GravityCompat
import kotlinx.android.synthetic.main.activity_main.*
Expand Down Expand Up @@ -172,6 +173,11 @@ class MainPresenter(private val context: MainActivity) {
var collectionList: List<Subject> = ArrayList()
var notify: Pair<Int, Int>? = null

@Keep
fun notifyCollectionChange() {
drawerView.homeFragment.collectionFragment.onCollectionChange()
}

/**
* 获取收藏
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.view_login.*
import soko.ekibun.bangumi.R
import soko.ekibun.bangumi.model.UserModel
import soko.ekibun.bangumi.ui.main.MainActivity
import soko.ekibun.bangumi.ui.main.fragment.home.fragment.HomeTabFragment
import soko.ekibun.bangumi.ui.web.WebActivity

Expand Down Expand Up @@ -71,4 +72,8 @@ class CollectionFragment: HomeTabFragment(R.layout.fragment_collection){
item_tab_container?.visibility = if (hasUser) View.VISIBLE else View.INVISIBLE
(item_pager?.adapter as? CollectionPagerAdapter)?.reset()
}

fun onCollectionChange() {
(item_pager?.adapter as? CollectionPagerAdapter)?.updateCollection((activity as? MainActivity)?.mainPresenter?.collectionList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CollectionPagerAdapter(
@SuppressLint("UseSparseArrays")
private val pageIndex = HashMap<Int, Int>()

private fun updateCollection(list: List<Subject>?, fromCache: Boolean = false) {
fun updateCollection(list: List<Subject>?, fromCache: Boolean = false) {
items.keys.forEach { position ->
if (!useApi(position)) return@forEach
val item = items[position] ?: return@forEach
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/soko/ekibun/bangumi/ui/view/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,24 @@ import java.util.concurrent.ConcurrentHashMap
* @property onBackListener Function0<Boolean>
* @constructor
*/
abstract class BaseActivity(@LayoutRes private val resId: Int) : AppCompatActivity(), CoroutineScope by MainScope() {
abstract class BaseActivity(@LayoutRes private val resId: Int? = null) : AppCompatActivity(),
CoroutineScope by MainScope() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

window.setBackgroundDrawable(ColorDrawable(ResourceUtil.resolveColorAttr(this, R.attr.colorPrimaryBackground)))
setContentView(resId)

ThemeModel.updateNavigationTheme(this)
resId?.let {
window.setBackgroundDrawable(
ColorDrawable(
ResourceUtil.resolveColorAttr(
this,
R.attr.colorPrimaryBackground
)
)
)
setContentView(it)
ThemeModel.updateNavigationTheme(this)
}

PluginsModel.setUpPlugins(this)
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
<item name="android:windowTranslucentStatus">true</item>
</style>

<style name="AppTheme.Transparent">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>

<style name="AppTheme.Splash">
<item name="android:windowLayoutInDisplayCutoutMode" tools:ignore="NewApi">shortEdges</item>
<item name="android:windowFullscreen">true</item>
Expand Down

0 comments on commit bf44683

Please sign in to comment.