Last active
August 29, 2015 14:02
-
-
Save IlyaEremin/f8f1503affecfdb07043 to your computer and use it in GitHub Desktop.
universalAdapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.sunsoft.freeme.adapters; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import org.jetbrains.annotations.NotNull; | |
import java.util.List; | |
import ru.sunsoft.freeme.interfaces.CanDraw; | |
/** | |
* Created by IlyaSun on 6/14/2014. | |
*/ | |
public class UniversalAdapter<T, S extends CanDraw<T>> extends ArrayAdapter<T> { | |
int resource; | |
LayoutInflater inflater; | |
public UniversalAdapter(Context context, int resource, List<T> objects) { | |
super(context, resource, objects); | |
this.resource = resource; | |
inflater = LayoutInflater.from(context); | |
} | |
@Override public View getView(int position, View view, ViewGroup parent) { | |
if (view == null) { | |
@NotNull View statusView = inflater.inflate(resource, parent, false); | |
view = statusView; | |
} | |
((S) view).drawMe(getItem(position)); | |
return view; | |
} | |
} |
Author
IlyaEremin
commented
Jul 31, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment