Android Open Source - AStory Library Adapter






From Project

Back to project page AStory.

License

The source code is released under:

Apache License

If you think the Android project AStory 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 com.Litterfeldt.AStory.adapters;
//from   ww w .  j  a  v  a 2s.c  om
import android.graphics.BitmapFactory;
import android.widget.ArrayAdapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.util.Log;

import android.widget.ImageView;
import android.widget.TextView;
import android.view.LayoutInflater;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.Typeface;
import java.util.*;


import com.Litterfeldt.AStory.R;
import com.Litterfeldt.AStory.models.Book;
import com.Litterfeldt.AStory.pagerView;

public class LibraryAdapter extends ArrayAdapter<Book> {

    private Context context;
    private Typeface font;
    public LibraryAdapter (Context context, int layoutRef, ArrayList<Book> books, Typeface font){
        super(context, layoutRef, (List<Book>) books);
        this.context = context;
        this.font = font;
    }

    @Override
    public int getCount(){
        return super.getCount() +1;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;

        if(position == 0){
            if (view == null){
                LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.library_header, null);
                TextView header = (TextView)view.findViewById(R.id.BoxHeaderTitle);
                TextView subHeader = (TextView)view.findViewById(R.id.BoxHeaderSubTitle);
                subHeader.setTypeface(font);
                header.setTypeface(font);
            }

        }else{


            Book item = getItem(position-1);
            if (item != null) {
                if(item.id() == -1) {

                        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                        view = inflater.inflate(R.layout.library_get_book_list, null);
                        TextView header = (TextView)view.findViewById(R.id.BoxGetBooksTitle);
                        header.setTypeface(font);

                }else{
                    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    view = inflater.inflate(R.layout.librarylistbox, null);
                    TextView header = (TextView)view.findViewById(R.id.BoxBookTitle);
                    TextView author = (TextView)view.findViewById(R.id.BoxBookAuthor);
                    ImageView img = (ImageView)view.findViewById(R.id.BoxBookCoverImage);
                    if (header != null && item.name() != null) {
                        header.setTypeface(font);
                        header.setText(item.name());
                    }
                    if (author != null && item.author() != null) {
                        author.setTypeface(font);
                        author.setText(item.author());
                    }
                    if (img != null && item.image() != null) {
                        img.setImageDrawable(new BitmapDrawable(BitmapFactory.decodeByteArray(item.image(), 0, item.image().length)));
                    }
                }
            }
        }
        return view;
    }
}




Java Source Code List

com.Litterfeldt.AStory.adapters.LibraryAdapter.java
com.Litterfeldt.AStory.customClasses.CoreApplication.java
com.Litterfeldt.AStory.customClasses.CustomMediaPlayer.java
com.Litterfeldt.AStory.dbConnector.dbBook.java
com.Litterfeldt.AStory.dbConnector.dbConnector.java
com.Litterfeldt.AStory.dbConnector.dbSave.java
com.Litterfeldt.AStory.fragments.LibraryFragment.java
com.Litterfeldt.AStory.fragments.PlayerFragment.java
com.Litterfeldt.AStory.models.Book.java
com.Litterfeldt.AStory.models.Chapter.java
com.Litterfeldt.AStory.models.FileSystem.java
com.Litterfeldt.AStory.models.SaveState.java
com.Litterfeldt.AStory.services.AudioplayerService.java
com.Litterfeldt.AStory.pagerView.java
com.handmark.pulltorefresh.library.ILoadingLayout.java
com.handmark.pulltorefresh.library.IPullToRefresh.java
com.handmark.pulltorefresh.library.LoadingLayoutProxy.java
com.handmark.pulltorefresh.library.OverscrollHelper.java
com.handmark.pulltorefresh.library.PullToRefreshAdapterViewBase.java
com.handmark.pulltorefresh.library.PullToRefreshBase.java
com.handmark.pulltorefresh.library.PullToRefreshExpandableListView.java
com.handmark.pulltorefresh.library.PullToRefreshGridView.java
com.handmark.pulltorefresh.library.PullToRefreshHorizontalScrollView.java
com.handmark.pulltorefresh.library.PullToRefreshListView.java
com.handmark.pulltorefresh.library.PullToRefreshScrollView.java
com.handmark.pulltorefresh.library.PullToRefreshWebView.java
com.handmark.pulltorefresh.library.extras.PullToRefreshWebView2.java
com.handmark.pulltorefresh.library.extras.SoundPullEventListener.java
com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor.java
com.handmark.pulltorefresh.library.internal.FlipLoadingLayout.java
com.handmark.pulltorefresh.library.internal.IndicatorLayout.java
com.handmark.pulltorefresh.library.internal.LoadingLayout.java
com.handmark.pulltorefresh.library.internal.RotateLoadingLayout.java
com.handmark.pulltorefresh.library.internal.Utils.java
com.handmark.pulltorefresh.library.internal.ViewCompat.java