Skip to content

Instantly share code, notes, and snippets.

View SelvinPL's full-sized avatar

SelvinPL SelvinPL

View GitHub Profile
//naive way of not getting OOME (still terrible but...)
//in loop DO NOT DECODE TO BITMAP
//map.put(TAG_Photo, bitmap); should become:
map.put(TAG_Photo, Base64.decode(photo, Base64.DEFAULT)); //byte array take less space than coresponded base64 string
SimpleAdapter adapter = ...;
adapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
@SelvinPL
SelvinPL / MainActivity.java
Last active September 15, 2015 12:11
Use CursorLoaders! It's easy! replace commented code with uncommented to get Phones(instead SMS) list in the same easy way
package pl.selvin.simplelistfragmentsample;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.content.Context;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager;
@SelvinPL
SelvinPL / Activities.java
Last active March 1, 2022 14:27
Dynamic fragment loading
package pl.selvin.fragmentloader;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
package pl.selvin.wallpaperchanger;
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.app.WallpaperManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@SelvinPL
SelvinPL / Program.cs
Last active December 9, 2015 17:36
DllImport thiscall vc++ and gcc compatible???
using System;
using System.Runtime.InteropServices;
namespace SharedObject1Test
{
class Program
{
public class SharedObject1Proxy : IDisposable
{
#if GCC
@SelvinPL
SelvinPL / MyPojo.java
Last active March 16, 2016 13:05
Extending ArrayAdapter hints
public class MyPojo {
private long id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
@SelvinPL
SelvinPL / AndroidManifest.xml
Last active January 3, 2017 23:17
ProxyActivity
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example" >
<application
<!-- other Activities goes here -->
<activity
android:name=".ProxyActivity"
android:label="Some nice label"
android:noHistory="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
static volatile boolean isRunning = true;
void test() {
final int SIZE = 16 * 1024;
try {
final PipedOutputStream pipedOutputStream = new PipedOutputStream();
final PipedInputStream pipedInputStream = new PipedInputStream(SIZE);
pipedOutputStream.connect(pipedInputStream);
final Object wait = new Object();
new Thread(new Runnable() {
@Override