Skip to content

Instantly share code, notes, and snippets.

Avatar

David Wong davidwong

View GitHub Profile
View MessagePagingSource.java
public class MessagePagingSource extends RxPagingSource<Integer, Message> {
private MessageRepository messageRepository;
// the initial load size for the first page may be different from the requested size
private int initialLoadSize;
public MessagePagingSource(MessageRepository messageRepository) {
this.messageRepository = messageRepository;
}
@davidwong
davidwong / ErrorLogger-release.java
Created Mar 21, 2019
Example code for blog post: Crashlytics and Android: Clean Way to Use Custom Crash Reports?
View ErrorLogger-release.java
import com.crashlytics.android.Crashlytics;
public class ErrorLogger extends LoggerWrapper {
public ErrorLogger(Class clazz) {
super(clazz);
}
public ErrorLogger(String className) {
super(className);
@davidwong
davidwong / ErrorReport.java
Last active Mar 21, 2019
Example code for blog post: Crashlytics and Android: Clean Way to Use Custom Crash Reports?
View ErrorReport.java
/**
* Attempt at generic non-fatal error report, modelled on Crashlytics error reporting methods.
*/
public class ErrorReport {
private String id; // could be user ID, for instance
private final Map<String, String> stateString;
private final Map<String, Boolean> stateBool;
private final Map<String, Integer> stateInt;
private final Map<String, Double> stateDouble;
@davidwong
davidwong / 01_RecyclerViewIdlingResourceTest.java
Created Feb 3, 2018
RecyclerView update Idling Resource example code
View 01_RecyclerViewIdlingResourceTest.java
@RunWith(AndroidJUnit4.class)
public class RecyclerViewIdlingResourceTest {
@Rule
public ActivityRule<MainActivity> activityRule = new ActivityRule<MainActivity>(MainActivity.class);
// number of items in the original list
int allItemsCount = ...;
// number of items after the list has been filtered
@davidwong
davidwong / AndroidMockStaticMethod.java
Last active Nov 24, 2017
Example code for blog post: Mocking Static Methods in Android: Let's Wrap it up.
View AndroidMockStaticMethod.java
// Example 1 - Test that fails
public class ClassUnderTest {
public String methodUnderTest(String str)
{
if (PhoneNumberUtils.isGlobalPhoneNumber(str))
{
return "yes";
}
@davidwong
davidwong / Dockerfile for JRebel and Tomcat
Created May 27, 2015
Dockerfile for adding JRebel to a Tomcat image
View Dockerfile for JRebel and Tomcat
FROM tomcat:8-jre8
MAINTAINER "David Wong"
RUN mkdir /jrebel
ADD jrebel.jar /jrebel/
ENV CATALINA_OPTS="-javaagent:/jrebel/jrebel.jar -Drebel.remoting_plugin=true"
@davidwong
davidwong / fig.yml
Created Jan 30, 2015
Fig YAML for backing up a Docker data volume container for Jenkins
View fig.yml
# Backup a data volume container for Jenkins
backup:
image: busybox
command: tar cvf /backup/jenkins-backup.tar /var/jenkins_home
volumes:
- .:/backup
@davidwong
davidwong / Dockerfile for Jenkins data container
Last active Aug 29, 2015
Dockerfile for creating a data volume container for Jenkins
View Dockerfile for Jenkins data container
# Create a data volume container for Jenkins config and data
FROM jenkins
VOLUME /var/jenkins_home
# run a do-nothing command
CMD ["true"]
You can’t perform that action at this time.