ActionBarBinder

An easy way to bind Toolbar into one activity with multiple fragments.

License

License

GroupId

GroupId

me.omico.binder.actionbar
ArtifactId

ArtifactId

binder
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

aar
Description

Description

ActionBarBinder
An easy way to bind Toolbar into one activity with multiple fragments.
Project URL

Project URL

https://github.com/Omico/ActionBarBinder
Source Code Management

Source Code Management

https://github.com/Omico/ActionBarBinder

Download binder

How to add to project

<!-- https://jarcasting.com/artifacts/me.omico.binder.actionbar/binder/ -->
<dependency>
    <groupId>me.omico.binder.actionbar</groupId>
    <artifactId>binder</artifactId>
    <version>1.0.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/me.omico.binder.actionbar/binder/
implementation 'me.omico.binder.actionbar:binder:1.0.0'
// https://jarcasting.com/artifacts/me.omico.binder.actionbar/binder/
implementation ("me.omico.binder.actionbar:binder:1.0.0")
'me.omico.binder.actionbar:binder:aar:1.0.0'
<dependency org="me.omico.binder.actionbar" name="binder" rev="1.0.0">
  <artifact name="binder" type="aar" />
</dependency>
@Grapes(
@Grab(group='me.omico.binder.actionbar', module='binder', version='1.0.0')
)
libraryDependencies += "me.omico.binder.actionbar" % "binder" % "1.0.0"
[me.omico.binder.actionbar/binder "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

ActionBarBinder

An easy way to bind Toolbar into one activity with multiple fragments.

Usage

Maven Central

Add the ActionBarBinder dependency to your app

Kotlin
dependencies {
    implementation("me.omico.binder.actionbar:binder:<version>")
}
Groovy
dependencies {
    implementation 'me.omico.binder.actionbar:binder:<version>'
}

Refer to the following code to bind your fragment's Toolbar

Kotlin

You can follow the FirstFragment.kt just simplify add bindToolbar(Toolbar) method, and then we are all done. It will automatically unbind our Toolbar when the fragment is destroyed.

Java

It will be a little complicated in Java.

There are two ways to achieve this.

First, make your fragment extends ActionBarFragment. You can find this example in SecondFragment.java.

Or, you can fowllow the ActionBarFragment to create an FragmentActionBarBinder instance in your own fragment.

FragmentActionBarBinder binder = FragmentActionBarBinder.create(Fragment)
binder.bindToolbar(Toolbar)

For more information, please look at FragmentActionBarBinder.kt.

License

Copyright 2020 Omico

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

    https://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.

Versions

Version
1.0.0