You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
etesync-android/app/src/main/java/at/bitfire/davdroid/syncadapter/WebDavResourceAdapter.java

64 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* Copyright (c) 2013 2015 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid.syncadapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
import at.bitfire.davdroid.webdav.WebDavResource;
public class WebDavResourceAdapter extends BaseAdapter {
protected int viewId;
protected LayoutInflater inflater;
WebDavResource[] items;
public WebDavResourceAdapter(Context context, int textViewResourceId, List<WebDavResource> objects) {
viewId = textViewResourceId;
inflater = LayoutInflater.from(context);
items = objects.toArray(new WebDavResource[0]);
}
@Override
public View getView(int position, View view, ViewGroup parent) {
WebDavResource item = items[position];
View itemView = (View)inflater.inflate(viewId, null);
TextView textName = (TextView) itemView.findViewById(android.R.id.text1);
textName.setText(item.getDisplayName());
TextView textDescription = (TextView) itemView.findViewById(android.R.id.text2);
String description = item.getDescription();
if (description == null)
description = item.getLocation().getPath();
textDescription.setText(description);
return itemView;
}
@Override
public int getCount() {
return items.length;
}
@Override
public Object getItem(int position) {
return items[position];
}
@Override
public long getItemId(int position) {
return position;
}
}