Android Open Source - book Page Adapter






From Project

Back to project page book.

License

The source code is released under:

MIT License

If you think the Android project book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fragments;
//from w ww  . j ava2s .c o  m
import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

public class PageAdapter extends FragmentPagerAdapter {     
    private List<Fragment> fragments;
    private FragmentManager fm;
   
    
    public PageAdapter(FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.fm = fm;
        this.fragments = fragments;        
    }
    

    public void remove(Fragment fragment){
      if (this.fragments.contains(fragment)){
        this.fragments.remove(fragment);  
      }      
    }
    
    public void addTo(int position, Fragment fragment){
      this.fragments.add(position,fragment);
    }
    
    public void add(Fragment fragment){
      this.fragments.add(fragment);      
    }
    
    public int getPosition(Fragment fragment){
      return this.fragments.indexOf(fragment);
    }

    @Override
    public Fragment getItem(int position) {
        return this.fragments.get(position);
    }
 
    @Override
    public int getCount() {
        return this.fragments.size();
    }
    
    @Override
    public void destroyItem(View collection, int position, Object view) {
         ((ViewPager) collection).removeView((View) view);
    }

}




Java Source Code List

book.BookListAdapter.java
book.Book.java
book.ExpandableListAdapter.java
book.SelectableWordListAdapter.java
com.BookTable.java
com.Db.java
com.TranslationsTable.java
com.WordTable.java
fragments.BookListFragment.java
fragments.BookViewFragment.java
fragments.CameraFragment.java
fragments.EditBookFragment.java
fragments.PageAdapter.java
fragments.PagerActivity.java
translator.TranslateWordTask.java
translator.Translator.java