Last active
August 29, 2015 14:00
-
-
Save izumin5210/11226418 to your computer and use it in GitHub Desktop.
Code templates for Android Studio
ref: http://qiita.com/KeithYokoma/items/c046dcb54607262c041a
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
package ${PACKAGE_NAME}; | |
import android.app.Activity; | |
import android.os.Bundle; | |
#parse("File Header.java") | |
public class ${NAME} extends Activity { | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
} | |
} |
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 | |
#parse("File Header.java") | |
public class ${NAME} { | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
} |
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
package ${PACKAGE_NAME}; | |
import android.app.Fragment; | |
import android.os.Bundle; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
#parse("File Header.java") | |
public class ${NAME} extends Fragment { | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
// Note: only the system can call this constructor by reflection. | |
public ${NAME}() {} | |
public static ${NAME} getInstance() { | |
${NAME} fragment = new ${NAME}(); | |
Bundle args = new Bundle(); | |
fragment.setArguments(args); | |
return fragment; | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
return null; | |
} | |
} |
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.v4.content.AsyncTaskLoader; | |
#parse("File Header.java") | |
public class ${NAME} extends AsyncTaskLoader<${RESULT}> { | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
public ${NAME}(Context context) { | |
super(context); | |
} | |
@Override | |
public ${RESULT} loadInBackground() { | |
return null; | |
} | |
@Override | |
public void onStartLoading() { | |
super.onStartLoading(); | |
forceLoad(); | |
} | |
} |
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.v4.content.AsyncTaskLoader; | |
#parse("File Header.java") | |
public class ${NAME} extends AsyncTaskLoader<${RESULT}> { | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
private ${CACHE_TYPE} mCache; | |
public ${NAME}(Context context) { | |
super(context); | |
} | |
@Override | |
public ${RESULT} loadInBackground() { | |
return null; | |
} | |
@Override | |
public void deliverResult(${RESULT} data) { | |
if (isReset()) { | |
if (mCache != null) { | |
mCache = null; | |
} | |
return; | |
} | |
mCache = data; | |
if (isStarted()) { | |
super.deliverResult(data); | |
} | |
} | |
@Override | |
public void onStartLoading() { | |
if (this.result != null) { | |
deliverResult(mCache); | |
} | |
if (takeContentChanged() || mCache == null) { | |
forceLoad(); | |
} | |
} | |
@Override | |
protected void onStopLoading() { | |
super.onStopLoading(); | |
cancelLoad(); | |
} | |
@Override | |
protected void onReset() { | |
super.onReset(); | |
onStopLoading(); | |
} | |
} |
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.os.Parcel; | |
import android.os.Parcelable; | |
import android.os.Parcelable.Creator; | |
#parse("File Header.java") | |
public class ${NAME} implements Parcelable{ | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
public static final Creator<${NAME}> CREATOR = new Creator<${NAME}>() { | |
@Nullable | |
@Override | |
public ${NAME} createFromParcel(Parcel source) { | |
return new ${NAME}(source); | |
} | |
@Override | |
public ${NAME}[] newArray(int size) { | |
return new ${NAME}[size]; | |
} | |
} | |
public ${NAME}(Parcel source) { | |
} | |
@Override | |
public int describeContents() { | |
return 0; | |
} | |
@Override | |
public void writeToParcel(Parcel dest, int flags) { | |
} | |
} |
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.os.Parcel; | |
import android.os.Parcelable; | |
import android.os.Parcelable.Creator; | |
#parse("File Header.java") | |
public class ${NAME} implements Parcelable{ | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
public static final Creator<${NAME}> CREATOR = new Creator<${NAME}>() { | |
@Nullable | |
@Override | |
public ${NAME} createFromParcel(Parcel source) { | |
return new ${NAME}(source); | |
} | |
@Override | |
public ${NAME}[] newArray(int size) { | |
return new ${NAME}[size]; | |
} | |
} | |
// Note: only the builder of this type can call this constructor. | |
private ${NAME} () {} | |
public ${NAME}(Parcel source) { | |
} | |
@Override | |
public int describeContents() { | |
return 0; | |
} | |
@Override | |
public void writeToParcel(Parcel dest, int flags) { | |
} | |
public static class Builder { | |
private final ${NAME} mTarget; | |
public Builder() { | |
mTarget = new ${NAME}(); | |
} | |
public ${NAME} create() { | |
return mTarget; | |
} | |
} | |
} |
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 | |
#parse("File Header.java") | |
public class ${NAME}{ | |
public static final String TAG = ${NAME}.class.getSimpleName(); | |
private static ${NAME} ourInstance = new ${NAME}(); | |
public static ${NAME} getInstance() { | |
return ourInstance; | |
} | |
private ${NAME}() { | |
} | |
} |
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 | |
#parse("File Header.java") | |
public final class ${NAME} { | |
private ${NAME}() { | |
throw new AssertionError("constructor of the utility class should not be called"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment