Skip to content

Instantly share code, notes, and snippets.

interface ModelObservable : Observable {
fun notifyChange()
fun notifyPropertyChanged(fieldId: Int)
}
/**
* A convenience class that implements an extension of the [Observable] interface and provides
* [.notifyPropertyChanged] and [.notifyChange] methods.
*/
class ModelObservableImpl : ModelObservable {
@nseidm1
nseidm1 / scroll_to_bottom.dart
Created April 25, 2019 21:04
Dart scroll to bottom
import 'package:flutter/material.dart';
class ScrollToBottomController extends ScrollController {
ScrollToBottomController({
@required Listenable listenable,
double initialScrollOffset = 0.0,
bool keepScrollOffset = true,
String debugLabel,
}) : _listenable = listenable,
super(
@nseidm1
nseidm1 / gist:b711ab6d3919fc385f7e819a9a3ba8b6
Last active April 12, 2017 15:29
Double save state fix for FragmentStatePagerAdapter
package com.huffingtonpost.android.base.widget;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.PagerAdapter;
import android.view.View;
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;
@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 {
@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: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: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: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: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;