Skip to content

Instantly share code, notes, and snippets.

@wingjay
Last active July 11, 2017 01:47
Show Gist options
  • Save wingjay/9f214aabf5eda842db5158f34964e64a to your computer and use it in GitHub Desktop.
Save wingjay/9f214aabf5eda842db5158f34964e64a to your computer and use it in GitHub Desktop.
* 每行字符数限制遵守 Android Studio 默认
------------------------------------------------------------------------------
* 多余注释,不需要“翻译式”注释
// 立即finish自身
finish();
/**
* 获取容器Fragment
*
* @return fragment对象
*/
public Fragment getContainerFragment() {
return mFragmentHost;
}
/**
* 获取原Bundle
* @param dataTag
* @return
*/
public Bundle getBundle(String dataTag) {}
// 进程名
String processName = runningAppProcessInfo.processName;
// 进程ID号
int pid = runningAppProcessInfo.pid;
// 用户ID
int uid = runningAppProcessInfo.uid;
// Title区
buildAreaTitle(choiceDialog, areaTitle);
// Button区
buildAreaButton(choiceDialog, areaButton, annourceId, annourceType);
// Message区
buildAreaMessage(choiceDialog, areaMessage);
------------------------------------------------------------------------------
* 无效注释
/**
* mv 数据埋点
* @param playLength
* @param totalLength
* @param songId
* @param songName
* @return
*/
public static void trackMVPlayEvent(long playLength, long totalLength, String songId, String songName) {}
/**
* Created by xxx on 16/12/2.
*/
// beginIndex
int begin = content.indexOf(':');
// endIndex
int end = content.indexOf('k');
------------------------------------------------------------------------------
* if () {} 格式
if (null == bundle)
throw new BundleException("the bundle pass to CustomBundle must not be null!");
***
建议
if (null == bundle) {
throw new BundleException("the bundle pass to CustomBundle must not be null!");
}
***
------------------------------------------------------------------------------
* 尽可能删除失效代码/无用逻辑/无用变量
mExecutor.execute(getRoamingSongsRespObservable, getRoamingSongsRespSubscriber);
/*XiaMiAPIRequest req = new XiaMiAPIRequest();
req.addParam("song_id", mId);
req.addParam("method", PlayerApi.API_ROAMING);
req.setApiName(PlayerApi.API_ROAMING);
XiaMiRemoteBusiness business = new XiaMiRemoteBusiness(req);
mApiProxy.request(business, new NormalAPIParser(new TypeReference<SongListModel>() {
}.getType()));*/
Animator[] animators = getAnimators(parent, view);
// Animator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);
// allAnimators[allAnimators.length - 1] = alphaAnimator;
return allAnimators;
public static long mLastADTime = 0;
// private static final String PUSH_TAG_LOGIN = "login";
// private static final String PUSH_TAG_UNLOGIN = "unlogin";
private static String sBuildtime; // 未使用
if (pathSegments.size() > 0) {
// mUrlOrder = pathSegments.get(0);
// mUrlTag = uri.getQueryParameter(PARAM_TAG);
// return;
}
------------------------------------------------------------------------------
* 变量名
private String mDeviceId = "";
public void setmDeviceId(String mDeviceId) {
this.mDeviceId = mDeviceId;
}
private List<?> mDatas;
***
建议
private String deviceId = "";
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
private List<?> mDataList;
***
------------------------------------------------------------------------------
* 不合适的缩写
boolean hasCurId = false;
***
建议
boolean hasCurrentId = false;
***
------------------------------------------------------------------------------
* Annotation 格式各异
private
@State
int mState = STATE_NORMAL;
public static
@Nullable
String getPathId(NavParamParser navParamParser) {}
***
建议
@State
private int mState = STATE_NORMAL;
@Nullable
public static String getPathId(NavParamParser navParamParser) {}
***
------------------------------------------------------------------------------
* 单词拼写错误
@Override
public void setArround(boolean[] arroundInfo) {}
------------------------------------------------------------------------------
* 驼峰命名
private void GetuiClickTrack(String title, String schemeUrl, String track, String msgID) {}
***
建议
private void getUiClickTrack(...) {}
***
------------------------------------------------------------------------------
* 删除个人debug log
AppLog.d(TAG,"data:"+message);
------------------------------------------------------------------------------
* 空格规范
if(e instanceof FileNotFoundException || e instanceof InvaildDirectoryException){
code = 50002;
}else if(eMsg.indexOf("enospc")>=0){
code = 50008;
}else if(eMsg.indexOf("ebusy")>=0){
code = 50007;
}else if(eMsg.indexOf("read-only")>=0){
code = 50003;
}
AppLog.d(TAG,"data:"+message);
***
建议
if(e instanceof FileNotFoundException || e instanceof InvaildDirectoryException){
code = 50002;
} else if (eMsg.indexOf("enospc")>=0){
code = 50008;
} else if (eMsg.indexOf("ebusy")>=0){
code = 50007;
} else if (eMsg.indexOf("read-only")>=0){
code = 50003;
}
AppLog.d(TAG, "data:" + message);
***
------------------------------------------------------------------------------
* 其他
android studio的所有lint warning,包括单词拼写错误,@supresslint
参考 View.java,空行,每行字符数,空格;函数内部如非必要,不用注释,而是取准确的函数名
@wingjay
Copy link
Author

wingjay commented Jul 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment