Skip to content

Instantly share code, notes, and snippets.

Avatar

Julian Vergel de Dios jvergeldedios

View GitHub Profile
@jvergeldedios
jvergeldedios / gist:a5b4b83f574e330c51cf
Created Sep 19, 2014
Simple example of Dagger in Android
View gist:a5b4b83f574e330c51cf
public class MyApp extends Application {
private ObjectGraph objectGraph;
public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.create(new AppModule(this));
}
public static void inject(Context context, Object toInject) {
View gist:6046027
public static final String PREFS_NAME = "MyPrefsFile";
public static final String IMAGE_TEMP_PATH = "ImageTempPath";
public static final int REQUEST_CAMERA = 1;
protected void launchCamera()
{
// Setup a temporary storage path for the image and save it in SharedPreferences
String imageTempPath = "image_" + UUID.randomUUID() + ".jpg";
getSharedPreferences(PREFS_NAME, 0).edit().putString(IMAGE_TEMP_PATH, imageTempPath).commit();
File dir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
View keybase.md

Keybase proof

I hereby claim:

  • I am jvergeldedios on github.
  • I am jvergeldedios (https://keybase.io/jvergeldedios) on keybase.
  • I have a public key ASDbicAEpaEZfyAYn6MGeIg3olcQwFQU_zNX_5mWdnlDdAo

To claim this, I am signing this object:

View private-route-example.jsx
import React from 'react';
import { connect } from 'react-redux';
import { Route, Redirect } from 'react-router-dom';
const PrivateRoute = ({component: Component, session, ...rest}) => {
return (
<Route
{...rest}
render={(props) => session ?
<Component {...props} /> :
View useSomethingAsync.js
//useSomethingAsync.js
export default () => {
const [thing, setThing] = useState(null);
useEffect(() => {
doAsyncThing().then(result => setThing(result));
}, []);
return thing;