Skip to content

Instantly share code, notes, and snippets.

Flaccuss

Block or report user

Report or block Flaccuss

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Flutter - Hide SliverAppBar with TabBar on Scroll.dart
class NewsScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() => _NewsScreenState();
}
class _NewsScreenState extends State<NewsScreen> {
final List<String> listItems = [];
final List<String> _tabs = <String>[
"Featured",
@Flaccuss
Flaccuss / OkHttpProgressGlideModule.java
Created Aug 17, 2018 — forked from TWiStErRob/OkHttpProgressGlideModule.java
Full POC for showing progress of loading in Glide v3 via OkHttp v2
View OkHttpProgressGlideModule.java
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" />
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" />
// or not use 'okhttp@aar' in Gradle depdendencies
public class OkHttpProgressGlideModule implements GlideModule {
@Override public void applyOptions(Context context, GlideBuilder builder) { }
@Override public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient();
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
@Flaccuss
Flaccuss / post.md
Created Aug 16, 2018 — forked from grantland/post.md
RecyclerView item onClick
View post.md

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
@Flaccuss
Flaccuss / Singleton.java
Created Mar 16, 2018 — forked from aritraroy/Singleton.java
A Perfect Singleton Design Pattern Implementation
View Singleton.java
import java.io.Serializable;
/**
* The perfect implementation of Singleton design pattern
* Properly solves all the below mentioned problems in Singleton pattern
* <p>
* 1) Attack using Reflection API
* 2) Problems from serialization/deserialization of your object
* 3) Problems from cloning your object
* 4) Uncertainty in a multi-threaded environment
@Flaccuss
Flaccuss / ParallelRxJavaUtil.java
Created Mar 16, 2018 — forked from PierceZ/ParallelRxJavaUtil.java
Util method to process a list of data in parallel.
View ParallelRxJavaUtil.java
/**
* Will process the data with the callable by splitting the data into the specified number of threads.
* <b>T</b> is ths type of data being parsed, and <b>U</b> is the type of data being returned.
*/
public static <T, U> Iterable<U> parseDataInParallel(@NonNull List<T> data, Function<List<T>, ObservableSource<U>> worker) {
int threadCount = Runtime.getRuntime().availableProcessors();
ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(threadCount);
Scheduler scheduler = Schedulers.from(threadPoolExecutor);
AtomicInteger groupIndex = new AtomicInteger();
View gist:1cf0c56874542a6bea9e5e4c31fe4c3c
package com.mirth.stevek.rxtest;
import rx.Observable;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.functions.Func3;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
You can’t perform that action at this time.