Skip to content

Instantly share code, notes, and snippets.

View e4basil's full-sized avatar
🎯
Focusing

Basi e4basil

🎯
Focusing
View GitHub Profile
public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder> {
private List<Model> items = new ArrayList<>();
SparseBooleanArray itemStateArray= new SparseBooleanArray();
Adapter() {
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
/* We create an interface with one method */
public interface TextWatcherWithInstance {
void onTextChanged(EditText editText, CharSequence s, int start, int before, int count);
}
/* We create a custom class called MultiTextWatcher.
* And pass the interface here
*/
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@e4basil
e4basil / introrx.md
Created November 10, 2016 19:16 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@e4basil
e4basil / README.md
Created November 1, 2016 07:24 — forked from lopspower/README.md
Publish AAR to jCenter and Maven Central

Publish AAR to jCenter and Maven Central

Twitter

Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:

  1. I use "Android Studio" and I have this simple android lib that I would like to be available on maven: CircularImageView

  2. In the library folder(module) I have the lib code abovementioned. And applying in the build.gradle of this folder apply plugin: 'com.android.library' I got as output an .aar in the build/outputs/aar/ directory of the module's directory

apply plugin: 'com.github.dcendents.android-maven'
group = publishedGroupId // Maven Group ID for the artifact
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
apply plugin: 'com.jfrog.bintray'
version = libraryVersion
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
apply plugin: 'com.jfrog.bintray'
version = libraryVersion
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
@e4basil
e4basil / starting_library_project_AS.md
Created August 29, 2016 07:16 — forked from daniellevass/starting_library_project_AS.md
Getting Started with a library project in Android Studio

Getting Started with a library project in Android Studio

So we're working on creating Android Material Awesome, a library which will hopefully incorperate the benefits of Material Design, Twitter's Bootstrap, and FontAwesome. What we really wanted is a project other people can easily include into their projects using gradle dependencies. To do this we needed to create a standalone library project so we could make it as lightweight as possible for including as a dependency, and a sample app that would use it for testing. These are the steps we took to get started in Android Studio (version 1.1).

Create Projects

The first thing we needed to do was to create two new projects, with all the default settings (Blank Activity etc). One for our sample app, and one for our library. We added both of ours into the same GitHub repo, however you can save them wherever you like.

Fix Up Library Project