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 static boolean readBoolean(Parcel in) { | |
if (in != null) { | |
return in.readInt() == 1 ? true : false; | |
} | |
return false; | |
} |
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 static void writeBoolean(Parcel destination, boolean value) { | |
if (destination != null) { | |
destination.writeInt(value ? 0 : 1); | |
} | |
} |
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 static String bundle2String(Bundle bundle) { | |
StringBuilder sb = new StringBuilder(); | |
List<String> keys = new ArrayList<String>(bundle.keySet()); | |
Collections.sort(keys); | |
for (String key : keys) { | |
Object value = bundle.get(key); | |
if (value == null) { | |
sb.append(String.format("%s: null", key)); |
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
task incrementVersionCode << { | |
println(":incrementVersionCode - Incrementing Version Code...") | |
def buildGradleFile = file("build.gradle") | |
def patternVersionCode = Pattern.compile("versionCode (\\d+)") | |
def buildGradleFileText = buildGradleFile.getText() | |
def matcherVersionCode = patternVersionCode.matcher(buildGradleFileText) | |
matcherVersionCode.find() | |
def mVersionCode = Integer.parseInt(matcherVersionCode.group(1)) | |
def mNextVersionCode = mVersionCode + 1 | |
def manifestContent = matcherVersionCode.replaceAll("versionCode " + mNextVersionCode) |
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 Observable<Intent> networkObservable() { | |
return Observable.create(new Observable.OnSubscribe<Intent>() { | |
@Override | |
public void call(Subscriber<? super Intent> subscriber) { | |
final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
subscriber.onNext(intent); | |
} | |
}; |
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 EspressoFriendlyExampleTest { | |
private static final String TEST_ITEM_TITLE = "A test title"; | |
private static final String TEST_ITEM_DESCRIPTION = "A test description"; | |
private static final String TEST_FLAVOUR_TITLE = "A test flavour"; | |
private static final String TEST_ITEM_COPY_TITLE = "A test copy"; | |
private static final String TEST_ITEM_COPY_DESCRIPTION = "A test copy description"; | |
@Override | |
protected void tearDown() throws Exception { |
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 MyDebugTree extends Timber.DebugTree { | |
@Override | |
protected String createStackElementTag(StackTraceElement element) { | |
return super.createStackElementTag(element) + ":" + element.getLineNumber(); | |
} | |
} |
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 CrashlyticsTree extends Timber.Tree { | |
@Override | |
protected void log(int priority, String tag, String message, Throwable t) { | |
if (priority == Log.VERBOSE || priority == Log.DEBUG) { | |
return; | |
} | |
Crashlytics.log(priority, tag, message); |
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
package com.example; | |
import android.content.SharedPreferences; | |
import android.support.annotation.NonNull; | |
import com.example.networking.ApiService; | |
import com.example.networking.response.ExampleResponse; | |
import com.google.gson.Gson; | |
import java.util.HashMap; |
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
@Test | |
public void testOnClickMapButton() throws Exception { | |
Context spyContext = spy(RuntimenEnvironment.application); | |
mActivity.onClickOnMapButton(spyContext); | |
verify(spyContext).startActivity(argThat(googleMapsIntentMatcher())); | |
} | |
private static Matcher<Intent> googleMapsIntentMatcher() { |
OlderNewer