2 * Copyright (C) 2016 Pedro Paulo de Amorim
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.folioreader.ui.folio.adapter;
18 import com.folioreader.Font;
19 import com.folioreader.R;
21 import android.support.v7.widget.RecyclerView;
22 import android.view.LayoutInflater;
23 import android.view.View;
24 import android.view.ViewGroup;
25 import android.widget.TextView;
27 import java.util.ArrayList;
29 public class FontAdapter extends RecyclerView.Adapter<FontAdapter.ViewHolder> {
31 private ArrayList<Font> mFonts = null;
34 public FontAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int i) {
35 return new ViewHolder(LayoutInflater.from(parent.getContext())
36 .inflate(R.layout.row_font, parent, false));
40 public void onBindViewHolder(ViewHolder viewHolder, int i) {
41 viewHolder.mName.setText(mFonts.get(i).getName());
45 public int getItemCount() {
46 return mFonts != null ? mFonts.size() : 0;
49 public void setFonts(ArrayList<Font> mFonts) {
53 public static class ViewHolder extends RecyclerView.ViewHolder {
55 private TextView mName;
57 public ViewHolder(View v) {
59 mName = (TextView) v.findViewById(R.id.name);