(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:
I use "Android Studio" and I have this simple android lib that I would like to be available on maven: CircularImageView
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) { |
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).
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.