https://github.com/bytedance/scene
Android Single Activity Framework compatible with Fragment.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.8%) to scientific vocabulary
Keywords
Repository
Android Single Activity Framework compatible with Fragment.
Basic Info
Statistics
- Stars: 2,256
- Watchers: 42
- Forks: 206
- Open Issues: 1
- Releases: 13
Topics
Metadata Files
README.md
Scene Framework
Android Single Activity Framework compatible with Fragment.
Scene is a lightweight library of navigation and UI composition based on view.
- ✅ Fully compatible with the Jetpack Fragment framework
- ✅ Simple navigation stack management, with support for multiple navigation stacks
- ✅ Enhanced lifecycle management and event distribution
- ✅ Simplifies complex cross-page and shared element animations
- ✅ Supports modification and automatic restoration of Activity and Window properties
- ✅ Enables data exchange between Scenes, including permission requests and grants within a Scene
- ✅ Supports saving and restoring Scene state via Parcelable
- ✅ No R8/Proguard configuration required
Download the latest Sample APK
Introduction
Scene is designed to replace the use of Activities and Fragments for navigation and page segmentation in Android applications. It addresses the following issues: 1. Activity, Poor performance, with the average startup time of even an empty Activity exceeding 100ms. 2. Fragment, Poor compatibility, Google Navigation Component destroys a Fragment’s view when it becomes invisible.
Scene provides a simple, reliable, and extensible API for lightweight, high-performance navigation and page management. We also offer a set of migration solutions to help developers gradually transition from Activities and Fragments to Scene.
Get Started
Add it to your root build.gradle at the end of repositories:
gradle
//build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
kotlin
//or settings.gradle.kts
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}
Add it to your build.gradle, latest_version :
gradle
dependencies {
implementation 'com.github.bytedance:scene:$latest_version'
//or
implementation 'com.github.bytedance.scene:scene:$latest_version'
implementation 'com.github.bytedance.scene:scene_navigation:$latest_version'
implementation 'com.github.bytedance.scene:scene_ui:$latest_version'
implementation 'com.github.bytedance.scene:scene_fragment:$latest_version'
implementation 'com.github.bytedance.scene:scene_dialog:$latest_version'
implementation 'com.github.bytedance.scene:scene_shared_element_animation:$latest_version'
implementation 'com.github.bytedance.scene:scene_ktx:$latest_version'
}
kotlin
//or build.gradle.kts
dependencies {
implementation ("com.github.bytedance:scene:$latest_version")
//or
implementation ("com.github.bytedance.scene:scene:$latest_version")
implementation ("com.github.bytedance.scene:scene_navigation:$latest_version")
implementation ("com.github.bytedance.scene:scene_ui:$latest_version")
implementation ("com.github.bytedance.scene:scene_fragment:$latest_version")
implementation ("com.github.bytedance.scene:scene_dialog:$latest_version")
implementation ("com.github.bytedance.scene:scene_shared_element_animation:$latest_version")
implementation ("com.github.bytedance.scene:scene_ktx:$latest_version")
}
For simple usage, just let your Activity inherit from SceneActivity:
```kotlin
class MainActivity : SceneActivity() {
override fun getHomeSceneClass(): Class
override fun supportRestore(): Boolean {
return false
}
} ```
A simple Scene example:
```kotlin class MainScene : AppCompatScene() { private lateinit var mButton: Button override fun onCreateContentView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View? { val frameLayout = FrameLayout(requireSceneContext()) mButton = Button(requireSceneContext()) mButton.text = "Click" frameLayout.addView(mButton, FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAPCONTENT, ViewGroup.LayoutParams.WRAPCONTENT)) return frameLayout }
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setTitle("Main")
toolbar?.navigationIcon = null
mButton.setOnClickListener {
navigationScene?.push(SecondScene())
}
}
}
class SecondScene : AppCompatScene() { private val mId: Int by lazy { View.generateViewId() }
override fun onCreateContentView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View? {
val frameLayout = FrameLayout(requireSceneContext())
frameLayout.id = mId
return frameLayout
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setTitle("Second")
add(mId, ChildScene(), "TAG")
}
}
class ChildScene : Scene() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View { val view = View(requireSceneContext()) view.setBackgroundColor(Color.GREEN) return view } } ```
Fragment
```kotlin import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import com.bytedance.scene.fragment.getNavigationScene import com.bytedance.scene.fragment.push
class YourFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { return View(requireContext()) }
override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) val navigationScene = getNavigationScene() requireView().setOnClickListener { navigationScene?.push(YourFragment()) } } } ```
Compose
https://github.com/bytedance/scene/wiki/Compose
Sample
Scene sample is built using Gradle. On Linux, simply run:
./gradlew installDebug
Document
https://github.com/bytedance/scene/wiki
Issues
Dialog
A normal Dialog's Window is independent and in front of the Activity's Window, so if try to push a Scene in a opening Dialog, it will cause the Scene to appear behind it. You can close the dialog box when click, or use transparent Scene to implement the dialog instead of a system Dialog.
Apps using Scene
|
|
|
|
|
|
|:-----------:|:-------:|:-------:|:-------:|:------------------------------------------------------:|
| TikTok | Douyin | Xigua Video | Toutiao | KeSong |
License
~~~ Copyright (c) 2019 ByteDance Inc
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ~~~
Owner
- Name: Bytedance Inc.
- Login: bytedance
- Kind: organization
- Location: Singapore
- Website: https://opensource.bytedance.com
- Twitter: ByteDanceOSS
- Repositories: 255
- Profile: https://github.com/bytedance
GitHub Events
Total
- Create event: 2
- Release event: 1
- Issues event: 3
- Watch event: 221
- Issue comment event: 5
- Push event: 37
- Gollum event: 4
- Fork event: 9
Last Year
- Create event: 2
- Release event: 1
- Issues event: 3
- Watch event: 221
- Issue comment event: 5
- Push event: 37
- Gollum event: 4
- Fork event: 9
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| qii | q****a@g****m | 424 |
| sunyongsheng.aengus | s****s@b****m | 21 |
| duansishu | d****u@b****m | 9 |
| fengminchao | f****o@b****m | 3 |
| Ikko Eltociear Ashimine | e****r@g****m | 1 |
| zhuqingying | z****g@b****m | 1 |
| xiedaowang | x****g@b****m | 1 |
| cuibohan.1 | c****1@b****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 69
- Total pull requests: 3
- Average time to close issues: 4 months
- Average time to close pull requests: about 2 months
- Total issue authors: 32
- Total pull request authors: 3
- Average comments per issue: 3.71
- Average comments per pull request: 1.33
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 1
- Average time to close issues: 24 days
- Average time to close pull requests: about 15 hours
- Issue authors: 4
- Pull request authors: 1
- Average comments per issue: 2.5
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Iridescentangle (13)
- Ccixyj (9)
- wflian (6)
- mokhtarabadi (5)
- chachako (5)
- zombiu (2)
- qii (2)
- qiushui95 (2)
- bozaixing (2)
- SimonRHW (1)
- Harlber (1)
- fanqingwen (1)
- wohsj110 (1)
- zhaopingfu (1)
- budaowengd (1)
Pull Request Authors
- eltociear (2)
- ipcjs (1)
- gtf35 (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- junit:junit 4.12 testImplementation