This file contains 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
the below is command line output generated from the (further below) main method | |
Factorial of '31' is '738197504' | |
Factorial of '10' is '3628800' | |
Factorial of '5' is '120' | |
Factorial of '4' is '24' | |
Factorial of '3' is '6' | |
Factorial of '2' is '2' | |
Factorial of '1' is '1' | |
Factorial of '0' is '1' |
This file contains 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 | |
protected AsyncTaskResult<String> doInBackground(User... users) { | |
int userCount = users.length; | |
if(apiService == null) { // Only do this once | |
UserApi.Builder builder = new UserApi.Builder(AndroidHttp.newCompatibleTransport(), | |
new AndroidJsonFactory(), null) | |
// options for running against local devappserver | |
.setRootUrl("http://" + ServerUtil.getHost() + ":8080/_ah/api/"); | |
//turn off compression when running against local devappserver | |
Utility.compressTrafficIfNecessary(builder); |
This file contains 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 BaseButton(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
TypedArray a = context.getTheme().obtainStyledAttributes( | |
attrs, | |
R.styleable.MaterialButton, | |
0, 0); | |
try { | |
colorButtonNormal = a.getInteger(R.styleable.MaterialButton_mbColorButtonNormal, Color.CYAN); |
This file contains 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 HomePresenter extends BasePresenter<HomeView> { | |
ArticleRepo articleRepo; | |
@Inject | |
public HomePresenter(ArticleRepo articleRepo) { | |
this.articleRepo = articleRepo; | |
} | |
@Override | |
public void onCreate(@Nullable PresenterBundle bundle) { |
This file contains 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
List<Integer> coolList = new ArrayList<Integer>(); | |
coolList.add(1); | |
coolList.add(2); | |
coolList.add(3); | |
Observable.from(coolList).map(new Func1<Integer, Long>() { | |
@Override | |
public Long call(Integer integer) { | |
//runs on the IO background thread because we specify `Schedulers.io()` | |
return integer * 10000000000L; |
This file contains 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
//append code below to existing build.gradle | |
def appModuleRootFolder = '.' | |
def srcDir = 'src' | |
def googleServicesJson = 'google-services.json' | |
task switchToDebug(type: Copy) { | |
def buildType = 'debug' | |
description = 'Switches to DEBUG google-services.json' | |
from "${srcDir}/${buildType}" |
This file contains 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 void elementClicked(int position){ | |
if (view != null){ | |
final int word = view.getWordByPosition(int position) | |
view.doAnimationStuff(); | |
view.launchActivityWithWord(word); | |
} | |
} | |
//because there are no android dependencies here, it becomes easy to implement Mockito style behavioral testing. |
This file contains 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 repository to store someone's favorite color. | |
*/ | |
public interface FavoriteColorRepo { | |
/** | |
* Loads the user's favorite color. | |
* @return ex- "blue" | |
*/ | |
public Observable<String> getFavoriteColor(); |
This file contains 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 controller that loads a shopping cart (think online shopping). | |
*/ | |
public class CartControllerImpl implements CartController { | |
final CartModel model; | |
final TaxModel taxModel; | |
final CurrencyUnit currencyUnit; | |
final MoneyFormatter moneyFormatter; | |
final RxBus rxBus; |
This file contains 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
/** | |
* Handles getting a user. | |
*/ | |
public interface UserModel { | |
/** | |
* @return the currently logged in user, or null if the user is not logged in | |
*/ | |
Single<User> getUser(); | |
} |
OlderNewer