Skip to content

Instantly share code, notes, and snippets.

View mistrydarshan99's full-sized avatar

Darshan Mistry mistrydarshan99

View GitHub Profile
@mistrydarshan99
mistrydarshan99 / CoroutineLifecycleObserver.kt
Created September 7, 2018 13:31 — forked from chrisbanes/CoroutineLifecycleObserver.kt
LifecycleObserver which allows easy cancelling of coroutines
/*
* Copyright 2018 Google LLC
*
* 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
@mistrydarshan99
mistrydarshan99 / Animators.kt
Created June 27, 2018 09:36 — forked from chrisbanes/Animators.kt
Material Image Loading treatment for Android
/*
* Copyright 2018 Google, Inc.
*
* 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
@mistrydarshan99
mistrydarshan99 / FlickerActivity.java
Created December 27, 2016 04:46 — forked from devunwired/FlickerActivity.java
Quick Android Things demo using ObjectAnimator to animate the brightness of a PWM output. This example uses a BounceInterpolator to create a flickering effect on an LED (like a candle).
/*
* Copyright 2016 Google Inc.
*
* 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
@mistrydarshan99
mistrydarshan99 / Decompress.java
Created October 26, 2016 08:34 — forked from dhavaln/Decompress.java
Android Download and Unzip File
package com.jumpbyte.webserver;
import android.content.Context;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@mistrydarshan99
mistrydarshan99 / LocalBroadcastExampleActivity.java
Created October 17, 2016 06:12 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
@mistrydarshan99
mistrydarshan99 / android_lifecycle_recommendations.md
Created September 21, 2016 13:13 — forked from kaushikgopal/android_lifecycle_recommendations.md
Notes on opportune moments to do "stuff" in the Android Lifecycle
  • In general you want to try and put things in onStart and onStop for logical start and stops.

Activity

onCreate

  • Dagger inject self into graph
  • setContentView(R.layout.xxx)
  • Butterknife.bind(this)
  • RxJava CompositeSubscription.add (if NON UI related work being done)

onStart

@mistrydarshan99
mistrydarshan99 / SomeFragment.java
Created September 2, 2016 12:36 — forked from joshdholtz/SomeFragment.java
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
@mistrydarshan99
mistrydarshan99 / ActivityA.java
Created August 24, 2016 09:59
Stackoverflow answer, "Singleton in Android"
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@mistrydarshan99
mistrydarshan99 / PerformancePatterns.md
Created March 5, 2016 06:35 — forked from colabug/PerformancePatterns.md
Performance Patterns Notes
@mistrydarshan99
mistrydarshan99 / ReadAndroidContacts.java
Created September 28, 2015 08:38 — forked from yanivmo/ReadAndroidContacts.java
Read Android contacts
// The flow starts in onReadClick
import android.app.LoaderManager;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.provider.ContactsContract;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;