A simple wrapper for Android navigation that helps you get rid of a lot of boilerplate code.
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.github.ShabanKamell:Navigator:x.y.z'
}
(Please replace x, y and z with the latest version numbers: )
Navigator supports Fragment/Activity navigation
// Declare Addresable Activity
object Profile: AddressableActivity {
override val className: String = "com.sha.navigator.profile.ProfileActivity"
}
// start Activity
ActivityModuleNavigator(this, packageName).navigate(Profile)
// Declare Addresable Fragment
object Profile: AddressableFragment {
override val className: String = "com.sha.navigator.profile.ProfileFragment"
}
// Add Fragment
FragmentModuleNavigator(this).add(Profile)
// OR Replace Fragment
FragmentModuleNavigator(this).replace(Profile)
FragmentNavigator(this).replace(ExampleFragment.newInstance()
FragmentNavigator(this).add(ExampleFragment.newInstance())
FragmentNavigator(this).showDialogFragment(CustomerDialogFragment.newInstance())
FrameLayout's ID can be Provided with 2 ways:
FragmentNavigator(this, R.id.mainFrame)
In this case, you don't have to pass the ID in the constructor in every call.
class SampleApp : Application() {
override fun onCreate() {
super.onCreate()
NavigatorOptions.frameLayoutId = R.id.mainFrame
}
}
Note: Passing the ID in the constructor will override the ID of NavigatorOptions
only this call and won't change NavigatorOptions
's ID.
new ActivityNavigator(this).navigate(ExampleActivity.class);
ActivityNavigator(this).navigate(ExampleActivity::class.java)
ActivityNavigator(this)
.withParcelable(Parcels.wrap(Message()), "message")
.navigate(ExampleActivity::class.java)
ActivityNavigator(this)
.withFlags(new Flags().newTask().singleTop())
.navigate(ExampleActivity.class)
// OR
ActivityNavigator(this)
.withFlags(Intent.FLAG_ACTIVITY_NEW_TASK, Intent.FLAG_ACTIVITY_SINGLE_TOP)
.navigate(ExampleActivity.class)
ActivityNavigator(this).openInGooglePlay()
ActivityNavigator(this).openCamera(2)
ActivityNavigator(this).navigateToSettings()
new ActivityNavigator(this).showRouteInGoogleMap(
25.095549, // from lat
29.644703, // from lng
24.457151, // to lat
27.184841 // to lng
);
Plaid Modular Navigation
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.