Skip to content

Instantly share code, notes, and snippets.

Avatar

Tyler McCraw TylerMcCraw

View GitHub Profile
View FragmentExtensions.kt
/**
* Navigates only if this is safely possible; when this Fragment is still the current destination.
*/
fun Fragment.navigateSafe(
@IdRes resId: Int,
args: Bundle? = null,
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
) {
if (mayNavigate()) findNavController().navigate(
@mlykotom
mlykotom / Connecting_InjectingSavedStateViewModelFactory.kt
Last active May 4, 2020
Connecting The Dots :: InjectingViewModelFactory.kt
View Connecting_InjectingSavedStateViewModelFactory.kt
@Reusable
class InjectingSavedStateViewModelFactory @Inject constructor(
private val assistedFactories: Map<Class<out ViewModel>, @JvmSuppressWildcards AssistedSavedStateViewModelFactory<out ViewModel>>,
private val viewModelProviders: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>
) {
/**
* Creates instance of ViewModel either annotated with @AssistedInject or @Inject and passes dependencies it needs.
*/
fun create(owner: SavedStateRegistryOwner, defaultArgs: Bundle? = null) =
object : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
@stevewadsworth
stevewadsworth / Gradle.properties
Last active Oct 13, 2020 — forked from neyguvj/build.gradle
Set default build variant witn variant filter (workaround)
View Gradle.properties
#.
# Add to the end of existing file
#.
#.
# By default this is not a CI environment
# To configure for CI either pass to the gradle command -PisCI=true or
# set ORG_GRADLE_PROJECT_isCI=true in the environment
isCI=false
@nickbutcher
nickbutcher / IconView.kt
Last active Oct 5, 2020
A prototype implementation of a shadow effect inspired by the Google Play Games app (https://play.google.com/store/apps/details?id=com.google.android.play.games).
View IconView.kt
/*
* Copyright 2017 Google 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
View FixAppBarLayoutBehavior.java
/*
* Copyright (C) 2017 The Android Open Source Project
*
* 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
@josh-burton
josh-burton / androidmanifest.xml
Created May 3, 2017
Prevent TouchWiz from surrounding your app icon in a frame
View androidmanifest.xml
<!-- Prevents TouchWiz from surrounding your app icon in a frame -->
<!-- Add to your manifest inside the application tag -->
<meta-data
android:name="com.samsung.android.icon_container.has_icon_container"
android:value="true"/>
@adavis
adavis / AppComponent.java
Last active Mar 2, 2019
Background Jobs with Android Job and Dagger
View AppComponent.java
@Singleton
@Component(
modules = {
AppModule.class, JobsModule.class
}
)
public interface AppComponent
{
Application getApplication ();
@Mariovc
Mariovc / ImagePicker.java
Last active Oct 12, 2020
Utility for picking an image from Gallery/Camera with Android Intents
View ImagePicker.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@libinbensin
libinbensin / MainActivity.java
Last active Oct 14, 2020
Facebook Popup using PopupWindow
View MainActivity.java
public class MainActivity extends
private PopupWindow popWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
You can’t perform that action at this time.