Skip to content

Instantly share code, notes, and snippets.

@yesidlazaro
Created November 29, 2017 20:31
Show Gist options
  • Save yesidlazaro/4234edd9dda53cad76f0d5bfcd2911ba to your computer and use it in GitHub Desktop.
Save yesidlazaro/4234edd9dda53cad76f0d5bfcd2911ba to your computer and use it in GitHub Desktop.
---CONTRACT---
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public interface ${NAME}{
interface View extends BaseView {
}
interface Presenter extends BasePresenter<View> {
}
}
----PRESENTER IMPL------
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} implements ${CONTRACT_NAME}.Presenter{
private ${CONTRACT_NAME}.View view;
public ${NAME}() {
}
@Override
public void attachView(${CONTRACT_NAME}.View view) {
this.view = view;
}
@Override
public void detachView() {
this.view = null;
}
}
----adapter----------
package ${PACKAGE_NAME};
#parse("File Header.java")
public class ${NAME} extends RecyclerView.Adapter<${ViewHolder}> {
private List<${LIST_MODEL}> ${LIST_MODEL}sList;
public ${NAME}(List<${LIST_MODEL}> list) {
this.${LIST_MODEL}sList = list;
}
@Override
public ${ViewHolder} onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.${item_layout}, parent, false);
return new ${ViewHolder}(view);
}
@Override
public void onBindViewHolder(${ViewHolder} holder, int position) {
holder.bind(${LIST_MODEL}sList.get(position))
}
@Override
public int getItemCount() {
return ${LIST_MODEL}sList!=null?${LIST_MODEL}sList.size():0;
}
}
--------VIEW HOLDER-------
package ${PACKAGE_NAME};
#parse("File Header.java")
public class ${NAME} extends RecyclerView.ViewHolder {
//TODO Bind views
public ${NAME}(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
public void bind(${LIST_MODEL} item){
}
}
----SINGLETON-----
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#if (${IMPORT_BLOCK} != "")${IMPORT_BLOCK}
#end
#parse("File Header.java")
#if (${VISIBILITY} == "PUBLIC")public #end class ${NAME} #if (${SUPERCLASS} != "")extends ${SUPERCLASS} #end #if (${INTERFACES} != "")implements ${INTERFACES} #end {
private static final ${NAME} ourInstance = new ${NAME}();
#if (${VISIBILITY} == "PUBLIC")public #end static ${NAME} getInstance() {
return ourInstance;
}
private ${NAME}() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment