Skip to content

Instantly share code, notes, and snippets.

View shakil807g's full-sized avatar
👋

Shakil Karim shakil807g

👋
View GitHub Profile
@shakil807g
shakil807g / chips.dart
Created September 19, 2018 23:05 — forked from slightfoot/chips.dart
Material Chips Input #HumpdayQandA
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// See: https://twitter.com/shakil807/status/1042127387515858949
// https://github.com/pchmn/MaterialChipsInput/tree/master/library/src/main/java/com/pchmn/materialchips
// https://github.com/BelooS/ChipsLayoutManager
void main() => runApp(ChipsDemoApp());
@shakil807g
shakil807g / LifecycleJob.kt
Created September 15, 2018 00:34 — forked from LouisCAD/LifecycleCoroutines.kt
A job that automatically gets cancelled when the lifecycle is destroyed. Meant to be used as a parent to your coroutines in lifecycle aware components.
import android.arch.lifecycle.GenericLifecycleObserver
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY
import android.arch.lifecycle.LifecycleOwner
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job = Job().also { job ->
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:cached_network_image/cached_network_image.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
@shakil807g
shakil807g / ApiClient.kt
Created March 17, 2018 09:31
Network calls with kotlin coroutine + Android Architecture components
object ApiClient {
fun getIntance(): ApiStores {
val builder = OkHttpClient.Builder()
if (BuildConfig.DEBUG) {
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
builder.addInterceptor(loggingInterceptor)
https://stackoverflow.com/questions/16536414/how-to-use-mapview-in-android-using-google-map-v2
import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.LifecycleObserver
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.OnLifecycleEvent
import android.util.Log
import kotlinx.coroutines.experimental.CoroutineStart
import kotlinx.coroutines.experimental.Deferred
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.async
inline fun <T> tryOrDefault(default: T? = null, block: () -> T?) = try {
block()
} catch(e: Exception){
default
}
inline fun <T> tryOrNull(block: () -> T?) = try {
block()
} catch(e: Exception){
@shakil807g
shakil807g / FragmentArgumentDelegate.kt
Created November 19, 2017 16:04 — forked from yanngx/FragmentArgumentDelegate.kt
Fragment arguments without hassle !
package be.brol
import android.os.Binder
import android.os.Bundle
import android.support.v4.app.BundleCompat
import android.support.v4.app.Fragment
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
showProgress("Loading..");
ApiClient.getInstance().login(email,pass) /// api call
.retryWhen(new RetryWithDelay(5,1000))
.doAfterNext(userResponse -> {
if(userResponse.isStatus()){
if(userResponse.getBody() != null){
User user = userResponse.getBody();
setUser(user);
@shakil807g
shakil807g / combineLatestExample.java
Last active August 21, 2017 19:52
Rxjava 2 combineLatest example
/* Rxjava combineLastest Example */
disposable.add(RxFirebase.observeChildEvent(mDatabase.child(AppConstant.USERS)
.child(Utils.fireUserId(getUser().getUserId())).child(AppConstant.GROUPS))
.filter(event -> event.getEventType() == RxFirebaseChildEvent.EventType.ADDED)
.flatMap(event -> {
Log.d(TAG, "setFirebaseListener: "+event.getValue());