Skip to content

Instantly share code, notes, and snippets.

@nseidm1
nseidm1 / gist:8345290
Last active January 2, 2016 18:39
A tremendously simplified, and increasingly reliable implementation of the AOSP messaging app's MMS TransactionService.
/*
* Copyright (C) 2007-2008 Esmertec AG.
* Copyright (C) 2007-2008 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
*
@nseidm1
nseidm1 / gist:8544457
Last active January 4, 2016 00:49
Workaround for Chips to add a telephone number programmatically with a successful chip conversion. This is the code that's run from an onActivityResult after a telephone number selection.
private void processPickResult(final Intent data) {
final Handler handler = new Handler();
ExecutorManager.sInstance.mExecutor.execute(new Runnable() {
@Override
public void run() {
Uri pickedPhoneNumber = data.getData();
Cursor cursor = getContentResolver().query(pickedPhoneNumber, null, null, null, null);
try{
if (cursor.moveToFirst()) {
final String telephone = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA1));
@nseidm1
nseidm1 / gist:9252142
Last active August 29, 2015 13:56
The ChildConsiderateFragment allows fragments to be defined in it's xml layout. The child fragments will be determined in the onCreateView callback by parsing the xml layout returned by the abstract getLayoutId method. The child fragments will automatically be cleaned up in the onDestroyView callback.
package com.paltalk.chat.utils;
import java.util.ArrayList;
import org.xmlpull.v1.XmlPullParser;
import android.content.res.XmlResourceParser;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
@nseidm1
nseidm1 / gist:9327674
Last active August 29, 2015 13:56
Overriden activity capable of inflating child fragment tags in fragment xml layouts. This activity will successfully use the ChildFragmentManager of the parent fragment. At the bottom of the gist is a custom attr definition. For your child fragment defined in xml you'll be definining the parent fragment name.
package com.project.floatingvideos;
import java.util.Random;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.res.TypedArray;
@nseidm1
nseidm1 / gist:9340378
Created March 4, 2014 04:37
Custom image view that accepts a gif loaded by the setGif method taking a File. Gif decoding from: GIF support comes from Code Aurora Forums: https://www.codeaurora.org/cgit/quic/la/platform/packages/apps/Gallery2/tree/src/com/android/gallery3d/util?h=jb_chocolate_rb4.1&id=2b133c9747af26701a12d60caef3e7e14cf55536
package com.project.vegassms.classes;
import java.io.File;
import java.io.FileInputStream;
import java.util.Observable;
import java.util.Observer;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
@nseidm1
nseidm1 / gist:9469161
Created March 10, 2014 17:02
GreenDao java generator
/*
* Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de)
*
* 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
@nseidm1
nseidm1 / gist:9469800
Created March 10, 2014 17:30
DatabaseManager
package com.project.vegassms.managers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.app.Application;
@nseidm1
nseidm1 / gist:9514890
Created March 12, 2014 19:49
Get the parent fragment, of a child fragment, on 4.0+ devices using SDK fragments, not V4 Fragments.
public Fragment getParentFragmentTwo() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return getParentFragment();
} else {
View view = getView();
while (view.getParent() != null) {
Fragment fragment = getFragmentManager().findFragmentByTag((String) view.getTag());
if (fragment != null)
return fragment;
view = (View) view.getParent();
@nseidm1
nseidm1 / gist:11399613
Last active August 29, 2015 14:00
Generic serializable and parcelable collection container with auto cast support
package com.serve.platform.service.support;
import java.io.Serializable;
import java.util.Arrays;
import java.util.LinkedList;
import android.os.Parcel;
import android.os.Parcelable;
public class Extras implements Parcelable {
package com.project.vegassms.helpers;
import java.io.Serializable;
import java.util.Observable;
import android.os.Handler;
import android.os.Looper;
import com.project.vegassms.Message;