add readme sample

This commit is contained in:
CsHeng
2017-09-21 12:12:45 +08:00
parent d6d49ac7ad
commit 10480a533c
18 changed files with 115 additions and 65 deletions

View File

@ -26,4 +26,17 @@
2. 初始化公用类库: `bash ./scripts/init_submodules.sh`
### submodule管理方式(只拉取master)
* 提交代码需要cd到submodule文件夹去做修改
* 提交代码需要cd到submodule文件夹去做修改
### TODO
* GSON 序列化用统一的一个, GsonUtil fromJson
* AreaAdapter这里的区域分层Fragment setTargetFragment onActivityResult
* CleanApkAdapter 转化字符串size工具函数 比如SpeedUtils
* getString 解决 字符串hardcode问题
* equals 写法,常量.equals(xxx val)
* Adapter 里面clicklistener 用接口传参将点击操作委托给controller
* Adapter ViewHolder的功能部分重写到ViewHolder类本身
* actionbar margin padding

View File

@ -37,6 +37,8 @@ public class Config {
public static final String USERSEA_APP_ID = BuildConfig.USERSEA_APP_ID; // 登录验证
public static final String USERSEA_APP_SECRET = BuildConfig.USERSEA_APP_SECRET; // 登录验证
public static final String BUGLY_APPID = BuildConfig.BUGLY_APPID;
// http://www.ghzs666.com/article/${articleId}.html
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/";
public static boolean isShow(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);

View File

@ -25,7 +25,7 @@ import butterknife.BindView;
* Created by khy on 23/06/17.
*/
public class UserAreaActivity extends BaseActivity implements AreaAdapter.OnAreaCallBackLintener,
public class UserAreaActivity extends BaseActivity implements AreaAdapter.OnAreaCallBackListener,
LoginUtils.onChangeUserInfoListener {
@BindView(R.id.area_rv_title)

View File

@ -4,11 +4,10 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
@ -77,20 +76,13 @@ public class UserInfoEditActivity extends BaseActivity implements LoginUtils.onC
mUserInfoEntity = LoginUtils.getUserInfo(this);
// 添加分享图标
mSaveTv = new TextView(this);
mSaveTv.setBackgroundResource(R.drawable.border_black_bg);
mSaveTv.setVisibility(View.GONE);
mSaveTv.setText("保存");
mSaveTv.setTextSize(13);
mSaveTv.setGravity(Gravity.CENTER);
mSaveTv.setTextColor(ContextCompat.getColor(this, R.color.title));
mSaveTv = (TextView) LayoutInflater.from(this).inflate(R.layout.menu_action_save, null);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
DisplayUtils.dip2px(this, 48), DisplayUtils.dip2px(this, 24));
params.addRule(RelativeLayout.CENTER_VERTICAL);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.setMargins(0, 0, DisplayUtils.dip2px(this, 18), 0);
RelativeLayout reuse_actionbar = (RelativeLayout) mContentView.findViewById(
R.id.reuse_actionbar);
RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar);
reuse_actionbar.addView(mSaveTv, params);
if (mUserInfoEntity != null) {

View File

@ -30,13 +30,13 @@ import java.util.List;
public class AreaAdapter extends BaseRecyclerAdapter {
private OnAreaCallBackLintener mCallBackLintener;
private OnAreaCallBackListener mCallBackLintener;
private List<LocalEntity> mLocalList;
private ArrayList<String> mProList;
private List<String> mProList;
private String mCurArea;
public AreaAdapter(Context context, ArrayList<String> proList, OnAreaCallBackLintener callBackLintener) {
public AreaAdapter(Context context, List<String> proList, OnAreaCallBackListener callBackLintener) {
super(context);
mCallBackLintener = callBackLintener;
mLocalList = new ArrayList<>();
@ -86,8 +86,7 @@ public class AreaAdapter extends BaseRecyclerAdapter {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
View view = LayoutInflater.from(mContext).inflate(R.layout.area_item, parent, false);
return new AreaViewHolder(view);
return new AreaViewHolder(mLayoutInflater.inflate(R.layout.area_item, parent, false));
} else {
View view = LayoutInflater.from(mContext).inflate(R.layout.area_title_item, parent, false);
return new AreaTitleViewHolder(view);
@ -169,7 +168,7 @@ public class AreaAdapter extends BaseRecyclerAdapter {
}
}
public interface OnAreaCallBackLintener {
public interface OnAreaCallBackListener {
void onAreaResult(String area, List<String> cityList);
}
}

View File

@ -14,15 +14,14 @@ import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.PackageUtils;
import com.lightgame.utils.RuntimeUtils;
import com.gh.common.util.StringUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.retrofit.Response;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.utils.RuntimeUtils;
import java.io.File;
import java.text.DecimalFormat;
@ -298,7 +297,8 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
double size = (((float) gameSize / 1024) / 1024);
DecimalFormat df = new DecimalFormat("0.00");
String sizeName = df.format(size) + "MB";
mApkDeleteBtn.setText(StringUtils.buildString("一键删除(", String.valueOf(i), "个,释放" + sizeName, ""));
mApkDeleteBtn.setText(mContext.getString(R.string.clean_apk_deleteall, i, sizeName));
// mApkDeleteBtn.setText(StringUtils.buildString("一键删除(", String.valueOf(i), "个,释放" + sizeName, ""));
}
}

View File

@ -117,6 +117,9 @@ public class FileReceiverAdapter extends BaseRecyclerAdapter<KcSelectGameViewHol
holder.downloadSpeed.setText(curSizeName + "/" + sizeName);
holder.downloadStatus.setTextColor(ContextCompat.getColor(mContext, R.color.type_huodong));
holder.downloadStatus.setBackgroundDrawable(new ColorDrawable(0));
// holder.downloadStatus.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.transparent));
holder.gameProgressbar.setProgress(percent);
// viewHolder.downloadPercentage.setText(percent + "%");
if (fileInfo.getResult() == FileInfo.FLAG_FAILURE) {

View File

@ -18,13 +18,10 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.halo.assistant.HaloApp;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.ItemViewType;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.StringUtils;
import com.lightgame.utils.Utils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
@ -34,6 +31,9 @@ import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.kuaichuan.FileInfo;
import com.gh.gamecenter.manager.ConcernManager;
import com.gh.gamecenter.retrofit.Response;
import com.halo.assistant.HaloApp;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.utils.Utils;
import java.io.File;
import java.text.DecimalFormat;
@ -153,7 +153,7 @@ public class KcSelectGameAdapter extends BaseRecyclerAdapter<ViewHolder> {
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<Object>(){
.subscribe(new Response<Object>() {
@Override
public void onCompleted() {
super.onCompleted();
@ -330,19 +330,28 @@ public class KcSelectGameAdapter extends BaseRecyclerAdapter<ViewHolder> {
holder.checkBoxRl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mSelectPosition.get(i)) {
checkBoxControl(false, i);
holder.selectCB.setChecked(false);
} else {
checkBoxControl(true, i);
holder.selectCB.setChecked(true);
}
toggleChecked(i, holder);
// if (mSelectPosition.get(i)) {
// checkBoxControl(false, i);
// holder.selectCB.setChecked(false);
// } else {
// checkBoxControl(true, i);
// holder.selectCB.setChecked(true);
// }
}
});
}
private void toggleChecked(int i, KcSelectGameViewHolder holder) {
boolean checked = mSelectPosition.get(i);
checkBoxControl(!checked, i);
holder.selectCB.setChecked(!checked);
}
private void checkBoxControl(boolean isChecked, int i) {
if (isChecked) {
mSelectPosition.put(i, true);

View File

@ -49,6 +49,7 @@ import rx.schedulers.Schedulers;
*/
public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
public static final int LIBAO_MAX_LINES = 3;
private OnRequestCallBackListener mOnRequestCallBackListener;
private OnCodeScrollListener mOnCodeScrollListener;
@ -58,6 +59,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
private LibaoDetailEntity mLibaoDetailEntity;
private String mEntrance;
private final int TYPE_FOOTER = 100;
public LibaoDetailAdapter(Context context, OnRequestCallBackListener onRequestCallBackListener,
OnCodeScrollListener onCodeScrollListener, LibaoEntity libaoEntity,
@ -94,7 +96,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
if (viewType == 0) {
View view = LayoutInflater.from(mContext).inflate(R.layout.libaodetail_item_top, parent, false);
return new LibaoDetailTopViewHolder(view);
} else if (viewType == 100) {
} else if (viewType == TYPE_FOOTER) {
View view = LayoutInflater.from(mContext).inflate(R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
} else {
@ -128,7 +130,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
@Override
public int getItemViewType(int position) {
if (position == getItemCount() - 1) {
return 100;
return TYPE_FOOTER;
}
return position;
}
@ -193,10 +195,10 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
holder.libaoCodeRv.setVisibility(View.VISIBLE);
holder.libaoCodeRv.setAdapter(new LiBaoCodeAdapter(mContext, userDataLibaoList));
ViewGroup.LayoutParams params = holder.libaoCodeRv.getLayoutParams();
if (userDataLibaoList.size() <= 3) {
if (userDataLibaoList.size() <= LIBAO_MAX_LINES) {
params.height = userDataLibaoList.size() * DisplayUtils.dip2px(mContext, 40);
} else {
params.height = 3 * DisplayUtils.dip2px(mContext, 40);
params.height = LIBAO_MAX_LINES * DisplayUtils.dip2px(mContext, 40);
}
holder.libaoCodeRv.setLayoutParams(params);

View File

@ -108,8 +108,9 @@ public class PluginAdapter extends BaseRecyclerAdapter<GameNormalViewHolder> {
GameEntity gameEntity;
for (int i = 0; i < mPluginList.size(); i++) {
gameEntity = mPluginList.get(i);
if (gameEntity.getApk() != null && gameEntity.getApk().size() != 0) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
List<ApkEntity> entityList = gameEntity.getApk();
if (!entityList.isEmpty()) {
for (ApkEntity apkEntity : entityList) {
list = mLocationMap.get(apkEntity.getPackageName());
if (list == null) {
list = new ArrayList<>();

View File

@ -48,14 +48,14 @@ import rx.schedulers.Schedulers;
*/
public class GameDetailKaiFuAdapter extends BaseRecyclerAdapter<ViewHolder> {
private String[] week = {"", "", "", "", "", "", ""};
private final String[] week;
private int monthCount;
private int curWeek;
private int curDay;
private boolean isNextMonth;
private boolean isExistCurServer; // 当月是否存在开服
private boolean isExistCurServer; //s 当月是否存在开服
private String suggestTime;
private String gameName;
@ -70,6 +70,9 @@ public class GameDetailKaiFuAdapter extends BaseRecyclerAdapter<ViewHolder> {
GameDetailKaiFuAdapter(Context context, List<KaiFuServerEntity> serverInfo,
GameDetailKaiFuViewHolder viewHolder, String gameName) {
super(context);
week = context.getResources().getStringArray(R.array.weekdays);
this.mServerList = serverInfo;
this.viewHolder = viewHolder;
this.gameName = gameName;

View File

@ -23,6 +23,10 @@ import java.util.ArrayList;
*/
public class GameDetailPluginAdapter extends BaseRecyclerAdapter<RecyclerView.ViewHolder> {
public static final int POSITION_LEFT = 0;
public static final int POSITION_MIDDLE = 1;
public static final int POSITION_RIGHT = 2;
public static final int LABEL_COLUMN_LIMIT = 3;
private ArrayList<TagEntity> tags;
private TipsEntity tips;
private boolean isOpen;
@ -42,14 +46,14 @@ public class GameDetailPluginAdapter extends BaseRecyclerAdapter<RecyclerView.Vi
viewType--;
}
if (!isOpen) {
switch (viewType % 3) {
case 0:
switch (viewType % LABEL_COLUMN_LIMIT) {
case POSITION_LEFT:
hintLl.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
break;
case 1:
case POSITION_MIDDLE:
hintLl.setGravity(Gravity.CENTER);
break;
case 2:
case POSITION_RIGHT:
hintLl.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
}
}

View File

@ -7,7 +7,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.Config;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
@ -16,6 +16,7 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.adapter.viewholder.ToolBoxViewHolder;
import com.gh.gamecenter.entity.ToolBoxEntity;
import com.lightgame.adapter.BaseRecyclerAdapter;
import java.util.List;
@ -76,8 +77,9 @@ public class GameDetailToolsAdapter extends BaseRecyclerAdapter {
@Override
public void onClick(View v) {
String url = toolBoxEntity.getUrl();
if (url.contains("http://www.ghzs666.com/article/")) {
String newsId = url.substring(url.lastIndexOf("/") + 1, url.length() - 5);
if (url.contains(Config.URL_ARTICLE)) {
// 写个注释例子, http://www.ghzs666.com/article/${articleId}.html
String newsId = url.substring(url.lastIndexOf("/") + 1, url.length() - ".html".length());
Intent intent = new Intent(mContext, NewsDetailActivity.class);
intent.putExtra("newsId", newsId);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, "工具箱列表");

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:fresco = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "wrap_content" >
@ -30,7 +29,7 @@
android:id = "@+id/gamedetail_tv_content"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_below = "@+id/gamedetail_ll_hint"
android:layout_below = "@id/gamedetail_ll_hint"
android:layout_marginTop = "8dp"
android:textColor = "#717171"
android:textSize = "13sp" />

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:background = "@drawable/border_black_bg"
android:gravity = "center"
android:orientation = "vertical"
android:text = "@string/text_save"
android:textColor = "@color/title"
android:textSize = "13sp" >
</TextView >

View File

@ -2,27 +2,25 @@
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:id = "@+id/reuse_actionbar"
android:layout_width = "match_parent"
android:layout_height = "48dp"
android:background = "@android:color/white" >
android:layout_height = "?attr/actionBarSize"
android:background = "@android:color/white"
android:gravity = "center_vertical" >
<TextView
android:id = "@+id/actionbar_tv_title"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_alignParentLeft = "true"
android:layout_alignParentStart = "true"
android:layout_centerVertical = "true"
android:gravity = "center"
android:singleLine = "true"
android:textColor = "@color/title"
android:textSize = "16sp"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
android:textStyle="bold"
android:singleLine="true"/>
android:textStyle = "bold"
android:layout_centerVertical = "true"
android:layout_centerHorizontal = "true" />
<RelativeLayout
android:id = "@+id/actionbar_rl_back"
android:layout_width = "48dp"
android:layout_width = "?attr/actionBarSize"
android:layout_height = "match_parent" >
<ImageView

View File

@ -36,7 +36,7 @@
<string name = "personale_settings" >设置</string >
<string name = "personale_mygame" >我的游戏</string >
<string name = "personale_default_username" >光环用户</string >
<string name = "personal_update_hint">新版本</string>
<string name = "personal_update_hint" >新版本</string >
<string name = "news_search_input" >请输入搜索关键字</string >
<string name = "news_search" >搜索</string >
<string name = "game_percentage" >44.5%</string >
@ -110,7 +110,7 @@
<string name = "libao_history" >历史礼包</string >
<string name = "libao_newest" >最新</string >
<string name = "libao_concern" >关注</string >
<string name = "libao_chunhaoxiang">存号箱</string>
<string name = "libao_chunhaoxiang" >存号箱</string >
<string name = "main_game" >游戏</string >
<string name = "main_info" >资讯</string >
<string name = "main_personal" >我的光环</string >
@ -252,6 +252,17 @@
<string name = "other_login_hint" >还可以选择以下方式登录</string >
<string name = "about_version_update" >版本更新</string >
<string name = "personal_userinfo" >个人中心</string >
<string name = "nickname_hint">起一个难忘的名字吧</string>
<string name = "nickname_hint" >起一个难忘的名字吧</string >
<string name = "clean_apk_deleteall" formatted = "false" >一键删除("$1%d"个,释放"$2%s"</string >
<string name = "text_save" >保存</string >
<string-array name = "weekdays" >
<item ></item >
<item ></item >
<item ></item >
<item ></item >
<item ></item >
<item ></item >
<item ></item >
</string-array >
</resources >

View File

@ -16,6 +16,6 @@ source ${CWD}/tinker_env.sh
# sample .rsyncenv file content: REMOTE_DIR=chenshuoheng@192.168.2.100:/app/halo/
REMOTE_DIR=`grep -r REMOTE_DIR ${CWD}/.rsyncenv | awk -F '=' '{print $2}'`
echo "syning ${APP_RELEASE_ALL} to ${REMOTE_DIR}"
echo "syncing ${APP_RELEASE_ALL} to ${REMOTE_DIR}"
# 根目录是脚本文件所在的上一级
rsync --exclude-from=${CWD}/.rsyncignore -e 'ssh -p 32200' -rctvO ${APP_RELEASE_ALL} ${REMOTE_DIR}