Skip to content

Instantly share code, notes, and snippets.

View AAverin's full-sized avatar

Anton Averin AAverin

View GitHub Profile
@AAverin
AAverin / AnimationManager.java
Created April 23, 2014 12:10
A simple animation manager capable of playing several parallel Animation objects
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.animation.Animation;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.CountDownLatch;
/**
@AAverin
AAverin / ExtendedMapView.java
Last active August 29, 2015 14:09
OpenScienceMap ExtendedMapView. Uses my custom preferences cache wrapper, just use your own implementation
public class ExtendedMapView extends MapView {
private BaseContext baseContext;
public ExtendedMapView(Context context) {
super(context);
baseContext = (BaseContext) context.getApplicationContext();
restorePosition();
}
@AAverin
AAverin / proguard.config
Created December 8, 2014 09:06
OpenScienceMap VTM proguard configuration
-printusage unused.txt
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-printmapping out.map
-dontpreverify
@AAverin
AAverin / gist:e3d293ca168b53443773
Created November 23, 2015 14:43
Xcode crash on breakpoint
Process: Xcode [42461]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 7.0.1 (8228)
Build Info: IDEFrameworks-8228000000000000~5
App Item ID: 497799835
App External ID: 813434267
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [42461]
//Implement this interface in classes that can handle events
public interface HasRxBusEvent {
void onEvent(RxBusEvent event);
}
@RunWith(PowerMockRunner::class)
@PrepareForTest(DrawerToggleFactory::class,
MainPresenter::class)
class NavigationDrawerViewExtensionTest {
@Mock lateinit private var activity: BaseActivity
@Mock lateinit private var drawerToggleFactory: DrawerToggleFactory
@Mock lateinit private var eventsDelegate: NavigationDrawerViewExtensionDelegate
@Mock lateinit private var toolbar: Toolbar
public class LI01Fragment extends BaseFragment {
public final static int DISCOUNTED_TAB = 99;
SlidingTabLayout slidingTabs;
ViewPager viewPager;
ArrayList<CarsPagerItem> mTabs;
LinearLayout blankSlate;
DrawerLayout filterDrawer;
ActionBarDrawerToggle drawerToggle;
interface NavigationDrawerViewExtensionDelegate : EventsDelegate {
fun showInitialScreen()
fun showNav1Screen()
fun showNav2Screen()
}
interface NavigationDrawerViewExtensionContract
@ActivityScope
class NavigationDrawerViewExtension @Inject constructor(
@AAverin
AAverin / ConsistencyManager.kt
Created June 13, 2016 13:47
A simple consistency manager implementation on Kotlin.
interface ConsistencyManagerContract {
fun notifyUpdateModel(model: Any)
fun notifyUpdateClass(kclass: KClass<*>)
fun subscribe(modelClass: KClass<*>, callback: WeakReference<(Any?) -> Unit>)
}
class ConsistencyManager : ConsistencyManagerContract {
private val subscriptionsMap: MutableMap<KClass<*>, MutableList<WeakReference<(Any?) -> Unit>>> = mutableMapOf()
override fun notifyUpdateModel(model: Any) {
open class RxBus {
private val bus = SerializedSubject<BusEvent, BusEvent>(PublishSubject.create());
fun post(event: BusEvent) {
bus.onNext(event)
}
fun <T> events(type: Class<T>): Observable<T> {
return events().ofType(type)
}