Instantly share code, notes, and snippets.

View PagedList.kt
val mainHandler = Handler(Looper.getMainLooper())
val pagedList = PagedList.Builder<Int, Screenshot>()
.setDataSource(dataSource)
.setMainThreadExecutor({ mainHandler.post(it) })
.setBackgroundThreadExecutor(diskExecutor)
.setConfig(PagedList.Config.Builder()
.setPageSize(8)
.setEnablePlaceholders(true)
.build())
View MainActivity.kt
var screenshotLoader: ScreenshotLoader? = null
var adapter: ScreenshotPickerAdapter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
screenshotLoader = SAFScreenshotLoader(contentResolver, diskExecutor)
adapter = ScreenshotPickerAdapter(this)
val recycler = findViewById(R.id.main_recycler) as RecyclerView?
recycler?.layoutManager = GridLayoutManager(this, 2)
View gist:44b075f40ed5ff4e3ca7
adb shell "run-as com.your.app.package chmod 666 /data/data/com.your.app.package/databases/yourDbName.db"
adb pull /data/data/com.your.app.package/databases/yourDbName.db
View update.sh
#!/bin/bash
ERR_SITE_GEN=1
ERR_SITE_DEPLOY=2
ERR_GIT_ADD=3
ERR_GIT_COMMIT=4
ERR_GIT_PUSH=5
ERR_NO_COMMIT_MESSAGE=6
if [ $# -eq 0 ]; then
View update.sh
#!/bin/bash
ERR_SITE_GEN=1
ERR_SITE_DEPLOY=2
ERR_GIT_ADD=3
ERR_GIT_COMMIT=4
ERR_GIT_PUSH=5
ERR_NO_COMMIT_MESSAGE=6
if [ $# -eq 0 ]; then
View MainActivity.java
package com.example.dtmformattingexamples;
import java.util.Date;
import java.util.Locale;
import android.app.Activity;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.widget.TextView;
View GsonRequest.java
/**
* Copyright 2013 Adam Speakman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View TextViewLinkHider.java
/**
* Copyright 2013 Adam Speakman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View DreamLinkMovementMethod.java
/**
* Copyright 2013 Adam Speakman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View WCFDateTimeParser.java
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
public class WCFDateTimeParser {
/**
* <p>WCF services supply Dates over JSON in a strange format. This method
* takes a WCF-formatted Date string and parses it into a JodaTime DateTime
* object. Assumes valid input matching a format described below.</p>
*