Skip to content

Instantly share code, notes, and snippets.

View nmhung's full-sized avatar
👨‍💻

Ken nmhung

👨‍💻
View GitHub Profile
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
# TODO: disable daemon on CI, since builds should be clean and reliable on servers
@nmhung
nmhung / AlertDialogUtils.java
Created September 17, 2018 06:22
Show the default alert dialog with options.
public class AlertDialogUtils {
public static void showError(Context context, int message) {
new AlertDialog.Builder(context).setTitle(R.string.app_name)
.setMessage(message)
.setIcon(R.mipmap.ic_launcher)
.setNegativeButton(R.string.ok, (dialog, which) -> dialog.dismiss())
.create()
.show();
}
@nmhung
nmhung / BottomNavigationBehavior.kt
Created September 15, 2018 14:38 — forked from ValCanBuild/BottomNavigationBehavior.kt
Full code of a BottomNavigationBehavior which hides itself on scroll and handles Snackbars and FAB. https://medium.com/@ValCanBuild/scroll-your-bottom-navigation-view-away-with-10-lines-of-code-346f1ed40e9e
// Apply to BottomNavigationView
class BottomNavigationBehavior<V : View>(context: Context, attrs: AttributeSet) :
CoordinatorLayout.Behavior<V>(context, attrs) {
override fun layoutDependsOn(parent: CoordinatorLayout?, child: V, dependency: View?): Boolean {
if (dependency is Snackbar.SnackbarLayout) {
updateSnackbar(child, dependency)
}
return super.layoutDependsOn(parent, child, dependency)
}