This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onResume() { | |
super.onResume() | |
presenter.getSuperHeroes().run(GetHeroesContext(this@MyActivity)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Reader<C, out A>(val run: (C) -> A) { | |
inline fun <B> map(crossinline fa: (A) -> B): Reader<C, B> = Reader { | |
c -> fa(run(c)) | |
} | |
inline fun <B> flatMap(crossinline fa: (A) -> Reader<C, B>): Reader<C, B> = Reader { | |
c -> fa(run(c)).run(c) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResizeAnimation extends Animation { | |
final int startWidth; | |
final int targetWidth; | |
View view; | |
public ResizeAnimation(View view, int targetWidth) { | |
this.view = view; | |
this.targetWidth = targetWidth; | |
startWidth = view.getWidth(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GridingCoffeeMaker { | |
@Inject Lazy<Grinder> lazyGrinder; | |
public void brew() { | |
while (needsGrinding()) { | |
// Grinder created once on first call to .get() and cached. | |
lazyGrinder.get().grind(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by jorge on 5/3/14. | |
*/ | |
public class InjectedActivity extends FragmentActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
((ApplicationClass) getApplicationContext()).inject(this); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by jorge on 3/17/14. | |
*/ | |
public class MainActivity extends InjectedActivity { | |
@Inject | |
GoogleApiClient mGoogleApiClient; | |
@Inject | |
LocationController mLocationController; | |
@Inject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocationController implements LocationListener { | |
private static final int TWO_MINUTES = 1000 * 60 * 2; | |
private Context context; | |
private LocationManager locationManager; | |
private String provider; | |
private Location bestLocationUntilNow; | |
@Inject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A module for dependencies which require a {@link android.content.Context} or | |
* {@link android.app.Application} to create. | |
*/ | |
@Module( | |
library = true | |
) | |
public class ContextModule { | |
private Context appContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A module for more generic or external dependencies wich doesnt require a {@link android.content.Context} or | |
* {@link android.app.Application} to create. | |
*/ | |
@Module( | |
library = true | |
) | |
public class AppModule { | |
@Provides |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module( | |
injects = { | |
ApplicationClass.class, | |
AbstractFontFactory.class, | |
RobotoFontFactory.class, | |
DataController.class, | |
LocationController.class, | |
RestAnimalProvider.class, | |
MainActivity.class, | |
TutorialActivity.class, |