Last active
April 3, 2017 22:11
-
-
Save KChernenko/55db0316f9c991ff7547ef6e2c7cfd04 to your computer and use it in GitHub Desktop.
This file contains 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
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import java.util.List; | |
import android.support.annotation.NonNull; | |
import java.util.ArrayList; | |
#parse("File Header.java") | |
class ${NAME} extends RecyclerView.Adapter<${NAME}.${VIEWHOLDER_CLASS}> { | |
private List<${ITEM_CLASS}> items; | |
public ${NAME}() { | |
this.items = new ArrayList<>(); | |
} | |
public void setItemsList(@NonNull List<${ITEM_CLASS}> items) { | |
this.items = items; | |
this.notifyDataSetChanged(); | |
} | |
@Override | |
public ${VIEWHOLDER_CLASS} onCreateViewHolder(ViewGroup parent, | |
int viewType) { | |
View v = LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.${LAYOUT_RES_ID}, parent, false); | |
return new ${VIEWHOLDER_CLASS}(v); | |
} | |
@Override | |
public void onBindViewHolder(${VIEWHOLDER_CLASS} holder, int position) { | |
${ITEM_CLASS} item = items.get(position); | |
//TODO Fill in your logic for binding the view. | |
} | |
@Override | |
public int getItemCount() { | |
if (items == null){ | |
return 0; | |
} | |
return items.size(); | |
} | |
static class ${VIEWHOLDER_CLASS} extends RecyclerView.ViewHolder { | |
${VIEWHOLDER_CLASS}(View itemView) { | |
super(itemView); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment