Skip to content

Instantly share code, notes, and snippets.

Avatar

Karol Wrótniak koral--

View GitHub Profile
@koral--
koral-- / SinglePagerTitleStrip.java
Last active Apr 10, 2017
Modification of android.support.v4.view.PagerTitleStrip preserving only primary page indicator, see http://www.thedroidsonroids.com/blog/android/pagertitlestrip-with-current-page-indicator-only/ for more info.
View SinglePagerTitleStrip.java
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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
@koral--
koral-- / ImageCaptureHelper.java
Last active Jan 16, 2019
Helper for sending ACTION_IMAGE_CAPTURE intent and retrieve its results. Handles all low level operations
View ImageCaptureHelper.java
//MIT License
//Copyright (c) 2015 Karol Wrótniak, Droids On Roids
package pl.droidsonroids.imagehelpers;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
View ImageSpanFragment.java
package pl.droidsonroids.gif.sample;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
View Casing
http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt
00DF ß
FB03 ffi
03C3 σ
03C2 ς FINAL
00CC I WITH GRAVE
i
java.text.Collator.getInstance().compare("ch","cw")
View MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GifImageView gifImageView=new GifImageView(this);
//https://github.com/koral--/android-gif-drawable-sample/blob/master/sample/src/main/res/drawable-nodpi/anim_flag_england.gif
gifImageView.setImageResource(R.drawable.anim_flag_england);
setContentView(gifImageView);
}
}
@koral--
koral-- / gist:844fae1940dd2c692e7c
Created Apr 17, 2015
Getting GifDrawable or default one from resources
View gist:844fae1940dd2c692e7c
public static Drawable getDrawable(@NonNull Resources resources, @DrawableRes @RawRes int resId, @Nullable Resources.Theme theme) {
try {
return new GifDrawable(resources, resId);
} catch (IOException ignored) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return resources.getDrawable(resId, theme);
else
return resources.getDrawable(resId);
}
}
View Sample.java
Drawable.Callback gifCallback;
private SpannableStringBuilder handleEmotion(final TextView gifTextView, String content) {
SpannableStringBuilder sb = new SpannableStringBuilder(content);
String regex = "\\[(.+?)\\]";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(content);
if (m.groupCount() > 0) {
gifCallback = new Drawable.Callback() {
@koral--
koral-- / README.md
Last active Jan 19, 2017
change-merged gerrit hook pushing branches according to ${GERRIT_SITE}/etc/client_replication_remotes
View README.md

Requirements

  • bash
  • git

Usage

  • create client_replication_remotes file in ${GERRIT_SITE}/etc/ (syntax in example below)
  • create change-merged file in ${GERRIT_SITE}/hooks
  • make change-merged executable (chmod +x change-merged)
@koral--
koral-- / create-full-ramdisk.sh
Last active Jun 26, 2019
Snippets for blog post about /dev/full alternative on OS X http://www.thedroidsonroids.com/blog/dev-full-osx/
View create-full-ramdisk.sh
#!/usr/bin/env bash
VOLUME=FULL_DISK
DEVICE=$(hdiutil attach -nomount ram://64)
diskutil erasevolume MS-DOS ${VOLUME} ${DEVICE}
touch "/Volumes/${VOLUME}/full"
cat /dev/zero > "/Volumes/${VOLUME}/space"
@koral--
koral-- / build.gradle
Last active Dec 12, 2017
testApt to testAnnotationProcessor migration, workaround for issue: https://code.google.com/p/android/issues/detail?id=224272
View build.gradle
android.applicationVariants.all {
def aptOutputDir = new File(buildDir, "generated/source/apt/${it.unitTestVariant.dirName}")
it.unitTestVariant.addJavaSourceFoldersToModel(aptOutputDir)
}