From bf7b0b0a829d8d1003a42e6de44ee6ced4d0ec0e Mon Sep 17 00:00:00 2001 From: CsHeng Date: Thu, 14 Dec 2017 17:56:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=80=E9=83=A8=E5=88=86ac?= =?UTF-8?q?tivity=E7=9A=84toolbar=EF=BC=8C=E5=B7=B2=E7=BB=8F=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=AE=8C=E6=AF=95=E7=9A=84=E6=A0=87=E8=AE=B0=E4=B8=BA?= =?UTF-8?q?Deprecated=EF=BC=8C=E4=B8=BA=E4=BA=86=E4=BF=9D=E6=8C=81MTA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8A=E6=8A=A5=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E6=9A=82=E6=97=B6=E6=9C=AA=E5=88=A0=E9=99=A4=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84Activity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/gh/base/BaseActivity.java | 8 +- .../GHActivityLifecycleCallbacksImpl.java | 7 +- .../com/gh/base/fragment/BaseFragment.java | 27 +- .../base/fragment/BaseFragment_ViewPager.java | 2 +- .../java/com/gh/common/util/CommentUtils.java | 2 +- .../java/com/gh/gamecenter/AboutActivity.java | 107 +---- .../gh/gamecenter/ChooseReceiverActivity.java | 4 +- .../com/gh/gamecenter/CleanApkActivity.java | 233 +--------- .../com/gh/gamecenter/CollectionActivity.java | 34 +- .../gh/gamecenter/CommentDetailActivity.java | 236 +--------- .../com/gh/gamecenter/ConcernActivity.java | 206 +-------- .../com/gh/gamecenter/GameDetailActivity.java | 7 +- .../com/gh/gamecenter/GameNewsActivity.java | 219 +-------- .../com/gh/gamecenter/InstallActivity.java | 2 +- .../java/com/gh/gamecenter/KaiFuActivity.java | 97 +--- .../java/com/gh/gamecenter/LoginActivity.java | 2 +- .../com/gh/gamecenter/NewsDetailActivity.java | 2 +- .../com/gh/gamecenter/NewsSearchActivity.java | 312 +------------ .../gamecenter/ReceiverWaitingActivity.java | 2 +- .../com/gh/gamecenter/SettingActivity.java | 416 +----------------- .../gh/gamecenter/UserInfoEditActivity.java | 2 +- .../java/com/gh/gamecenter/WebActivity.java | 2 +- .../gh/gamecenter/adapter/ConcernAdapter.java | 6 +- .../viewholder/GameTestViewHolder.java | 2 +- ...nt.java => CollectionWrapperFragment.java} | 13 +- .../gh/gamecenter/fragment/GameFragment.java | 2 +- .../gh/gamecenter/kaifu/KaiFuFragment.java | 10 +- .../gh/gamecenter/kaifu/KaiFuVpAdapter.java | 7 +- .../kaifu/KaiFuWrapperFragment.java | 108 +++++ .../gh/gamecenter/login/LoginFragment.java | 2 +- .../login/LoginOldUserFragment.java | 2 +- .../com/gh/gamecenter/news/News3Fragment.java | 8 +- .../gh/gamecenter/normal/NormalFragment.java | 2 +- .../gamecenter/personal/PersonalFragment.java | 2 +- .../assistant/fragment/AboutFragment.java | 110 +++++ .../fragment/ApkCleanerFragment.java | 238 ++++++++++ .../assistant/fragment/ConcernFragment.java | 207 +++++++++ .../{ui => fragment}/SettingsFragment.java | 56 +-- .../comment/CommentDetailFragment.java | 230 ++++++++++ .../fragment}/game/GameFragmentAdapter.java | 2 +- .../fragment/game/GameNewsSearchFragment.java | 217 +++++++++ .../game/GameNewsSearchResultFragment.java | 309 +++++++++++++ .../fragment}/game/GamePluginAdapter.java | 2 +- .../fragment}/game/GamePluginViewHolder.java | 3 +- .../com/halo/assistant/ui/IntentFactory.java | 8 +- .../res/drawable-hdpi/ic_search_white.png | Bin 2766 -> 0 bytes .../res/drawable-xxhdpi/ic_search_white.png | Bin 0 -> 1395 bytes app/src/main/res/layout/activity_about.xml | 153 ------- .../main/res/layout/activity_clean_apk.xml | 102 ----- .../res/layout/activity_comment_detail.xml | 108 ----- .../main/res/layout/activity_game_news.xml | 33 -- app/src/main/res/layout/activity_kaifu.xml | 14 - app/src/main/res/layout/activity_setting.xml | 228 ---------- app/src/main/res/layout/fragment_about.xml | 144 ++++++ .../main/res/layout/fragment_apk_cleaner.xml | 92 ++++ .../res/layout/fragment_comment_detail.xml | 101 +++++ ...ivity_concern.xml => fragment_concern.xml} | 2 - .../res/layout/fragment_game_news_search.xml | 24 + ...l => fragment_game_news_search_result.xml} | 2 - .../res/layout/fragment_kaifu_wrapper.xml | 5 + app/src/main/res/layout/fragment_setting.xml | 220 +++++++++ .../main/res/layout/layout_menu_button.xml | 16 + app/src/main/res/layout/reuse_actionbar.xml | 1 + app/src/main/res/layout/reuse_none_data.xml | 1 + app/src/main/res/menu/menu_button.xml | 11 + app/src/main/res/menu/menu_search_white.xml | 11 + app/src/main/res/values/strings.xml | 3 + 67 files changed, 2251 insertions(+), 2495 deletions(-) rename app/src/main/java/com/gh/gamecenter/collection/{CollectionFragment.java => CollectionWrapperFragment.java} (84%) create mode 100644 app/src/main/java/com/gh/gamecenter/kaifu/KaiFuWrapperFragment.java create mode 100644 app/src/main/java/com/halo/assistant/fragment/AboutFragment.java create mode 100644 app/src/main/java/com/halo/assistant/fragment/ApkCleanerFragment.java create mode 100644 app/src/main/java/com/halo/assistant/fragment/ConcernFragment.java rename app/src/main/java/com/halo/assistant/{ui => fragment}/SettingsFragment.java (87%) create mode 100644 app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java rename app/src/main/java/com/{gh/gamecenter => halo/assistant/fragment}/game/GameFragmentAdapter.java (99%) create mode 100644 app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchFragment.java create mode 100644 app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchResultFragment.java rename app/src/main/java/com/{gh/gamecenter => halo/assistant/fragment}/game/GamePluginAdapter.java (99%) rename app/src/main/java/com/{gh/gamecenter => halo/assistant/fragment}/game/GamePluginViewHolder.java (94%) delete mode 100644 app/src/main/res/drawable-hdpi/ic_search_white.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_search_white.png delete mode 100644 app/src/main/res/layout/activity_about.xml delete mode 100644 app/src/main/res/layout/activity_clean_apk.xml delete mode 100644 app/src/main/res/layout/activity_comment_detail.xml delete mode 100644 app/src/main/res/layout/activity_game_news.xml delete mode 100644 app/src/main/res/layout/activity_kaifu.xml delete mode 100644 app/src/main/res/layout/activity_setting.xml create mode 100644 app/src/main/res/layout/fragment_about.xml create mode 100644 app/src/main/res/layout/fragment_apk_cleaner.xml create mode 100644 app/src/main/res/layout/fragment_comment_detail.xml rename app/src/main/res/layout/{activity_concern.xml => fragment_concern.xml} (97%) create mode 100644 app/src/main/res/layout/fragment_game_news_search.xml rename app/src/main/res/layout/{activity_gamedetail_news.xml => fragment_game_news_search_result.xml} (98%) create mode 100644 app/src/main/res/layout/fragment_kaifu_wrapper.xml create mode 100644 app/src/main/res/layout/fragment_setting.xml create mode 100644 app/src/main/res/layout/layout_menu_button.xml create mode 100644 app/src/main/res/menu/menu_button.xml create mode 100644 app/src/main/res/menu/menu_search_white.xml diff --git a/app/src/main/java/com/gh/base/BaseActivity.java b/app/src/main/java/com/gh/base/BaseActivity.java index 7c53fc5c6e..e1fd4bab17 100644 --- a/app/src/main/java/com/gh/base/BaseActivity.java +++ b/app/src/main/java/com/gh/base/BaseActivity.java @@ -41,6 +41,7 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + EventBus.getDefault().register(this); ButterKnife.bind(this); mEntrance = getIntent().getStringExtra(KEY_ENTRANCE); if (getIntent().getBundleExtra(KEY_DATA) != null) { @@ -69,12 +70,13 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe } //如果是游戏分享,newsTitle默认为空 - public void showShare(String url, String gameName, String icon, String newsTitle, ArrayList tag, boolean isToolsBox) { + public void showShare(String url, String gameName, String icon, String newsTitle, ArrayList tagList, boolean isToolsBox) { //判断是否是官方版 boolean isPlugin = false; - if (tag != null) { - for (String s : tag) { +// tagList.contains("官方版")??? + if (tagList != null) { + for (String s : tagList) { if (!"官方版".equals(s)) { isPlugin = true; } diff --git a/app/src/main/java/com/gh/base/GHActivityLifecycleCallbacksImpl.java b/app/src/main/java/com/gh/base/GHActivityLifecycleCallbacksImpl.java index 7e689cd188..0c8f4a2ae8 100644 --- a/app/src/main/java/com/gh/base/GHActivityLifecycleCallbacksImpl.java +++ b/app/src/main/java/com/gh/base/GHActivityLifecycleCallbacksImpl.java @@ -4,11 +4,13 @@ import android.app.Activity; import android.app.Application.ActivityLifecycleCallbacks; import android.os.Bundle; -import com.gh.gamecenter.DataUtils; import com.gh.download.DownloadManager; +import com.gh.gamecenter.DataUtils; +import com.lightgame.config.CommonDebug; import com.lightgame.utils.AppManager; import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; /** * 1、写点针对生命周期的统计代码 @@ -24,8 +26,6 @@ public class GHActivityLifecycleCallbacksImpl implements ActivityLifecycleCallba @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - EventBus.getDefault().register(activity); - AppManager.getInstance().addActivity(activity); } @@ -65,7 +65,6 @@ public class GHActivityLifecycleCallbacksImpl implements ActivityLifecycleCallba @Override public void onActivityDestroyed(Activity activity) { AppManager.getInstance().finishActivity(activity); - EventBus.getDefault().unregister(activity); } } diff --git a/app/src/main/java/com/gh/base/fragment/BaseFragment.java b/app/src/main/java/com/gh/base/fragment/BaseFragment.java index b0dce26505..97c59bde19 100644 --- a/app/src/main/java/com/gh/base/fragment/BaseFragment.java +++ b/app/src/main/java/com/gh/base/fragment/BaseFragment.java @@ -10,6 +10,7 @@ import android.view.View; import android.view.ViewGroup; import com.gh.base.BaseActivity; +import com.gh.base.BaseToolBarActivity; import com.gh.base.OnListClickListener; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.EntranceUtils; @@ -57,13 +58,13 @@ public abstract class BaseFragment extends Fragment implements OnRequestCallB handleOnClick(v); } - protected void initTitle(@StringRes int res) { - initTitle(getString(res)); + protected void setNavigationTitle(@StringRes int res) { + setNavigationTitle(getString(res)); } - protected void initTitle(String title) { - if (getActivity() instanceof BaseActivity) { - ((BaseActivity) getActivity()).setNavigationTitle(title); + protected void setNavigationTitle(String title) { + if (getActivity() instanceof BaseToolBarActivity) { + ((BaseToolBarActivity) getActivity()).setNavigationTitle(title); } } @@ -124,10 +125,22 @@ public abstract class BaseFragment extends Fragment implements OnRequestCallB EventBus.getDefault().unregister(this); } + public void toast(@StringRes int res) { + toast(getString(res)); + } + public void toast(String msg) { Utils.toast(getContext(), msg); } + public void toastLong(@StringRes int msg) { + toastLong(getString(msg)); + } + + public void toastLong(String msg) { + RuntimeUtils.getInstance().toastLong(getContext(), msg); + } + public boolean isEverPause() { return isEverPause; } @@ -138,7 +151,7 @@ public abstract class BaseFragment extends Fragment implements OnRequestCallB } @Override - public void loadDone(Object obj) { + public void loadDone(T obj) { } @@ -153,7 +166,7 @@ public abstract class BaseFragment extends Fragment implements OnRequestCallB } @Override - public void onListClick(View view, int position, T data) { + public void onListClick(View view, int position, LIST data) { } diff --git a/app/src/main/java/com/gh/base/fragment/BaseFragment_ViewPager.java b/app/src/main/java/com/gh/base/fragment/BaseFragment_ViewPager.java index 3ab26e243a..1d60e19309 100755 --- a/app/src/main/java/com/gh/base/fragment/BaseFragment_ViewPager.java +++ b/app/src/main/java/com/gh/base/fragment/BaseFragment_ViewPager.java @@ -35,7 +35,7 @@ import java.util.List; */ public abstract class BaseFragment_ViewPager extends BaseFragment implements DoubleTapTextView.OnDoubleTapListener { - protected static final String ARGS_INDEX = "index"; + public static final String ARGS_INDEX = "index"; protected int mCheckedIndex = 0; protected PagerAdapter mAdapter; protected List mFragmentsList; diff --git a/app/src/main/java/com/gh/common/util/CommentUtils.java b/app/src/main/java/com/gh/common/util/CommentUtils.java index abbf378094..286038ce58 100644 --- a/app/src/main/java/com/gh/common/util/CommentUtils.java +++ b/app/src/main/java/com/gh/common/util/CommentUtils.java @@ -137,7 +137,7 @@ public class CommentUtils { break; case "查看对话": - context.startActivity(CommentDetailActivity.getCommentDetailIntent(context, commentEntity.getId())); + context.startActivity(CommentDetailActivity.getIntent(context, commentEntity.getId())); break; } } diff --git a/app/src/main/java/com/gh/gamecenter/AboutActivity.java b/app/src/main/java/com/gh/gamecenter/AboutActivity.java index 908ec92e12..5de33b8b4a 100644 --- a/app/src/main/java/com/gh/gamecenter/AboutActivity.java +++ b/app/src/main/java/com/gh/gamecenter/AboutActivity.java @@ -2,114 +2,23 @@ package com.gh.gamecenter; import android.content.Context; import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; import android.support.annotation.NonNull; -import android.text.TextUtils; -import android.view.View; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; -import com.gh.base.BaseActivity; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.StringUtils; -import com.gh.gamecenter.manager.UpdateManager; -import com.tencent.bugly.beta.tinker.TinkerManager; - -import java.lang.ref.WeakReference; - -import butterknife.BindView; -import butterknife.OnClick; -import butterknife.OnLongClick; +import com.halo.assistant.fragment.AboutFragment; +import com.halo.assistant.ui.IntentFactory; /** * Created by khy on 2017/2/28. */ -public class AboutActivity extends BaseActivity { - - @BindView(R.id.about_version_tv) - TextView mAboutVersion; - @BindView(R.id.setting_rl_update) - RelativeLayout mAboutUpdateRl; - @BindView(R.id.about_version_pb) - ProgressBar mAboutPb; - @BindView(R.id.about_tv_version) - TextView mVersionName; - - private Handler handler = new MyHandler(this); +@Deprecated +public class AboutActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context) { - Intent intent = new Intent(context, AboutActivity.class); - return intent; +// Intent intent = new Intent(context, AboutActivity.class); + return new IntentFactory.Builder(context) + .setActivity(AboutActivity.class) + .setFragment(AboutFragment.class).build(); } - @Override - protected int getLayoutId() { - return R.layout.activity_about; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setNavigationTitle(getString(R.string.title_about)); - -// ((TextView) findViewById(R.id.about_tv_version)).setText("V" + PackageUtils.getVersionName(this)); - mVersionName.setText("V" + PackageUtils.getPatchVersionName()); // TODO 版本号暂时与gradle versionName不一致 - } - - @Override - protected void onDestroy() { - super.onDestroy(); - handler.removeCallbacksAndMessages(null); - } - - @OnClick({R.id.about_shengming, R.id.setting_rl_update}) - public void OnClick(View view) { - if (view.getId() == R.id.setting_rl_update) { - UpdateManager.getInstance(AboutActivity.this).checkUpdate(false, handler); // 检出更新 - } else if (view.getId() == R.id.about_shengming) { - Intent intent = WebActivity.getWebIntent(this); - startActivity(intent); - } - } - - @OnLongClick(R.id.about_tv_version) - public boolean OnLongClick(View view) { - if (view.getId() == R.id.about_tv_version) { - String tinkerId = TinkerManager.getNewTinkerId(); - if (!TextUtils.isEmpty(tinkerId)) { - mVersionName.setText("V" + PackageUtils.getPatchVersionName() + "." + tinkerId); - } else { - Toast.makeText(getApplicationContext(), R.string.toast_upload_latest, Toast.LENGTH_SHORT).show(); - } - } - return false; - } - - private static class MyHandler extends Handler { - - private WeakReference mWeakReference; - - public MyHandler(AboutActivity activity) { - mWeakReference = new WeakReference<>(activity); - } - - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - final AboutActivity activity = mWeakReference.get(); - if (activity != null) { - if (msg.what == 0) { - final String version = (String) msg.obj; - activity.mAboutVersion.setText(StringUtils.buildString("发现新版本 V", version)); - } else if (msg.what == 1) { - activity.mAboutVersion.setText(R.string.toast_upload_latest); - } - } - } - } } diff --git a/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java b/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java index f6a60c87ac..303d499e3d 100644 --- a/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java @@ -162,7 +162,6 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick mTitleTv.setTextColor(Color.WHITE); mBackIv.setImageResource(R.drawable.reuse_kc_back); - // 添加分享图标 TextView hintTv = new TextView(this); hintTv.setText("操作说明"); @@ -173,8 +172,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); - RelativeLayout reuse_actionbar = (RelativeLayout) mContentView.findViewById( - R.id.reuse_actionbar); + RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar); reuse_actionbar.addView(hintTv, params); //修改沉浸栏以及ActionBar 颜色 diff --git a/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java b/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java index 959e529d90..c6d24aa5bf 100644 --- a/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java +++ b/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java @@ -2,240 +2,23 @@ package com.gh.gamecenter; import android.content.Context; import android.content.Intent; -import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.v4.util.ArrayMap; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.Html; -import android.view.View; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; -import android.widget.TextView; -import com.gh.base.BaseActivity; -import com.gh.common.util.DialogUtils; -import com.gh.common.view.VerticalItemDecoration; -import com.gh.gamecenter.adapter.CleanApkAdapter; -import com.gh.gamecenter.entity.InstallGameEntity; -import com.gh.gamecenter.eventbus.EBSkip; -import com.lightgame.utils.Utils; - -import org.greenrobot.eventbus.EventBus; - -import java.io.File; -import java.text.DecimalFormat; -import java.util.List; - -import butterknife.BindView; -import butterknife.OnClick; +import com.halo.assistant.fragment.ApkCleanerFragment; +import com.halo.assistant.ui.IntentFactory; /** * Created by khy on 2017/1/24. */ -public class CleanApkActivity extends BaseActivity implements CleanApkAdapter.OnScanListener { - - @BindView(R.id.apk_count) - TextView mApkCount; - @BindView(R.id.apk_rv) - RecyclerView mApkRv; - @BindView(R.id.delete_btn) - TextView mApkDeleteBtn; - @BindView(R.id.select_game_all) - CheckBox mApkSelectAll; - @BindView(R.id.scan_pb) - ProgressBar mScanPb; - @BindView(R.id.reuse_nodata_skip_tv_hint) - TextView mNodataSkipTv; - @BindView(R.id.reuse_nodata_skip_tv_btn) - TextView mNodataSkipBtn; - @BindView(R.id.reuse_nodata_skip) - LinearLayout mNodataSkipLl; - @BindView(R.id.delete_bottom) - LinearLayout mDeleteBottom; - @BindView(R.id.select_game_installed_ll) - RelativeLayout mInstallAllData; - - private CleanApkAdapter mAdapter; +@Deprecated +public class CleanApkActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context) { - Intent intent = new Intent(context, CleanApkActivity.class); - return intent; +// Intent intent = new Intent(context, CleanApkActivity.class); + return new IntentFactory.Builder(context) + .setActivity(CleanApkActivity.class) + .setFragment(ApkCleanerFragment.class).build(); } - @Override - protected int getLayoutId() { - return R.layout.activity_clean_apk; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setNavigationTitle(getString(R.string.title_clean_apk)); - - mNodataSkipLl.setVisibility(View.GONE); - - mAdapter = new CleanApkAdapter(this, this, mApkDeleteBtn, mApkSelectAll); - mApkRv.setLayoutManager(new LinearLayoutManager(this)); - mApkRv.addItemDecoration(new VerticalItemDecoration(this, 8, true)); - mApkRv.setAdapter(mAdapter); - - mApkSelectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - ArrayMap selectPosition = new ArrayMap<>(); - ArrayMap selectPosition1 = mAdapter.getSelectPosition(); - int itemCount = mAdapter.getItemCount(); - if (isChecked) { - for (int i = 0; i < itemCount; i++) { - selectPosition.put(i, true); - } - } else { - int selectCount = 0; - for (Integer integer : selectPosition1.keySet()) { - if (selectPosition1.get(integer)) { - selectCount++; - } - } - - if (selectCount != itemCount) { - return; - } - - for (int i = 0; i < itemCount; i++) { - selectPosition.put(i, false); - } - } - - mAdapter.setSelectPosition(selectPosition); - mAdapter.notifyItemRangeChanged(0, itemCount); - mAdapter.checkBoxControl(isChecked, 0); - } - }); - - mNodataSkipBtn.setText("去首页看看"); - mNodataSkipTv.setText("安装包已清理干净\n快去发现更多好玩的游戏吧!"); - mNodataSkipTv.setLineSpacing(0, 1.5f); - - } - - @OnClick({R.id.delete_btn, R.id.reuse_nodata_skip_tv_btn}) - public void onClick(View view) { - switch (view.getId()) { - case R.id.delete_btn: { - String s = mApkDeleteBtn.getText().toString(); - if ("停止扫描".equals(s)) { - mAdapter.isStopScan(); - } else { - if ("一键删除".equals(s)) { - Utils.toast(CleanApkActivity.this, "请选择需要删除的安装包"); - return; - } - - final List apkList = mAdapter.getApkList(); - final ArrayMap selectPosition = mAdapter.getSelectPosition(); - - for (int i = 0; i < apkList.size(); i++) { - if (selectPosition.get(i) && apkList.get(i).getInstallStatus() == 1) { - DialogUtils.showWarningDialog(CleanApkActivity.this, "删除安装包" - , Html.fromHtml(getString(R.string.delete_apk_hint)) - , "取消 ", "确定" - , new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - deleteApk(apkList, selectPosition); - } - }, null); - return; - } - } - - deleteApk(apkList, selectPosition); - } - break; - } - case R.id.reuse_nodata_skip_tv_btn: { - Intent intent = MainActivity.getMainIntent(this); - startActivity(intent); - - mNodataSkipBtn.postDelayed(new Runnable() { - @Override - public void run() { - EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 0)); - } - }, 300); - break; - } - } - } - - private void deleteApk(List apkList, ArrayMap selectPosition) { - long size = 0; - for (int i = 0; i < apkList.size(); i++) { - if (selectPosition.get(i)) { - InstallGameEntity installGameEntity = apkList.get(i); - size = size + installGameEntity.getGameSize(); - File file = new File(installGameEntity.getGamePath()); - if (file.isFile() && file.exists()) { - file.delete(); - mAdapter.deleteApk(i); - i--; - } - } - } - - double allSize = (((float) size / 1024) / 1024); - DecimalFormat df = new DecimalFormat("#.00"); - String sizeName = df.format(allSize) + "MB"; - Utils.toast(CleanApkActivity.this, "删除成功,已为您节省" + sizeName + "空间"); - mApkDeleteBtn.setText("一键删除"); - mAdapter.notifyDataSetChanged(); // 刷新Adapter position - - updateScanData(); - - if (apkList.size() == 0) { // 全部删除 - mNodataSkipLl.setVisibility(View.VISIBLE); - mInstallAllData.setVisibility(View.GONE); - mDeleteBottom.setVisibility(View.GONE); - } - } - - private void updateScanData() { - long allSize = 0; - List apkList = mAdapter.getApkList(); - for (InstallGameEntity installGameEntity : apkList) { - allSize = allSize + installGameEntity.getGameSize(); - } - - double size = (((float) allSize / 1024) / 1024); - DecimalFormat df = new DecimalFormat("0.00"); - String sizeName = df.format(size) + "MB"; - - mApkCount.setText(Html.fromHtml(getString(R.string.clean_apk_count, apkList.size(), sizeName))); - } - - @Override - public void onScanOver() { - mApkDeleteBtn.setText("立即删除"); - mApkDeleteBtn.setBackgroundResource(R.drawable.game_item_btn_red_style); - - updateScanData(); - - mScanPb.setVisibility(View.GONE); - mApkSelectAll.setVisibility(View.VISIBLE); - mApkSelectAll.setChecked(true); - } - - @Override - public void noData() { - mNodataSkipBtn.setText("去首页看看"); - mNodataSkipTv.setText("暂无安装包"); - mNodataSkipLl.setVisibility(View.VISIBLE); - mInstallAllData.setVisibility(View.GONE); - mDeleteBottom.setVisibility(View.GONE); - } } diff --git a/app/src/main/java/com/gh/gamecenter/CollectionActivity.java b/app/src/main/java/com/gh/gamecenter/CollectionActivity.java index 4bf201c3a9..2aa1ebeb33 100644 --- a/app/src/main/java/com/gh/gamecenter/CollectionActivity.java +++ b/app/src/main/java/com/gh/gamecenter/CollectionActivity.java @@ -3,33 +3,25 @@ package com.gh.gamecenter; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.support.annotation.NonNull; -import com.gh.base.BaseActivity; -import com.gh.gamecenter.collection.CollectionFragment; +import com.gh.base.fragment.BaseFragment_ViewPager; +import com.gh.gamecenter.collection.CollectionWrapperFragment; +import com.halo.assistant.ui.IntentFactory; /** * Created by khy on 18/07/17. */ +@Deprecated +public class CollectionActivity extends CommonActivity { -public class CollectionActivity extends BaseActivity { - - - public static final Intent getCollectionActivity(Context context) { - Intent intent = new Intent(context, CollectionActivity.class); - return intent; + @NonNull + public static Intent getCollectionActivity(Context context) { + Bundle args = new Bundle(); + args.putInt(BaseFragment_ViewPager.ARGS_INDEX, CollectionWrapperFragment.INDEX_TOOL); + return new IntentFactory.Builder(context) + .setActivity(CollectionActivity.class) + .setFragment(CollectionWrapperFragment.class).setArgs(args).build(); } - @Override - protected int getLayoutId() { - return R.layout.activity_collection; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setNavigationTitle("我的收藏"); - - getSupportFragmentManager().beginTransaction().replace( - R.id.layout_fragment_content, CollectionFragment.newInstance(0)).commitAllowingStateLoss(); - } } diff --git a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java index 84157a1cfa..f3f5a6d607 100644 --- a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java @@ -1,241 +1,25 @@ package com.gh.gamecenter; -import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.View; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.RelativeLayout; -import android.widget.ScrollView; -import android.widget.TextView; -import com.facebook.drawee.view.SimpleDraweeView; -import com.gh.base.BaseActivity; -import com.gh.common.util.CheckLoginUtils; -import com.gh.common.util.DialogUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.ImageUtils; -import com.gh.common.util.LoginUtils; -import com.gh.common.util.PostCommentUtils; -import com.gh.gamecenter.adapter.CommentDetailAdapter; -import com.gh.gamecenter.adapter.OnCommentCallBackListener; -import com.gh.gamecenter.entity.CommentEntity; -import com.gh.gamecenter.entity.UserInfoEntity; -import com.lightgame.utils.Utils; - -import org.json.JSONException; -import org.json.JSONObject; - -import butterknife.BindView; -import butterknife.OnClick; -import butterknife.OnTouch; -import retrofit2.HttpException; +import com.halo.assistant.fragment.comment.CommentDetailFragment; +import com.halo.assistant.ui.IntentFactory; /** * Created by khy on 2017/3/22. */ +@Deprecated +public class CommentDetailActivity extends CommonActivity { -// TODO: 16/11/17 时间比较紧 先暂时这么做 最好发表评论那块和评论详情整合 -public class CommentDetailActivity extends BaseActivity implements OnCommentCallBackListener { - - @BindView(R.id.comment_detail_rv) - RecyclerView mRecyclerView; - @BindView(R.id.comment_detail_close_comment) - View mCommentDetailCloseComment; - @BindView(R.id.comment_detail_comment_et) - EditText mCommentDetailCommentEt; - @BindView(R.id.comment_user_icon) - SimpleDraweeView mCommentUserIcon; - @BindView(R.id.comment_user_name) - TextView mCommentUserName; - @BindView(R.id.comment_send) - TextView mCommentSend; - @BindView(R.id.comment_detail_user_rl) - RelativeLayout mCommentDetailUserRl; - @BindView(R.id.comment_detail_comment_rl) - RelativeLayout mCommentDetailCommentRl; - @BindView(R.id.comment_detail_sv) - ScrollView mCommentDetailSv; - @BindView(R.id.reuse_none_data) - View mNoData; - - private Dialog mSendingDialog; - - private UserInfoEntity mUserInfo; - private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空 - - private CommentDetailAdapter mAdapter; - private LinearLayoutManager mLayoutManager; - - public static Intent getCommentDetailIntent(Context context, String commentId) { - Intent intent = new Intent(context, CommentDetailActivity.class); - intent.putExtra(EntranceUtils.KEY_COMMENTID, commentId); - return intent; - } - - - @Override - protected int getLayoutId() { - return R.layout.activity_comment_detail; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setNavigationTitle(getString(R.string.title_comment_detail)); - - String commentId = getIntent().getStringExtra(EntranceUtils.KEY_COMMENTID); - - mAdapter = new CommentDetailAdapter(this, commentId, this, mNoData, mRecyclerView); - mLayoutManager = new LinearLayoutManager(this); - mRecyclerView.setLayoutManager(mLayoutManager); - mRecyclerView.setAdapter(mAdapter); - - mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - if (newState == RecyclerView.SCROLL_STATE_IDLE && !mAdapter.isOver() && !mAdapter.isLoading()) { - mAdapter.loadData(mAdapter.getItemCount()); - } - } - }); - - mUserInfo = LoginUtils.getUserInfo(this); - if (mUserInfo != null) { - ImageUtils.Companion.display(mCommentUserIcon, mUserInfo.getIcon()); - mCommentUserName.setText(mUserInfo.getName()); - } - } - - @Override - public void onCommentCallback(CommentEntity entity) { - mCommentEntity = entity; - setSoftInput(true); - } - - @OnTouch(R.id.comment_detail_close_comment) - public boolean OnRecyclerTouchListener() { - if (mCommentDetailCloseComment.getVisibility() == View.VISIBLE) { - setSoftInput(false); - } - return true; - } - - @OnClick(R.id.comment_send) - public void OnSendCommentListener() { - final String content = mCommentDetailCommentEt.getText().toString(); - - if (content.length() == 0) { - Utils.toast(this, "评论内容不能为空!"); - return; - } - - mSendingDialog = DialogUtils.showWaitDialog(this, "正在提交"); - - JSONObject jsonObject = new JSONObject(); - try { - jsonObject.put("content", content); - } catch (JSONException e) { - e.printStackTrace(); - } - if (mCommentEntity != null && mCommentEntity.getId() == null) { - Utils.toast(this, "评论异常 id null"); - mSendingDialog.cancel(); - return; - } - - PostCommentUtils.addCommentData(CommentDetailActivity.this, null, jsonObject.toString(), mCommentEntity, - new PostCommentUtils.PostCommentListener() { - @Override - public void postSuccess(JSONObject response) { - mSendingDialog.dismiss(); - toast("发表成功"); - mCommentDetailCommentEt.setText(""); - - setSoftInput(false); - - } - - @Override - public void postFailed(Throwable e) { - mSendingDialog.dismiss(); - - if (e instanceof HttpException) { - HttpException exception = (HttpException) e; - if (exception.code() == 403) { - try { - JSONObject errorJson = new JSONObject(exception.response().errorBody().string()); - String detail = errorJson.getString("detail"); - switch (detail) { - case "too frequent": - toast("别话痨哦~休息一会再来评论吧~"); - break; - case "user blocked": - toast("账号状态异常,暂时无法发表评论"); - break; - case "article blocked": - toast("文章异常,无法发表评论"); - setSoftInput(false); - break; - case "illegal": - toast("评论内容可能包括敏感信息,请修改后再发表"); - break; - default: - toast("评论失败,未知原因"); - break; - } - } catch (Exception ex) { - ex.printStackTrace(); - toast("评论异常"); - } - return; - } - } - - toast("提交失败,请检查网络设置"); - } - }); - } - - //软键盘控制 - private void setSoftInput(boolean isShow) { - final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - if (isShow) { - CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - imm.showSoftInputFromInputMethod(mCommentDetailCommentEt.getWindowToken(), 0); - imm.toggleSoftInputFromWindow(mCommentDetailCommentEt.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS); - mCommentDetailCommentRl.setVisibility(View.VISIBLE); - mCommentDetailCommentEt.setFocusable(true); - mCommentDetailCommentEt.setFocusableInTouchMode(true); - mCommentDetailCommentEt.requestFocus(); - mCommentDetailCloseComment.setVisibility(View.VISIBLE); - - if (mCommentEntity != null && mCommentEntity.getUser() != null) { - mCommentDetailCommentEt.setHint("回复" + mCommentEntity.getUser().getName() + ":"); - } else { - mCommentDetailCommentEt.setHint("优质评论会被优先展示"); - } - } - }); - } else { - imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0); - - mCommentDetailCloseComment.setVisibility(View.GONE); - - mCommentDetailCommentRl.setVisibility(View.GONE); - if (mCommentEntity != null) { - mCommentEntity = null; // 清空当前评论实体 - mCommentDetailCommentEt.setHint("优质评论会被优先展示"); - mCommentDetailCommentEt.setText(""); - } - } + public static Intent getIntent(Context context, String commentId) { + Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_COMMENTID, commentId); + return new IntentFactory.Builder(context) + .setActivity(CommentDetailActivity.class) + .setFragment(CommentDetailFragment.class).setArgs(args).build(); } } diff --git a/app/src/main/java/com/gh/gamecenter/ConcernActivity.java b/app/src/main/java/com/gh/gamecenter/ConcernActivity.java index 25f5c00599..8f2b59fd20 100644 --- a/app/src/main/java/com/gh/gamecenter/ConcernActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ConcernActivity.java @@ -4,209 +4,21 @@ 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.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; -import com.gh.base.BaseActivity; -import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.EntranceUtils; -import com.gh.common.view.Concern_LinearLayout; -import com.gh.gamecenter.adapter.ConcernAdapter; -import com.gh.gamecenter.adapter.ConcernRecommendAdapter; -import com.gh.gamecenter.entity.GameEntity; -import com.gh.gamecenter.eventbus.EBConcernChanged; -import com.gh.gamecenter.eventbus.EBReuse; - -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.List; - -import butterknife.BindView; -import butterknife.OnClick; - -import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG; - -public class ConcernActivity extends BaseActivity implements OnClickListener, OnRequestCallBackListener { - - @BindView(R.id.concern_rv_show) - RecyclerView mConcernRv; - @BindView(R.id.concern_rv_recommend) - RecyclerView mConcernRecommendRv; - @BindView(R.id.concern_rl_title) - RelativeLayout mConcernTitleRl; - @BindView(R.id.reuse_none_data) - LinearLayout mNoneData; - @BindView(R.id.reuse_tv_none_data) - TextView mNoDataTv; - @BindView(R.id.reuse_no_connection) - LinearLayout mNoConn; - - private ConcernAdapter concernAdapter; - private ConcernRecommendAdapter concernRecommendAdapter; +import com.halo.assistant.fragment.ConcernFragment; +import com.halo.assistant.ui.IntentFactory; +@Deprecated +public class ConcernActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context, String entrance) { - Intent intent = new Intent(context, ConcernActivity.class); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); - return intent; + Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_ENTRANCE, entrance); + return new IntentFactory.Builder(context) + .setActivity(ConcernActivity.class) + .setFragment(ConcernFragment.class).setArgs(args).build(); } - @Override - protected int getLayoutId() { - return R.layout.activity_concern; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setNavigationTitle(getString(R.string.title_concern)); - - mConcernTitleRl.setOnClickListener(this); - - mConcernRv.setHasFixedSize(true); - mConcernRv.setLayoutManager(new GridLayoutManager(this, 3)); - concernAdapter = new ConcernAdapter(this, this, mEntrance); - mConcernRv.setAdapter(concernAdapter); - - mConcernRecommendRv.setHasFixedSize(true); - mConcernRecommendRv.setLayoutManager(new GridLayoutManager(this, 4)); - - - } - - @Override - public void loadDone() { // 关注推荐 回调 - mConcernTitleRl.setVisibility(View.VISIBLE); - mConcernRecommendRv.setVisibility(View.VISIBLE); - int size = concernRecommendAdapter.getRecommendGameList().size(); - mConcernRecommendRv.setLayoutManager(new GridLayoutManager(this, size > 4 ? 4 : size)); - mConcernRecommendRv.getAdapter().notifyDataSetChanged(); - } - - // 关注的游戏加载完成 再加载热门推荐(根据已关注的游戏过滤) - @Override - public void loadDone(Object obj) { - mNoConn.setVisibility(View.GONE); - mNoneData.setVisibility(View.GONE); - - concernRecommendAdapter = new ConcernRecommendAdapter(this, this, (List)obj, mEntrance); - mConcernRecommendRv.setAdapter(concernRecommendAdapter); - - if (obj == null) { // 未登录状态 - mNoneData.setVisibility(View.VISIBLE); - mConcernRv.setVisibility(View.GONE); - mNoDataTv.setText(R.string.login_hint); - mNoDataTv.setTextColor(ContextCompat.getColor(ConcernActivity.this, R.color.theme)); - } - } - - @Override - public void loadError() { - mNoConn.setVisibility(View.VISIBLE); - mNoneData.setVisibility(View.GONE); - } - - @Override - public void loadEmpty() { - if (concernAdapter.getConcernGameList() == null - || concernAdapter.getConcernGameList().isEmpty()) { - mNoneData.setVisibility(View.VISIBLE); - mConcernRv.setVisibility(View.GONE); - mNoDataTv.setText(R.string.game_empty); - mNoDataTv.setTextColor(ContextCompat.getColor(ConcernActivity.this, R.color.c7c7c7)); - } - if (concernRecommendAdapter.getRecommendGameList() == null - || concernRecommendAdapter.getRecommendGameList().isEmpty()) { - mConcernTitleRl.setVisibility(View.GONE); - mConcernRecommendRv.setVisibility(View.GONE); - } else { - if (concernRecommendAdapter.getRecommendGameList().size() < 4) { - mConcernRecommendRv.setLayoutManager( - new GridLayoutManager(this, concernRecommendAdapter.getRecommendGameList().size())); - } - } - } - - @OnClick({R.id.concern_rl_title, R.id.reuse_tv_none_data}) - public void onClick(View v) { - switch (v.getId()) { - case R.id.concern_rl_title: - if (mConcernRecommendRv.getVisibility() == View.VISIBLE) { - ((Concern_LinearLayout) mContentView).hideRecyclerView(); - } else { - ((Concern_LinearLayout) mContentView).showRecyclerView(); - } - break; - case R.id.reuse_tv_none_data: - String hint = getString(R.string.login_hint); - if (hint.equals(mNoDataTv.getText().toString())) - startActivity(LoginActivity.getIntent(this, false)); - break; - } - } - // 关注事件 - @Subscribe(threadMode = ThreadMode.MAIN) - public void onEventMainThread(EBConcernChanged changed) { - if (!changed.isSingle()) { - return; - } - if (changed.isConcern()) { - GameEntity concernGame = concernRecommendAdapter.concernGame(changed.getGameId()); - - if (concernGame != null) { - concernAdapter.getConcernGameList().add(0, concernGame); - concernAdapter.notifyDataSetChanged(); - if (mNoneData.getVisibility() == View.VISIBLE) { - mNoneData.setVisibility(View.GONE); - mConcernRv.setVisibility(View.VISIBLE); - } - } - - for (int i = 0, size = concernRecommendAdapter.getRecommendGameList().size(); i < size; i++) { - if (changed.getGameId().equals(concernRecommendAdapter.getRecommendGameList().get(i).getId())) { - concernRecommendAdapter.getRecommendGameList().remove(i); - concernRecommendAdapter.notifyItemRemoved(i); // 删除动画 - concernRecommendAdapter.notifyDataSetChanged(); // 防止列表串行 - if (concernRecommendAdapter.getRecommendGameList().isEmpty()) { - mConcernTitleRl.setVisibility(View.GONE); - mConcernRecommendRv.setVisibility(View.GONE); - } - break; - } - } - } else { - GameEntity gameEntity = concernAdapter.cancelConcern(changed.getGameId()); - if (gameEntity != null) { - concernRecommendAdapter.getRecommendGameList().add(0, gameEntity); - concernRecommendAdapter.notifyDataSetChanged(); - } - - if (concernRecommendAdapter.getRecommendGameList().isEmpty()) { - mConcernTitleRl.setVisibility(View.GONE); - mConcernRecommendRv.setVisibility(View.GONE); - } else { - mConcernTitleRl.setVisibility(View.VISIBLE); - mConcernRecommendRv.setVisibility(View.VISIBLE); - } - } - } - - // 登录事件 - @Subscribe(threadMode = ThreadMode.MAIN) - public void onEventMainThread(EBReuse reuse) { - if (reuse.getType().equals(LOGIN_TAG)) { // 登入 - concernAdapter = new ConcernAdapter(this, this, mEntrance); - mConcernRv.setAdapter(concernAdapter); - mConcernRv.setVisibility(View.VISIBLE); - } - } } diff --git a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java index 8182b5537a..b6f11cd0c0 100644 --- a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java @@ -119,7 +119,6 @@ public class GameDetailActivity extends BaseActivity { private GameDetailEntity mGameDetailEntity; private String downloadAddWord; private String downloadOffText; - private String name; // 页面位置 private String title; // 页面标题 private String shareCode; private boolean mIsTouchScreen = false; @@ -146,7 +145,7 @@ public class GameDetailActivity extends BaseActivity { private DetailViewHolder getDetailViewHolder() { // 每次获取需要重新创建, 防止数据刷新 return new DetailViewHolder(mContentView, mGameEntity, mDownloadEntity, downloadOffText, downloadAddWord, - false, mEntrance, name, title); // 下载按钮ViewHolder + false, mEntrance, getString(R.string.title_game_detail), title); // 下载按钮ViewHolder } /** @@ -195,7 +194,7 @@ public class GameDetailActivity extends BaseActivity { setNavigationTitle(""); // 增加actionBar Button - RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar); + RelativeLayout reuse_actionbar = findViewById(R.id.reuse_actionbar); mShareIv = LayoutInflater.from(this).inflate(R.layout.menu_action_share, reuse_actionbar, false); // 绑定parentView 否则会丢失宽高 RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mShareIv.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); @@ -204,8 +203,6 @@ public class GameDetailActivity extends BaseActivity { mViewPager.setScrollable(true); - name = "游戏详情"; - mGameId = getIntent().getStringExtra(EntranceUtils.KEY_GAMEID); mEntrance = getIntent().getStringExtra(EntranceUtils.KEY_ENTRANCE); Bundle data = getIntent().getBundleExtra(EntranceUtils.KEY_DATA); diff --git a/app/src/main/java/com/gh/gamecenter/GameNewsActivity.java b/app/src/main/java/com/gh/gamecenter/GameNewsActivity.java index b3154cc504..5131b8415e 100644 --- a/app/src/main/java/com/gh/gamecenter/GameNewsActivity.java +++ b/app/src/main/java/com/gh/gamecenter/GameNewsActivity.java @@ -4,216 +4,33 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.v4.util.ArrayMap; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.TextUtils; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; -import com.gh.base.BaseActivity; -import com.gh.common.util.DisplayUtils; import com.gh.common.util.EntranceUtils; -import com.gh.gamecenter.adapter.GameNewsAdapter; -import com.gh.gamecenter.adapter.GameNewsTypeListAdapter; -import com.gh.gamecenter.eventbus.EBTypeChange; -import com.gh.gamecenter.retrofit.Response; -import com.gh.gamecenter.retrofit.RetrofitManager; - -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.BindView; -import retrofit2.HttpException; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; +import com.halo.assistant.fragment.game.GameNewsSearchFragment; +import com.halo.assistant.ui.IntentFactory; /** * Created by LGT on 2016/8/29. - * 游戏新闻界面 + * 游戏新闻界面,由于MTA界面统计未重新记录的原因,暂留此傀儡,连名字都不能改,真是可怕 */ -public class GameNewsActivity extends BaseActivity implements View.OnClickListener { - - @BindView(R.id.game_news_list) - RecyclerView mGameNewsRv; - @BindView(R.id.game_news_top_type_list) - RecyclerView mGameNewsTypeRv; - @BindView(R.id.reuse_none_data) - LinearLayout mNoDataLl; - @BindView(R.id.reuse_tv_none_data) - TextView mNoDataTv; - - private GameNewsAdapter adapter; - private GameNewsTypeListAdapter typeListAdapter; - private LinearLayoutManager layoutManager; - private ImageView ivSearch; - - private ArrayMap adapterMap; - - private List typeList; - - private String gameId; - - private float startY = 0; +@Deprecated +public class GameNewsActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context, String gameName, String gameId, String entrance) { - Intent intent = new Intent(context, GameNewsActivity.class); - intent.putExtra(EntranceUtils.KEY_GAMENAME, gameName); - intent.putExtra(EntranceUtils.KEY_GAMEID, gameId); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); - return intent; +// Intent intent = new Intent(context, GameNewsActivity.class); +// intent.putExtra(EntranceUtils.KEY_GAMENAME, gameName); +// intent.putExtra(EntranceUtils.KEY_GAMEID, gameId); +// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); +// return intent; + + final Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_GAMENAME, gameName); + args.putString(EntranceUtils.KEY_GAMEID, gameId); + args.putString(EntranceUtils.KEY_ENTRANCE, entrance); + return new IntentFactory.Builder(context) + .setActivity(GameNewsActivity.class) + .setFragment(GameNewsSearchFragment.class).setArgs(args).build(); } - @Override - protected int getLayoutId() { - return R.layout.activity_game_news; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - ivSearch = new ImageView(this); - ivSearch.setImageResource(R.drawable.ic_search_white); - - RelativeLayout.LayoutParams ivSearchParams = new RelativeLayout.LayoutParams( - DisplayUtils.dip2px(this, 20), DisplayUtils.dip2px(this, 20)); - ivSearchParams.addRule(RelativeLayout.CENTER_VERTICAL); - ivSearchParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - ivSearchParams.setMargins(0, 0, DisplayUtils.dip2px(this, 10), 0); - - RelativeLayout reuse_actionbar = (RelativeLayout) mContentView.findViewById(R.id.reuse_actionbar); - reuse_actionbar.addView(ivSearch, ivSearchParams); - ivSearch.setOnClickListener(this); - ivSearch.setVisibility(View.GONE); - - String gameName = getIntent().getStringExtra(EntranceUtils.KEY_GAMENAME); - setNavigationTitle(gameName); - - mNoDataTv.setText("暂无内容"); - - adapterMap = new ArrayMap<>(); - - typeList = new ArrayList<>(); - - gameId = getIntent().getStringExtra(EntranceUtils.KEY_GAMEID); - - mGameNewsRv.setHasFixedSize(true); - layoutManager = new LinearLayoutManager(this); - mGameNewsRv.setLayoutManager(layoutManager); - - mGameNewsRv.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - if (adapter != null && newState == RecyclerView.SCROLL_STATE_IDLE - && layoutManager.findLastVisibleItemPosition() == adapter.getItemCount() - 1) { - if (!adapter.isRemove() && !adapter.isLoading() && !adapter.isNetworkError()) { - adapter.addList(adapter.getNewsList().size()); - } - } - } - - @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - super.onScrolled(recyclerView, dx, dy); - - if (layoutManager.findFirstVisibleItemPosition() >= 1) { - mGameNewsTypeRv.setVisibility(View.VISIBLE); - ivSearch.setVisibility(View.VISIBLE); - } else { - mGameNewsTypeRv.setVisibility(View.GONE); - ivSearch.setVisibility(View.GONE); - } - - } - }); - - mGameNewsTypeRv.setHasFixedSize(true); - mGameNewsTypeRv.setLayoutManager(new GridLayoutManager(this, 5)); - - //禁止由于滑动出现的阴影 - mGameNewsTypeRv.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - startY = event.getY(); - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (Math.abs(startY - event.getY()) > 0) { - return true; - } - } - return false; - } - }); - - if (!TextUtils.isEmpty(gameId)) { - getGameArticleType(); - } - } - - private void getGameArticleType() { - RetrofitManager.getInstance(this).getApi() - .getGameArticleType(gameId) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Response>() { - @Override - public void onResponse(List response) { - super.onResponse(response); - typeList = response; - typeList.add(0, "全部"); - adapter = new GameNewsAdapter(GameNewsActivity.this, typeList, mGameNewsRv, gameId, "全部", mEntrance, mNoDataLl); - adapterMap.put("全部", adapter); - mGameNewsRv.setAdapter(adapter); - - typeListAdapter = new GameNewsTypeListAdapter(GameNewsActivity.this, typeList, "全部"); - mGameNewsTypeRv.setAdapter(typeListAdapter); - - ViewGroup.LayoutParams params = mGameNewsTypeRv.getLayoutParams(); - params.height = (int) Math.ceil(typeList.size() / 5f) * DisplayUtils.dip2px(GameNewsActivity.this, 35) - + DisplayUtils.dip2px(GameNewsActivity.this, 12); - mGameNewsTypeRv.setLayoutParams(params); - } - - @Override - public void onFailure(HttpException e) { - super.onFailure(e); - } - }); - } - - @Subscribe(threadMode = ThreadMode.MAIN) - public void onEventMainThread(EBTypeChange change) { - adapter = adapterMap.get(change.getType()); - if (adapter == null) { - adapter = new GameNewsAdapter(GameNewsActivity.this, typeList, mGameNewsRv, gameId, change.getType(), mEntrance, mNoDataLl); - adapterMap.put(change.getType(), adapter); - } - mGameNewsRv.setAdapter(adapter); - - mGameNewsTypeRv.setVisibility(View.GONE); - ivSearch.setVisibility(View.GONE); - typeListAdapter.setNewsType(change.getType(), change.getPosition()); - } - - @Override - public void onClick(View v) { - if (v == ivSearch) { - mGameNewsRv.scrollToPosition(0); - mGameNewsTypeRv.setVisibility(View.GONE); - ivSearch.setVisibility(View.GONE); - adapter.openKeyBoard(); - } - } } diff --git a/app/src/main/java/com/gh/gamecenter/InstallActivity.java b/app/src/main/java/com/gh/gamecenter/InstallActivity.java index fd96c1a3e0..98d7fb6d12 100644 --- a/app/src/main/java/com/gh/gamecenter/InstallActivity.java +++ b/app/src/main/java/com/gh/gamecenter/InstallActivity.java @@ -200,7 +200,6 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap } } - // 滑动item @Override public void onSmooth() { @@ -215,4 +214,5 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap public void onOpen() { startActivityForResult(ChooseReceiverActivity.getIntent(this, true), KC_REQUEST); } + } diff --git a/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java b/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java index 8314723786..593f43007b 100644 --- a/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java +++ b/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java @@ -16,6 +16,8 @@ import com.gh.common.util.DisplayUtils; import com.gh.common.util.EntranceUtils; import com.gh.gamecenter.eventbus.EBKaiFuReset; import com.gh.gamecenter.kaifu.KaiFuFragment; +import com.gh.gamecenter.kaifu.KaiFuWrapperFragment; +import com.halo.assistant.ui.IntentFactory; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -25,97 +27,16 @@ import butterknife.BindView; /** * Created by khy on 18/08/17. */ - -public class KaiFuActivity extends BaseActivity { - - @BindView(R.id.reuse_actionbar) - RelativeLayout mReuseActionbar; - - private TextView mResetTv; - - private KaiFuFragment mKaiFuFragment; - private KaiFuFragment mGameKaiFuFragment; - - public static final String SINGLE_GAME_KAIFU = "SINGLE_GAME_KAIFU"; - public static final String ALL_GAME_KAIFU = "ALL_GAME_KAIFU"; +@Deprecated +public class KaiFuActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context, String entrance) { - Intent intent = new Intent(context, KaiFuActivity.class); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); - return intent; - } - - - @Override - protected int getLayoutId() { - return R.layout.activity_kaifu; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setNavigationTitle("开服表"); - - mResetTv = new TextView(this); - mResetTv.setText("重置"); - mResetTv.setTextColor(ContextCompat.getColor(this, R.color.title)); - mResetTv.setGravity(Gravity.CENTER); - mResetTv.setVisibility(View.GONE); - mResetTv.setBackgroundResource(R.drawable.border_black_bg); - RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( - DisplayUtils.dip2px(this, 48), DisplayUtils.dip2px(this, 28)); - params.addRule(RelativeLayout.CENTER_VERTICAL); - params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - params.setMargins(0, 0, DisplayUtils.dip2px(this, 8), 0); - mReuseActionbar.addView(mResetTv, params); - - - FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - mKaiFuFragment = new KaiFuFragment(); - fragmentTransaction.add(R.id.layout_fragment_content, mKaiFuFragment); - fragmentTransaction.commit(); - mResetTv.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - resetFragment(); - } - }); - } - - private void resetFragment() { - mKaiFuFragment.setCurPage(mGameKaiFuFragment.getCurPage()); - - mResetTv.setVisibility(View.GONE); - mKaiFuFragment.onResume(); // 启动观察者 - FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - fragmentTransaction.remove(mGameKaiFuFragment); - fragmentTransaction.show(mKaiFuFragment); - fragmentTransaction.commit(); - } - - - @Subscribe(threadMode = ThreadMode.MAIN) - public void onEventMainThread(EBKaiFuReset reset) { - if (SINGLE_GAME_KAIFU.equals(reset.getControl())) { - mResetTv.setVisibility(View.VISIBLE); - - FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - fragmentTransaction.hide(mKaiFuFragment); - mKaiFuFragment.onPause(); - - Bundle args = new Bundle(); - args.putString(EntranceUtils.KEY_GAMEID, reset.getGameId()); - args.putInt("curPage", mKaiFuFragment.getCurPage()); - - mGameKaiFuFragment = new KaiFuFragment(); - mGameKaiFuFragment.setArguments(args); - - fragmentTransaction.add(R.id.layout_fragment_content, mGameKaiFuFragment, KaiFuFragment.class.getSimpleName()); - fragmentTransaction.commit(); - } else if (ALL_GAME_KAIFU.equals(reset.getControl())) { - resetFragment(); - } + Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_ENTRANCE, entrance); + return new IntentFactory.Builder(context) + .setActivity(KaiFuActivity.class) + .setFragment(KaiFuWrapperFragment.class).setArgs(args).build(); } } diff --git a/app/src/main/java/com/gh/gamecenter/LoginActivity.java b/app/src/main/java/com/gh/gamecenter/LoginActivity.java index 70bbdace3a..131f33f570 100644 --- a/app/src/main/java/com/gh/gamecenter/LoginActivity.java +++ b/app/src/main/java/com/gh/gamecenter/LoginActivity.java @@ -72,7 +72,7 @@ public class LoginActivity extends BaseActivity { DisplayUtils.dip2px(this, 48), ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.CENTER_VERTICAL); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - RelativeLayout reuseActionbar = (RelativeLayout) mContentView.findViewById(R.id.reuse_actionbar); + RelativeLayout reuseActionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar); reuseActionbar.addView(mOldUserIcon, params); mOldUserIcon.setVisibility(View.GONE); diff --git a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java index a638bcf73a..3c7bba5070 100644 --- a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java @@ -247,7 +247,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener, setNavigationTitle(""); // 增加actionBar Button - RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar); + RelativeLayout reuse_actionbar = findViewById(R.id.reuse_actionbar); mNewsShare = LayoutInflater.from(this).inflate(R.layout.menu_action_share, reuse_actionbar, false); // 绑定parentView 否则会丢失宽高 mNewsShare.setVisibility(View.GONE); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mNewsShare.getLayoutParams(); diff --git a/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java b/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java index 9f4a767b46..c96f3bf4fd 100644 --- a/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java +++ b/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java @@ -3,317 +3,29 @@ package com.gh.gamecenter; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.os.Handler; import android.support.annotation.NonNull; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.text.Html; -import android.util.DisplayMetrics; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.TextView; -import com.gh.base.BaseActivity; -import com.gh.common.util.DataCollectionUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.NewsUtils; -import com.gh.common.view.VerticalItemDecoration; -import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; -import com.gh.gamecenter.adapter.viewholder.NewsTextViewHolder; -import com.gh.gamecenter.entity.NewsEntity; -import com.gh.gamecenter.retrofit.Response; -import com.gh.gamecenter.retrofit.RetrofitManager; -import com.lightgame.utils.Utils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import butterknife.BindView; -import retrofit2.HttpException; -import rx.android.schedulers.AndroidSchedulers; -import rx.functions.Func1; -import rx.schedulers.Schedulers; +import com.halo.assistant.fragment.game.GameNewsSearchResultFragment; +import com.halo.assistant.ui.IntentFactory; /** * Created by khy on 2016/8/22. * 新闻搜索界面 */ -public class NewsSearchActivity extends BaseActivity { - - @BindView(R.id.gamedetail_news_rv) - RecyclerView mNewsSearchRv; - @BindView(R.id.tv_search) - TextView mNewsSearchTv; - @BindView(R.id.reuse_none_data) - LinearLayout mNoneData; - @BindView(R.id.et_search) - EditText mNewsSearchEt; - @BindView(R.id.gamedetail_news_ll_loading) - LinearLayout mLoading; - @BindView(R.id.reuse_no_connection) - LinearLayout mNoConn; - - private LinearLayoutManager layoutManager; - private List newsEntities; - private NewsSearchAdapter searchAdapter; - - private boolean isLoadOver = true; - private boolean isRemove = false; - private boolean isNetworkError = false; - - private String searchKey; - private String gameId; - - private Handler handler = new Handler(); - - private int page = 1; +@Deprecated +public class NewsSearchActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context, String gameName, String searchKey, String gameId, String entrance) { - Intent intent = new Intent(context, NewsSearchActivity.class); - intent.putExtra(EntranceUtils.KEY_GAMENAME, gameName); - intent.putExtra(EntranceUtils.KEY_SEARCHKEY, searchKey); - intent.putExtra(EntranceUtils.KEY_GAMEID, gameId); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); - return intent; + Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_GAMENAME, gameName); + args.putString(EntranceUtils.KEY_SEARCHKEY, searchKey); + args.putString(EntranceUtils.KEY_GAMEID, gameId); + args.putString(EntranceUtils.KEY_ENTRANCE, entrance); + return new IntentFactory.Builder(context) + .setActivity(NewsSearchActivity.class) + .setFragment(GameNewsSearchResultFragment.class).setArgs(args).build(); } - - @Override - protected int getLayoutId() { - return R.layout.activity_gamedetail_news; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Intent intent = getIntent(); - String gameName = intent.getExtras().getString(EntranceUtils.KEY_GAMENAME); - searchKey = intent.getExtras().getString(EntranceUtils.KEY_SEARCHKEY); - gameId = intent.getExtras().getString(EntranceUtils.KEY_GAMEID); - - setNavigationTitle(gameName); - - DisplayMetrics outMetrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(outMetrics); - - newsEntities = new ArrayList<>(); - searchAdapter = new NewsSearchAdapter(); - - layoutManager = new LinearLayoutManager(this); - - mNewsSearchRv.setLayoutManager(layoutManager); - mNewsSearchRv.setAdapter(searchAdapter); - mNewsSearchRv.addItemDecoration(new VerticalItemDecoration(NewsSearchActivity.this, 1, false)); - - mNewsSearchEt.setText(searchKey); - - loadNewsData(page); - - mNewsSearchTv.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - searchKey = mNewsSearchEt.getText().toString().trim(); - if (searchKey.length() >= 1) { - newsEntities.clear(); - searchAdapter.notifyDataSetChanged(); - mLoading.setVisibility(View.VISIBLE); - mNoneData.setVisibility(View.GONE); - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(v.getWindowToken(), 0); - handler.postDelayed(new Runnable() { - @Override - public void run() { - page = 1; - loadNewsData(page); - } - }, 500); - - } else { - Utils.toast(NewsSearchActivity.this, getString(R.string.search_hint)); - } - - } - }); - - mNewsSearchRv.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - if (newState == RecyclerView.SCROLL_STATE_IDLE && layoutManager.findLastVisibleItemPosition() + 1 == searchAdapter.getItemCount() - && isLoadOver && !isRemove && !isNetworkError) { - isLoadOver = false; - page++; - loadNewsData(page); - } - } - }); - - mNoConn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - mNoConn.setVisibility(View.GONE); - mLoading.setVisibility(View.VISIBLE); - handler.postDelayed(new Runnable() { - @Override - public void run() { - loadNewsData(1); - } - }, 1000); - } - }); - - } - - @Override - protected void onDestroy() { - super.onDestroy(); - handler.removeCallbacksAndMessages(null); - } - - private void loadNewsData(final int page) { -// DataUtils.onEvent(this, "游戏新闻搜索", searchKey); -// DataCollectionUtils.uploadSearch(this, searchKey, "游戏新闻搜索"); - - RetrofitManager.getInstance(this).getApi().getSearchNews(gameId, searchKey, page, 20) - .map(new Func1, List>() { - @Override - public List call(List list) { - // 去掉重复数据 - return NewsUtils.removeDuplicateData(newsEntities, list); - } - }) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Response>() { - @Override - public void onResponse(List response) { - isLoadOver = true; - mLoading.setVisibility(View.GONE); - mNoneData.setVisibility(View.GONE); - - if (response.size() != 0) { - newsEntities.addAll(response); - searchAdapter.notifyDataSetChanged(); - } else { - if (page == 1) { - mNoneData.setVisibility(View.VISIBLE); - } - - isRemove = true; - searchAdapter.notifyItemChanged(searchAdapter.getItemCount() - 1); - } - - if (response.size() < 20) { - isRemove = true; - } - } - - @Override - public void onFailure(HttpException e) { - if (page == 1) { - mNoConn.setVisibility(View.VISIBLE); - mLoading.setVisibility(View.GONE); - } - isLoadOver = true; - toast(R.string.loading_failed_hint); - isNetworkError = true; - searchAdapter.notifyItemChanged(searchAdapter.getItemCount() - 1); - } - }); - } - - public class NewsSearchAdapter extends RecyclerView.Adapter { - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == 0) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.refresh_footerview, parent, false); - return new FooterViewHolder(view); - } else { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_text_item, parent, false); - return new NewsTextViewHolder(view); - } - } - - @Override - public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { - if (holder instanceof NewsTextViewHolder) { - NewsTextViewHolder viewHolder = (NewsTextViewHolder) holder; - viewHolder.title.setText(Html.fromHtml(newsEntities.get(position).getTitle())); - viewHolder.type.setVisibility(View.GONE); - viewHolder.line.setVisibility(View.GONE); - viewHolder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - NewsEntity newsEntity = newsEntities.get(holder.getPosition()); - - Map kv = new HashMap<>(); - kv.put("名字", newsEntity.getTitle()); - kv.put("位置", String.valueOf(holder.getPosition() + 1)); - DataUtils.onEvent(NewsSearchActivity.this, "点击", "游戏新闻搜索", kv); - - DataCollectionUtils.uploadClick(NewsSearchActivity.this, - "列表", "游戏新闻搜索", newsEntity.getTitle()); - - // 统计阅读量 - NewsUtils.statNewsViews(NewsSearchActivity.this, newsEntity.getId()); - NewsDetailActivity.startNewsDetailActivity(NewsSearchActivity.this, newsEntity, - mEntrance + "+(游戏新闻搜索[" + searchKey + "])"); - } - }); - } else if (holder instanceof FooterViewHolder) { - FooterViewHolder viewHolder = (FooterViewHolder) holder; - viewHolder.itemView.setPadding(0, 0, 0, 0); - if (isNetworkError) { - viewHolder.loading.setVisibility(View.GONE); - viewHolder.hint.setText(R.string.loading_failed_retry); - viewHolder.itemView.setClickable(true); - viewHolder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - isNetworkError = false; - notifyItemChanged(getItemCount() - 1); - loadNewsData(page); - } - }); - } else if (isRemove) { - viewHolder.loading.setVisibility(View.GONE); - viewHolder.hint.setText(R.string.loading_complete); - viewHolder.itemView.setClickable(false); - } else { - viewHolder.loading.setVisibility(View.VISIBLE); - viewHolder.hint.setText(R.string.loading); - viewHolder.itemView.setClickable(false); - } - } - - } - - @Override - public int getItemViewType(int position) { - if (position == newsEntities.size()) { - return 0; - } else { - return 1; - } - } - - @Override - public int getItemCount() { - if (newsEntities.isEmpty()) { - return 0; - } - return newsEntities.size() + 1; - } - - } } diff --git a/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java b/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java index ad0998542f..5ec411bf92 100644 --- a/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java @@ -138,7 +138,7 @@ public class ReceiverWaitingActivity extends BaseActivity { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - RelativeLayout reuse_actionbar = (RelativeLayout) mContentView.findViewById( + RelativeLayout reuse_actionbar = (RelativeLayout) findViewById( R.id.reuse_actionbar); reuse_actionbar.addView(hintTv, params); diff --git a/app/src/main/java/com/gh/gamecenter/SettingActivity.java b/app/src/main/java/com/gh/gamecenter/SettingActivity.java index d95b51c2fa..0a58480f71 100644 --- a/app/src/main/java/com/gh/gamecenter/SettingActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SettingActivity.java @@ -1,54 +1,11 @@ package com.gh.gamecenter; -import android.app.Dialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AlertDialog; -import android.text.TextUtils; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.RadioButton; -import android.widget.RadioGroup; -import android.widget.RelativeLayout; -import android.widget.TextView; -import com.gh.base.BaseActivity; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.EntranceUtils; -import com.gh.common.util.LoginUtils; -import com.gh.common.util.StringUtils; -import com.gh.gamecenter.entity.LoginResponseEntity; -import com.gh.gamecenter.eventbus.EBReuse; -import com.gh.gamecenter.eventbus.EBSkip; +import com.halo.assistant.fragment.SettingsFragment; import com.halo.assistant.ui.IntentFactory; -import com.halo.assistant.ui.SettingsFragment; -import com.kyleduo.switchbutton.SwitchButton; -import com.lightgame.download.FileUtils; -import com.tencent.bugly.beta.Beta; - -import org.greenrobot.eventbus.EventBus; - -import java.io.File; - -import butterknife.BindView; -import butterknife.OnClick; -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Observer; -import rx.Subscriber; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; - -import static com.gh.gamecenter.R.id.setting_rl_about; -import static java.lang.Thread.sleep; /** * 游戏设置页面 @@ -56,374 +13,17 @@ import static java.lang.Thread.sleep; * @ 吕方 * @since 0814 */ -public class SettingActivity extends BaseActivity implements OnClickListener { - - @BindView(R.id.setting_sb_autoinstall) - SwitchButton mSettingAutoinstallSb; - @BindView(R.id.setting_sb_autodelete) - SwitchButton mSettingAutodeleteSb; - @BindView(R.id.setting_sb_concerngame) - SwitchButton mSettingConcerngameSb; - @BindView(R.id.setting_tv_cache) - TextView mSettingCacheTv; - @BindView(R.id.setting_tv_size) - TextView mSettingSizeTv; - @BindView(R.id.setting_logout_tv) - TextView mSettingLoginType; - @BindView(R.id.setting_logout_rl) - RelativeLayout mSettingLoginRl; - - private SharedPreferences sp; - - private Dialog loadingDialog = null; - - private int checkSizeIndex; +public class SettingActivity extends CommonActivity { @NonNull public static Intent getIntent(Context context, String entrance) { - Intent intent = new Intent(context, SettingActivity.class); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); +// Intent intent = new Intent(context, SettingActivity.class); +// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); // return intent; - return new IntentFactory.Builder(context).setEntrance(entrance).setFragment(SettingsFragment.class).build(); - } - - @Override - public void finish() { - saveCurrentSetting(); - super.finish(); - } - - @Override - protected int getLayoutId() { - return R.layout.activity_setting; - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setNavigationTitle(getString(R.string.title_settings)); - - mSettingCacheTv.setText(getCacheSize()); - - sp = PreferenceManager.getDefaultSharedPreferences(this); - - // 未打开下载按钮,显示修复下载按钮 - if (!sp.getBoolean("isShow", true)) { - findViewById(R.id.setting_cv_fix_download).setVisibility(View.VISIBLE); - } - - mSettingAutoinstallSb.setChecked(sp.getBoolean("autoinstall", true)); - mSettingAutodeleteSb.setChecked(sp.getBoolean("autodelete", true)); - mSettingConcerngameSb.setChecked(sp.getBoolean("concerngame", true)); - - checkSizeIndex = sp.getInt("fontsize", 1); - if (checkSizeIndex == 0) { - checkSizeIndex = 1; - } - fontTextSize(checkSizeIndex); - - initLoginStatus(); - } - - private void initLoginStatus() { - LoginResponseEntity loginToken = LoginUtils.getLoginToken(this); - if (loginToken != null) { - if (!TextUtils.isEmpty(loginToken.getLoginType())) { - String loginType = loginToken.getLoginType().trim(); - switch (loginType) { - case "qq": - loginType = "QQ"; - break; - case "wechat": - loginType = "微信"; - break; - case "weibo": - loginType = "新浪微博"; - break; - default: - if (loginType.length() == 11) { - String sub1 = loginType.substring(0, 3); - String sub2 = loginType.substring(9, 11); - loginType = StringUtils.buildString(sub1, "******", sub2); - } - break; - } - mSettingLoginType.setText(loginType); - } - mSettingLoginRl.setVisibility(View.VISIBLE); - } else { - mSettingLoginRl.setVisibility(View.GONE); - } - } - - @Override - public void onPause() { - super.onPause(); - saveCurrentSetting(); - } - - private void saveCurrentSetting() { - Editor mEditor = sp.edit(); - mEditor.putBoolean("autoinstall", mSettingAutoinstallSb.isChecked()); - mEditor.putBoolean("autodelete", mSettingAutodeleteSb.isChecked()); - mEditor.putBoolean("concerngame", mSettingConcerngameSb.isChecked()); - mEditor.putInt("fontsize", checkSizeIndex); - mEditor.apply(); - } - - // 获取缓存大小 - private String getCacheSize() { - File ecDir = getExternalCacheDir(); - long cacheLength = getFolderSize(getCacheDir()); - if (ecDir != null) { - cacheLength += getFolderSize(ecDir); - } - return long2Size(cacheLength); - } - - private long getFolderSize(File folder) { - long size = 0; - size += folder.length(); - if (folder.isDirectory()) { - for (File file : folder.listFiles()) { - if (file.isDirectory()) { - size += getFolderSize(file); - } else { - size += file.length(); - } - } - } - return size; - } - - private String long2Size(Long length) { - float m = length / 1024f / 1024f; - String str = Float.toString(m); - int index = str.lastIndexOf("."); - if (index != -1 && str.length() > index + 3) { - str = str.substring(0, index + 3); - } - return str + "M"; - } - - @OnClick({ - R.id.setting_cv_fix_download, - R.id.setting_rl_autoinstall, - R.id.setting_rl_autodelete, - R.id.setting_rl_cache, - R.id.setting_cv_font_size, - R.id.setting_rl_concerngame, - R.id.setting_rl_about, - R.id.setting_logout_rl - }) - @Override - public void onClick(final View v) { - - switch (v.getId()) { - case R.id.setting_cv_fix_download: - Editor editor = sp.edit(); - editor.putBoolean("isShow", true); - editor.putBoolean("isCheckShow", false); - editor.apply(); - toast("修复成功"); - EventBus.getDefault().post(new EBReuse("Refresh")); - finish(); - new Thread() { - @Override - public void run() { - try { - sleep(800); - } catch (InterruptedException e) { - e.printStackTrace(); - } - EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 0)); - } - }.start(); - break; - case R.id.setting_rl_autoinstall: - mSettingAutoinstallSb.performClick(); - break; - case R.id.setting_rl_autodelete: - mSettingAutodeleteSb.performClick(); - break; - case R.id.setting_rl_cache: - DialogUtils.showWarningDialog(this, "清除缓存", "清空缓存后未安装的游戏可能需要重新下载,确定清空?", - new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - loadingDialog = DialogUtils.showWaitDialog(SettingActivity.this, "清除缓存中..."); - clearCache(); - } - }); - break; - case R.id.setting_cv_font_size: - fontSize(); - break; - case setting_rl_about: - if (BuildConfig.DEBUG) { - Beta.checkUpgrade(); // 手动检查热补丁 - } - startActivity(AboutActivity.getIntent(this)); - break; - case R.id.setting_rl_concerngame: - mSettingConcerngameSb.performClick(); - break; - case R.id.setting_logout_rl: - DialogUtils.showForceDialog(this, "注销登录", "退出账号即会回到游客状态,很多功能将无法使用(例如评论、客服消息),确定退出吗?", - "确定退出", "取消", new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - loadingDialog = DialogUtils.showWaitDialog(SettingActivity.this, "退出登录中..."); - LoginUtils.logout(SettingActivity.this, new LoginUtils.OnLogoutListener() { - @Override - public void onCompleted() { - LoginUtils.cleanUserData(SettingActivity.this); - if (loadingDialog != null) loadingDialog.dismiss(); - finish(); - } - }); - } - }, null); - break; - default: - break; - } - } - - private void fontTextSize(int i) { - switch (i) { - case 1: - mSettingSizeTv.setText("小字号"); - break; - case 2: - mSettingSizeTv.setText("中字号"); - break; - case 3: - mSettingSizeTv.setText("大字号"); - break; - case 4: - mSettingSizeTv.setText("特大字号"); - break; - } - } - - //设置正文字号 - private void fontSize() { - View inflate = View.inflate(this, R.layout.dialog_font_size, null); - final RadioGroup radioGroup = (RadioGroup) inflate.findViewById(R.id.font_size_radiogroup); - ((RadioButton) (radioGroup.getChildAt(checkSizeIndex - 1))).setChecked(true); - AlertDialog alertDialog = new AlertDialog.Builder(this, R.style.GhAlertDialog) - .setTitle(getString(R.string.font_primary)) - .setPositiveButton("取消", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - - } - }) - .setNegativeButton("确认", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - checkSizeIndex = radioGroup.getCheckedRadioButtonId() % 4; - - if (checkSizeIndex == 0) { - checkSizeIndex = 4; - } - dialog.cancel(); - saveCurrentSetting(); - fontTextSize(checkSizeIndex); - } - }) - .setView(inflate) - .create(); - alertDialog.show(); - - TextView mesage = (TextView) alertDialog.findViewById(android.R.id.message); - Button positiveBtn = alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE); - Button negativeBtn = alertDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE); - - positiveBtn.setTextSize(14); - positiveBtn.setTextColor(ContextCompat.getColor(this, R.color.theme)); - negativeBtn.setTextSize(14); - negativeBtn.setTextColor(ContextCompat.getColor(this, R.color.theme)); - if (mesage != null) { - mesage.setTextSize(14); - mesage.setTextColor(ContextCompat.getColor(this, R.color.system_bar)); - } - -// final Dialog dialog = new Dialog(this); -// View inflate = View.inflate(this, R.layout.dialog_font_size, null); -// TextView tv_negative = (TextView) inflate.findViewById(R.id.font_size_negative); -// TextView tv_positive = (TextView) inflate.findViewById(R.id.font_size_positive); -// final RadioGroup radioGroup = (RadioGroup) inflate.findViewById(R.id.font_size_radiogroup); -// ((RadioButton) (radioGroup.getChildAt(checkSizeIndex - 1))).setChecked(true); -// -// tv_negative.setOnClickListener(new OnClickListener() { -// @Override -// public void onClick(View v) { -// dialog.cancel(); -// } -// }); -// tv_positive.setOnClickListener(new OnClickListener() { -// @Override -// public void onClick(View v) { -// checkSizeIndex = radioGroup.getCheckedRadioButtonId() % 4; -// -// if (checkSizeIndex == 0) { -// checkSizeIndex = 4; -// } -// dialog.cancel(); -// saveCurrentSetting(); -// fontTextSize(checkSizeIndex); -// } -// }); -// dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); -// dialog.setContentView(inflate); -// dialog.show(); - } - - // 清除缓存 - private void clearCache() { - - Observable.create(new OnSubscribe() { - @Override - public void call(Subscriber subscriber) { - - long start = System.currentTimeMillis(); - FileUtils.deleteFolder(getCacheDir()); - FileUtils.deleteFolder(getExternalCacheDir()); - long time = System.currentTimeMillis() - start; - if (time < 1000) { - try { - sleep(1000 - time); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - subscriber.onCompleted(); - } - - }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { - @Override - public void onCompleted() { - if (loadingDialog != null) { - loadingDialog.dismiss(); - } - mSettingCacheTv.setText(getCacheSize()); - toast("缓存清除成功"); - } - - @Override - public void onError(Throwable e) { - - } - - @Override - public void onNext(Object o) { - - } - }); - + return new IntentFactory.Builder(context) + .setEntrance(entrance) + .setActivity(SettingActivity.class) + .setFragment(SettingsFragment.class).build(); } } diff --git a/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java b/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java index 6fc1a00bcf..a97955a3da 100644 --- a/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java +++ b/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java @@ -88,7 +88,7 @@ public class UserInfoEditActivity extends BaseActivity implements LoginUtils.onC params.addRule(RelativeLayout.CENTER_VERTICAL); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.setMargins(0, 0, DisplayUtils.dip2px(this, 18), 0); - RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar); + RelativeLayout reuse_actionbar = findViewById(R.id.reuse_actionbar); reuse_actionbar.addView(mSaveTv, params); if (mUserInfoEntity != null) { diff --git a/app/src/main/java/com/gh/gamecenter/WebActivity.java b/app/src/main/java/com/gh/gamecenter/WebActivity.java index 840de4bdcf..52c64c45e5 100644 --- a/app/src/main/java/com/gh/gamecenter/WebActivity.java +++ b/app/src/main/java/com/gh/gamecenter/WebActivity.java @@ -162,7 +162,7 @@ public class WebActivity extends BaseActivity implements View.OnClickListener{ } // 增加actionBar Button - RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar); + RelativeLayout reuse_actionbar = findViewById(R.id.reuse_actionbar); mShareIv = LayoutInflater.from(this).inflate(R.layout.menu_action_share, reuse_actionbar, false); // 绑定parentView 否则会丢失宽高 RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mShareIv.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); diff --git a/app/src/main/java/com/gh/gamecenter/adapter/ConcernAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/ConcernAdapter.java index 973012be0c..5be6016ff7 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/ConcernAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/ConcernAdapter.java @@ -1,5 +1,6 @@ package com.gh.gamecenter.adapter; +import android.app.Activity; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -42,7 +43,8 @@ public class ConcernAdapter extends BaseRecyclerAdapter { private String mEntrance; - public ConcernAdapter(ConcernActivity context, OnRequestCallBackListener listener, String entrance) { + //TODO remove activity + public ConcernAdapter(Activity context, OnRequestCallBackListener listener, String entrance) { super(context); mListener = listener; mEntrance = entrance; @@ -91,8 +93,6 @@ public class ConcernAdapter extends BaseRecyclerAdapter { public void onBindViewHolder(final ConcernViewHolder holder, int position) { final GameEntity gameEntity = mConcernGameList.get(position); if (mConcernGameList != null && position < mConcernGameList.size()) { - - if (gameEntity.isLibaoExists()) { holder.concern_libao_icon.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameTestViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameTestViewHolder.java index 104ab03e49..c05659cbe8 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameTestViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameTestViewHolder.java @@ -17,7 +17,7 @@ import com.gh.common.util.StringUtils; import com.gh.gamecenter.R; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.SubjectEntity; -import com.gh.gamecenter.game.GameFragmentAdapter; +import com.halo.assistant.fragment.game.GameFragmentAdapter; import java.util.Date; import java.util.List; diff --git a/app/src/main/java/com/gh/gamecenter/collection/CollectionFragment.java b/app/src/main/java/com/gh/gamecenter/collection/CollectionWrapperFragment.java similarity index 84% rename from app/src/main/java/com/gh/gamecenter/collection/CollectionFragment.java rename to app/src/main/java/com/gh/gamecenter/collection/CollectionWrapperFragment.java index f8f1e7b304..1f64184a88 100644 --- a/app/src/main/java/com/gh/gamecenter/collection/CollectionFragment.java +++ b/app/src/main/java/com/gh/gamecenter/collection/CollectionWrapperFragment.java @@ -17,9 +17,14 @@ import butterknife.BindView; /** * Created by khy on 18/07/17. + * + * 我的收藏viewpager页面 + * */ +public class CollectionWrapperFragment extends BaseFragment_ViewPager_Checkable { -public class CollectionFragment extends BaseFragment_ViewPager_Checkable { + public static final int INDEX_TOOL = 0; + public static final int INDEX_ARTICLE = 1; @BindView(R.id.slidebar_line) View mSlideLine; @@ -27,10 +32,10 @@ public class CollectionFragment extends BaseFragment_ViewPager_Checkable { private LinearLayout.LayoutParams mLayoutParams; private int mWindowWidth; - public static CollectionFragment newInstance(int checkedIndex) { + public static CollectionWrapperFragment newInstance(int checkedIndex) { final Bundle args = new Bundle(1); args.putInt(ARGS_INDEX, checkedIndex); - final CollectionFragment fragment = new CollectionFragment(); + final CollectionWrapperFragment fragment = new CollectionWrapperFragment(); fragment.setArguments(args); return fragment; } @@ -64,7 +69,7 @@ public class CollectionFragment extends BaseFragment_ViewPager_Checkable { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + setNavigationTitle("我的收藏"); DisplayMetrics outMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics); mWindowWidth = outMetrics.widthPixels / 2; diff --git a/app/src/main/java/com/gh/gamecenter/fragment/GameFragment.java b/app/src/main/java/com/gh/gamecenter/fragment/GameFragment.java index 254114df7f..fdbfd63f60 100644 --- a/app/src/main/java/com/gh/gamecenter/fragment/GameFragment.java +++ b/app/src/main/java/com/gh/gamecenter/fragment/GameFragment.java @@ -24,7 +24,7 @@ import com.gh.gamecenter.eventbus.EBNetworkState; import com.gh.gamecenter.eventbus.EBPackage; import com.gh.gamecenter.eventbus.EBReuse; import com.gh.gamecenter.eventbus.EBUISwitch; -import com.gh.gamecenter.game.GameFragmentAdapter; +import com.halo.assistant.fragment.game.GameFragmentAdapter; import com.lightgame.download.DataWatcher; import com.lightgame.download.DownloadEntity; diff --git a/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuFragment.java b/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuFragment.java index d12fef9b79..e032d0fc2d 100644 --- a/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuFragment.java +++ b/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuFragment.java @@ -4,14 +4,18 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.widget.CheckedTextView; import android.widget.LinearLayout; +import android.widget.TextView; -import com.halo.assistant.HaloApp; import com.gh.base.adapter.FragmentAdapter; import com.gh.base.fragment.BaseFragment; import com.gh.gamecenter.R; +import com.halo.assistant.HaloApp; import java.util.ArrayList; import java.util.List; @@ -22,7 +26,7 @@ import butterknife.OnClick; /** * Created by khy on 20/08/17. */ - +//TODO 改写viewpgerfragment public class KaiFuFragment extends BaseFragment { @BindView(R.id.kaifu_tabbar_today) @@ -38,7 +42,6 @@ public class KaiFuFragment extends BaseFragment { private List mFragments; - @Override protected int getLayoutId() { return R.layout.fragment_kaifu; @@ -47,7 +50,6 @@ public class KaiFuFragment extends BaseFragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mFragments = new ArrayList<>(); for (int i = 0; i < 3; i++) { KaiFuVpFragment kaiFuVpFragment = new KaiFuVpFragment(); diff --git a/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuVpAdapter.java b/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuVpAdapter.java index e92755cdaa..4af4955d63 100644 --- a/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuVpAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuVpAdapter.java @@ -44,9 +44,6 @@ import retrofit2.HttpException; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; -import static com.gh.gamecenter.KaiFuActivity.ALL_GAME_KAIFU; -import static com.gh.gamecenter.KaiFuActivity.SINGLE_GAME_KAIFU; - /** * Created by khy on 18/08/17. @@ -324,14 +321,14 @@ public class KaiFuVpAdapter extends BaseRecyclerAdapter { dialog.cancel(); switch (skipTv.getText().toString()) { case "只看这个游戏": - EventBus.getDefault().post(new EBKaiFuReset(SINGLE_GAME_KAIFU, gameEntity.getId())); + EventBus.getDefault().post(new EBKaiFuReset(KaiFuWrapperFragment.SINGLE_GAME_KAIFU, gameEntity.getId())); break; case "进入游戏详情": GameDetailActivity.startGameDetailActivity(mContext, gameEntity, StringUtils.buildString(entrance, "+(开服表[", String.valueOf(position), "])")); break; case "返回所有游戏": - EventBus.getDefault().post(new EBKaiFuReset(ALL_GAME_KAIFU, gameEntity.getId())); + EventBus.getDefault().post(new EBKaiFuReset(KaiFuWrapperFragment.ALL_GAME_KAIFU, gameEntity.getId())); break; } } diff --git a/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuWrapperFragment.java b/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuWrapperFragment.java new file mode 100644 index 0000000000..8e86da2fd3 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/kaifu/KaiFuWrapperFragment.java @@ -0,0 +1,108 @@ +package com.gh.gamecenter.kaifu; + +import android.os.Bundle; +import android.support.v4.app.FragmentTransaction; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.TextView; + +import com.gh.base.fragment.BaseFragment; +import com.gh.common.util.EntranceUtils; +import com.gh.gamecenter.R; +import com.gh.gamecenter.eventbus.EBKaiFuReset; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +/** + * Created by CsHeng on 14/12/2017. + *

+ * 用于控制开服界面的切换 + */ +public class KaiFuWrapperFragment extends BaseFragment { + + public static final String SINGLE_GAME_KAIFU = "SINGLE_GAME_KAIFU"; + public static final String ALL_GAME_KAIFU = "ALL_GAME_KAIFU"; + + private MenuItem mResetMenuItem; + private KaiFuFragment mKaiFuFragment; + private KaiFuFragment mGameKaiFuFragment; + + @Override + protected int getLayoutId() { + return R.layout.fragment_kaifu_wrapper; + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + super.onCreateOptionsMenu(menu, inflater); + inflater.inflate(R.menu.menu_button, menu); + mResetMenuItem = menu.findItem(R.id.menu_button); + mResetMenuItem.setTitle(R.string.menu_text_reset); + mResetMenuItem.setVisible(false); + final TextView textView = mResetMenuItem.getActionView().findViewById(R.id.tv_menu_button); + textView.setText(R.string.menu_text_reset); + textView.setOnClickListener(this); + } + + @Override + protected boolean handleOnClick(View view) { + switch (view.getId()) { + case R.id.tv_menu_button: + resetFragment(); + return true; + + } + return super.handleOnClick(view); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setHasOptionsMenu(true); + setNavigationTitle("开服表"); + + FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction(); + mKaiFuFragment = new KaiFuFragment(); + fragmentTransaction.add(R.id.layout_fragment_content, mKaiFuFragment); + fragmentTransaction.commit(); + } + + private void resetFragment() { + mKaiFuFragment.setCurPage(mGameKaiFuFragment.getCurPage()); + + mResetMenuItem.setVisible(false); + mKaiFuFragment.onResume(); // 启动观察者 + FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction(); + fragmentTransaction.remove(mGameKaiFuFragment); + fragmentTransaction.show(mKaiFuFragment); + fragmentTransaction.commit(); + } + + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(EBKaiFuReset reset) { + if (SINGLE_GAME_KAIFU.equals(reset.getControl())) { + mResetMenuItem.setVisible(true); + + FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction(); + fragmentTransaction.hide(mKaiFuFragment); + mKaiFuFragment.onPause(); + + Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_GAMEID, reset.getGameId()); + args.putInt("curPage", mKaiFuFragment.getCurPage()); + + mGameKaiFuFragment = new KaiFuFragment(); + mGameKaiFuFragment.setArguments(args); + + fragmentTransaction.add(R.id.layout_fragment_content, mGameKaiFuFragment, KaiFuFragment.class.getSimpleName()); + fragmentTransaction.commit(); + } else if (ALL_GAME_KAIFU.equals(reset.getControl())) { + resetFragment(); + } + } + +} diff --git a/app/src/main/java/com/gh/gamecenter/login/LoginFragment.java b/app/src/main/java/com/gh/gamecenter/login/LoginFragment.java index 088aa4c313..cc756f2a48 100644 --- a/app/src/main/java/com/gh/gamecenter/login/LoginFragment.java +++ b/app/src/main/java/com/gh/gamecenter/login/LoginFragment.java @@ -35,7 +35,7 @@ public class LoginFragment extends BaseLoginFragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - initTitle("登录光环助手"); + setNavigationTitle("登录光环助手"); } @Override diff --git a/app/src/main/java/com/gh/gamecenter/login/LoginOldUserFragment.java b/app/src/main/java/com/gh/gamecenter/login/LoginOldUserFragment.java index af550819b2..32f6d39ada 100644 --- a/app/src/main/java/com/gh/gamecenter/login/LoginOldUserFragment.java +++ b/app/src/main/java/com/gh/gamecenter/login/LoginOldUserFragment.java @@ -14,7 +14,7 @@ public class LoginOldUserFragment extends BaseLoginFragment{ @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - initTitle("老用户登录"); + setNavigationTitle("老用户登录"); } @Override diff --git a/app/src/main/java/com/gh/gamecenter/news/News3Fragment.java b/app/src/main/java/com/gh/gamecenter/news/News3Fragment.java index f894d6f75d..9a391136d4 100644 --- a/app/src/main/java/com/gh/gamecenter/news/News3Fragment.java +++ b/app/src/main/java/com/gh/gamecenter/news/News3Fragment.java @@ -124,11 +124,11 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On @Override public void call(Void aVoid) { if (mConcernGame.size() > 1 || (mConcernGame.size() == 1 - && !getContext().getString(R.string.ghzs_id).equals(mConcernGame.get(0).getId()))) { + && !getString(R.string.ghzs_id).equals(mConcernGame.get(0).getId()))) { OnSelectGameClickListener(); } else { Intent intent = ConcernActivity.getIntent(getContext(), "资讯(攻略-我关注的游戏)"); - getContext().startActivity(intent); + startActivity(intent); } } }); @@ -162,7 +162,7 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On selectGameRv.setLayoutParams(params); } - int widthPixels = getContext().getResources().getDisplayMetrics().widthPixels; + int widthPixels = getResources().getDisplayMetrics().widthPixels; allGameRl.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10, DisplayUtils.dip2px(getContext(), 50))); @@ -171,7 +171,7 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On public void onClick(View v) { isShowPopupBg(false); Intent intent = ConcernActivity.getIntent(getContext(), "资讯(攻略-我关注的游戏)"); - getContext().startActivity(intent); + startActivity(intent); } }); diff --git a/app/src/main/java/com/gh/gamecenter/normal/NormalFragment.java b/app/src/main/java/com/gh/gamecenter/normal/NormalFragment.java index 59d1480222..876351bc9f 100644 --- a/app/src/main/java/com/gh/gamecenter/normal/NormalFragment.java +++ b/app/src/main/java/com/gh/gamecenter/normal/NormalFragment.java @@ -12,7 +12,7 @@ import com.gh.gamecenter.NormalActivity; public abstract class NormalFragment extends BaseFragment { - protected void initTitle(String title) { + protected void setNavigationTitle(String title) { if (getActivity() instanceof NormalActivity) { ((NormalActivity) getActivity()).setNavigationTitle(title); } diff --git a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java index c9c7c4de0a..e7450e70dd 100644 --- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java +++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java @@ -43,7 +43,7 @@ import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; import com.halo.assistant.HaloApp; import com.halo.assistant.ui.IntentFactory; -import com.halo.assistant.ui.SettingsFragment; +import com.halo.assistant.fragment.SettingsFragment; import com.lightgame.config.CommonDebug; import com.lightgame.utils.Utils; import com.tencent.connect.common.Constants; diff --git a/app/src/main/java/com/halo/assistant/fragment/AboutFragment.java b/app/src/main/java/com/halo/assistant/fragment/AboutFragment.java new file mode 100644 index 0000000000..d3371d0324 --- /dev/null +++ b/app/src/main/java/com/halo/assistant/fragment/AboutFragment.java @@ -0,0 +1,110 @@ +package com.halo.assistant.fragment; + +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.gh.base.fragment.BaseFragment; +import com.gh.common.util.PackageUtils; +import com.gh.common.util.StringUtils; +import com.gh.gamecenter.R; +import com.gh.gamecenter.WebActivity; +import com.gh.gamecenter.manager.UpdateManager; +import com.tencent.bugly.beta.tinker.TinkerManager; + +import java.lang.ref.WeakReference; + +import butterknife.BindView; +import butterknife.OnClick; +import butterknife.OnLongClick; + +/** + * Created by CsHeng on 14/12/2017. + */ + +public class AboutFragment extends BaseFragment { + + @BindView(R.id.about_version_tv) + TextView mAboutVersion; + @BindView(R.id.setting_rl_update) + RelativeLayout mAboutUpdateRl; + @BindView(R.id.about_version_pb) + ProgressBar mAboutPb; + @BindView(R.id.about_tv_version) + TextView mVersionName; + + private Handler handler = new MyHandler(this); + + @Override + protected int getLayoutId() { + return R.layout.fragment_about; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setNavigationTitle(getString(R.string.title_about)); + +// ((TextView) findViewById(R.id.about_tv_version)).setText("V" + PackageUtils.getVersionName(this)); + mVersionName.setText("V" + PackageUtils.getPatchVersionName()); // TODO 版本号暂时与gradle versionName不一致 + } + + @Override + public void onDestroy() { + super.onDestroy(); + handler.removeCallbacksAndMessages(null); + } + + @OnClick({R.id.about_shengming, R.id.setting_rl_update}) + public void OnClick(View view) { + if (view.getId() == R.id.setting_rl_update) { + UpdateManager.getInstance(getContext()).checkUpdate(false, handler); // 检出更新 + } else if (view.getId() == R.id.about_shengming) { + Intent intent = WebActivity.getWebIntent(getContext()); + startActivity(intent); + } + } + + @OnLongClick(R.id.about_tv_version) + public boolean OnLongClick(View view) { + if (view.getId() == R.id.about_tv_version) { + String tinkerId = TinkerManager.getNewTinkerId(); + if (!TextUtils.isEmpty(tinkerId)) { + mVersionName.setText("V" + PackageUtils.getPatchVersionName() + "." + tinkerId); + } else { + toastLong(R.string.toast_upload_latest); + } + } + return false; + } + + private static class MyHandler extends Handler { + + private WeakReference mWeakReference; + + public MyHandler(AboutFragment fragment) { + mWeakReference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + final AboutFragment fragment = mWeakReference.get(); + if (fragment != null) { + if (msg.what == 0) { + final String version = (String) msg.obj; + fragment.mAboutVersion.setText(StringUtils.buildString("发现新版本 V", version)); + } else if (msg.what == 1) { + fragment.mAboutVersion.setText(R.string.toast_upload_latest); + } + } + } + } + +} diff --git a/app/src/main/java/com/halo/assistant/fragment/ApkCleanerFragment.java b/app/src/main/java/com/halo/assistant/fragment/ApkCleanerFragment.java new file mode 100644 index 0000000000..d4e47c6c93 --- /dev/null +++ b/app/src/main/java/com/halo/assistant/fragment/ApkCleanerFragment.java @@ -0,0 +1,238 @@ +package com.halo.assistant.fragment; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.util.ArrayMap; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.text.Html; +import android.view.View; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.gh.base.fragment.BaseFragment; +import com.gh.common.util.DialogUtils; +import com.gh.common.view.VerticalItemDecoration; +import com.gh.gamecenter.MainActivity; +import com.gh.gamecenter.R; +import com.gh.gamecenter.adapter.CleanApkAdapter; +import com.gh.gamecenter.entity.InstallGameEntity; +import com.gh.gamecenter.eventbus.EBSkip; +import com.lightgame.utils.Utils; + +import org.greenrobot.eventbus.EventBus; + +import java.io.File; +import java.text.DecimalFormat; +import java.util.List; + +import butterknife.BindView; +import butterknife.OnClick; + +/** + * Created by CsHeng on 14/12/2017. + *

+ * 扫描并删除apk + */ +public class ApkCleanerFragment extends BaseFragment implements CleanApkAdapter.OnScanListener { + + @BindView(R.id.apk_count) + TextView mApkCount; + @BindView(R.id.apk_rv) + RecyclerView mApkRv; + @BindView(R.id.delete_btn) + TextView mApkDeleteBtn; + @BindView(R.id.select_game_all) + CheckBox mApkSelectAll; + @BindView(R.id.scan_pb) + ProgressBar mScanPb; + @BindView(R.id.reuse_nodata_skip_tv_hint) + TextView mNodataSkipTv; + @BindView(R.id.reuse_nodata_skip_tv_btn) + TextView mNodataSkipBtn; + @BindView(R.id.reuse_nodata_skip) + LinearLayout mNodataSkipLl; + @BindView(R.id.delete_bottom) + LinearLayout mDeleteBottom; + @BindView(R.id.select_game_installed_ll) + RelativeLayout mInstallAllData; + + private CleanApkAdapter mAdapter; + + @Override + protected int getLayoutId() { + return R.layout.fragment_apk_cleaner; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setNavigationTitle(getString(R.string.title_clean_apk)); + + mNodataSkipLl.setVisibility(View.GONE); + + mAdapter = new CleanApkAdapter(getContext(), this, mApkDeleteBtn, mApkSelectAll); + mApkRv.setLayoutManager(new LinearLayoutManager(getContext())); + mApkRv.addItemDecoration(new VerticalItemDecoration(getContext(), 8, true)); + mApkRv.setAdapter(mAdapter); + + mApkSelectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + ArrayMap selectPosition = new ArrayMap<>(); + ArrayMap selectPosition1 = mAdapter.getSelectPosition(); + int itemCount = mAdapter.getItemCount(); + if (isChecked) { + for (int i = 0; i < itemCount; i++) { + selectPosition.put(i, true); + } + } else { + int selectCount = 0; + for (Integer integer : selectPosition1.keySet()) { + if (selectPosition1.get(integer)) { + selectCount++; + } + } + + if (selectCount != itemCount) { + return; + } + + for (int i = 0; i < itemCount; i++) { + selectPosition.put(i, false); + } + } + + mAdapter.setSelectPosition(selectPosition); + mAdapter.notifyItemRangeChanged(0, itemCount); + mAdapter.checkBoxControl(isChecked, 0); + } + }); + + mNodataSkipBtn.setText("去首页看看"); + mNodataSkipTv.setText("安装包已清理干净\n快去发现更多好玩的游戏吧!"); + mNodataSkipTv.setLineSpacing(0, 1.5f); + + } + + @OnClick({R.id.delete_btn, R.id.reuse_nodata_skip_tv_btn}) + public void onClick(View view) { + switch (view.getId()) { + case R.id.delete_btn: { + String s = mApkDeleteBtn.getText().toString(); + if ("停止扫描".equals(s)) { + mAdapter.isStopScan(); + } else { + if ("一键删除".equals(s)) { + Utils.toast(getContext(), "请选择需要删除的安装包"); + return; + } + + final List apkList = mAdapter.getApkList(); + final ArrayMap selectPosition = mAdapter.getSelectPosition(); + + for (int i = 0; i < apkList.size(); i++) { + if (selectPosition.get(i) && apkList.get(i).getInstallStatus() == 1) { + DialogUtils.showWarningDialog(getContext(), "删除安装包" + , Html.fromHtml(getString(R.string.delete_apk_hint)) + , "取消 ", "确定" + , new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + deleteApk(apkList, selectPosition); + } + }, null); + return; + } + } + + deleteApk(apkList, selectPosition); + } + break; + } + case R.id.reuse_nodata_skip_tv_btn: { + Intent intent = MainActivity.getMainIntent(getContext()); + startActivity(intent); + + mNodataSkipBtn.postDelayed(new Runnable() { + @Override + public void run() { + EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 0)); + } + }, 300); + break; + } + } + } + + private void deleteApk(List apkList, ArrayMap selectPosition) { + long size = 0; + for (int i = 0; i < apkList.size(); i++) { + if (selectPosition.get(i)) { + InstallGameEntity installGameEntity = apkList.get(i); + size = size + installGameEntity.getGameSize(); + File file = new File(installGameEntity.getGamePath()); + if (file.isFile() && file.exists()) { + file.delete(); + mAdapter.deleteApk(i); + i--; + } + } + } + + double allSize = (((float) size / 1024) / 1024); + DecimalFormat df = new DecimalFormat("#.00"); + String sizeName = df.format(allSize) + "MB"; + Utils.toast(getContext(), "删除成功,已为您节省" + sizeName + "空间"); + mApkDeleteBtn.setText("一键删除"); + mAdapter.notifyDataSetChanged(); // 刷新Adapter position + + updateScanData(); + + if (apkList.size() == 0) { // 全部删除 + mNodataSkipLl.setVisibility(View.VISIBLE); + mInstallAllData.setVisibility(View.GONE); + mDeleteBottom.setVisibility(View.GONE); + } + } + + private void updateScanData() { + long allSize = 0; + List apkList = mAdapter.getApkList(); + for (InstallGameEntity installGameEntity : apkList) { + allSize = allSize + installGameEntity.getGameSize(); + } + + double size = (((float) allSize / 1024) / 1024); + DecimalFormat df = new DecimalFormat("0.00"); + String sizeName = df.format(size) + "MB"; + + mApkCount.setText(Html.fromHtml(getString(R.string.clean_apk_count, apkList.size(), sizeName))); + } + + @Override + public void onScanOver() { + mApkDeleteBtn.setText("立即删除"); + mApkDeleteBtn.setBackgroundResource(R.drawable.game_item_btn_red_style); + + updateScanData(); + + mScanPb.setVisibility(View.GONE); + mApkSelectAll.setVisibility(View.VISIBLE); + mApkSelectAll.setChecked(true); + } + + @Override + public void noData() { + mNodataSkipBtn.setText("去首页看看"); + mNodataSkipTv.setText("暂无安装包"); + mNodataSkipLl.setVisibility(View.VISIBLE); + mInstallAllData.setVisibility(View.GONE); + mDeleteBottom.setVisibility(View.GONE); + } + +} diff --git a/app/src/main/java/com/halo/assistant/fragment/ConcernFragment.java b/app/src/main/java/com/halo/assistant/fragment/ConcernFragment.java new file mode 100644 index 0000000000..3b308bb02b --- /dev/null +++ b/app/src/main/java/com/halo/assistant/fragment/ConcernFragment.java @@ -0,0 +1,207 @@ +package com.halo.assistant.fragment; + +import android.os.Bundle; +import android.support.v4.content.ContextCompat; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.gh.base.OnRequestCallBackListener; +import com.gh.base.fragment.BaseFragment; +import com.gh.common.view.Concern_LinearLayout; +import com.gh.gamecenter.LoginActivity; +import com.gh.gamecenter.R; +import com.gh.gamecenter.adapter.ConcernAdapter; +import com.gh.gamecenter.adapter.ConcernRecommendAdapter; +import com.gh.gamecenter.entity.GameEntity; +import com.gh.gamecenter.eventbus.EBConcernChanged; +import com.gh.gamecenter.eventbus.EBReuse; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.List; + +import butterknife.BindView; +import butterknife.OnClick; + +import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG; + +/** + * Created by CsHeng on 14/12/2017. + *

+ * 关注页面 + */ +public class ConcernFragment extends BaseFragment implements View.OnClickListener, OnRequestCallBackListener { + + @BindView(R.id.concern_rv_show) + RecyclerView mConcernRv; + @BindView(R.id.concern_rv_recommend) + RecyclerView mConcernRecommendRv; + @BindView(R.id.concern_rl_title) + RelativeLayout mConcernTitleRl; + @BindView(R.id.reuse_none_data) + LinearLayout mNoneData; + @BindView(R.id.reuse_tv_none_data) + TextView mNoDataTv; + @BindView(R.id.reuse_no_connection) + LinearLayout mNoConn; + + private ConcernAdapter concernAdapter; + private ConcernRecommendAdapter concernRecommendAdapter; + + @Override + protected int getLayoutId() { + return R.layout.fragment_concern; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setNavigationTitle(getString(R.string.title_concern)); + + mConcernTitleRl.setOnClickListener(this); + + mConcernRv.setHasFixedSize(true); + mConcernRv.setLayoutManager(new GridLayoutManager(getContext(), 3)); + concernAdapter = new ConcernAdapter(getActivity(), this, mEntrance); + mConcernRv.setAdapter(concernAdapter); + + mConcernRecommendRv.setHasFixedSize(true); + mConcernRecommendRv.setLayoutManager(new GridLayoutManager(getContext(), 4)); + + } + + @Override + public void loadDone() { // 关注推荐 回调 + mConcernTitleRl.setVisibility(View.VISIBLE); + mConcernRecommendRv.setVisibility(View.VISIBLE); + int size = concernRecommendAdapter.getRecommendGameList().size(); + mConcernRecommendRv.setLayoutManager(new GridLayoutManager(getContext(), size > 4 ? 4 : size)); + mConcernRecommendRv.getAdapter().notifyDataSetChanged(); + } + + // 关注的游戏加载完成 再加载热门推荐(根据已关注的游戏过滤) + @Override + public void loadDone(Object obj) { + mNoConn.setVisibility(View.GONE); + mNoneData.setVisibility(View.GONE); + + concernRecommendAdapter = new ConcernRecommendAdapter(getContext(), this, (List) obj, mEntrance); + mConcernRecommendRv.setAdapter(concernRecommendAdapter); + + if (obj == null) { // 未登录状态 + mNoneData.setVisibility(View.VISIBLE); + mConcernRv.setVisibility(View.GONE); + mNoDataTv.setText(R.string.login_hint); + mNoDataTv.setTextColor(ContextCompat.getColor(getContext(), R.color.theme)); + } + } + + @Override + public void loadError() { + mNoConn.setVisibility(View.VISIBLE); + mNoneData.setVisibility(View.GONE); + } + + @Override + public void loadEmpty() { + if (concernAdapter.getConcernGameList() == null + || concernAdapter.getConcernGameList().isEmpty()) { + mNoneData.setVisibility(View.VISIBLE); + mConcernRv.setVisibility(View.GONE); + mNoDataTv.setText(R.string.game_empty); + mNoDataTv.setTextColor(ContextCompat.getColor(getContext(), R.color.c7c7c7)); + } + if (concernRecommendAdapter.getRecommendGameList() == null + || concernRecommendAdapter.getRecommendGameList().isEmpty()) { + mConcernTitleRl.setVisibility(View.GONE); + mConcernRecommendRv.setVisibility(View.GONE); + } else { + if (concernRecommendAdapter.getRecommendGameList().size() < 4) { + mConcernRecommendRv.setLayoutManager( + new GridLayoutManager(getContext(), concernRecommendAdapter.getRecommendGameList().size())); + } + } + } + + @OnClick({R.id.concern_rl_title, R.id.reuse_tv_none_data}) + public void onClick(View v) { + switch (v.getId()) { + case R.id.concern_rl_title: + if (mConcernRecommendRv.getVisibility() == View.VISIBLE) { + ((Concern_LinearLayout) view).hideRecyclerView(); + } else { + ((Concern_LinearLayout) view).showRecyclerView(); + } + break; + case R.id.reuse_tv_none_data: + String hint = getString(R.string.login_hint); + if (hint.equals(mNoDataTv.getText().toString())) + startActivity(LoginActivity.getIntent(getContext(), false)); + break; + } + } + + // 关注事件 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(EBConcernChanged changed) { + if (!changed.isSingle()) { + return; + } + if (changed.isConcern()) { + GameEntity concernGame = concernRecommendAdapter.concernGame(changed.getGameId()); + + if (concernGame != null) { + concernAdapter.getConcernGameList().add(0, concernGame); + concernAdapter.notifyDataSetChanged(); + if (mNoneData.getVisibility() == View.VISIBLE) { + mNoneData.setVisibility(View.GONE); + mConcernRv.setVisibility(View.VISIBLE); + } + } + + for (int i = 0, size = concernRecommendAdapter.getRecommendGameList().size(); i < size; i++) { + if (changed.getGameId().equals(concernRecommendAdapter.getRecommendGameList().get(i).getId())) { + concernRecommendAdapter.getRecommendGameList().remove(i); + concernRecommendAdapter.notifyItemRemoved(i); // 删除动画 + concernRecommendAdapter.notifyDataSetChanged(); // 防止列表串行 + if (concernRecommendAdapter.getRecommendGameList().isEmpty()) { + mConcernTitleRl.setVisibility(View.GONE); + mConcernRecommendRv.setVisibility(View.GONE); + } + break; + } + } + } else { + GameEntity gameEntity = concernAdapter.cancelConcern(changed.getGameId()); + if (gameEntity != null) { + concernRecommendAdapter.getRecommendGameList().add(0, gameEntity); + concernRecommendAdapter.notifyDataSetChanged(); + } + + if (concernRecommendAdapter.getRecommendGameList().isEmpty()) { + mConcernTitleRl.setVisibility(View.GONE); + mConcernRecommendRv.setVisibility(View.GONE); + } else { + mConcernTitleRl.setVisibility(View.VISIBLE); + mConcernRecommendRv.setVisibility(View.VISIBLE); + } + } + } + + // 登录事件 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(EBReuse reuse) { + if (reuse.getType().equals(LOGIN_TAG)) { // 登入 + concernAdapter = new ConcernAdapter(getActivity(), this, mEntrance); + mConcernRv.setAdapter(concernAdapter); + mConcernRv.setVisibility(View.VISIBLE); + } + } + +} diff --git a/app/src/main/java/com/halo/assistant/ui/SettingsFragment.java b/app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java similarity index 87% rename from app/src/main/java/com/halo/assistant/ui/SettingsFragment.java rename to app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java index 9b8ea9672e..2286e5e5bc 100644 --- a/app/src/main/java/com/halo/assistant/ui/SettingsFragment.java +++ b/app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java @@ -1,4 +1,4 @@ -package com.halo.assistant.ui; +package com.halo.assistant.fragment; import android.app.Dialog; import android.content.DialogInterface; @@ -67,11 +67,11 @@ public class SettingsFragment extends BaseFragment { @BindView(R.id.setting_logout_rl) RelativeLayout mSettingLoginRl; - private SharedPreferences sp; + private SharedPreferences mSharedPreferences; - private Dialog loadingDialog = null; + private Dialog mLoadingDialog = null; - private int checkSizeIndex; + private int mCheckSizeIndex; @Override public void onStop() { @@ -81,32 +81,32 @@ public class SettingsFragment extends BaseFragment { @Override protected int getLayoutId() { - return R.layout.activity_setting; + return R.layout.fragment_setting; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - initTitle(getString(R.string.title_settings)); + setNavigationTitle(getString(R.string.title_settings)); mSettingCacheTv.setText(getCacheSize()); - sp = PreferenceManager.getDefaultSharedPreferences(getContext()); + mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); // 未打开下载按钮,显示修复下载按钮 - if (!sp.getBoolean("isShow", true)) { + if (!mSharedPreferences.getBoolean("isShow", true)) { view.findViewById(R.id.setting_cv_fix_download).setVisibility(View.VISIBLE); } - mSettingAutoinstallSb.setChecked(sp.getBoolean("autoinstall", true)); - mSettingAutodeleteSb.setChecked(sp.getBoolean("autodelete", true)); - mSettingConcerngameSb.setChecked(sp.getBoolean("concerngame", true)); + mSettingAutoinstallSb.setChecked(mSharedPreferences.getBoolean("autoinstall", true)); + mSettingAutodeleteSb.setChecked(mSharedPreferences.getBoolean("autodelete", true)); + mSettingConcerngameSb.setChecked(mSharedPreferences.getBoolean("concerngame", true)); - checkSizeIndex = sp.getInt("fontsize", 1); - if (checkSizeIndex == 0) { - checkSizeIndex = 1; + mCheckSizeIndex = mSharedPreferences.getInt("fontsize", 1); + if (mCheckSizeIndex == 0) { + mCheckSizeIndex = 1; } - fontTextSize(checkSizeIndex); + fontTextSize(mCheckSizeIndex); initLoginStatus(); } @@ -149,11 +149,11 @@ public class SettingsFragment extends BaseFragment { } private void saveCurrentSetting() { - SharedPreferences.Editor mEditor = sp.edit(); + SharedPreferences.Editor mEditor = mSharedPreferences.edit(); mEditor.putBoolean("autoinstall", mSettingAutoinstallSb.isChecked()); mEditor.putBoolean("autodelete", mSettingAutodeleteSb.isChecked()); mEditor.putBoolean("concerngame", mSettingConcerngameSb.isChecked()); - mEditor.putInt("fontsize", checkSizeIndex); + mEditor.putInt("fontsize", mCheckSizeIndex); mEditor.apply(); } @@ -207,7 +207,7 @@ public class SettingsFragment extends BaseFragment { switch (v.getId()) { case R.id.setting_cv_fix_download: - SharedPreferences.Editor editor = sp.edit(); + SharedPreferences.Editor editor = mSharedPreferences.edit(); editor.putBoolean("isShow", true); editor.putBoolean("isCheckShow", false); editor.apply(); @@ -237,7 +237,7 @@ public class SettingsFragment extends BaseFragment { new DialogUtils.ConfirmListener() { @Override public void onConfirm() { - loadingDialog = DialogUtils.showWaitDialog(getContext(), "清除缓存中..."); + mLoadingDialog = DialogUtils.showWaitDialog(getContext(), "清除缓存中..."); clearCache(); } }); @@ -259,12 +259,12 @@ public class SettingsFragment extends BaseFragment { "确定退出", "取消", new DialogUtils.ConfirmListener() { @Override public void onConfirm() { - loadingDialog = DialogUtils.showWaitDialog(getContext(), "退出登录中..."); + mLoadingDialog = DialogUtils.showWaitDialog(getContext(), "退出登录中..."); LoginUtils.logout(getContext(), new LoginUtils.OnLogoutListener() { @Override public void onCompleted() { LoginUtils.cleanUserData(getContext()); - if (loadingDialog != null) loadingDialog.dismiss(); + if (mLoadingDialog != null) mLoadingDialog.dismiss(); getActivity().finish(); } }); @@ -297,7 +297,7 @@ public class SettingsFragment extends BaseFragment { private void fontSize() { View inflate = View.inflate(getContext(), R.layout.dialog_font_size, null); final RadioGroup radioGroup = (RadioGroup) inflate.findViewById(R.id.font_size_radiogroup); - ((RadioButton) (radioGroup.getChildAt(checkSizeIndex - 1))).setChecked(true); + ((RadioButton) (radioGroup.getChildAt(mCheckSizeIndex - 1))).setChecked(true); AlertDialog alertDialog = new AlertDialog.Builder(getContext(), R.style.GhAlertDialog) .setTitle(getString(R.string.font_primary)) .setPositiveButton("取消", new DialogInterface.OnClickListener() { @@ -309,14 +309,14 @@ public class SettingsFragment extends BaseFragment { .setNegativeButton("确认", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - checkSizeIndex = radioGroup.getCheckedRadioButtonId() % 4; + mCheckSizeIndex = radioGroup.getCheckedRadioButtonId() % 4; - if (checkSizeIndex == 0) { - checkSizeIndex = 4; + if (mCheckSizeIndex == 0) { + mCheckSizeIndex = 4; } dialog.cancel(); saveCurrentSetting(); - fontTextSize(checkSizeIndex); + fontTextSize(mCheckSizeIndex); } }) .setView(inflate) @@ -362,8 +362,8 @@ public class SettingsFragment extends BaseFragment { }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { @Override public void onCompleted() { - if (loadingDialog != null) { - loadingDialog.dismiss(); + if (mLoadingDialog != null) { + mLoadingDialog.dismiss(); } mSettingCacheTv.setText(getCacheSize()); toast("缓存清除成功"); diff --git a/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java b/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java new file mode 100644 index 0000000000..c7bf48996a --- /dev/null +++ b/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java @@ -0,0 +1,230 @@ +package com.halo.assistant.fragment.comment; + +import android.app.Dialog; +import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.widget.EditText; +import android.widget.TextView; + +import com.facebook.drawee.view.SimpleDraweeView; +import com.gh.base.fragment.BaseFragment; +import com.gh.common.util.CheckLoginUtils; +import com.gh.common.util.DialogUtils; +import com.gh.common.util.EntranceUtils; +import com.gh.common.util.ImageUtils; +import com.gh.common.util.LoginUtils; +import com.gh.common.util.PostCommentUtils; +import com.gh.gamecenter.R; +import com.gh.gamecenter.adapter.CommentDetailAdapter; +import com.gh.gamecenter.adapter.OnCommentCallBackListener; +import com.gh.gamecenter.entity.CommentEntity; +import com.gh.gamecenter.entity.UserInfoEntity; +import com.lightgame.utils.Util_System_Keyboard; +import com.lightgame.utils.Utils; + +import org.json.JSONException; +import org.json.JSONObject; + +import butterknife.BindView; +import butterknife.OnClick; +import butterknife.OnTouch; +import retrofit2.HttpException; + +/** + * Created by CsHeng on 14/12/2017. + *

+ * 评论详情页面 + * TODO: 16/11/17 时间比较紧 先暂时这么做 最好发表评论那块和评论详情整合 + */ +public class CommentDetailFragment extends BaseFragment implements OnCommentCallBackListener { + + @BindView(R.id.comment_detail_rv) + RecyclerView mRecyclerView; + @BindView(R.id.comment_detail_close_comment) + View mCommentDetailCloseComment; + @BindView(R.id.comment_detail_comment_et) + EditText mCommentDetailCommentEt; + @BindView(R.id.comment_user_icon) + SimpleDraweeView mCommentUserIcon; + @BindView(R.id.comment_user_name) + TextView mCommentUserName; + @BindView(R.id.comment_detail_comment_rl) + View mCommentDetailCommentRl; + @BindView(R.id.reuse_none_data) + View mNoData; + + private Dialog mSendingDialog; + + private UserInfoEntity mUserInfo; + private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空 + + private CommentDetailAdapter mAdapter; + private LinearLayoutManager mLayoutManager; + + @Override + protected int getLayoutId() { + return R.layout.fragment_comment_detail; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setNavigationTitle(getString(R.string.title_comment_detail)); + + String commentId = getArguments().getString(EntranceUtils.KEY_COMMENTID); + + mAdapter = new CommentDetailAdapter(getContext(), commentId, this, mNoData, mRecyclerView); + mLayoutManager = new LinearLayoutManager(getContext()); + mRecyclerView.setLayoutManager(mLayoutManager); + mRecyclerView.setAdapter(mAdapter); + + mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + if (newState == RecyclerView.SCROLL_STATE_IDLE && !mAdapter.isOver() && !mAdapter.isLoading()) { + mAdapter.loadData(mAdapter.getItemCount()); + } + } + }); + + mUserInfo = LoginUtils.getUserInfo(getContext()); + if (mUserInfo != null) { + ImageUtils.Companion.display(mCommentUserIcon, mUserInfo.getIcon()); + mCommentUserName.setText(mUserInfo.getName()); + } + } + + @Override + public void onCommentCallback(CommentEntity entity) { + mCommentEntity = entity; + setSoftInput(true); + } + + @OnTouch(R.id.comment_detail_close_comment) + public boolean OnRecyclerTouchListener() { + if (mCommentDetailCloseComment.getVisibility() == View.VISIBLE) { + setSoftInput(false); + } + return true; + } + + @OnClick(R.id.comment_send) + public void OnSendCommentListener() { + final String content = mCommentDetailCommentEt.getText().toString(); + + if (content.length() == 0) { + Utils.toast(getContext(), "评论内容不能为空!"); + return; + } + + mSendingDialog = DialogUtils.showWaitDialog(getContext(), "正在提交"); + + JSONObject jsonObject = new JSONObject(); + try { + jsonObject.put("content", content); + } catch (JSONException e) { + e.printStackTrace(); + } + if (mCommentEntity != null && mCommentEntity.getId() == null) { + Utils.toast(getContext(), "评论异常 id null"); + mSendingDialog.cancel(); + return; + } + + PostCommentUtils.addCommentData(getContext(), null, jsonObject.toString(), mCommentEntity, + new PostCommentUtils.PostCommentListener() { + @Override + public void postSuccess(JSONObject response) { + mSendingDialog.dismiss(); + toast("发表成功"); + mCommentDetailCommentEt.setText(""); + + setSoftInput(false); + + } + + @Override + public void postFailed(Throwable e) { + mSendingDialog.dismiss(); + + if (e instanceof HttpException) { + HttpException exception = (HttpException) e; + if (exception.code() == 403) { + try { + JSONObject errorJson = new JSONObject(exception.response().errorBody().string()); + String detail = errorJson.getString("detail"); + switch (detail) { + case "too frequent": + toast("别话痨哦~休息一会再来评论吧~"); + break; + case "user blocked": + toast("账号状态异常,暂时无法发表评论"); + break; + case "article blocked": + toast("文章异常,无法发表评论"); + setSoftInput(false); + break; + case "illegal": + toast("评论内容可能包括敏感信息,请修改后再发表"); + break; + default: + toast("评论失败,未知原因"); + break; + } + } catch (Exception ex) { + ex.printStackTrace(); + toast("评论异常"); + } + return; + } + } + + toast("提交失败,请检查网络设置"); + } + }); + } + + //软键盘控制 + private void setSoftInput(boolean isShow) { +// final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + if (isShow) { + CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { + @Override + public void onLoggedIn() { + Util_System_Keyboard.showSoftKeyboard(getContext(), mCommentDetailCommentEt); +// imm.showSoftInputFromInputMethod(mCommentDetailCommentEt.getWindowToken(), 0); +// imm.toggleSoftInputFromWindow(mCommentDetailCommentEt.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS); + mCommentDetailCommentRl.setVisibility(View.VISIBLE); + mCommentDetailCommentEt.setFocusable(true); + mCommentDetailCommentEt.setFocusableInTouchMode(true); + mCommentDetailCommentEt.requestFocus(); + mCommentDetailCloseComment.setVisibility(View.VISIBLE); + + if (mCommentEntity != null && mCommentEntity.getUser() != null) { + mCommentDetailCommentEt.setHint("回复" + mCommentEntity.getUser().getName() + ":"); + } else { + mCommentDetailCommentEt.setHint("优质评论会被优先展示"); + } + } + }); + } else { + Util_System_Keyboard.hideSoftKeyboard(getContext(), mCommentDetailCommentEt); + +// imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0); + + mCommentDetailCloseComment.setVisibility(View.GONE); + + mCommentDetailCommentRl.setVisibility(View.GONE); + if (mCommentEntity != null) { + mCommentEntity = null; // 清空当前评论实体 + mCommentDetailCommentEt.setHint("优质评论会被优先展示"); + mCommentDetailCommentEt.setText(""); + } + } + } + + +} diff --git a/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java b/app/src/main/java/com/halo/assistant/fragment/game/GameFragmentAdapter.java similarity index 99% rename from app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java rename to app/src/main/java/com/halo/assistant/fragment/game/GameFragmentAdapter.java index 53434d66ba..528443e257 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java +++ b/app/src/main/java/com/halo/assistant/fragment/game/GameFragmentAdapter.java @@ -1,4 +1,4 @@ -package com.gh.gamecenter.game; +package com.halo.assistant.fragment.game; import android.content.Intent; import android.graphics.Color; diff --git a/app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchFragment.java b/app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchFragment.java new file mode 100644 index 0000000000..41a58412fa --- /dev/null +++ b/app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchFragment.java @@ -0,0 +1,217 @@ +package com.halo.assistant.fragment.game; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.util.ArrayMap; +import android.support.v7.widget.GridLayoutManager; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.gh.base.fragment.BaseFragment; +import com.gh.common.util.DisplayUtils; +import com.gh.common.util.EntranceUtils; +import com.gh.gamecenter.R; +import com.gh.gamecenter.adapter.GameNewsAdapter; +import com.gh.gamecenter.adapter.GameNewsTypeListAdapter; +import com.gh.gamecenter.eventbus.EBTypeChange; +import com.gh.gamecenter.retrofit.Response; +import com.gh.gamecenter.retrofit.RetrofitManager; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; +import retrofit2.HttpException; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +/** + * 游戏新闻搜索界面 + *

+ * Created by CsHeng on 14/12/2017. + */ +public class GameNewsSearchFragment extends BaseFragment { + + @BindView(R.id.game_news_list) + RecyclerView mGameNewsRv; + @BindView(R.id.game_news_top_type_list) + RecyclerView mGameNewsTypeRv; + @BindView(R.id.reuse_none_data) + LinearLayout mNoDataLl; + @BindView(R.id.reuse_tv_none_data) + TextView mNoDataTv; + + private GameNewsAdapter mGameNewsAdapter; + private GameNewsTypeListAdapter mTypeListAdapter; + private LinearLayoutManager mLayoutManager; + private MenuItem mMenuItemSearch; + + private ArrayMap mAdapterMap; + private List mTypeList; + private String mGameId; + private float mStartY = 0; + + public static GameNewsSearchFragment newInstance(String gameName, String gameId, String entrance) { + final GameNewsSearchFragment fragment = new GameNewsSearchFragment(); + Bundle args = new Bundle(); + args.putString(EntranceUtils.KEY_GAMENAME, gameName); + args.putString(EntranceUtils.KEY_GAMEID, gameId); + args.putString(EntranceUtils.KEY_ENTRANCE, entrance); + fragment.setArguments(args); + return fragment; + } + + @Override + protected int getLayoutId() { + return R.layout.fragment_game_news_search; + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + super.onCreateOptionsMenu(menu, inflater); + inflater.inflate(R.menu.menu_search_white, menu); + mMenuItemSearch = menu.findItem(R.id.menu_search); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_search: + mGameNewsRv.scrollToPosition(0); + mGameNewsTypeRv.setVisibility(View.GONE); + mMenuItemSearch.setVisible(false); + mGameNewsAdapter.openKeyBoard(); + break; + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setHasOptionsMenu(true); + + Bundle args = getArguments(); + + String gameName = args.getString(EntranceUtils.KEY_GAMENAME); + setNavigationTitle(gameName); + + mNoDataTv.setText("暂无内容"); + + mAdapterMap = new ArrayMap<>(); + mTypeList = new ArrayList<>(); + + mGameId = args.getString(EntranceUtils.KEY_GAMEID); + + mLayoutManager = new LinearLayoutManager(getContext()); + mGameNewsRv.setHasFixedSize(true); + mGameNewsRv.setLayoutManager(mLayoutManager); + mGameNewsRv.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + if (mGameNewsAdapter != null && newState == RecyclerView.SCROLL_STATE_IDLE + && mLayoutManager.findLastVisibleItemPosition() == mGameNewsAdapter.getItemCount() - 1) { + if (!mGameNewsAdapter.isRemove() && !mGameNewsAdapter.isLoading() && !mGameNewsAdapter.isNetworkError()) { + mGameNewsAdapter.addList(mGameNewsAdapter.getNewsList().size()); + } + } + } + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + + if (mLayoutManager.findFirstVisibleItemPosition() >= 1) { + mGameNewsTypeRv.setVisibility(View.VISIBLE); + mMenuItemSearch.setVisible(true); + } else { + mGameNewsTypeRv.setVisibility(View.GONE); + mMenuItemSearch.setVisible(false); + } + + } + }); + + mGameNewsTypeRv.setHasFixedSize(true); + mGameNewsTypeRv.setLayoutManager(new GridLayoutManager(getContext(), 5)); + + //禁止由于滑动出现的阴影 + mGameNewsTypeRv.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + mStartY = event.getY(); + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { + if (Math.abs(mStartY - event.getY()) > 0) { + return true; + } + } + return false; + } + }); + + if (!TextUtils.isEmpty(mGameId)) { + getGameArticleType(); + } + } + + private void getGameArticleType() { + RetrofitManager.getInstance(getContext()).getApi() + .getGameArticleType(mGameId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Response>() { + @Override + public void onResponse(List response) { + super.onResponse(response); + mTypeList = response; + mTypeList.add(0, "全部"); + mGameNewsAdapter = new GameNewsAdapter(getContext(), mTypeList, mGameNewsRv, mGameId, "全部", mEntrance, mNoDataLl); + mAdapterMap.put("全部", mGameNewsAdapter); + mGameNewsRv.setAdapter(mGameNewsAdapter); + + mTypeListAdapter = new GameNewsTypeListAdapter(getContext(), mTypeList, "全部"); + mGameNewsTypeRv.setAdapter(mTypeListAdapter); + + ViewGroup.LayoutParams params = mGameNewsTypeRv.getLayoutParams(); + params.height = (int) Math.ceil(mTypeList.size() / 5f) * DisplayUtils.dip2px(getContext(), 35) + + DisplayUtils.dip2px(getContext(), 12); + mGameNewsTypeRv.setLayoutParams(params); + } + + @Override + public void onFailure(HttpException e) { + super.onFailure(e); + } + }); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(EBTypeChange change) { + mGameNewsAdapter = mAdapterMap.get(change.getType()); + if (mGameNewsAdapter == null) { + mGameNewsAdapter = new GameNewsAdapter(getContext(), mTypeList, mGameNewsRv, mGameId, change.getType(), mEntrance, mNoDataLl); + mAdapterMap.put(change.getType(), mGameNewsAdapter); + } + mGameNewsRv.setAdapter(mGameNewsAdapter); + + mGameNewsTypeRv.setVisibility(View.GONE); + mMenuItemSearch.setVisible(false); + mTypeListAdapter.setNewsType(change.getType(), change.getPosition()); + } + +} diff --git a/app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchResultFragment.java b/app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchResultFragment.java new file mode 100644 index 0000000000..8c66d0a08f --- /dev/null +++ b/app/src/main/java/com/halo/assistant/fragment/game/GameNewsSearchResultFragment.java @@ -0,0 +1,309 @@ +package com.halo.assistant.fragment.game; + +import android.os.Bundle; +import android.os.Handler; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.text.Html; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.gh.base.fragment.BaseFragment; +import com.gh.common.util.DataCollectionUtils; +import com.gh.common.util.EntranceUtils; +import com.gh.common.util.NewsUtils; +import com.gh.common.view.VerticalItemDecoration; +import com.gh.gamecenter.DataUtils; +import com.gh.gamecenter.NewsDetailActivity; +import com.gh.gamecenter.R; +import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; +import com.gh.gamecenter.adapter.viewholder.NewsTextViewHolder; +import com.gh.gamecenter.entity.NewsEntity; +import com.gh.gamecenter.retrofit.Response; +import com.gh.gamecenter.retrofit.RetrofitManager; +import com.lightgame.utils.Util_System_Keyboard; +import com.lightgame.utils.Utils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import butterknife.BindView; +import retrofit2.HttpException; +import rx.android.schedulers.AndroidSchedulers; +import rx.functions.Func1; +import rx.schedulers.Schedulers; + +/** + * Created by CsHeng on 14/12/2017. + * 游戏新闻搜索结果界面 + */ +public class GameNewsSearchResultFragment extends BaseFragment { + + @BindView(R.id.gamedetail_news_rv) + RecyclerView mNewsSearchRv; + @BindView(R.id.tv_search) + TextView mNewsSearchTv; + @BindView(R.id.reuse_none_data) + LinearLayout mNoneData; + @BindView(R.id.et_search) + EditText mNewsSearchEt; + @BindView(R.id.gamedetail_news_ll_loading) + LinearLayout mLoading; + @BindView(R.id.reuse_no_connection) + LinearLayout mNoConn; + + private LinearLayoutManager mLayoutManager; + private List mNewsEntities; + private NewsSearchAdapter mNewsSearchAdapter; + + private boolean mIsLoadOver = true; + private boolean mIsRemove = false; + private boolean mIsNetworkError = false; + + private String mSearchKey; + private String mGameId; + + private Handler mHandler = new Handler(); + + private int mPage = 1; + + @Override + protected int getLayoutId() { + return R.layout.fragment_game_news_search_result; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Bundle args = getArguments(); + + String gameName = args.getString(EntranceUtils.KEY_GAMENAME); + mSearchKey = args.getString(EntranceUtils.KEY_SEARCHKEY); + mGameId = args.getString(EntranceUtils.KEY_GAMEID); + + setNavigationTitle(gameName); + + mNewsEntities = new ArrayList<>(); + mNewsSearchAdapter = new NewsSearchAdapter(); + + mLayoutManager = new LinearLayoutManager(getContext()); + + mNewsSearchRv.setLayoutManager(mLayoutManager); + mNewsSearchRv.setAdapter(mNewsSearchAdapter); + mNewsSearchRv.addItemDecoration(new VerticalItemDecoration(getContext(), 1, false)); + + mNewsSearchEt.setText(mSearchKey); + + loadNewsData(mPage); + + mNewsSearchTv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mSearchKey = mNewsSearchEt.getText().toString().trim(); + if (mSearchKey.length() >= 1) { + mNewsEntities.clear(); + mNewsSearchAdapter.notifyDataSetChanged(); + mLoading.setVisibility(View.VISIBLE); + mNoneData.setVisibility(View.GONE); + + Util_System_Keyboard.hideSoftKeyboard(getActivity()); + + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + mPage = 1; + loadNewsData(mPage); + } + }, 500); + + } else { + Utils.toast(getContext(), getString(R.string.search_hint)); + } + + } + }); + + mNewsSearchRv.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + if (newState == RecyclerView.SCROLL_STATE_IDLE && mLayoutManager.findLastVisibleItemPosition() + 1 == mNewsSearchAdapter.getItemCount() + && mIsLoadOver && !mIsRemove && !mIsNetworkError) { + mIsLoadOver = false; + mPage++; + loadNewsData(mPage); + } + } + }); + + mNoConn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mNoConn.setVisibility(View.GONE); + mLoading.setVisibility(View.VISIBLE); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + loadNewsData(1); + } + }, 1000); + } + }); + + } + + @Override + public void onDestroy() { + super.onDestroy(); + mHandler.removeCallbacksAndMessages(null); + } + + private void loadNewsData(final int page) { +// DataUtils.onEvent(getContext(), "游戏新闻搜索", mSearchKey); +// DataCollectionUtils.uploadSearch(getContext(), mSearchKey, "游戏新闻搜索"); + + RetrofitManager.getInstance(getContext()).getApi().getSearchNews(mGameId, mSearchKey, page, 20) + .map(new Func1, List>() { + @Override + public List call(List list) { + // 去掉重复数据 + return NewsUtils.removeDuplicateData(mNewsEntities, list); + } + }) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Response>() { + @Override + public void onResponse(List response) { + mIsLoadOver = true; + mLoading.setVisibility(View.GONE); + mNoneData.setVisibility(View.GONE); + + if (response.size() != 0) { + mNewsEntities.addAll(response); + mNewsSearchAdapter.notifyDataSetChanged(); + } else { + if (page == 1) { + mNoneData.setVisibility(View.VISIBLE); + } + + mIsRemove = true; + mNewsSearchAdapter.notifyItemChanged(mNewsSearchAdapter.getItemCount() - 1); + } + + if (response.size() < 20) { + mIsRemove = true; + } + } + + @Override + public void onFailure(HttpException e) { + if (page == 1) { + mNoConn.setVisibility(View.VISIBLE); + mLoading.setVisibility(View.GONE); + } + mIsLoadOver = true; + toast(R.string.loading_failed_hint); + mIsNetworkError = true; + mNewsSearchAdapter.notifyItemChanged(mNewsSearchAdapter.getItemCount() - 1); + } + }); + } + + //TODO move out + public class NewsSearchAdapter extends RecyclerView.Adapter { + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == 0) { + View view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.refresh_footerview, parent, false); + return new FooterViewHolder(view); + } else { + View view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_text_item, parent, false); + return new NewsTextViewHolder(view); + } + } + + @Override + public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { + if (holder instanceof NewsTextViewHolder) { + NewsTextViewHolder viewHolder = (NewsTextViewHolder) holder; + viewHolder.title.setText(Html.fromHtml(mNewsEntities.get(position).getTitle())); + viewHolder.type.setVisibility(View.GONE); + viewHolder.line.setVisibility(View.GONE); + viewHolder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + NewsEntity newsEntity = mNewsEntities.get(holder.getPosition()); + + Map kv = new HashMap<>(); + kv.put("名字", newsEntity.getTitle()); + kv.put("位置", String.valueOf(holder.getPosition() + 1)); + DataUtils.onEvent(getContext(), "点击", "游戏新闻搜索", kv); + + DataCollectionUtils.uploadClick(getContext(), + "列表", "游戏新闻搜索", newsEntity.getTitle()); + + // 统计阅读量 + NewsUtils.statNewsViews(getContext(), newsEntity.getId()); + NewsDetailActivity.startNewsDetailActivity(getContext(), newsEntity, + mEntrance + "+(游戏新闻搜索[" + mSearchKey + "])"); + } + }); + } else if (holder instanceof FooterViewHolder) { + FooterViewHolder viewHolder = (FooterViewHolder) holder; + viewHolder.itemView.setPadding(0, 0, 0, 0); + if (mIsNetworkError) { + viewHolder.loading.setVisibility(View.GONE); + viewHolder.hint.setText(R.string.loading_failed_retry); + viewHolder.itemView.setClickable(true); + viewHolder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mIsNetworkError = false; + notifyItemChanged(getItemCount() - 1); + loadNewsData(mPage); + } + }); + } else if (mIsRemove) { + viewHolder.loading.setVisibility(View.GONE); + viewHolder.hint.setText(R.string.loading_complete); + viewHolder.itemView.setClickable(false); + } else { + viewHolder.loading.setVisibility(View.VISIBLE); + viewHolder.hint.setText(R.string.loading); + viewHolder.itemView.setClickable(false); + } + } + + } + + @Override + public int getItemViewType(int position) { + if (position == mNewsEntities.size()) { + return 0; + } else { + return 1; + } + } + + @Override + public int getItemCount() { + if (mNewsEntities.isEmpty()) { + return 0; + } + return mNewsEntities.size() + 1; + } + + } + +} diff --git a/app/src/main/java/com/gh/gamecenter/game/GamePluginAdapter.java b/app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java similarity index 99% rename from app/src/main/java/com/gh/gamecenter/game/GamePluginAdapter.java rename to app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java index df3baab3a4..cd0215c6df 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GamePluginAdapter.java +++ b/app/src/main/java/com/halo/assistant/fragment/game/GamePluginAdapter.java @@ -1,4 +1,4 @@ -package com.gh.gamecenter.game; +package com.halo.assistant.fragment.game; import android.content.Context; import android.support.v7.widget.RecyclerView; diff --git a/app/src/main/java/com/gh/gamecenter/game/GamePluginViewHolder.java b/app/src/main/java/com/halo/assistant/fragment/game/GamePluginViewHolder.java similarity index 94% rename from app/src/main/java/com/gh/gamecenter/game/GamePluginViewHolder.java rename to app/src/main/java/com/halo/assistant/fragment/game/GamePluginViewHolder.java index 19c3f39f5c..72c6be8ef3 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GamePluginViewHolder.java +++ b/app/src/main/java/com/halo/assistant/fragment/game/GamePluginViewHolder.java @@ -1,4 +1,4 @@ -package com.gh.gamecenter.game; +package com.halo.assistant.fragment.game; import android.support.v7.widget.RecyclerView; import android.view.View; @@ -29,4 +29,5 @@ public class GamePluginViewHolder extends BaseRecyclerViewHolder { public GamePluginViewHolder(View itemView) { super(itemView); } + } diff --git a/app/src/main/java/com/halo/assistant/ui/IntentFactory.java b/app/src/main/java/com/halo/assistant/ui/IntentFactory.java index 0cb36f5461..94d56d1926 100644 --- a/app/src/main/java/com/halo/assistant/ui/IntentFactory.java +++ b/app/src/main/java/com/halo/assistant/ui/IntentFactory.java @@ -31,6 +31,12 @@ public class IntentFactory { mContext = context; } + @NonNull + public Builder setActivity(Class activityClass) { + mActivityClass = activityClass; + return this; + } + @NonNull public Builder setFragment(@NonNull Class cls) { mFragmentClass = cls; @@ -44,7 +50,7 @@ public class IntentFactory { } @NonNull - public Builder args(@NonNull Bundle args) { + public Builder setArgs(@NonNull Bundle args) { mBundleArgs = args; return this; } diff --git a/app/src/main/res/drawable-hdpi/ic_search_white.png b/app/src/main/res/drawable-hdpi/ic_search_white.png deleted file mode 100644 index b673b9b3c51ef8f3a9736d836dcf8a4e4ca03425..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2766 zcmbVOdstF;AIIgTdE4VPHKz!qIpr!K;4LQ*EHp8kR+bSA#4OWd<+asPRx5L^7hCRq|JbuX-t(Mue&65kd_Ld%_jyi!bktfK zOE*gp2xLR2kzBqGo_B8GtV2V+oZJQ9UPqKR;H0Lge`QQ-F% z#Ar>%b!UGyM;@`ty z-26RGfY>-gGUKp_zT5Kz1Tue0Cx^3?!%wR=r#i;Ebgs7={uEif?kk)|6Tevp-WtQz zolh!eANSgA+JyeGztnuzps$Pd{L$XQbB~4RC%*RfGtM}>e)HTC%L8|7kN4-E-?}U5 zKppF(Vqxb!NfD_!Am~dzKRG$$&u-*y)u>AT=lo4#a$lWmA&m^9@A=NYIOo(F-_;)s ztnuhFeav=IoA`tWPMJK+3(*(Tm_V}t<|?;{x2thSKk#a&!JQ&&h)=f^5SKFZ6*+`bw%K@W4K18k_$ z#1ZzImXWqfX8Ok!C+mgEpPbf*#?e;khfTlQ@6~UOhc#Lc;$*f0GbiWJFKx3;L(N;- z(+mOYBF5)!UYJBf>? zR=Bl?rP*Kh^fz-w_*B;?UV9bbaQs4ONkKL~D%bb3xI8V7+-{1QYn!b;G{Hg{E)w#y zS7;e$bEte7DHuJ_v+s@y_S8N8mxdhb9oZ$;w!2o)lc$4zp!K^(mn3=L&^&t4O`bcM z@ur%8)ANhYkM;N}rcU3w(%t^#DKoZDW~mFM3KA#}x-*yoYZ_<+1=9MM*XA;2>S){H z`aYYDsBAOwct$-m1dGA>GXAJs*|7t~oN?H2a~l7II#W<-W0+$zm~Ge^fl6?E!Ovm5 zQCru;-}mT5T__GsJq1ZT+|0bkl69VB`m_%w(B@-x4m(}6rRr1qv$_V1L3n-AwyFmo`Y zK&uyLAA7J2YJxjtc-c1g8Zv4Uj4_Z<>ty2Zm!Id&`Hfw{!=b%Slc6@vg)NSqz3B)2 zi`<{DAD*hrbc-HqU<`HHch8CoJr0dG!myaM1$|B7+<`OeEf)NVr9Y(bs*h%UYwO0u zYMTnwpAbXU-qaq0ihE(;YR~L-B*JGBMY?Yweh`*v+9{62FLBzo2a(*uM;a4 zp+rpz@0&5Du)@W+chYVPv?T)i_Smr~w~f~I*3J39k0$)6CpdGN97-OE@MN?Y$H*v52R`XHK2H2J+&~!DlSnByxB$Owsw$j2W2p@RG84~ z^(MnbuN_u|pScdn@(q#-n42)e;MH;@lxaaxIOj5T)?e5?sNd1F`N}yO1J>%Rj%R^Y z+es_bv0AanFr7N;U9<{85!W|n>39cwVh*bW=RX&e+_x$fY)`CwG~rn16pC)RIyOCA zeYzxZMczY(N4}+Jxn|Qs`p9%s5kD{N#fip*TeRa1i50ugK`4G@PU_HmE-z7+lMiRS z_}Y1-?IAB`jG+9G5mmTat(|raq|58ddJBd+Hnz2trF@BuRQFEr|2`^uYW(V}LGPx- z)AmQxNAJ<`sLJO-ZVd=btTPU6+TnLk+bT)*#AF@hzeg zqg5J>YWC9pUzhP>kBwxlc|6^!&$O$0HoKzB`IZnCpmZ#n_~f=*m+yxOZ+*`6^%qe# z7l`a{J-fksGLBYn4Xg~C?fTifQ_!*bpp+zYoUZ8_VH*}qP{@1VoVTtu8_MH+WSwoJ zJ=+}jtsnmqv+{Nn^P64BE%+I*z;w=SC6XvUQMoeB67f*uUgvmg0ea$Yv-3f}XBM8) zxgl=jPJ@lz=w!^xZ9ftUH?9z`6uLiXrITN&{KwIUlIjy=%>(J>e$e4vyGu3hk4@&6 zjZ6nmNGk*_H+-BX&9m^-0sS*vWOc zp(h;j4Li}-w>5;d5~1e}NI(HC86u|(YSIVOcK1|2deGn1LEhQLEz)Yw6fhVshCcJK ue|uOlpCzcNR_Snee|r1S>WjBdY|vQq2S-^I+ewRmm~=`Mx&Bjj?tcK^&YXV$ diff --git a/app/src/main/res/drawable-xxhdpi/ic_search_white.png b/app/src/main/res/drawable-xxhdpi/ic_search_white.png new file mode 100644 index 0000000000000000000000000000000000000000..761e26933e57c44840480887870eff03b5286e0f GIT binary patch literal 1395 zcmV-(1&sQMP)!%IEWqhF z6}z`-w{z{c2fk5~Z^8q(8_)Eh#~4Ky*Bm3>>~mPAy&>)R0)C38u^z{Fd7m*RV$9xn z1dm~1uMbWfj&-%)zTMuW(_!`l+<}=b>OaDt@dx}3ujAj?j2W1NeQ+SYiNi2dai8OB z*Pn+wJJfBA@r;>{+i_Nl`j@d1tHm5>#T#N+uCA4L#`kcJSTxGaz$(#OXNwor5$%TA zj(AwLA){D=`S_*whE(xC@#Yuc1iVtw=7(5Y)1xC=88aOZ;>0BX6xZM@V*YIH^g(S{ zCtk|snwRQh@f+1cvWZs4tirdG?48=pe_;Y$-yt94YOz;sOm&O!t4?lGWz3m4Bgr=4 z2s}O!4ZC2ym@984`KdT}yo<9j^KeU&ZNhQ*dzT7Mlz)o7EceijVtBVC8?#cZCUri= zcWpaE>bxfA>nA1IkXTu#wYsQm%n~e4^;e4BelmC(mn7K{IHlDEWn(T*b+6#M{^->; zH{pdOyHtzbsT;FUqZ0_{i&bVa*&@7wG6#w|+(g}&)06yJ{I0)xbXRN&|&drCxyQ;E&^eUcrO z8x_JYD)ZEU6zY{cZ?fJBvFn%F)*ED}yqL=S34#!Uu3=VzN5esNp>W59h630 zGE1}jlJ!>LulR3CHY5^sQ;F;)zlT5NMuk`r?oaY%+QizE!17dnNI0Jj)Hlq#ll%bj zHl_mK!XZhP^~LALJfqoLz5zS*SFZ^(B=P`dp3@u-pwX4ND%I^HQn8cC71%$?u58t~ zY|In*b*le4PU??d6J{|kO0q{q)LBV(GJmGoy}3_w=4Q}*6>Bu=_r5sdXh}BaE&Mpi zcEoSR0nxVLV9^7!lYE)xn5KcM#Q7SL*DW(gB+YXcr{A0;CU zwX5>m_EVAmnIQLxz3pGMa=jNiGH4$j|veSHSNSzg$k6Q?X zu3x%z>DY_y=5v$h@qH1-UalhI>yT05n#>hT@?YAtZDr5}xUFu`v_5>*L`>j?;#_~O znBY5!VZ23n6>p0W{UzblzR|^Vs^$=}U7XX)S50N!#=W)QAZay+eu8(V&!69vf1c{B z7ip$NNxq<)IWrZgnnRoVHOwZ175I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_clean_apk.xml b/app/src/main/res/layout/activity_clean_apk.xml deleted file mode 100644 index ea2a606e4b..0000000000 --- a/app/src/main/res/layout/activity_clean_apk.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_comment_detail.xml b/app/src/main/res/layout/activity_comment_detail.xml deleted file mode 100644 index 3c4c3fe599..0000000000 --- a/app/src/main/res/layout/activity_comment_detail.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_game_news.xml b/app/src/main/res/layout/activity_game_news.xml deleted file mode 100644 index 023a109630..0000000000 --- a/app/src/main/res/layout/activity_game_news.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_kaifu.xml b/app/src/main/res/layout/activity_kaifu.xml deleted file mode 100644 index 58aa60dd14..0000000000 --- a/app/src/main/res/layout/activity_kaifu.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml deleted file mode 100644 index 28c9cff9d4..0000000000 --- a/app/src/main/res/layout/activity_setting.xml +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml new file mode 100644 index 0000000000..9eadfc33a2 --- /dev/null +++ b/app/src/main/res/layout/fragment_about.xml @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_apk_cleaner.xml b/app/src/main/res/layout/fragment_apk_cleaner.xml new file mode 100644 index 0000000000..c67d2a32a1 --- /dev/null +++ b/app/src/main/res/layout/fragment_apk_cleaner.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_comment_detail.xml b/app/src/main/res/layout/fragment_comment_detail.xml new file mode 100644 index 0000000000..03feda2115 --- /dev/null +++ b/app/src/main/res/layout/fragment_comment_detail.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_concern.xml b/app/src/main/res/layout/fragment_concern.xml similarity index 97% rename from app/src/main/res/layout/activity_concern.xml rename to app/src/main/res/layout/fragment_concern.xml index 76b9c02542..434b08d9d3 100644 --- a/app/src/main/res/layout/activity_concern.xml +++ b/app/src/main/res/layout/fragment_concern.xml @@ -4,8 +4,6 @@ android:layout_height = "match_parent" android:orientation = "vertical" > - - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_gamedetail_news.xml b/app/src/main/res/layout/fragment_game_news_search_result.xml similarity index 98% rename from app/src/main/res/layout/activity_gamedetail_news.xml rename to app/src/main/res/layout/fragment_game_news_search_result.xml index 11beb2014d..db930f7d77 100644 --- a/app/src/main/res/layout/activity_gamedetail_news.xml +++ b/app/src/main/res/layout/fragment_game_news_search_result.xml @@ -4,8 +4,6 @@ android:layout_height = "wrap_content" android:orientation = "vertical" > - - + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_setting.xml b/app/src/main/res/layout/fragment_setting.xml new file mode 100644 index 0000000000..f84c1f00da --- /dev/null +++ b/app/src/main/res/layout/fragment_setting.xml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_menu_button.xml b/app/src/main/res/layout/layout_menu_button.xml new file mode 100644 index 0000000000..cc5373fe33 --- /dev/null +++ b/app/src/main/res/layout/layout_menu_button.xml @@ -0,0 +1,16 @@ + + + + + + diff --git a/app/src/main/res/layout/reuse_actionbar.xml b/app/src/main/res/layout/reuse_actionbar.xml index 576d0d4a39..e983de28ba 100644 --- a/app/src/main/res/layout/reuse_actionbar.xml +++ b/app/src/main/res/layout/reuse_actionbar.xml @@ -5,6 +5,7 @@ android:layout_width = "match_parent" android:layout_height = "?attr/actionBarSize" > + diff --git a/app/src/main/res/menu/menu_button.xml b/app/src/main/res/menu/menu_button.xml new file mode 100644 index 0000000000..55e235a4da --- /dev/null +++ b/app/src/main/res/menu/menu_button.xml @@ -0,0 +1,11 @@ + +

+ + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_search_white.xml b/app/src/main/res/menu/menu_search_white.xml new file mode 100644 index 0000000000..cbe134db1c --- /dev/null +++ b/app/src/main/res/menu/menu_search_white.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 01c8c26d8b..7510387272 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -382,6 +382,9 @@ %1$d票 光环客服 I\'m a Text + 搜索 + 游戏详情 + 重置 小字号