Created
November 24, 2022 08:39
-
-
Save ibrahim-mrq/dbcb1d7ee42dcdce68b2d72a09f6f208 to your computer and use it in GitHub Desktop.
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
| #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | |
| import android.content.Context; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import androidx.annotation.NonNull; | |
| import androidx.recyclerview.widget.RecyclerView; | |
| import java.util.ArrayList; | |
| public class ${NAME}Adapter extends RecyclerView.Adapter<${NAME}Adapter.${NAME}ViewHolder> { | |
| Context mContext; | |
| ArrayList<${Model_Name}> list; | |
| public ${NAME}Adapter(Context mContext) { | |
| this.mContext = mContext; | |
| } | |
| public ArrayList<${Model_Name}> getList() { | |
| return list; | |
| } | |
| public void setList(ArrayList<${Model_Name}> list) { | |
| this.list = list; | |
| notifyDataSetChanged(); | |
| } | |
| @NonNull | |
| @Override | |
| public ${NAME}ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |
| View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.${design_Name}, parent, false); | |
| return new ${NAME}ViewHolder(v); | |
| } | |
| @Override | |
| public void onBindViewHolder(@NonNull ${NAME}ViewHolder holder, int position) { | |
| ${Model_Name} model = list.get(position); | |
| holder.bind(model); | |
| } | |
| @Override | |
| public int getItemCount() { | |
| return (list != null ? list.size() : 0); | |
| } | |
| static class ${NAME}ViewHolder extends RecyclerView.ViewHolder { | |
| Custom${NAME}Binding binding; | |
| private ${NAME}ViewHolder(@NonNull View itemView) { | |
| super(itemView); | |
| binding = Custom${NAME}Binding.bind(itemView); | |
| } | |
| private void bind(${Model_Name} model) { | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment