Coder Social home page Coder Social logo

jyprksh001 / alphabetindexfastscrollrecyclerview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kapilmhr/alphabetindexfastscrollrecyclerview

0.0 1.0 0.0 2.35 MB

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

Java 100.00%

alphabetindexfastscrollrecyclerview's Introduction

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);

alphabetindexfastscrollrecyclerview's People

Contributors

kapilmaharjan avatar kapilmhr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.