kapilmhr/AlphabetIndexFastScrollRecyclerview


This is android alphabet Index fastscroll (very smooth) Recycler View

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.kapilmhr:AlphabetIndexFastScrollRecyclerview:1.0.0'
	}
	dependencies {
		implementation("com.github.kapilmhr:AlphabetIndexFastScrollRecyclerview:1.0.0")
	}
	<dependency>
	    <groupId>com.github.kapilmhr</groupId>
	    <artifactId>AlphabetIndexFastScrollRecyclerview</artifactId>
	    <version>1.0.0</version>
	</dependency>

                            
    libraryDependencies += "com.github.kapilmhr" % "AlphabetIndexFastScrollRecyclerview" % "1.0.0"
        
        

                            
    :dependencies [[com.github.kapilmhr/AlphabetIndexFastScrollRecyclerview "1.0.0"]]
        
        

Readme


AlphabetIndexFastScrollRecyclerview

This is android alphabet Index fastscroll (very smooth) Recycler View

alt text

Follow these steps to use this library:

In build.gradle (Project)

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

And then in the other gradle file(may be your app gradle or your own module library gradle, but never add in both of them to avoid conflict.)

dependencies {
	        compile 'com.github.kapilmhr:AlphabetIndexFastScrollRecyclerview:1.0.0'
          }

How to use

Step 1: add this to your xml:

<fastscroll.app.fastscrollalphabetindex.AlphabetIndexFastScrollRecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

Step 2: implement SectionIndexer to RecyclerViewAdapter.


public class DataAdapter extends RecyclerView.Adapter<DataAdapter.MyHolder> implements SectionIndexer{
    List<Data> dataList;
    private ArrayList<Integer> mSectionPositions;

    public DataAdapter(List<Data> dataList) {
        this.dataList = dataList;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item,null);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        Data data = dataList.get(position);
        holder.title.setText(data.getTitle());

    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    @Override
    public Object[] getSections() {
        List<String> sections = new ArrayList<>();
        mSectionPositions = new ArrayList<>();
        for (int i = 0, size = dataList.size(); i < size; i++) {
            String section = String.valueOf(dataList.get(i).getTitle().charAt(0)).toUpperCase();
            if (!sections.contains(section)) {
                sections.add(section);
                mSectionPositions.add(i);
            }
        }
        return sections.toArray(new String[0]);
    }

    @Override
    public int getPositionForSection(int i) {
        return mSectionPositions.get(i);    }

    @Override
    public int getSectionForPosition(int i) {
        return 0;
    }

Note: mDataArray: this is your recycler data array model.

Features

  • Change IndexTextSize:
recyclerView.setIndexTextSize(12);
  • Change IndexBarTextColor:

    recyclerView.setIndexBarTextColor("#FFFFFF");
    recyclerView.setIndexBarTextColor(R.color.index_bar_text_color);
    
    
  • Change IndexBarColor:

    recyclerView.setIndexBarColor("#33334c");
    recyclerView.setIndexBarColor(R.color.index_bar_color);
    
  • Change IndexBarCornerRadius:

    recyclerView.setIndexBarCornerRadius(3);
    
  • Change IndexBarTransparentValue:
recyclerView.setIndexBarTransparentValue((float) 0.4);
  • Change IndexbarMargin:
 recyclerView.setIndexbarMargin(4);
  • Change IndexbarWidth:
 recyclerView.setIndexbarWidth(40);

*Change PreviewPadding:

 recyclerView.setPreviewPadding(2);
  • Change PreviewVisibility:

    recyclerView.setPreviewVisibility(false);
    
  • Change Typeface:

    Typeface typeface = Typeface.createFromAsset(context.getAssets(), "Custom-Font.ttf");
    recyclerView.setTypeface(typeface);
    
  • To hide/show Fast Scroll IndexBar:
recyclerView.setIndexBarVisibility(true);
  • Change IndexBarHighLateTextColor:
recyclerView.setIndexbarHighLateTextColor("#33334c);

recyclerView.setIndexbarHighLateTextColor(R.color.index_bar_highlight_text_color);
  • To hide/show IndexBarHighLateText:
recyclerView.setIndexBarHighLateTextVisibility(true);