Skip to content

Instantly share code, notes, and snippets.

View grantland's full-sized avatar

Grantland Chew grantland

View GitHub Profile
@grantland
grantland / README.md
Last active January 25, 2024 23:09
NextBus API
@grantland
grantland / post.md
Last active February 9, 2023 05:09
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
@grantland
grantland / AGB-001_Light_Mod.md
Last active January 25, 2023 15:12
AGB-001 Front/Backlight Mod Instructions

AGB-001 Front/Backlight Mod Instructions

AGB-001 Backlight Mod

Requirements

  • AGB-001
  • ASS101 screen
@grantland
grantland / sleephack.cpp
Created October 2, 2015 07:07 — forked from Jakz/sleephack.cpp
GBA Sleep Hack
#include <cstdio>
#include <cassert>
#include <stdint.h>
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
@grantland
grantland / gist:1096474
Created July 21, 2011 04:09
Android Activity Lifecycle
[...] = starting state
States:
not running (dead)
onResume (running)
onStop (minimized)
onPause (screen off)
Launch Application:
@grantland
grantland / gist:5464067
Last active September 26, 2017 15:49
Enabling Auto-Rotate Quick Settings Toggle on Phones
import android.annotation.TargetApi;
import android.os.Build;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Created by Grantland Chew on 11/14/13.

Android Development

Gradle

Enable Gradle Daemon

Speed up Gradle build times by enabling the Gradle Daemon

echo org.gradle.daemon=true >> ~/.gradle/gradle.properties
@grantland
grantland / gist:3989521
Created October 31, 2012 20:12
Printing stack traces in iOS 5+
// source: http://stackoverflow.com/questions/7841610/xcode-4-2-debug-doesnt-symbolicate-stack-call
void uncaughtExceptionHandler(NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
// Internal error reporting
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
@grantland
grantland / gist:3949145
Created October 24, 2012 21:50
Fix for "Dx warning: Ignoring InnerClasses attribute for an anonymous inner class"
To fix the following warning, you must add "-keepattributes EnclosingMethod" to your proguard config.
Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(me.kiip.internal.c.h) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.