DobList


Source link: https://github.com/bilalsammour/DobList

DobList

DobList (Google Play Demo)

Any Android developer needs Endless ListView, and needs progress dialog to be shown in the middle of his own ListView at first loading data, so he will write the code line by line or use a custom ListView to get some features and lost his own ListView.

What about getting desired features with your own ListView and its derivatives!

DobList is an Open Source Android library that provides to ListView adding ProgressBar (or any view) to the footer of ListView to be shown in loading more, and callback that is called when reaching last item in ListView.

Here is a short video for the example application in this repository : http://youtu.be/1TPzJDpUwug

Setup

In Eclipse, just import the library as an Android library project. Project > Clean to generate the binaries you need, like R.java, etc. Then, just add DobList as a dependency to your existing project.

How?

 public View onCreateView(LayoutInflater inflater, ViewGroup container,
 Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.fragment_main, container,
  false);

 // ListView initializing
ListView mListView = (ListView) rootView.findViewById(R.id.mListView);

 // Set DobList before setting adapter
initDobList(rootView, mListView);

 // Set adapter
mListView.setAdapter(adapter);

 return rootView;  
}

private void initDobList(View rootView, ListView listView) {

 // DobList initializing
dobList = new DobList();

try {

  // Register ListView
 //
 // NoListViewException will be thrown when
 // there is no ListView
 dobList.register(listView);

  // Add ProgressBar to footers of ListView
 // to be shown in loading more
 dobList.addDefaultLoadingFooterView();

  // Sets the view to show if the adapter is empty
 // see startCentralLoading() method
 View noItems = rootView.findViewById(R.id.noItems);

 dobList.setEmptyView(noItems);

  // Callback called when reaching last item in ListView
 dobList.setOnLoadMoreListener(new OnLoadMoreListener() {

@Override
  public void onLoadMore(final int totalItemCount) {

Log.i(TAG, "onStart totalItemCount " + totalItemCount);

 // Just inserting some dummy data after

// period of time to simulate waiting

// data from server

addDummyData(10);

  
}

 
}
);

 
}
 catch (NoListViewException e) {

 e.printStackTrace();

}

 try {

 // Show ProgressBar at the center of ListView
 // this can be used while loading data from
 // server at the first time
 //
 // setEmptyView() must be called before
 //
 // NoEmptyViewException will be thrown when
 // there is no EmptyView
 dobList.startCentralLoading();

 
}
 catch (NoEmptyViewException e) {

 e.printStackTrace();

}

// Simulate adding data at the first time
addDummyData(5);
  
}

protected void addDummyData(final int itemsCount) {

new Handler().postDelayed(new Runnable() {

  @Override
 public void run() {

  addItems(adapter.getCount(), adapter.getCount() + itemsCount);

// We must call finishLoading
  // when finishing adding data
  dobList.finishLoading();

 
}

 
}
, 2000);
  
}

Properties

  • Set / get ListView - for ListView and its derivatives such as ExpandableListView
  • Set / get footerLoadingView - to define and access a custom footer that will be shown in loading more
  • Set / get emptyView - Sets and get the view to show if the adapter is empty. See startCentralLoading() method
  • Set / get maxItemsCount - Here you can specify the maximum number of items in ListView.
  • Set / get onLoadMoreListener - Callback that is called when reaching last item in ListView.
  • Set / get onScrollListener - Because DobList consumes OnScrollListener, here you can use OnScrollListener.

Methods

  • register - Register ListView. NoListViewException will be thrown when there is no ListView.
  • addDefaultLoadingFooterView - Add ProgressBar to footers of ListView to be shown in loading more.
  • startCentralLoading - Show ProgressBar at the center of ListView this can be used while loading data from server at the first time.

setEmptyView() must be called before.

NoEmptyViewException will be thrown when there is no EmptyView.

Events

  • OnLoadMoreListener - Callback that is called when reaching last item in ListView.

Developed By

Bilal Sammour - [email protected]

License

Copyright 2014 Bilal Sammour  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

WaspDB is a pure Java key/value (NoSQL) database library for Android. It supports AES256 encryption for all the disk storage.

This library is an enhancement to the TextView component that allows you to style various spans of text inside the view.

Parrot is a gradle plugin that allows your app to speak multiple languages, without the hassle of working with multiple resources, using the translation editor or ordering an expensive translation from AS/IDEA

It leverages the Google Translate API in order to translate your string resources into all the languages specified in the configuration.

FAB to Toolbar Button library for Android Material Collapsing Toolbar.

ReDex is an Android bytecode (dex) optimizer originally developed at Facebook. It provides a framework for reading, writing, and analyzing .dex files, and a set of optimization passes that use this framework to improve the bytecode. An APK optimized by ReDex should be smaller and faster than its source.

FoldingCell is an expanding content cell inspired by folding paper material.

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