Skip to content

Instantly share code, notes, and snippets.

View ralphpina's full-sized avatar

Ralph Pina ralphpina

  • Affirm
  • San Francisco, CA
View GitHub Profile
mmflogger E java.lang.RuntimeException: Could not dispatch event: class com.mapmyfitness.android.sensor.events.SensorErrorEvent to handler [EventHandler public void com.mapmyfitness.android
.activity.SensorConnectFragment.onSensorErrorEvent(com.mapmyfitness.android.sensor.events.SensorErrorEvent)]
17461 mmflogger E at com.squareup.otto.Bus.throwRuntimeException(Bus.java:456)
17461 mmflogger E at com.squareup.otto.Bus.dispatch(Bus.java:386)
17461 mmflogger E at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:367)
17461 mmflogger E at com.squareup.otto.Bus.post(Bus.java:336)
17461 mmflogger E at com.mapmyfitness.android.event.EventBus.post(EventBus.java:52)
17461 mmflogger E at com.mapmyfitness.android.event.EventBus$MyAsyncHandler.handleMessage(EventBus.java:72)
17461 mmflogger E at android.os.Handler.dispatchMessage(Handler.java:102)
17461
signingConfigs {
release {
storeFile file(“keystore_name.keystore”)
keyAlias “keystore_alias”
storePassword getPassword(‘ANDROID_KEYSTORE_PASSWORD’)
keyPassword getPassword(‘ANDROID_KEY_PASSWORD’)
}
}
// what package should Fragment belong to? I want to use it in Gingerbread!
public class MyFragment extends Fragment {
private TextView mTextView;
// Holding references to Activities is a no no.
// You are leaking its whole view hierarchy
private MyCallBack mMyCallBack;
// In fragments inflating views happens on onCreateView
@Override
@ralphpina
ralphpina / MainActivity.java
Created September 3, 2015 19:07
Sample Interview Activity
public class MainActivity extends AppCompatActivity {
private TextView _name;
private TextView _address;
private TextView _phoneNumber;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@ralphpina
ralphpina / RecyclerViewCursorAdapter.java
Created January 8, 2016 17:05
RecyclerView that wraps a Cursor.
package com.cotap.android.adapters;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
/**
public class TestComponentRule implements TestRule {
private ApplicationTestModule module;
private TestComponent testComponent;
private TestComponentRule(ApplicationTestModule applicationTestModule) {
this.module = applicationTestModule;
}
private void setupDaggerTestComponentInApplication() {
@ralphpina
ralphpina / BaseTest.java
Last active February 16, 2017 19:59
base test class
public class BaseTest {
public List<Giphy> getGiphies(int count) {
List<Giphy> list = new ArrayList<>();
for (int i = count; i > 0; i--) {
list.add(new Giphy.Builder().url("some_url_" + i).build());
}
return list;
}
}
@ralphpina
ralphpina / ActivityTestRule.java
Created February 16, 2017 20:04
instrumentation test rule example
public final TestComponentRule component = new TestComponentRule.Builder()
.withClient()
.withUserManager(true)
.build();
public final ActivityTestRule<MainActivity> activity = new ActivityTestRule<>(
MainActivity.class,
false,
false);
@ralphpina
ralphpina / App.java
Created February 16, 2017 20:06
injecting application component into the Application subclass
// Needed to replace the component with a test specific one
@VisibleForTesting
public void setComponent(ApplicationComponent applicationComponent) {
this.applicationComponent = applicationComponent;
// we need to inject again, otherwise the objects here are the originals
// not the test ones as one would expect R.Pina 20160105
this.applicationComponent.inject(this);
}
@ralphpina
ralphpina / DependencyBuilder.java
Created February 16, 2017 20:11
injecting dependencies.
public Builder withClient() {
this.testClient = new TestGiphyClient();
return this;
}
public Builder withUserManager(boolean real) {
if (real) {
this.userManager = new UserManagerImpl();
} else {
this.userManager = new TestUserManager();
}