Skip to content

Instantly share code, notes, and snippets.

View Richie97's full-sized avatar

Eric Richardson Richie97

View GitHub Profile
@Richie97
Richie97 / gist:7226214
Created October 30, 2013 02:17
Pager that peeks on either side
int pagerWidth = size.x - getResources().getDimensionPixelSize(R.dimen.hero_pager_margins);
pager.setLayoutParams(new RelativeLayout.LayoutParams(Math.max(pagerWidth, 1), getResources().getDimensionPixelSize(R.dimen.hero_pager_height)));
pager.setClipChildren(false);
pager.setPageMargin(-getResources().getDimensionPixelSize(R.dimen.hero_pager_margins));
SpannableString s = new SpannableString(title);
s.setSpan(new FontTypefaceSpan(this, "Roboto-Light.ttf"), 0, s.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
@Richie97
Richie97 / gist:5373818
Created April 12, 2013 17:49
Gson Array parsing test
String json = "[{\"id\":5,\"name\":\"Action\"},{\"id\":6,\"name\":\"Adventure\"}]";
@Test
public void testJsonArray() throws Exception {
parseJson();
}
void parseJson(){
Type t = new TypeToken<List<Result>>(){}.getType();
List<Result> result = new Gson().fromJson(json, t);
Assert.assertEquals(2, result.size());
public String introduction(){
return getString(R.string.hello_world);
}
@Richie97
Richie97 / gist:4675709
Created January 30, 2013 18:55
Enabling Activites, DayDreams, ETC
getApplicationContext().getPackageManager().setComponentEnabledSetting(new ComponentName(AboutActivity.this, VergeDaydream.class), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
@Richie97
Richie97 / MapFragment BlackBoxes
Created January 14, 2013 22:55
Map Fragment Black Box Fix
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){
FrameLayout frameLayout = new FrameLayout(getActivity());
frameLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
((ViewGroup) v).addView(frameLayout,
new ViewGroup.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT));
}
//Do them SlidingMenu as so
SlidingMenu menu;
private void setUpSideMenu(){
menu = new SlidingMenu(this);
menu.setMenu(R.layout.side_menu);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
menu.setBehindOffsetRes(R.dimen.actionbar_home_width);
menu.setBehindScrollScale(0.25f);
menu.setShadowDrawable(R.drawable.shadow);
@Richie97
Richie97 / gist:3286131
Created August 7, 2012 15:05
Broadcast Receiver Stuff
public class ButtonStuff extends BaseButtonStuff {
private boolean whatevs;
//Broadcast Receiver
private BroadcastReceiver br = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateShit();
}
};
@Richie97
Richie97 / wireshark on device
Created July 10, 2012 20:57
Enable WireShark type stuff for Logcat
**Paste this shiz where you need to troubleshoot*****************************************************
java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST);
java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST);
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "debug");
@Richie97
Richie97 / gist:3006339
Created June 27, 2012 19:47
Custom View onClick
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.entry_menu, menu);
MenuItem mItem = menu.findItem(R.id.menu_comments);
commentCount = (TextView)mItem.getActionView().findViewById(R.id.actionEntryCommentCount);
commentCount.setText(Integer.toString(article.numComments));
mItem.getActionView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {