import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
#parse("File Header.java") | |
public class ${NAME} extends AppCompatActivity { | |
private static final String TAG = ${NAME}.class.getSimpleName(); | |
/** | |
* Change the null parameter in {@code setContentView()} | |
* to a layout resource {@code R.layout.example} | |
*/ | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
Log.d(TAG, "onCreate: hit"); | |
super.onCreate(savedInstanceState); | |
setContentView(null); | |
} | |
@Override | |
protected void onResume() { | |
Log.d(TAG, "onResume: hit"); | |
super.onResume(); | |
} | |
@Override | |
protected void onPause() { | |
Log.d(TAG, "onPause: hit"); | |
super.onPause(); | |
} | |
@Override | |
protected void onDestroy() { | |
Log.d(TAG, "onDestroy: hit"); | |
super.onDestroy(); | |
} | |
} |
import android.os.Bundle; | |
import android.support.v4.app.Fragment; | |
import android.util.Log; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
#parse("File Header.java") | |
public class ${NAME} extends Fragment { | |
private static final String TAG = ${NAME}.class.getSimpleName(); | |
public ${NAME}() { | |
} | |
public static ${NAME} newInstance() { | |
${NAME} fragment = new ${NAME}(); | |
return fragment; | |
} | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
Log.d(TAG, "onCreate: hit"); | |
super.onCreate(savedInstanceState); | |
} | |
/** | |
* Change the null parameter in {@code inflater.inflate()} | |
* to a layout resource {@code R.layout.example} | |
*/ | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
Log.d(TAG, "onCreateView: hit"); | |
View rootView = inflater.inflate(null, container, false); | |
return rootView; | |
} | |
@Override | |
public void onActivityCreated(Bundle savedInstanceState) { | |
Log.d(TAG, "onActivityCreated: hit"); | |
super.onActivityCreated(savedInstanceState); | |
} | |
@Override | |
public void onResume() { | |
Log.d(TAG, "onResume: hit"); | |
super.onResume(); | |
} | |
@Override | |
public void onPause() { | |
Log.d(TAG, "onPause: hit"); | |
super.onPause(); | |
} | |
@Override | |
public void onDestroyView() { | |
Log.d(TAG, "onDestroyView: hit"); | |
super.onDestroyView(); | |
} | |
@Override | |
public void onDestroy() { | |
Log.d(TAG, "onDestroy: hit"); | |
super.onDestroy(); | |
} | |
} |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import java.util.List; | |
#parse("File Header.java") | |
public class ${NAME} extends ArrayAdapter<Object> { | |
private static final String TAG = ${NAME}.class.getSimpleName(); | |
public ${NAME} (Context context, int resourceId) { | |
super(context, resourceId); | |
} | |
public ${NAME} (Context context, int resourceId, List<Object> items) { | |
super(context, resourceId, items); | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
View view = convertView; | |
if(view == null) { | |
LayoutInflater layoutInflater = LayoutInflater.from(getContext()); | |
view = layoutInflater.inflate(null, null); | |
} | |
Object object = getItem(position); | |
if(object != null) { | |
// edit view's components here | |
} | |
return view; | |
} | |
} |
import android.content.Context; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import java.util.List; | |
#parse("File Header.java") | |
public class ${NAME} extends RecyclerView.Adapter<${NAME}.ViewHolder> { | |
private static final String TAG = ${NAME}.class.getSimpleName(); | |
private Context mContext; | |
private List<Object> mData; | |
/** | |
* Change {@link List} type according to your needs | |
*/ | |
public ${NAME}(Context context, List<Object> data) { | |
if(context == null) { | |
throw new NullPointerException("context can not be NULL"); | |
} | |
if(data == null) { | |
throw new NullPointerException("data list can not be NULL"); | |
} | |
this.mContext = context; | |
this.mData = data; | |
} | |
/** | |
* Change the null parameter to a layout resource {@code R.layout.example} | |
*/ | |
@Override | |
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
View view = LayoutInflater.from(parent.getContext()) | |
.inflate(null, parent, false); | |
return new ViewHolder(view); | |
} | |
@Override | |
public void onBindViewHolder(ViewHolder holder, int position) { | |
// include binding logic here | |
} | |
@Override | |
public int getItemCount() { | |
return mData.size(); | |
} | |
public static class ViewHolder extends RecyclerView.ViewHolder { | |
// include {@link View} components here | |
public ViewHolder(View itemView) { | |
super(itemView); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment