Skip to content

Instantly share code, notes, and snippets.

@pfn
pfn / gist:ec2465ff64a7fd22ab40
Created November 19, 2015 21:06
all tests go
> scripted
[info] :: delivering :: com.hanhuy.sbt#android-sdk-plugin;1.5.9-SNAPSHOT :: 1.5.9-SNAPSHOT :: integration :: Thu Nov 19 12:54:52 PST 2015
[info] delivering ivy file to C:\Users\pfnguyen\src\sbt\target\scala-2.10\sbt-0.13\ivy-1.5.9-SNAPSHOT.xml
[info] Packaging C:\Users\pfnguyen\src\sbt\target\scala-2.10\sbt-0.13\android-sdk-plugin-1.5.9-SNAPSHOT.jar ...
[info] Done packaging.
[info] published android-sdk-plugin to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-SNAPSHOT\jars\android-sdk-plugin.jar
[info] published android-sdk-plugin to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-SNAPSHOT\srcs\android-sdk-plugin-sources.jar
[info] published android-sdk-plugin to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-SNAPSHOT\docs\android-sdk-plugin-javadoc.jar
[info] published ivy to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-S
@pfn
pfn / build.txt
Last active November 20, 2015 01:12
building u2020 with sbt
[pfnguyen@GALACTICA src] $ git clone https://github.com/jakewharton/u2020
Cloning into 'u2020'...
remote: Counting objects: 3519, done.
emote: Total 3519 (delta 0), reused 0 (delta 0), pack-reused 3519
Receiving objects: 100% (3519/3519), 8.96 MiB | 1.28 MiB/s, done.
Resolving deltas: 100% (1598/1598), done.
Checking connectivity... done.
[pfnguyen@GALACTICA src] $ cd u2020/
[pfnguyen@GALACTICA u2020] $ mkdir project
[pfnguyen@GALACTICA u2020] $ echo 'addSbtPlugin("com.hanhuy.sbt" % "android-gradle-build" % "1.1.9")' > project/p.sbt
@pfn
pfn / lint.txt
Created November 20, 2015 01:35
lint errors from VectorDrawables
> android:lint
[error] [NewApi] src\main\res\drawable\ic_add_circle_black_24dp.xml:1:<vector> requires API level 21 (current min is 9) or building with Android Gradle plugin 1.4 or higher
[error] <vector xmlns:android="http://schemas.android.com/apk/res/android"
[error] ^
[error] [NewApi] src\main\res\drawable\ic_add_circle_white_24dp.xml:1:<vector> requires API level 21 (current min is 9) or building with Android Gradle plugin 1.4 or higher
[error] <vector xmlns:android="http://schemas.android.com/apk/res/android"
[error] ^
[error] [NewApi] src\main\res\drawable\ic_history_black_24dp.xml:1:<vector> requires API level 21 (current min is 9) or building with Android Gradle plugin 1.4 or higher
[error] <vector xmlns:android="http://schemas.android.com/apk/res/android"
[error] ^
@pfn
pfn / createview.scala
Created November 23, 2015 17:12
layout.perform should create a new instance
override def onCreateView(i: LayoutInflater, c: ViewGroup, b: Bundle) = {
adapter foreach (_.context = getActivity)
val v = layout.perform()
def inputHeight = for {
a <- MainActivity.instance
h <- a.inputHeight
} yield h
log.v("view hash: " + System.identityHashCode(v) + " " + System.identityHashCode(this) + " " + System.identityHashCode(layout))
// why is this only occurring on gingerbread?
@pfn
pfn / ioapply.scala
Created November 23, 2015 19:19
iota strangeness
IO.apply({
val iota$generatedContainer$1 = iota.IO.apply[android.widget.FrameLayout](new android.widget.FrameLayout(this)).perform.apply();
Seq.apply(iota.IO.apply[android.view.View](new android.view.View(this))).foreach(((iov) => {
val iota$generatedView = iov.perform.apply();
if (iota$generatedView.getParent().$bang$eq(null))
iota$generatedView.getParent().asInstanceOf[ViewGroup].removeView(iota$generatedView)
else
();
iota$generatedContainer$1.addView(iota$generatedView)
}));
@pfn
pfn / extractor.py
Created December 1, 2015 03:40
gradle dependency extractor
#!/usr/bin/python
import re
modulere = re.compile("""\s*compile\s*['"]([^:]+):([^:]+):([^:@]+)(@aar)?['"]""")
repore = re.compile("""\s*maven\s*\{\s*url\s*['"]([^'"]+)['"]\s*\}\s*""")
script = file("mobile/build.gradle", "r")
lines = script.readlines()
def convertlines(acc, l):
repo = re.match(repore, l)
@pfn
pfn / file.rb
Created December 8, 2015 14:49
Android created Gist
> inspect libraryDependencies
[info] Setting: scala.collection.Seq[sbt.ModuleID] = List()
[info] Description:
[info] Declares managed dependencies.
[info] Provided by:
[info] {file:/cifs/pfnguyen/src/sample/}com-foo/*:libraryDependencies
[info] Defined at:
[info] (sbt.Classpaths) Defaults.scala:1142
[info] Dependencies:
[info] *:scalaOrganization
@Override
public boolean onNestedFling(final CoordinatorLayout coordinatorLayout, final AppBarLayout child, View target, float velocityX, final float velocityY, boolean consumed) {
if (target instanceof RecyclerView && velocityY < 0) {
final RecyclerView recyclerView = (RecyclerView) target;
final long start = System.currentTimeMillis();
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
@pfn
pfn / keypath.txt
Created January 5, 2016 04:26
sbt keypath output for multi-project dependencies
[pfnguyen@GALACTICA sbtm] $ sbt "keypath b/compile a/compile"
[info] Loading global plugins from C:\Users\pfnguyen\.sbt\0.13\plugins
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] Loading project definition from C:\Users\pfnguyen\src\sbtm\project
[info] Updating {file:/C:/Users/pfnguyen/src/sbtm/project/}sbtm-build...
[info] Resolving org.eclipse.jgit#org.eclipse.jgit.archive;3.7.0.201502260915-r [info] Resolving com.hanhuy.sbt#key-path;0.3-SNAPSHOT ...
[warn] Host repo.scala-sbt.org not found. url=https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.hanhuy.sbt/key-path/scala_2.10/sbt_0.13/0.3-SNAPSHOT/ivys/ivy.xml
[info] You probably access the destination server through a proxy server that is not well configured.
@pfn
pfn / log.txt
Last active January 21, 2016 23:12
package installation failure
[pfnguyen@GALACTICA output] $ ~/android-sdk-windows/build-tools/23.0.2/aapt.exe d xmltree keepshare-debug.apk AndroidManifest.xml | grep -A5 provider
E: provider (line=58)
A: android:label(0x01010001)=@0x7f070039
A: android:name(0x01010003)="com.hanhuy.android.keepshare.SearchProvider" (Raw: "com.hanhuy.android.keepshare.SearchProvider")
A: android:readPermission(0x01010007)="android.permission.GLOBAL_SEARCH" (Raw: "android.permission.GLOBAL_SEARCH")
A: android:exported(0x01010010)=(type 0x12)0xffffffff
A: android:authorities(0x01010018)=@0x7f070093
[pfnguyen@GALACTICA output] $ ~/android-sdk-windows/build-tools/23.0.2/aapt.exe d resources keepshare-debug.apk | grep 70093
spec resource 0x7f070093 com.hanhuy.android.keepshare:string/search_suggest_authority: flags=0x40000000
resource 0x7f070093 com.hanhuy.android.keepshare:string/search_suggest_authority: t=0x03 d=0x00000346 (s=0x0008 r=0x00) (PUBLIC)