123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package com.epson.iprint.storage.gdrivev3;
- import android.content.Context;
- import android.support.annotation.NonNull;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.BaseAdapter;
- import android.widget.ImageView;
- import android.widget.TextView;
- import epson.print.R;
- import java.util.ArrayList;
- public class FileListAdapter extends BaseAdapter {
- private ArrayList<OnlineFile> mDriveFiles;
- private final LayoutInflater mLayoutInflater;
- public Object getItem(int i) {
- return null;
- }
- public long getItemId(int i) {
- return 0;
- }
- public FileListAdapter(@NonNull Context context) {
- this.mLayoutInflater = LayoutInflater.from(context);
- }
- @UiThread
- public void setDriveFile(ArrayList<OnlineFile> arrayList) {
- this.mDriveFiles = arrayList;
- notifyDataSetChanged();
- }
- public int getCount() {
- ArrayList<OnlineFile> arrayList = this.mDriveFiles;
- if (arrayList == null) {
- return 0;
- }
- return arrayList.size();
- }
- public OnlineFile getDriveItem(int i) {
- return this.mDriveFiles.get(i);
- }
- public View getView(int i, View view, ViewGroup viewGroup) {
- int i2;
- if (view == null) {
- view = this.mLayoutInflater.inflate(R.layout.file_list_item, viewGroup, false);
- }
- OnlineFile onlineFile = this.mDriveFiles.get(i);
- String name = onlineFile.getName();
- int i3 = R.C2136drawable.file;
- if (onlineFile.isFolder()) {
- i3 = onlineFile instanceof ParentFolder ? R.C2136drawable.parent_folder : R.C2136drawable.folder;
- i2 = R.C2136drawable.more;
- } else {
- i2 = 0;
- }
- ((TextView) view.findViewById(R.id.file_folder_name)).setText(name);
- ImageView imageView = (ImageView) view.findViewById(R.id.file_folder_icon);
- imageView.setImageResource(i3);
- imageView.setVisibility(0);
- ImageView imageView2 = (ImageView) view.findViewById(R.id.browse_folder);
- if (i2 != 0) {
- imageView2.setVisibility(0);
- imageView2.setImageResource(i2);
- } else {
- imageView2.setVisibility(8);
- }
- return view;
- }
- public void clearItems() {
- ArrayList<OnlineFile> arrayList = this.mDriveFiles;
- if (arrayList != null) {
- arrayList.clear();
- }
- notifyDataSetChanged();
- }
- }
|