Skip to content

Instantly share code, notes, and snippets.

View korniltsev's full-sized avatar
🏳️‍🌈
s/jz/jnz/

Tolya Korniltsev korniltsev

🏳️‍🌈
s/jz/jnz/
View GitHub Profile
@korniltsev
korniltsev / GZIPUtils.java
Created October 23, 2012 13:49 — forked from johnkil/GZIPUtils.java
Utilities for working with GZIP archives.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.GZIPInputStream;
@korniltsev
korniltsev / gist:4024343
Created November 6, 2012 12:26
Use declared stylable from apklib
Added support for custom views with custom attributes in libraries. Layouts using custom attributes must use the namespace URI http://schemas.android.com/apk/res-auto instead of the URI that includes the app package name. This URI is replaced with the app specific one at build time.
@korniltsev
korniltsev / gist:4030294
Created November 7, 2012 09:03
Android ListViews not clickable
http://netpenthe.wordpress.com/2011/11/20/android-listviews-not-clickable/
Apparently ListViews lose their clickability if they contain focusable child elements in their layout.
I initially set all the child elements to not be focusable.
But now do this in the getView() method instead:
((ViewGroup) convertedView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
@korniltsev
korniltsev / MyActivity.java
Created November 14, 2012 12:48
AutoCompleteTextView sample
package com.example.popup_test;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
@korniltsev
korniltsev / gist:4202436
Created December 4, 2012 10:17
inf. sec. 04
function [ out ] = berlekamp_massey( )
z=[ 0 0 0 0 1 1 1 1 1 0 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 1];
n = length(z);
c = zeros(1,n);
b= zeros(1,n);
c(1) = 1;
b(1) = 1;
@korniltsev
korniltsev / qwe
Created February 1, 2013 10:20
fragment reuse
@Override
public void onDestroyView() {
super.onDestroyView();
getFragmentManager()
.beginTransaction()
.detach(mFilter)
.commit();
}
@korniltsev
korniltsev / gist:5014112
Created February 22, 2013 15:15
Change locale in runtime
public void setLocale(String lang) {
myLocale = new Locale(lang);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
Intent refresh = new Intent(this, AndroidLocalize.class);
Intent.createChooser(it, "Choose Email Client")
/**
* User: korniltsev
* Date: 22.03.13
* Time: 14:51
*/
public class ConfirmDialogFactory {
public static void build(Context c)
{
       final Dialog dialog = new Dialog(c,R.style.CustomStyle);
/**
* User: korniltsev
* Date: 22.03.13
* Time: 14:51
*/
public class ConfirmDialogFactory {
public static Dialog build(Activity a)
{
final Dialog dialog = new Dialog(a,R.style.CustomStyle);