PrettyListView


Source link: https://github.com/Rohyme/PrettyListView

PrettyListView

Android Arsenal MIT license

Because Life is too short for duplicating Recyclerview code, PrettylistView introduce a very simple generic adapter, pagination handling with customized views (Error,loading) and updating via diffUtils.

Enough talking let's see how to use it .

Installation

  • Step 1. Add the JitPack repository to your build file

allprojects {
 		repositories {
 			... 			maven {
 url 'https://jitpack.io' 
}
 		
}
 	
}
  • Step 2. Add the dependency

 	dependencies {
 	

  implementation 'com.github.Rohyme:PrettyListView:2.0.0' 		
}

Usage :

  1. Get your view
 val prettyList =  findViewById<RecyclerView>(R.id.testListView)
  1. Build your adapter using
 val myAdapterBuilder = BaseListAdapter.with<TestModel>(prettyList)
  1. Make instance of class implementing MainHolderInterface<T> to set your adapter specification in .

    val holderInterfaceInstance = object : MainHolderInterface<TestModel> {
    
    // Mandatory
    
     // return the instance of your list that will be used in your list view
      override fun getList(): ArrayList<TestModel?> {
    
     return testListData
      
    }
    
      // Mandatory
    
     // return the layout of your list view item
      override fun getView(type: Int): Int {
    
      return R.layout.test_list_item
      
    }
    
      // Mandatory
    
     // Here you can use your model item data for your list item view 
      override fun getViewData(holder: RecyclerView.ViewHolder, t: TestModel,
    
     position: Int) {
    
    val listItemView = holder.itemView
    
    val listItemText = listItemView.findViewById<RecyclerView>(R.id.testListView)
    
    listItemText.text = t.text
     
    }
    
      // Optional 
    
     // For itemViewTypes 
      override fun getItemViewType(position: Int): Int {
    
      return super.getItemViewType(position)
     
    }
      
    }
     

    Note : Don't use (-30 , -31) as Item view types constants Because they are already taken for Loading & Error items of pagination

  2. Then set your holderInterface instance to your adapter builder

    myAdapterBuilder.setAdapter(holderInterfaceInstance)
  3. For using pagination

    val myPaginationBuilder = myAdapterBuilder.hasPaginated() //return PaginationBuilder instance
  4. Configure your pagination

    myPaginationBuilder.setErrorLayout(R.layout.error_layout)
    
      .setLoadingLayout(R.layout.loading_layout) 				
    .setVisibleThreshold(5)
  5. Get your final adapter

    mAdapter = myAdapterBuilder.adapterDone()
  6. Set list and pagination calls & callbacks :

    • setListCallBacks Used to notify if items count in recycler view changed :
    mAdapter.setListCallBacks(object : ListUtilsCallbacks<TestModel> {
    
      override fun onDataCountChanged(itemCount: Int) {
    
    Log.i("MyListView","list item count = $itemCount")
      
    }
     
    }
    )
    • setPaginationListener Used for pagination callbacks :

      val paginationListener = object : ListPaginationListener {
      
        override fun onLoadMore(page: Int, totalItemCount: Int, listView: RecyclerView) {
      
        getlist(page)
        
      }
      
       //Optional
        override fun onError(errorView: View) {
      
      errorView.setOnClickListener {
      
       retryGettingList()
      
      }
      
        
      }
      
      //Optional 
        //get the view of your loading view to make any action on it
        override fun onLoading(loadingView: View) {
      
      val progressText = view.findViewById<TextView>(R.id.progressText)
        	val progressText.text = "Loading new Item"
        
      }
       
      }
      
    • Pagination Calls

      • mAdapter.paginatedDataAdded() used when new paginated data added.

      • mAdapter.paginationDone() used when there is no more items for pagination.

      • mAdapter.paginationError() used to show pagination error item.

      • mAdapter.paginationNormalState() used to hide loading or error pagination item.

      • mAdapter.paginationLoading() used to show pagination loading item.

  7. You have 3 ways to update your list

    • You can make change to testListData returned in the mainHolderInstance then call mAdatper.updateList() e.g :

      testListData.add(TestModel("new test")) mAdapter.update()
    • You can use Observable list instead of your list instance and any change happened in it will be updated automatically . e.g :

      // global field var testListData: ObservableArrayList<TestModel> = ObservableArrayList()  // in your holderInstance  override fun getList(): ArrayList<TestModel?> {
      
        return testListData
      
       
      }
        // updating testListData.add(TestModel("new test in observable list"))
    • You can use update list with just passing a list from the same type in order not to change your original data in testListData . It could be useful for filtering or searching. e.g:

       searchField.addTextChangedListener(object : TextWatcher {
      
       override fun afterTextChanged(s: Editable?) {
      
       
      }
      
       override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
      
       
      }
      
        override fun onTextChanged(s: CharSequence?, start: Int, before:Int, count: Int) {
      
        mAdapter.updateList(ArrayList(testListData.filter {
      
      it?.text?.contains(s.toString()) ?: false
      
        
      }
      ))
      
       
      }
      
      }
      )

      Credits :

      CodePathGuide

      Mahmoud Abd Elaal

Resources

The MultiViewPager is an extension of the support-v4 library's ViewPager that allows the pages to be wider or narrower than the ViewPager itself. It takes care of aligning the pages next to each other, and always keeping the selected page centered.

JavaCPP provides efficient access to native C++ inside Java, not unlike the way some C/C++ compilers interact with assembly language. No need to invent new languages such as with SWIG, SIP, C++/CLI, Cython, or RPython as required by cppyy. Instead, it exploits the syntactic and semantic similarities between Java and C++. Under the hood, it uses JNI, so it works with all implementations of Java SE, in addition to Android, Avian, and RoboVM (instructions).

Material Design implementation for Android 2.2 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implementation of the most useful things as shown in the design specification. The library also features some additional non-standard extensions, like rounded corners for layouts or a Divider view for easy divider creation.

MonthView is an android library to display month calendar within the app.

In the spirit of the Maven Versions Plugin, Gradle Versions Plugin provides a task to determine which dependencies have updates.

This library provides a version of GridLayout that works across all versions of Android 1.5+. As a side effect, this library also includes the lightweight Space as well.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes