All Projects → ssseasonnn → Bracer

ssseasonnn / Bracer

Licence: other
Pass parameters safely and quickly between activities or fragments.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Bracer

Bundler
🎁 Android Intent & Bundle extensions that insert and retrieve values elegantly.
Stars: ✭ 195 (+242.11%)
Mutual labels:  intent, fragment
Navigator
Android Multi-module navigator, trying to find a way to navigate into a modularized android project
Stars: ✭ 131 (+129.82%)
Mutual labels:  intent, fragment
Inlineactivityresult
Receive the activity result directly after the startActivityForResult with InlineActivityResult
Stars: ✭ 264 (+363.16%)
Mutual labels:  intent, fragment
Robin
Robin is a logging library for Bundle data passed between Activities and fragments. It also provides a callback to send screen views of user visited pages to your analytics client
Stars: ✭ 63 (+10.53%)
Mutual labels:  intent
Dart
Extras binding and intent builders for Android apps.
Stars: ✭ 1,203 (+2010.53%)
Mutual labels:  intent
Watbot
An Android ChatBot powered by IBM Watson Services (Assistant V1, Text-to-Speech, and Speech-to-Text with Speaker Recognition) on IBM Cloud.
Stars: ✭ 64 (+12.28%)
Mutual labels:  intent
React Native Share
Social share, sending simple data to other apps.
Stars: ✭ 2,955 (+5084.21%)
Mutual labels:  intent
Handle Path Oz
Android Library to handle multiple Uri's(paths) received through Intents.
Stars: ✭ 36 (-36.84%)
Mutual labels:  intent
Rnn For Joint Nlu
Pytorch implementation of "Attention-Based Recurrent Neural Network Models for Joint Intent Detection and Slot Filling" (https://arxiv.org/abs/1609.01454)
Stars: ✭ 176 (+208.77%)
Mutual labels:  intent
Padatious
A neural network intent parser
Stars: ✭ 124 (+117.54%)
Mutual labels:  intent
Callapp Lib
🔥call app from h5(H5唤起客户端 )
Stars: ✭ 1,857 (+3157.89%)
Mutual labels:  intent
Intent
A simple Flutter plugin to deal with Android Intents, written with ❤️
Stars: ✭ 79 (+38.6%)
Mutual labels:  intent
Android Cheat Sheet
Cheat Sheet for Android Interviews
Stars: ✭ 1,891 (+3217.54%)
Mutual labels:  intent
Chatbot Watson Android
An Android ChatBot powered by Watson Services - Assistant, Speech-to-Text and Text-to-Speech on IBM Cloud.
Stars: ✭ 169 (+196.49%)
Mutual labels:  intent
Know Your Intent
State of the Art results in Intent Classification using Sematic Hashing for three datasets: AskUbuntu, Chatbot and WebApplication.
Stars: ✭ 116 (+103.51%)
Mutual labels:  intent
Potato Library
Easy to use Utility library for Android
Stars: ✭ 45 (-21.05%)
Mutual labels:  intent
Kotlin Playground
Kotlin practice
Stars: ✭ 111 (+94.74%)
Mutual labels:  intent
Widgetexamples
A demo project showcasing different types of Widgets created with SwiftUI and WidgetKit.
Stars: ✭ 125 (+119.3%)
Mutual labels:  intent
BottomNavigationViewDemo
BottomNavigationView + Fragment 学习Demo
Stars: ✭ 22 (-61.4%)
Mutual labels:  fragment
Sapconversationalai
✨ 🤖 🤖 Build your own conversational bot on our Collaborative Bot Platform! 🤖🤖 ✨
Stars: ✭ 247 (+333.33%)
Mutual labels:  intent

Bracer

Pass parameters between Activity or Fragment like a master.

Read this in other languages: 中文, English, Change Log

Prepare

1. Add the JitPack repository to your build file

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

2. Add the dependency

dependencies {
	implementation 'com.github.ssseasonnn:Bracer:1.0.7'
}

Usage

1. For Activity

class DemoActivity : AppCompatActivity() {
    //define
    var intParam by mutableParams<Int>()
    var booleanParam by mutableParams<Boolean>()
    var stringParam by mutableParams<String>()
    var customParam by mutableParams<CustomParams1>()

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

        //use
        println(intParams)
        println(booleanParams)
        println(stringParams)
        println(customParams)
    }
}

pass parameter to Activity:

binding.button.setOnClickListener {
    startActivity<DemoActivity> {
        intParam = 1
        booleanParam = true
        stringParam = "abc"
        customParam = CustomParams1()
    }
}

//or using tradition way:
val intent = Intent(context, DemoActivity::class.java)
intent.putExtra("intParam", 1.toByte())
intent.putExtra("booleanParam", true)
intent.putExtra("stringParam", "abc")
startActivity(intent)

No need to worry, Bracer can be integrated with any third-party router, just ensure that the parameter name is the correspond

2. For Fragment

As Same

class DemoFragment : Fragment() {
    var intParam by mutableParams<Int>()
    var booleanParam by mutableParams<Boolean>()
    var stringParam by mutableParams<String>()
    var customParam by mutableParams<CustomParams1>()
}

pass parameter to Fragment

val fragment = DemoFragment().apply {
        intParam = 1
        booleanParam = true
        stringParam = "abc"
        customParam = CustomParams1()
}

supportFragmentManager.beginTransaction().apply {
        add(R.id.frameLayout, fragment)
        commit()
    }

3. Get parameters in ViewModel

//using SavedStateHandle
class DemoViewModel(private val stateHandle: SavedStateHandle) : ViewModel() {
    private val intParam by stateHandle.params<Int>()
    private val booleanParam by stateHandle.params<Boolean>()
    private val stringParam by stateHandle.params<String>()
    private val customParam by stateHandle.params<CustomParams1>()
}

//create ViewModel
class DemoActivity : AppCompatActivity() {
    var intParam by mutableParams<Int>()
    var booleanParam by mutableParams<Boolean>()
    var stringParam by mutableParams<String>()
    var customParam by mutableParams<CustomParams1>()

    //create ViewModel by viewModels extend function
    val viewModel by viewModels<DemoViewModel>()

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

        println(intParams)
        println(booleanParams)
        println(stringParams)
        println(customParams)
    }
}

To use with viewModels extension function, you need to add dependencies:implementation 'androidx.fragment:fragment-ktx:1.5.1'

4. Get params from everywhere

You can use bracer anywhere, as long as you can get Activity or Fragment.

class TestAdapter(
    val activity: Activity,
    val fragment: Fragment,
    val intent: Intent,
    val bundle: Bundle
) {
    val paramFromActivity by activity.params<String>()
    val paramFromFragment by fragment.params<String>()
    val paramFromIntent by intent.params<String>()
    val paramFromBundle by bundle.params<String>()

    fun test(){
        val string by activity.params<String>()
    }
}

5. valvar

Bracer provides two types,params and mutableParams,corresponding to val and var in Kotlin.

//Read only
val param by params<String>()

//Read and Write
var mutableParams by mutableParams<String>()

6. Other Features

Custom key:

var customKeyParams by mutableParams<Byte>("this is custom key")

Default value:

var defaultParams by mutableParams<BigDecimal>(defaultValue = BigDecimal.ONE)

License

Copyright 2019 Season.Zlc

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].