Leave a comment

Posted by on January 14, 2017 in Video Tutorials


Optimize Android .apk size in Android Studio

Leave a comment

Posted by on January 7, 2017 in Android Source Code


Fabric Crashlytics Integration (By Twitter) in Android Studio

Leave a comment

Posted by on January 3, 2017 in Android Source Code


Subversion (SVN) Integration in Android Studio

1 Comment

Posted by on December 29, 2016 in Android Source Code


Login with Google Plus (G+) in Android – using Android Studio

Leave a comment

Posted by on December 27, 2016 in Video Tutorials


Implement Endless scrolling using StaggeredLayoutManager – Android

You can use one of two methods in the StaggeredGridLayoutManager:

  1. mLayoutManager.findFirstVisibleItemPositions
  2. mLayoutManager.findFirstCompletelyVisibleItemPositions

Pass an empty int array that will get initialized with the positions and use the one that makes sense for you.

private boolean loading = true;
private int pastVisibleItems, visibleItemCount, totalItemCount;

mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener({
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

        visibleItemCount = mLayoutManager.getChildCount();
        totalItemCount = mLayoutManager.getItemCount();
        int[] firstVisibleItems = null;
        firstVisibleItems = mLayoutManager.findFirstVisibleItemPositions(firstVisibleItems);
        if(firstVisibleItems != null && firstVisibleItems.length > 0) {
            pastVisibleItems = firstVisibleItems[0];

        if (loading) {
            if ((visibleItemCount + pastVisibleItems) >= totalItemCount) {
                loading = false;
                Log.d("tag", "LOAD NEXT ITEM");
Leave a comment

Posted by on October 25, 2016 in Android Source Code


Divider in RecyclerView with ItemDecoration


device-2016-10-12-1614071. Create class

package com.nikshit.Utilities;

import android.view.View;

public class DividerItemDecoration extends RecyclerView.ItemDecoration{
    private Drawable mDivider;
    public DividerItemDecoration(Drawable divider) {
        mDivider = divider;

    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);

        if (parent.getChildAdapterPosition(view) == 0) {
        } = mDivider.getIntrinsicHeight();

    public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
        int dividerLeft = parent.getPaddingLeft();
        int dividerRight = parent.getWidth() - parent.getPaddingRight();

        int childCount = parent.getChildCount();
        for (int i = 0; i < childCount - 1; i++) {
            View child = parent.getChildAt(i);

            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();

            int dividerTop = child.getBottom() + params.bottomMargin;
            int dividerBottom = dividerTop + mDivider.getIntrinsicHeight();

            mDivider.setBounds(dividerLeft, dividerTop, dividerRight, dividerBottom);

2. Create divider.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="" >
    <size android:height=".5dip" />
    <solid android:color="@android:color/darker_gray" />


3. Add lines below where you have defined RecyclerView

  RecyclerView.ItemDecoration dividerItemDecoration = new DividerItemDecoration(getResources().getDrawable(R.drawable.divider));
Leave a comment

Posted by on October 12, 2016 in Android Source Code