diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 30b260dacb..37d032f5a3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -139,9 +139,6 @@
android:name="com.gh.gamecenter.SuggestionActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible" />
-
@@ -149,30 +146,8 @@
android:name="com.gh.gamecenter.HotCardActivity"
android:screenOrientation="portrait" />
-
-
-
-
-
-
diff --git a/app/src/main/java/com/gh/common/util/PlatformUtils.java b/app/src/main/java/com/gh/common/util/PlatformUtils.java
index 5d611aa505..8e26c64745 100644
--- a/app/src/main/java/com/gh/common/util/PlatformUtils.java
+++ b/app/src/main/java/com/gh/common/util/PlatformUtils.java
@@ -18,7 +18,6 @@ import com.gh.gamecenter.eventbus.EBPlatformChanged;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HTTP;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/app/src/main/java/com/gh/gamecenter/AccountActivity.java b/app/src/main/java/com/gh/gamecenter/AccountActivity.java
deleted file mode 100644
index d7cd7efdad..0000000000
--- a/app/src/main/java/com/gh/gamecenter/AccountActivity.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.gh.gamecenter;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.TextView;
-
-import com.gh.base.AppController;
-import com.gh.base.BaseActivity;
-import com.gh.gamecenter.entity.UserEntity;
-
-public class AccountActivity extends BaseActivity implements OnClickListener {
-
- private TextView account_tv_mobile_title, account_tv_mobile;
- private UserEntity user;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- user = (UserEntity) AppController.get("user", false);
-
- View contentView = View.inflate(this, R.layout.activity_account, null);
-
- init(contentView, "账户安全设置");
-
- findViewById(R.id.account_ll_account).setOnClickListener(this);
- findViewById(R.id.account_ll_mobile).setOnClickListener(this);
- findViewById(R.id.account_rl_password).setOnClickListener(this);
-
- TextView account_tv_account = (TextView) findViewById(R.id.account_tv_account);
- account_tv_account.setText(user.getAccount());
-
- if (user.getMobileNumber() != null) {
- account_tv_mobile_title.setText("修改绑定手机");
- account_tv_mobile.setText(user.getMobileNumber());
- } else {
- account_tv_mobile_title.setText("绑定手机");
- account_tv_mobile.setVisibility(View.GONE);
- }
-
- TextView account_tv_password = (TextView) findViewById(R.id.account_tv_password);
- if (user.isActivation()) {
- account_tv_password.setText("修改登录密码");
- } else {
- account_tv_password.setText("设置登录密码");
- }
- }
-
- private final static int MOBILEACTIVITY = 0x123;
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.account_ll_mobile) {
- if (user.getMobileNumber() != null) {
- startActivity(new Intent(AccountActivity.this,
- ModifyMobileActivity.class));
- } else {
- Intent intent = new Intent(AccountActivity.this,
- MobileActivity.class);
- startActivityForResult(intent, MOBILEACTIVITY);
- }
- } else if (v.getId() == R.id.account_rl_password) {
- Intent intent = new Intent(AccountActivity.this,
- PasswordActivity.class);
- startActivity(intent);
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK && requestCode == MOBILEACTIVITY) {
- if (user.getMobileNumber() != null) {
- account_tv_mobile_title.setText("修改绑定手机");
- account_tv_mobile.setVisibility(View.VISIBLE);
- account_tv_mobile.setText(user.getMobileNumber());
- }
- }
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/CropImageActivity.java b/app/src/main/java/com/gh/gamecenter/CropImageActivity.java
deleted file mode 100644
index b8aff88e87..0000000000
--- a/app/src/main/java/com/gh/gamecenter/CropImageActivity.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.Dialog;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.TypedValue;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.gh.base.BaseActivity;
-import com.gh.common.constant.Config;
-import com.gh.common.util.DialogUtils;
-import com.gh.common.util.DisplayUtils;
-import com.gh.common.util.FileUtils;
-import com.gh.common.util.ImageUtils;
-import com.gh.common.util.TokenUtils;
-import com.gh.common.view.CropImageCustom;
-
-import java.io.File;
-
-public class CropImageActivity extends BaseActivity {
-
- private CropImageCustom cropimage_custom;
-
- private Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- toast("上传成功");
- } else if (msg.what == 1) {
- toast("上传失败");
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- View contentView = View
- .inflate(this, R.layout.activity_cropimage, null);
-
- init(contentView, "图片裁剪");
-
- RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
-
- TextView confirm = new TextView(this);
- confirm.setText("确定");
- confirm.setTextColor(0xffffffff);
- confirm.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
- int padding = DisplayUtils.dip2px(getApplicationContext(), 10);
- confirm.setPadding(padding, padding, padding, padding);
- confirm.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- final Dialog dialog = DialogUtils.showWaitDialog(
- CropImageActivity.this, "上传中...");
- new Thread(new Runnable() {
- @Override
- public void run() {
- String path = getCacheDir() + File.separator
- + System.currentTimeMillis() + ".jpg";
- // String path = getExternalCacheDir() + File.separator
- // + System.currentTimeMillis() + ".jpg";
- cropimage_custom.savePicture(path);
- // 上传图片
- String token = TokenUtils
- .getToken(CropImageActivity.this);
- String url = FileUtils.uploadFile(Config.HOST + "v2/user/upload_user_icon", path, token);
- dialog.dismiss();
- if (url != null) {
- Intent data = new Intent();
- data.putExtra("url", url);
- setResult(RESULT_OK, data);
- finish();
- handler.sendEmptyMessage(0);
- } else {
- handler.sendEmptyMessage(1);
- }
- }
- }).start();
- }
- });
- RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(
- LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- rparams.addRule(RelativeLayout.CENTER_VERTICAL);
- confirm.setLayoutParams(rparams);
- reuse_actionbar.addView(confirm);
-
- String path = getIntent().getStringExtra("path");
-
- ImageUtils.getInstance(getApplicationContext()).displayFile(
- "file://" + path, cropimage_custom.getCropImageZoomView());
-
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/DatabaseActivity.java b/app/src/main/java/com/gh/gamecenter/DatabaseActivity.java
deleted file mode 100644
index 75b1526638..0000000000
--- a/app/src/main/java/com/gh/gamecenter/DatabaseActivity.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.ActionBar;
-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.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
-import android.webkit.JavascriptInterface;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-import android.widget.EditText;
-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.GameViewUtils;
-import com.gh.common.util.Utils;
-
-import java.util.ArrayList;
-
-public class DatabaseActivity extends BaseActivity implements OnClickListener {
-
- private RecyclerView database_rv_show;
- private LinearLayoutManager linearLayoutManager;
- private DatabaseAdapter adapter;
- private LinearLayout database_ll_loading;
- private EditText database_et_search;
- private TextView database_tv_search;
-
- private WebView db_show;
-
- private TextView actionbar_tv_title;
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && db_show.canGoBack()) {
- db_show.goBack();// 返回前一个页面
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- View contentView = View.inflate(this, R.layout.activity_database, null);
-
- init(contentView, "数据库");
-
- db_show.addJavascriptInterface(new JsInterface(DatabaseActivity.this), "imagelistener");
- WebSettings setting = db_show.getSettings();
- setting.setJavaScriptEnabled(true);
- db_show.loadUrl("http://admin.ghzhushou.com/database/hhw.html");
- db_show.setWebViewClient(new WebViewClient(){
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- view.loadUrl(url);
- return true;
- }
-
- @Override
- public void onPageFinished(WebView view, String url) {
- super.onPageFinished(view, url);
- view.loadUrl("javascript:(function(){"
- + "var title = document.getElementsByTagName(\"title\");"
- + "window.imagelistener.getTitle(title[0].innerHTML);"
- + "})()");
- }
- });
-
-// // 自定义ActionBar
-// ActionBar mActionBar = getActionBar();
-// mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
-// View view = View.inflate(this, R.layout.resue_actionbar, null);
-// view.findViewById(R.id.actionbar_rl_back).setOnClickListener(this);
-// ((TextView) view.findViewById(R.id.actionbar_tv_title)).setText("数据库");
-// ActionBar.LayoutParams params = new ActionBar.LayoutParams(
-// LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-// mActionBar.setCustomView(view, params);// 自定义ActionBar布局
-//
-// database_tv_search.setOnClickListener(this);
-//
-// linearLayoutManager = new LinearLayoutManager(this);
-// linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
-// database_rv_show.setLayoutManager(linearLayoutManager);
-// database_rv_show.setHasFixedSize(true);
-// adapter = new DatabaseAdapter();
-// database_rv_show.setAdapter(adapter);
- }
-
- public class JsInterface {
- private Context context;
-
- public JsInterface(Context context) {
- this.context = context;
- }
-
- @JavascriptInterface
- public void getTitle(String title) {
- Utils.log("title = " + title);
- actionbar_tv_title.setText(title);
- }
-
- }
-
- @Override
- public void onClick(View v) {
-// switch (v.getId()) {
-// case R.id.actionbar_rl_back:
-// finish();
-// break;
-// case R.id.database_tv_search:
-//
-// break;
-// default:
-// break;
-// }
- }
-
- private class DatabaseViewHolder extends RecyclerView.ViewHolder {
-
- private TextView tv_label;
-
- private ImageView home1_game_thumb;
- private TextView home1_game_nameAndsize, home1_game_des,
- database_item1, database_item2, database_item3, database_item4;
- private LinearLayout home1_label_list;
- private TextView home1_download_btn;
-
- public DatabaseViewHolder(View convertView) {
- super(convertView);
-
- int tag = (Integer) convertView.getTag();
- if (tag == 0 || tag == 2) {
- tv_label = (TextView) convertView.findViewById(R.id.tv_label);
- } else {
- home1_game_thumb = (ImageView) convertView
- .findViewById(R.id.home1_game_thumb);
- home1_game_nameAndsize = (TextView) convertView
- .findViewById(R.id.home1_game_nameAndsize);
- home1_game_des = (TextView) convertView
- .findViewById(R.id.home1_game_des);
- home1_label_list = (LinearLayout) convertView
- .findViewById(R.id.home1_label_list);
- home1_download_btn = (TextView) convertView
- .findViewById(R.id.home1_download_btn);
- database_item1 = (TextView) convertView
- .findViewById(R.id.database_item1);
- database_item2 = (TextView) convertView
- .findViewById(R.id.database_item2);
- database_item3 = (TextView) convertView
- .findViewById(R.id.database_item3);
- database_item4 = (TextView) convertView
- .findViewById(R.id.database_item4);
- }
- }
-
- }
-
- private class DatabaseAdapter extends
- RecyclerView.Adapter {
-
- @Override
- public int getItemCount() {
-
- return 4;
- }
-
- @Override
- public void onBindViewHolder(DatabaseViewHolder viewHolder, int position) {
-
- if (position == 0 || position == 2) {
- viewHolder.tv_label.setText("我的游戏");
- viewHolder.tv_label
- .setBackgroundResource(R.drawable.title_blue);
- } else if (position == 1) {
- viewHolder.home1_game_thumb.setImageResource(R.drawable.logo);
- viewHolder.home1_game_nameAndsize.setText("少年三国志");
- GameViewUtils.setLabelList(DatabaseActivity.this,
- viewHolder.home1_label_list, "已关注,已安装");
- viewHolder.home1_download_btn.setVisibility(View.GONE);
- viewHolder.home1_game_des.setVisibility(View.GONE);
- viewHolder.database_item1.setText("阵容模拟器");
- viewHolder.database_item2.setText("阵容推荐");
- viewHolder.database_item3.setText("装备资料");
- viewHolder.database_item4.setText("武将资料");
- } else if (position == 2) {
- viewHolder.tv_label.setText("其他游戏");
- viewHolder.tv_label
- .setBackgroundResource(R.drawable.border_scarlet_bg);
- } else {
- viewHolder.home1_game_thumb.setImageResource(R.drawable.logo);
- viewHolder.home1_game_nameAndsize.setText("全民卡牌 | 121M");
- GameViewUtils.setLabelList(DatabaseActivity.this,
- viewHolder.home1_label_list, "加速,跳过");
- viewHolder.home1_download_btn.setVisibility(View.VISIBLE);
- viewHolder.home1_download_btn.setText("查看");
- viewHolder.home1_game_des.setVisibility(View.VISIBLE);
- viewHolder.home1_game_des
- .setText("2015最萌即时战斗手游,无处不在的指尖争锋呼醒真正的魔兽情怀。");
- viewHolder.database_item1.setText("阵容模拟器");
- viewHolder.database_item2.setText("阵容推荐");
- viewHolder.database_item3.setText("装备资料");
- viewHolder.database_item4.setText("武将资料");
- }
- }
-
- @Override
- public DatabaseViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
-
- View view;
- if (i == 0 || i == 2) {
- view = LayoutInflater.from(viewGroup.getContext()).inflate(
- R.layout.news_list_item_category, viewGroup, false);
- } else {
- view = LayoutInflater.from(viewGroup.getContext()).inflate(
- R.layout.datebase_item, viewGroup, false);
- }
- view.setTag(i);
- return new DatabaseViewHolder(view);
- }
-
- @Override
- public int getItemViewType(int position) {
-
- return position;
- }
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java
index 3ffacf3cdb..65308d0283 100644
--- a/app/src/main/java/com/gh/gamecenter/MainActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java
@@ -66,7 +66,6 @@ import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.manager.SuspectedGameManager;
import com.gh.gamecenter.personal.PersonalFragment;
import com.gh.gamecenter.plugin.PluginFragment;
-import com.gh.gamecenter.read.ReadFragment;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
import com.google.gson.Gson;
@@ -109,10 +108,9 @@ public class MainActivity extends BaseFragmentActivity implements
private HomeFragment home1Fragment;
private PluginFragment pluginFragmentActivity;
private PersonalFragment home3Fragment;
- private ReadFragment readFragment;
- private View home1Layout, home2Layout, home3Layout, home4Layout;
- private ImageView home1Image, home2Image, home3Image, home4Image;
- private TextView home1Title, home2Title, home3Title, home4Title;
+ private View home1Layout, home2Layout, home3Layout;
+ private ImageView home1Image, home2Image, home3Image;
+ private TextView home1Title, home2Title, home3Title;
private SharedPreferences sp;
@@ -919,19 +917,15 @@ public class MainActivity extends BaseFragmentActivity implements
home1Layout = findViewById(R.id.home1_layout);
home2Layout = findViewById(R.id.home2_layout);
home3Layout = findViewById(R.id.home3_layout);
- home4Layout = findViewById(R.id.home4_layout);
home1Image = (ImageView) findViewById(R.id.message_image);
home2Image = (ImageView) findViewById(R.id.contacts_image);
home3Image = (ImageView) findViewById(R.id.news_image);
- home4Image = (ImageView) findViewById(R.id.read_image);
home1Title = (TextView) findViewById(R.id.message_title);
home2Title = (TextView) findViewById(R.id.contacts_title);
home3Title = (TextView) findViewById(R.id.news_title);
- home4Title = (TextView) findViewById(R.id.read_title);
home1Layout.setOnClickListener(this);
home2Layout.setOnClickListener(this);
home3Layout.setOnClickListener(this);
- home4Layout.setOnClickListener(this);
}
@Override
@@ -952,10 +946,6 @@ public class MainActivity extends BaseFragmentActivity implements
EventBus.getDefault().post(new EBUISwitch("MainActivity", 2));
setTabSelection(2);
break;
- case R.id.home4_layout:
- EventBus.getDefault().post(new EBUISwitch("MainActivity", 3));
- setTabSelection(3);
- break;
default:
break;
}
@@ -1003,17 +993,6 @@ public class MainActivity extends BaseFragmentActivity implements
transaction.show(home3Fragment);
}
break;
- case 3:
- home4Layout.setClickable(false);
- home4Image.setImageResource(R.drawable.home4_selected);
- home4Title.setTextColor(getResources().getColor(R.color.theme_colors));
- if (readFragment == null) {
- readFragment = new ReadFragment();
- transaction.add(R.id.main_content, readFragment);
- } else {
- transaction.show(readFragment);
- }
- break;
default:
break;
}
@@ -1027,15 +1006,12 @@ public class MainActivity extends BaseFragmentActivity implements
home1Layout.setClickable(true);
home2Layout.setClickable(true);
home3Layout.setClickable(true);
- home4Layout.setClickable(true);
home1Image.setImageResource(R.drawable.home1_unselected);
home2Image.setImageResource(R.drawable.home2_unselected);
home3Image.setImageResource(R.drawable.home3_unselected);
- home4Image.setImageResource(R.drawable.home4_unselected);
home1Title.setTextColor(0xFF333333);
home2Title.setTextColor(0xFF333333);
home3Title.setTextColor(0xFF333333);
- home4Title.setTextColor(0xFF333333);
}
/**
@@ -1051,9 +1027,6 @@ public class MainActivity extends BaseFragmentActivity implements
if (home1Fragment != null) {
transaction.hide(home1Fragment);
}
- if (readFragment != null) {
- transaction.hide(readFragment);
- }
}
private void uploadData(String id, String platform) {
@@ -1212,19 +1185,15 @@ public class MainActivity extends BaseFragmentActivity implements
home1Fragment = null;
pluginFragmentActivity = null;
home3Fragment = null;
- readFragment = null;
home1Layout = null;
home2Layout = null;
home3Layout = null;
- home4Layout = null;
home1Image = null;
home2Image = null;
home3Image = null;
- home4Image = null;
home1Title = null;
home2Title = null;
home3Title = null;
- home4Title = null;
sp = null;
entryMap = null;
doneMap = null;
diff --git a/app/src/main/java/com/gh/gamecenter/MobileActivity.java b/app/src/main/java/com/gh/gamecenter/MobileActivity.java
deleted file mode 100644
index 6bf71c6981..0000000000
--- a/app/src/main/java/com/gh/gamecenter/MobileActivity.java
+++ /dev/null
@@ -1,463 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.text.Editable;
-import android.text.TextUtils;
-import android.text.TextWatcher;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.android.volley.Request.Method;
-import com.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gh.base.AppController;
-import com.gh.base.BaseActivity;
-import com.gh.common.constant.Config;
-import com.gh.common.constant.Constants;
-import com.gh.common.util.DialogUtils;
-import com.gh.common.util.TokenUtils;
-import com.gh.common.util.Utils;
-import com.gh.gamecenter.entity.UserEntity;
-import com.gh.gamecenter.eventbus.EBSms;
-import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.regex.Pattern;
-
-public class MobileActivity extends BaseActivity implements OnClickListener {
-
- private TextView mobile_tv_title, mobile_tv_hint, mobile_tv_send_again,
- mobile_tv_confirm;
- private EditText mobile_et_mobile, mobile_et_code;
- private ImageView mobile_iv_mobile, mobile_iv_mobile_clean;
- private LinearLayout mobile_ll_code;
- private RelativeLayout mobile_rl_mobile;
- private View mobile_mobile_cutting_line;
-
- private int countdown = 60;
-
- private boolean isDestroy = false;
-
- private UserEntity user;
-
- private Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (!isDestroy) {
- if (msg.what == 0) {
- if (countdown == 0) {
- mobile_tv_send_again.setText("重新获取");
- mobile_tv_send_again.setClickable(true);
- } else if (countdown > 0) {
- mobile_tv_send_again.setText("重新获取(" + countdown--
- + ")");
- sendEmptyMessageDelayed(0, 1000);
- }
- }
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- user = (UserEntity) AppController.get("user", false);
-
- View contentView = View.inflate(this, R.layout.activity_mobile, null);
-
- init(contentView, "绑定手机");
-
- TextView mobile_tv_account = (TextView) findViewById(R.id.mobile_tv_account);
- mobile_tv_account.setText(user.getAccount());
-
- mobile_et_mobile.requestFocus();
- mobile_iv_mobile_clean.setOnClickListener(this);
- mobile_et_mobile.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() > 0) {
- mobile_iv_mobile_clean.setVisibility(View.VISIBLE);
- } else {
- mobile_iv_mobile_clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
-
- }
- });
-
- mobile_et_mobile
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String mobileNumber = mobile_et_mobile.getText()
- .toString();
- if (TextUtils.isEmpty(mobileNumber)) {
- toast("请输入手机号码");
- return true;
- } else if (mobileNumber.length() != 11) {
- toast("手机号码长度错误");
- return true;
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- toast("手机号码错误");
- return true;
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- mobile_et_mobile.getWindowToken(), 0);
- getCode(mobileNumber);
- }
- }
- return false;
- }
- });
-
- mobile_et_code
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String code = mobile_et_code.getText().toString()
- .trim();
- if (TextUtils.isEmpty(code)) {
- toast("请输入验证码");
- return true;
- } else if (code.length() != 6) {
- toast("验证码长度错误");
- return true;
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- mobile_et_code.getWindowToken(), 0);
- binding(mobile_et_mobile.getHint().toString(),
- code);
- }
- }
- return false;
- }
- });
-
- mobile_tv_send_again.setOnClickListener(this);
- mobile_tv_send_again.setClickable(false);
-
- mobile_tv_confirm.setOnClickListener(this);
- }
-
- Runnable showSoftInput = new Runnable() {
- @Override
- public void run() {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(mobile_et_code, InputMethodManager.SHOW_FORCED);
- }
- };
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.mobile_iv_mobile_clean) {
- mobile_et_mobile.setText("");
- } else if (v.getId() == R.id.mobile_tv_confirm) {
- String str = mobile_tv_confirm.getText().toString().trim();
- if ("发送验证码".equals(str)) {
- String mobileNumber = mobile_et_mobile.getText().toString();
- if (TextUtils.isEmpty(mobileNumber)) {
- toast("请输入手机号码");
- } else if (mobileNumber.length() != 11) {
- toast("手机号码长度错误");
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- toast("手机号码错误");
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- mobile_et_mobile.getWindowToken(), 0);
- getCode(mobileNumber);
- }
- } else if ("确定绑定号码".equals(str)) {
- String code = mobile_et_code.getText().toString().trim();
- if (TextUtils.isEmpty(code)) {
- toast("请输入验证码");
- } else if (code.length() != 6) {
- toast("验证码长度错误");
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- mobile_et_code.getWindowToken(), 0);
- binding(mobile_et_mobile.getHint().toString(), code);
- }
- } else if ("确定".equals(str)) {
- finish();
- }
- } else if (v.getId() == R.id.mobile_tv_send_again) {
- getCode(mobile_et_mobile.getHint().toString());
- }
- }
-
- // 绑定手机号码
- private void binding(final String mobileNumber, final String code) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(
- MobileActivity.this, "绑定中...");
- new Thread() {
- @Override
- public void run() {
- String token = TokenUtils.getToken(MobileActivity.this);
- String url = Config.HOST + "v2/user/mobile?time="
- + System.currentTimeMillis();
- HashMap params = new HashMap();
- params.put("code", code);
- params.put("mobile_number", mobileNumber);
- params.put("type", "binding");
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- Utils.log(response.toString());
- waitDialog.dismiss();
- if (!isDestroy) {
- try {
- if ("success".equals(response
- .getString("status"))) {
- toast("绑定成功");
- mobile_tv_confirm.setText("确定");
-
- user.setMobileNumber(mobileNumber
- .substring(0, 3)
- + "****"
- + mobileNumber.substring(7,
- 11));
-
- mobile_tv_title
- .setVisibility(View.VISIBLE);
- mobile_tv_hint.setText("您已成功绑定手机"
- + user.getMobileNumber());
- mobile_tv_hint
- .setTextColor(0xff666666);
-
- mobile_rl_mobile
- .setVisibility(View.GONE);
- mobile_ll_code
- .setVisibility(View.GONE);
-
- handler.removeMessages(0);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(
- error.networkResponse.data));
- if (!response.isNull("reason")
- && "MOBILE_NUMBER_ERROR".equals(response
- .getString("reason"))) {
- toast("手机号码错误");
- return;
- } else if (!response.isNull("reason")
- && "CODE_ERROR".equals(response
- .getString("reason"))) {
- toast("验证码错误");
- return;
- } else if (!response.isNull("reason")
- && "CODE_EXPIRE".equals(response
- .getString("reason"))) {
- toast("验证码过期");
- return;
- }
- }
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- toast("发送失败");
- }
- });
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- MobileActivity.class);
- }
- }.start();
- }
-
- // 获取验证码
- private void getCode(final String mobileNumber) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(this, "发送中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/mobile/code/"
- + mobileNumber + "?time=" + System.currentTimeMillis();
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- url, new Response.Listener() {
-
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- if (!isDestroy) {
- try {
- if ("success".equals(response
- .getString("status"))) {
- toast("发送成功");
- if (mobile_tv_send_again != null) {
- mobile_tv_send_again
- .setClickable(false);
- }
- waitDialog.dismiss();
-
- mobile_tv_confirm.setText("确定绑定号码");
-
- mobile_rl_mobile
- .setBackgroundResource(R.drawable.border_input_up);
- mobile_et_mobile.setEnabled(false);
- mobile_et_mobile.setText("");
- mobile_et_mobile
- .setHint(mobileNumber);
- mobile_iv_mobile
- .setImageResource(R.drawable.register_mobile_up);
- mobile_mobile_cutting_line
- .setBackgroundColor(0xffDBDBDB);
- mobile_iv_mobile_clean
- .setVisibility(View.GONE);
-
- mobile_ll_code
- .setVisibility(View.VISIBLE);
- countdown = 60;
- handler.removeMessages(0);
- handler.sendEmptyMessage(0);
-
- mobile_et_code.requestFocus();
- handler.postDelayed(showSoftInput,
- 300);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(
- error.networkResponse.data));
- if (!response.isNull("reason")
- && "MOBILE_NUMBER_ERROR".equals(response
- .getString("reason"))) {
- toast("手机号码错误");
- return;
- } else if (!response.isNull("reason")
- && "USER_EXIST".equals(response
- .getString("reason"))) {
- toast("用户已存在");
- return;
- } else if (!response.isNull("reason")
- && "TIME_IS_NOT".equals(response
- .getString("reason"))) {
- toast("稍后再试");
- return;
- }
- }
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- toast("发送失败");
- }
- });
- String token = TokenUtils.getToken(MobileActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- MobileActivity.class);
- }
- }.start();
- }
-
- public void onEventMainThread(EBSms sms) {
- if ("身份验证".equals(sms.getType()) && mobile_et_code != null) {
- mobile_et_code.setText(sms.getCode());
- }
- }
-
- @Override
- public void finish() {
-
- if (user.getMobileNumber() != null) {
- setResult(RESULT_OK);
- }
- super.finish();
- }
-
- @Override
- protected void onDestroy() {
-
- super.onDestroy();
- isDestroy = true;
- mobile_tv_title = null;
- mobile_tv_hint = null;
- mobile_tv_send_again = null;
- mobile_tv_confirm = null;
- mobile_et_mobile = null;
- mobile_et_code = null;
- mobile_iv_mobile = null;
- mobile_iv_mobile_clean = null;
- mobile_ll_code = null;
- mobile_rl_mobile = null;
- mobile_mobile_cutting_line = null;
- handler = null;
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/ModifyMobileActivity.java b/app/src/main/java/com/gh/gamecenter/ModifyMobileActivity.java
deleted file mode 100644
index 2542d7a995..0000000000
--- a/app/src/main/java/com/gh/gamecenter/ModifyMobileActivity.java
+++ /dev/null
@@ -1,406 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.text.TextUtils;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.android.volley.Request.Method;
-import com.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gh.base.AppController;
-import com.gh.base.BaseActivity;
-import com.gh.common.constant.Config;
-import com.gh.common.constant.Constants;
-import com.gh.common.util.DialogUtils;
-import com.gh.common.util.TokenUtils;
-import com.gh.common.util.Utils;
-import com.gh.gamecenter.entity.UserEntity;
-import com.gh.gamecenter.eventbus.EBSms;
-import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.regex.Pattern;
-
-public class ModifyMobileActivity extends BaseActivity implements
- OnClickListener {
-
- private TextView modify_tv_title, modify_tv_step_one, mobile_tv_step_two,
- mobile_tv_step_three, modify_tv_send_again, modify_tv_confirm,
- modify_tv_mobile;
- private RelativeLayout modify_rl_mobile;
- private ImageView modify_iv_mobile, modify_iv_mobile_clean;
- private View modify_mobile_cutting_line;
- private EditText modify_et_mobile, modify_et_code;
- private LinearLayout modify_ll_code;
-
- private UserEntity user;
-
- private int step;
- private int countdown;
-
- private boolean isDestroy = false;
-
- private Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (!isDestroy) {
- if (msg.what == 0) {
- if (countdown == 0) {
- modify_tv_send_again.setText("重新获取");
- modify_tv_send_again.setClickable(true);
- } else if (countdown > 0) {
- modify_tv_send_again.setText("重新获取(" + countdown-- + ")");
- sendEmptyMessageDelayed(0, 1000);
- }
- }
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- user = (UserEntity) AppController.get("user", false);
-
- View contentView = View.inflate(this, R.layout.activity_modifymobile,
- null);
-
- init(contentView, "更换绑定手机");
-
- TextView modify_tv_account = (TextView) findViewById(R.id.modify_tv_account);
- modify_tv_account.setText(user.getAccount());
-
- modify_tv_mobile.setText(user.getMobileNumber());
-
- modify_tv_send_again.setOnClickListener(this);
- modify_tv_send_again.setClickable(false);
-
- modify_tv_confirm.setOnClickListener(this);
-
- step = 1;
- }
-
- Runnable showSoftInput = new Runnable() {
- @Override
- public void run() {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- if (step == 2 || step == 4) {
- imm.showSoftInput(modify_et_code,
- InputMethodManager.SHOW_FORCED);
- } else if (step == 3) {
- imm.showSoftInput(modify_et_mobile,
- InputMethodManager.SHOW_FORCED);
- }
- }
- };
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.modify_tv_confirm) {
- if (step == 1 || step == 3) {
- String mobileNumber = modify_et_mobile.getText().toString();
- if (TextUtils.isEmpty(mobileNumber)) {
- toast("请输入手机号码");
- } else if (mobileNumber.length() != 11) {
- toast("手机号码长度错误");
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- toast("手机号码格式错误");
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- modify_et_mobile.getWindowToken(), 0);
- getCode(mobileNumber);
- }
- } else if (step == 2 || step == 4) {
- String code = modify_et_code.getText().toString().trim();
- if (TextUtils.isEmpty(code)) {
- toast("请输入验证码");
- } else if (code.length() != 6) {
- toast("验证码长度错误");
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- modify_et_code.getWindowToken(), 0);
- if (step == 2) {
- verifyMobile(modify_et_mobile.getHint().toString(),
- code);
- } else if (step == 4) {
- binding(modify_et_mobile.getHint().toString(), code);
- }
- }
- } else if (step == 0) {
- finish();
- }
- } else if (v.getId() == R.id.modify_tv_send_again) {
- getCode(modify_et_mobile.getText().toString());
- }
- }
-
- private void getCode(final String mobileNumber) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(this, "发送中...");
- new Thread() {
- @Override
- public void run() {
- String url = null;
- if (step == 1) {
- url = Config.HOST + "v2/user/verifymobile/code/"
- + mobileNumber + "?time="
- + System.currentTimeMillis();
- } else if (step == 3) {
- url = Config.HOST + "v2/user/modifymobile/code/"
- + mobileNumber + "?time="
- + System.currentTimeMillis();
- }
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- url, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- if ("success".equals(response
- .getString("status"))) {
- toast("发送成功");
- if (modify_tv_send_again != null) {
- modify_tv_send_again
- .setClickable(false);
- }
- if (step == 1) {
- step = 2;
- } else if (step == 3) {
- step = 4;
- }
- if (step == 2) {
- modify_tv_confirm
- .setText("验证原绑定号码");
- } else if (step == 4) {
- modify_tv_confirm.setText("确定绑定号码");
- }
-
- modify_rl_mobile
- .setBackgroundResource(R.drawable.border_input_up);
- modify_et_mobile.setEnabled(false);
- modify_et_mobile.setText("");
- modify_et_mobile.setHint(mobileNumber);
- modify_iv_mobile
- .setImageResource(R.drawable.register_mobile_up);
- modify_mobile_cutting_line
- .setBackgroundColor(0xffDBDBDB);
- modify_iv_mobile_clean
- .setVisibility(View.GONE);
-
- modify_ll_code
- .setVisibility(View.VISIBLE);
- countdown = 60;
- handler.removeMessages(0);
- handler.sendEmptyMessage(0);
-
- modify_et_code.setText("");
- modify_et_code.requestFocus();
- handler.postDelayed(showSoftInput, 300);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- }
- });
- String token = TokenUtils.getToken(ModifyMobileActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- ModifyMobileActivity.class);
- }
- }.start();
- }
-
- private void verifyMobile(final String mobileNumber, final String code) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(this, "验证中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST
- + "v2/user/mobile/verify?mobile_number=" + mobileNumber
- + "&code=" + code + "&time="
- + System.currentTimeMillis();
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- url, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- if ("success".equals(response
- .getString("status"))) {
- toast("验证成功");
- step = 3;
-
- modify_tv_confirm.setText("发送验证码");
-
- modify_tv_step_one
- .setTextColor(0xff666666);
- mobile_tv_step_three
- .setVisibility(View.VISIBLE);
-
- modify_rl_mobile.setBackgroundResource(R.drawable.border_input_dn);
- modify_et_mobile.setEnabled(true);
- modify_et_mobile.setText("");
- modify_et_mobile.setHint("请输入新号码");
- modify_iv_mobile
- .setImageResource(R.drawable.register_mobile_dn);
- modify_mobile_cutting_line
- .setBackgroundColor(0xff1BA4FC);
-
- modify_ll_code.setVisibility(View.GONE);
-
- mobile_tv_step_two
- .setVisibility(View.GONE);
-
- modify_et_mobile.requestFocus();
- handler.postDelayed(showSoftInput, 300);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- }
- });
- String token = TokenUtils.getToken(ModifyMobileActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- ModifyMobileActivity.class);
- }
- }.start();
- }
-
- private void binding(final String mobileNumber, final String code) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(this, "绑定中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/mobile?time="
- + System.currentTimeMillis();
- HashMap params = new HashMap();
- params.put("mobile_number", mobileNumber);
- params.put("code", code);
- params.put("type", "modify");
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- if ("success".equals(response
- .getString("status"))) {
- step = 0;
-
- modify_tv_confirm.setText("确定");
-
- modify_tv_title.setText("绑定成功");
- modify_tv_title
- .setTextColor(0xff1BA4FC);
-
- user.setMobileNumber(mobileNumber
- .substring(0, 3)
- + "****"
- + mobileNumber.substring(7, 11));
-
- modify_tv_step_one.setText("您已成功绑定手机"
- + user.getMobileNumber());
- mobile_tv_step_three
- .setVisibility(View.GONE);
- modify_rl_mobile
- .setVisibility(View.GONE);
- modify_ll_code.setVisibility(View.GONE);
-
- modify_tv_mobile.setText(user
- .getMobileNumber());
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- }
- });
- String token = TokenUtils.getToken(ModifyMobileActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- ModifyMobileActivity.class);
- }
- }.start();
- }
-
- public void onEventMainThread(EBSms sms) {
- if ("身份验证".equals(sms.getType()) && modify_et_code != null) {
- modify_et_code.setText(sms.getCode());
- } else if ("变更验证".equals(sms.getType()) && modify_et_code != null) {
- modify_et_code.setText(sms.getCode());
- }
- }
-
- @Override
- protected void onDestroy() {
-
- super.onDestroy();
- isDestroy = true;
- modify_tv_title = null;
- modify_tv_step_one = null;
- mobile_tv_step_two = null;
- mobile_tv_step_three = null;
- modify_tv_send_again = null;
- modify_tv_confirm = null;
- modify_tv_mobile = null;
- modify_rl_mobile = null;
- modify_iv_mobile = null;
- modify_iv_mobile_clean = null;
- modify_mobile_cutting_line = null;
- modify_et_mobile = null;
- modify_et_code = null;
- modify_ll_code = null;
- user = null;
- handler = null;
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/OriginalActivity.java b/app/src/main/java/com/gh/gamecenter/OriginalActivity.java
new file mode 100644
index 0000000000..cdac6afb09
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/OriginalActivity.java
@@ -0,0 +1,73 @@
+package com.gh.gamecenter;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
+import com.gh.base.BaseActivity;
+import com.gh.common.view.VerticalItemDecoration;
+import com.gh.gamecenter.adapter.OriginalAdapter;
+
+/**
+ * Created by LGT on 2016/6/12.
+ */
+public class OriginalActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener {
+
+ private SwipeRefreshLayout original_swipe_refresh;
+ private RecyclerView original_list;
+ private LinearLayoutManager layoutManager;
+ private OriginalAdapter adapter;
+ private ProgressBarCircularIndeterminate original_pb_loading;
+ private LinearLayout reuse_no_connection;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ View contentView = View.inflate(this, R.layout.activity_original, null);
+
+ init(contentView, "原创");
+
+ original_swipe_refresh.setColorSchemeResources(R.color.theme_colors);
+ original_swipe_refresh.setOnRefreshListener(this);
+
+ reuse_no_connection.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ original_swipe_refresh.setRefreshing(true);
+ original_list.setVisibility(View.VISIBLE);
+ original_pb_loading.setVisibility(View.VISIBLE);
+ reuse_no_connection.setVisibility(View.GONE);
+ }
+ });
+
+ original_list.setHasFixedSize(true);
+ layoutManager = new LinearLayoutManager(this);
+ original_list.setLayoutManager(layoutManager);
+ adapter = new OriginalAdapter(this, original_swipe_refresh,
+ original_pb_loading, reuse_no_connection, true);
+ original_list.setAdapter(adapter);
+ original_list.addItemDecoration(new VerticalItemDecoration(this, 1));
+ }
+
+ private Handler handler = new Handler();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ adapter = new OriginalAdapter(OriginalActivity.this, original_swipe_refresh,
+ original_pb_loading, reuse_no_connection, true);
+ original_list.setAdapter(adapter);
+ }
+ };
+
+ @Override
+ public void onRefresh() {
+ handler.postDelayed(runnable, 1000);
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/PasswordActivity.java b/app/src/main/java/com/gh/gamecenter/PasswordActivity.java
deleted file mode 100644
index 9011292f71..0000000000
--- a/app/src/main/java/com/gh/gamecenter/PasswordActivity.java
+++ /dev/null
@@ -1,367 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.Dialog;
-import android.os.Bundle;
-import android.text.InputType;
-import android.text.TextUtils;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.EditorInfo;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.android.volley.Request.Method;
-import com.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gh.base.AppController;
-import com.gh.base.BaseActivity;
-import com.gh.common.constant.Config;
-import com.gh.common.constant.Constants;
-import com.gh.common.util.DialogUtils;
-import com.gh.common.util.RSEUtils;
-import com.gh.common.util.TokenUtils;
-import com.gh.common.util.Utils;
-import com.gh.gamecenter.entity.UserEntity;
-import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.regex.Pattern;
-
-public class PasswordActivity extends BaseActivity implements OnClickListener {
-
- private EditText password_et_current, password_et_new, password_et_again;
- private View password_line_one, password_line_two, password_line_three;
- private ImageView password_iv_show;
-
- private UserEntity user;
-
- private boolean isShowPassword = true;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- user = (UserEntity) AppController.get("user", false);
-
- View contentView = View.inflate(this, R.layout.activity_password, null);
-
- if (user.isActivation()) {
- init(contentView, "修改密码");
- } else {
- init(contentView, "设置密码");
- }
-
- findViewById(R.id.password_tv_confirm).setOnClickListener(this);
-
- findViewById(R.id.password_ll_show).setOnClickListener(this);
-
- password_et_current
- .setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- password_line_one.setBackgroundColor(0xff1BA4FC);
- } else {
- password_line_one.setBackgroundColor(0xffCCCCCC);
- }
- }
- });
- password_et_new
- .setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- password_line_two.setBackgroundColor(0xff1BA4FC);
- } else {
- password_line_two.setBackgroundColor(0xffCCCCCC);
- }
- }
- });
- password_et_again
- .setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- password_line_three.setBackgroundColor(0xff1BA4FC);
- } else {
- password_line_three.setBackgroundColor(0xffCCCCCC);
- }
- }
- });
-
- password_et_current
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_NEXT) {
- String currentPassword = password_et_current
- .getText().toString().trim();
- if (TextUtils.isEmpty(currentPassword)) {
- toast("请输入旧密码");
- password_et_current.requestFocus();
- return true;
- }
- }
- return false;
- }
- });
- password_et_new
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_NEXT) {
- String newPassword = password_et_new.getText()
- .toString().trim();
- if (TextUtils.isEmpty(newPassword)) {
- toast("请输入新密码");
- password_et_new.requestFocus();
- return true;
- } else if (newPassword.length() < 6
- || newPassword.length() > 32) {
- toast("新密码长度错误");
- password_et_new.requestFocus();
- return true;
- } else if (!Pattern.matches(
- Constants.REGEX_PASSWORD, newPassword)) {
- toast("新密码格式错误");
- password_et_new.requestFocus();
- return true;
- }
- }
- return false;
- }
- });
- password_et_again
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String newPassword = password_et_new.getText()
- .toString().trim();
- String confirmPassword = password_et_again
- .getText().toString().trim();
- if (TextUtils.isEmpty(newPassword)) {
- toast("请输入新密码");
- password_et_new.requestFocus();
- return true;
- } else if (newPassword.length() < 6
- || newPassword.length() > 32) {
- toast("新密码长度错误");
- password_et_new.requestFocus();
- return true;
- } else if (!Pattern.matches(
- Constants.REGEX_PASSWORD, newPassword)) {
- toast("新密码格式错误");
- password_et_new.requestFocus();
- return true;
- } else if (!newPassword.equals(confirmPassword)) {
- toast("两次输入的密码不相同");
- password_et_again.requestFocus();
- return true;
- } else {
- if (user.isActivation()) {
- String currentPassword = password_et_current
- .getText().toString().trim();
- if (TextUtils.isEmpty(currentPassword)) {
- toast("请输入旧密码");
- password_et_current.requestFocus();
- return true;
- } else {
- Dialog dialog = DialogUtils.showWaitDialog(PasswordActivity.this, "修改中...");
- modifyPassword(dialog, currentPassword, newPassword);
- }
- } else {
- Dialog dialog = DialogUtils.showWaitDialog(PasswordActivity.this, "设置中...");
- modifyPassword(dialog, null, newPassword);
- }
- }
- }
- return false;
- }
- });
-
- password_et_current.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_NORMAL);
- password_et_new.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_NORMAL);
- password_et_again.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_NORMAL);
-
- if (user.isActivation()) {
- password_et_current.requestFocus();
- } else {
- findViewById(R.id.password_tv_current).setVisibility(View.GONE);
- password_et_current.setVisibility(View.GONE);
- password_line_one.setVisibility(View.GONE);
- password_et_new.requestFocus();
- }
-
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.password_tv_confirm) {
- String newPassword = password_et_new.getText().toString().trim();
- String confirmPassword = password_et_again.getText().toString()
- .trim();
- if (TextUtils.isEmpty(newPassword)) {
- toast("请输入新密码");
- password_et_new.requestFocus();
- } else if (newPassword.length() < 6 || newPassword.length() > 32) {
- toast("新密码长度错误");
- password_et_new.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_PASSWORD, newPassword)) {
- toast("新密码格式错误");
- password_et_new.requestFocus();
- } else if (!newPassword.equals(confirmPassword)) {
- toast("两次输入的密码不相同");
- password_et_again.requestFocus();
- } else {
- if (user.isActivation()) {
- String currentPassword = password_et_current.getText()
- .toString().trim();
- if (TextUtils.isEmpty(currentPassword)) {
- toast("请输入旧密码");
- password_et_current.requestFocus();
- } else {
- Dialog dialog = DialogUtils.showWaitDialog(this, "修改中...");
- modifyPassword(dialog, currentPassword, newPassword);
- }
- } else {
- Dialog dialog = DialogUtils.showWaitDialog(this, "设置中...");
- modifyPassword(dialog, null, newPassword);
- }
- }
- } else if (v.getId() == R.id.password_ll_show) {
- if (isShowPassword) {
- isShowPassword = false;
- password_iv_show
- .setBackgroundResource(R.drawable.login_auto_style);
- password_et_current.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- password_et_new.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- password_et_again.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- } else {
- isShowPassword = true;
- password_iv_show
- .setBackgroundResource(R.drawable.login_auto_dn);
- password_et_current.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_NORMAL);
- password_et_new.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_NORMAL);
- password_et_again.setInputType(InputType.TYPE_CLASS_TEXT
- | InputType.TYPE_TEXT_VARIATION_NORMAL);
- }
- if (password_et_current.isFocused()) {
- password_et_current.setSelection(password_et_current.getText()
- .length());
- }
- if (password_et_new.isFocused()) {
- password_et_new
- .setSelection(password_et_new.getText().length());
- }
- if (password_et_again.isFocused()) {
- password_et_again.setSelection(password_et_again.getText()
- .length());
- }
- }
- }
-
- // 修改密码
- private void modifyPassword(final Dialog dialog,
- final String currentPassword, final String newPassword) {
- new Thread() {
- @Override
- public void run() {
- String token = TokenUtils.getToken(PasswordActivity.this);
- String url = Config.HOST + "v2/user/password?time="
- + System.currentTimeMillis();
- HashMap params = new HashMap();
- if (currentPassword != null) {
- try {
- String s = RSEUtils.encryptByPublic(currentPassword + user.getAccount() + System.currentTimeMillis() / 1000);
- Utils.log("加密 = " + s);
- params.put("current_password", s);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- }
- try {
- String s = RSEUtils.encryptByPublic(newPassword + user.getAccount() + System.currentTimeMillis() / 1000);
- Utils.log("加密 = " + s);
- params.put("new_password", s);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
-
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- dialog.dismiss();
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- dialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("PASSWORD_ERROR".equals(reason)) {
- toast("两次输入的密码不相同");
- password_et_again.requestFocus();
- return;
- } else if ("PASSWORD_ILLEGAL".equals(reason)) {
- toast("新密码格式错误");
- password_et_new.requestFocus();
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- if (currentPassword != null) {
- toast("修改密码失败");
- } else {
- toast("设置密码失败");
- }
- }
- });
- request.addHeader("Auth", token);
- request.setShouldCache(false);
- AppController.addToRequestQueue(request,
- PasswordActivity.class);
- }
- }.start();
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/RetrieveActivity.java b/app/src/main/java/com/gh/gamecenter/RetrieveActivity.java
deleted file mode 100644
index 957d17293f..0000000000
--- a/app/src/main/java/com/gh/gamecenter/RetrieveActivity.java
+++ /dev/null
@@ -1,575 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.text.TextUtils;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.android.volley.Request.Method;
-import com.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gh.base.AppController;
-import com.gh.base.BaseActivity;
-import com.gh.common.constant.Config;
-import com.gh.common.constant.Constants;
-import com.gh.common.util.DialogUtils;
-import com.gh.common.util.RSEUtils;
-import com.gh.common.util.TokenUtils;
-import com.gh.common.util.Utils;
-import com.gh.gamecenter.eventbus.EBSms;
-import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.regex.Pattern;
-
-public class RetrieveActivity extends BaseActivity implements OnClickListener {
-
- private LinearLayout retrieve_ll_mobile, retrieve_ll_title,
- retrieve_ll_account;
- private ImageView retrieve_iv_title, retrieve_iv_mobile_clean,
- retrieve_iv_password_clean, retrieve_iv_mobile;
- private TextView retrieve_tv_title, retrieve_tv_hint, retrieve_tv_again,
- retrieve_tv_confrim, retrieve_tv_account, retrieve_tv_mobile;
- private RelativeLayout retrieve_rl_mobile, retrieve_rl_password;
- private EditText retrieve_et_account, retrieve_et_password,
- retrieve_et_mobile;
- private View retrieve_line_one, retrieve_line_two,
- retrieve_mobile_cutting_line, retrieve_line;
-
- private int countdown = 60;
- private boolean isDestroy = false;
-
- private Handler handler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (!isDestroy) {
- if (msg.what == 0) {
- if (countdown == 0) {
- retrieve_tv_again.setText("重新获取");
- retrieve_tv_again
- .setBackgroundResource(R.drawable.textview_logout_style);
- retrieve_tv_again.setClickable(true);
- } else if (countdown > 0) {
- retrieve_tv_again.setText("重新获取(" + countdown-- + ")");
- sendEmptyMessageDelayed(0, 1000);
- }
- }
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- View contentView = View.inflate(this, R.layout.activity_retrieve, null);
-
- init(contentView, "找回密码");
-
- retrieve_et_account.requestFocus();
-
- retrieve_line = findViewById(R.id.retrieve_line);
-
- retrieve_tv_again.setOnClickListener(this);
-
- retrieve_tv_confrim.setOnClickListener(this);
-
- retrieve_et_account
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String account = retrieve_et_account.getText()
- .toString().trim();
- if (TextUtils.isEmpty(account)) {
- toast("请输入光环号");
- retrieve_et_account.requestFocus();
- return true;
- } else if (account.length() < 6
- || account.length() > 18) {
- toast("光环号长度错误");
- retrieve_et_account.requestFocus();
- return true;
- } else {
- verifyAccount(account);
- }
- }
- return false;
- }
- });
-
- retrieve_et_mobile
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- Utils.log("retrieve_et_mobile");
- }
- return false;
- }
- });
- retrieve_et_mobile
- .setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
-
- if (hasFocus) {
- retrieve_rl_mobile.setBackgroundResource(R.drawable.border_input_dn);
- } else {
- retrieve_rl_mobile.setBackgroundResource(R.drawable.border_input_up);
- }
- }
- });
-
- retrieve_et_password
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- Utils.log("retrieve_et_password");
- }
- return false;
- }
- });
- retrieve_et_password
- .setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
-
- if (hasFocus) {
- retrieve_rl_password.setBackgroundResource(R.drawable.border_input_dn);
- } else {
- retrieve_rl_password.setBackgroundResource(R.drawable.border_input_up);
- }
- }
- });
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.retrieve_tv_confrim) {
- String str = retrieve_tv_confrim.getText().toString();
- if ("下一步".equals(str)) {
- String account = retrieve_et_account.getText().toString()
- .trim();
- if (TextUtils.isEmpty(account)) {
- toast("请输入光环号");
- retrieve_et_account.requestFocus();
- } else if (account.length() < 6 || account.length() > 18) {
- toast("光环号长度错误");
- retrieve_et_account.requestFocus();
- } else {
- verifyAccount(account);
- }
- } else if ("返回登录页面".equals(str)) {
- finish();
- } else if ("获取验证码".equals(str)) {
- String mobileNumber = retrieve_et_mobile.getText().toString()
- .trim();
- if (TextUtils.isEmpty(mobileNumber)) {
- toast("请输入手机号码");
- retrieve_et_mobile.requestFocus();
- } else if (mobileNumber.length() != 11) {
- toast("手机号码长度错误");
- retrieve_et_mobile.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- toast("手机号码错误");
- retrieve_et_mobile.requestFocus();
- } else {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(
- retrieve_et_mobile.getWindowToken(), 0);
- String account = retrieve_et_account.getText().toString()
- .trim();
- getCode(account, mobileNumber, true);
- }
- } else if ("确定修改密码".equals(str)) {
- String account = retrieve_tv_account.getText().toString();
- String mobile_number = retrieve_tv_mobile.getText().toString();
- String code = retrieve_et_mobile.getText().toString().trim();
- String password = retrieve_et_password.getText().toString()
- .trim();
- if (TextUtils.isEmpty(code)) {
- toast("验证码为空");
- retrieve_et_mobile.requestFocus();
- } else if (code.length() != 6) {
- toast("验证码长度错误");
- retrieve_et_mobile.requestFocus();
- } else if (!Pattern.matches("^\\d{6}$", code)) {
- toast("验证码格式错误");
- retrieve_et_mobile.requestFocus();
- } else if (TextUtils.isEmpty(password)) {
- toast("请输入密码");
- retrieve_et_password.requestFocus();
- } else if (password.length() < 6 || password.length() > 32) {
- toast("密码长度错误");
- retrieve_et_password.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_PASSWORD, password)) {
- toast("密码格式错误");
- retrieve_et_password.requestFocus();
- } else {
- resetPassword(account, mobile_number, code, password);
- }
- } else if ("确定".equals(str)) {
- finish();
- }
- } else if (v.getId() == R.id.retrieve_tv_again) {
- String account = retrieve_tv_account.getText().toString();
- String mobile_number = retrieve_tv_mobile.getText().toString();
- getCode(account, mobile_number, false);
- }
- }
-
- Runnable showSoftInput = new Runnable() {
- @Override
- public void run() {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(retrieve_et_mobile,
- InputMethodManager.SHOW_FORCED);
- }
- };
-
- private void verifyAccount(final String account) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(
- RetrieveActivity.this, "检查中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/account/verify?account="
- + account + "&time=" + System.currentTimeMillis();
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- url, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- String status = response
- .getString("status");
- if ("success".equals(status)) {
- retrieve_et_account
- .setVisibility(View.GONE);
- retrieve_line.setVisibility(View.GONE);
- retrieve_rl_mobile
- .setVisibility(View.VISIBLE);
- retrieve_ll_account
- .setVisibility(View.VISIBLE);
- retrieve_tv_account.setText(account);
- retrieve_tv_confrim.setText("获取验证码");
- retrieve_iv_mobile
- .setVisibility(View.VISIBLE);
- retrieve_mobile_cutting_line
- .setVisibility(View.VISIBLE);
- retrieve_et_mobile.setText("");
- retrieve_et_mobile.setHint("请输入绑定的手机号");
- retrieve_line_one
- .setVisibility(View.VISIBLE);
- retrieve_line_two
- .setVisibility(View.VISIBLE);
- retrieve_et_mobile.requestFocus();
- handler.postDelayed(showSoftInput, 300);
- } else if ("nomobile".equals(status)) {
- retrieve_et_account
- .setVisibility(View.GONE);
- retrieve_line.setVisibility(View.GONE);
- retrieve_ll_account
- .setVisibility(View.VISIBLE);
- retrieve_rl_mobile
- .setVisibility(View.GONE);
- retrieve_tv_confrim.setText("返回登录页面");
- retrieve_tv_account.setText(account);
- retrieve_ll_title
- .setVisibility(View.VISIBLE);
- retrieve_tv_hint
- .setVisibility(View.VISIBLE);
- retrieve_line_two
- .setVisibility(View.VISIBLE);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(
- error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("USER_NO_EXIST".equals(reason)) {
- toast("用户不存在");
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- toast("验证失败");
- }
- });
- String token = TokenUtils.getToken(RetrieveActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- RetrieveActivity.class);
- }
- }.start();
- }
-
- private void getCode(final String account, final String mobileNumber,
- final boolean isFirst) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(
- RetrieveActivity.this, "发送中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/modifypassword/code/"
- + mobileNumber + "?account=" + account + "&time="
- + System.currentTimeMillis();
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- url, new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- if ("success".equals(response
- .getString("status"))) {
- toast("发送成功");
- if (isFirst) {
- retrieve_ll_mobile.setVisibility(View.VISIBLE);
- retrieve_tv_mobile.setText(mobileNumber);
- retrieve_tv_confrim.setText("确定修改密码");
- retrieve_iv_mobile.setVisibility(View.GONE);
- retrieve_mobile_cutting_line.setVisibility(View.GONE);
- retrieve_et_mobile.setText("");
- retrieve_et_mobile.setHint("请输入短信验证码");
- retrieve_rl_password.setVisibility(View.VISIBLE);
- retrieve_tv_again.setVisibility(View.VISIBLE);
- retrieve_line_one.setVisibility(View.VISIBLE);
- retrieve_line_two.setVisibility(View.VISIBLE);
- }
- retrieve_tv_again.setClickable(false);
-
- countdown = 60;
- handler.removeMessages(0);
- handler.sendEmptyMessage(0);
-
- retrieve_et_mobile.requestFocus();
- handler.postDelayed(showSoftInput, 300);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(
- error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("TIME_IS_NOT".equals(reason)) {
- toast("请稍后再试");
- return;
- } else if ("MOBILE_NUMBER_ERROR"
- .equals(reason)) {
- toast("手机号码错误");
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- toast("发送失败");
- }
- });
- String token = TokenUtils.getToken(RetrieveActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- RetrieveActivity.class);
- }
- }.start();
- }
-
- private void resetPassword(final String account, final String mobileNumber,
- final String code, final String password) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(
- RetrieveActivity.this, "修改中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/password/reset";
- HashMap params = new HashMap();
- params.put("account", account);
- params.put("mobile_number", mobileNumber);
- params.put("code", code);
- try {
- String s = RSEUtils.encryptByPublic(password + account + System.currentTimeMillis() / 1000);
- Utils.log("加密 = " + s);
- params.put("password", s);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- if ("success".equals(response
- .getString("status"))) {
- retrieve_tv_confrim.setText("确定");
- retrieve_rl_mobile
- .setVisibility(View.GONE);
- retrieve_rl_password
- .setVisibility(View.GONE);
- retrieve_tv_again
- .setVisibility(View.GONE);
- retrieve_ll_title
- .setVisibility(View.VISIBLE);
- retrieve_iv_title
- .setVisibility(View.GONE);
- retrieve_tv_title
- .setVisibility(View.VISIBLE);
- retrieve_tv_title.setText("操作成功");
- retrieve_tv_hint
- .setVisibility(View.VISIBLE);
- retrieve_tv_hint.setText("您的密码已经修改成功!");
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(
- error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("USER_NO_EXIST".equals(reason)) {
- toast("用户不存在");
- return;
- } else if ("CODE_ERROR"
- .equals(reason)) {
- toast("验证码错误");
- return;
- } else if ("CODE_EXPIRE"
- .equals(reason)) {
- toast("验证码已过期");
- return;
- } else if ("PASSWORD_ILLEGAL"
- .equals(reason)) {
- toast("密码格式错误");
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- toast("修改失败");
- }
- });
- String token = TokenUtils.getToken(RetrieveActivity.this);
- request.addHeader("Auth", token);
- AppController.addToRequestQueue(request,
- RetrieveActivity.class);
- }
- }.start();
- }
-
- public void onEventMainThread(EBSms sms) {
- if ("变更验证".equals(sms.getType()) && retrieve_et_mobile != null) {
- retrieve_et_mobile.setText(sms.getCode());
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- isDestroy = true;
- retrieve_ll_mobile = null;
- retrieve_ll_title = null;
- retrieve_ll_account = null;
- retrieve_iv_title = null;
- retrieve_iv_mobile_clean = null;
- retrieve_iv_password_clean = null;
- retrieve_iv_mobile = null;
- retrieve_tv_title = null;
- retrieve_tv_hint = null;
- retrieve_tv_again = null;
- retrieve_tv_confrim = null;
- retrieve_tv_account = null;
- retrieve_tv_mobile = null;
- retrieve_rl_mobile = null;
- retrieve_rl_password = null;
- retrieve_et_account = null;
- retrieve_et_password = null;
- retrieve_et_mobile = null;
- retrieve_line_one = null;
- retrieve_line_two = null;
- retrieve_mobile_cutting_line = null;
- retrieve_line = null;
- handler = null;
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/SettingActivity.java b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
index 086daccba4..09fbd9d865 100644
--- a/app/src/main/java/com/gh/gamecenter/SettingActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
@@ -200,48 +200,44 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
@Override
public void onClick(final View v) {
switch (v.getId()) {
- case R.id.actionbar_rl_back:
- finish();
- break;
- case R.id.setting_rl_autoinstall:
- setting_sb_autoinstall.performClick();
- break;
- case R.id.setting_rl_autodelete:
- setting_sb_autodelete.performClick();
- break;
- case R.id.setting_rl_deletedata:
- setting_sb_deletedata.performClick();
- break;
- case R.id.setting_rl_autoupdate:
- setting_sb_autoupdate.performClick();
- break;
- case R.id.setting_rl_update:
- dialog = DialogUtils.showWaitDialog(this, "检查更新中...");
- if (isChecking)
+ case R.id.actionbar_rl_back:
+ finish();
+ break;
+ case R.id.setting_rl_autoinstall:
+ setting_sb_autoinstall.performClick();
+ break;
+ case R.id.setting_rl_autodelete:
+ setting_sb_autodelete.performClick();
+ break;
+ case R.id.setting_rl_deletedata:
+ setting_sb_deletedata.performClick();
+ break;
+ case R.id.setting_rl_autoupdate:
+ setting_sb_autoupdate.performClick();
+ break;
+ case R.id.setting_rl_update:
+ dialog = DialogUtils.showWaitDialog(this, "检查更新中...");
+ if (isChecking)
+ break;
+ isChecking = true;
+ checkUpdate();
+ break;
+ case R.id.setting_rl_cache:
+ dialog = DialogUtils.showWaitDialog(this, "清除缓存中...");
+ claerCache();
+ break;
+ case R.id.setting_rl_feedback:
+ startActivity(new Intent(SettingActivity.this,
+ SuggestionActivity.class));
+ break;
+ case R.id.setting_tv_disclaimer:
+ String content = sp.getString("disclaimer", null);
+ if (!TextUtils.isEmpty(content)) {
+ showDisclaimerDialog(content);
+ }
+ break;
+ default:
break;
- isChecking = true;
- checkUpdate();
- break;
- case R.id.setting_rl_cache:
- dialog = DialogUtils.showWaitDialog(this, "清除缓存中...");
- claerCache();
- break;
- case R.id.setting_rl_feedback:
- startActivity(new Intent(SettingActivity.this,
- SuggestionActivity.class));
- break;
- case R.id.setting_tv_disclaimer:
- String content = sp.getString("disclaimer", null);
- if (!TextUtils.isEmpty(content)) {
- showDisclaimerDialog(content);
- }
- break;
- case R.id.setting_tv_account:
- startActivity(new Intent(SettingActivity.this,
- AccountActivity.class));
- break;
- default:
- break;
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/UserInfoActivity.java b/app/src/main/java/com/gh/gamecenter/UserInfoActivity.java
deleted file mode 100644
index 9eec6c95b7..0000000000
--- a/app/src/main/java/com/gh/gamecenter/UserInfoActivity.java
+++ /dev/null
@@ -1,461 +0,0 @@
-package com.gh.gamecenter;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.provider.MediaStore;
-import android.text.TextUtils;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup.LayoutParams;
-import android.view.WindowManager;
-import android.view.inputmethod.EditorInfo;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.PopupWindow;
-import android.widget.TextView;
-
-import com.android.volley.Request.Method;
-import com.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gh.base.AppController;
-import com.gh.base.BaseActivity;
-import com.gh.common.constant.Config;
-import com.gh.common.util.DialogUtils;
-import com.gh.common.util.FileUtils;
-import com.gh.common.util.ImageUtils;
-import com.gh.common.util.TokenUtils;
-import com.gh.common.util.Utils;
-import com.gh.common.view.KeyboardLayout;
-import com.gh.common.view.KeyboardLayout.OnKeyboardChangedListener;
-import com.gh.gamecenter.entity.UserEntity;
-import com.gh.gamecenter.eventbus.EBLogout;
-import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
-
-import org.json.JSONObject;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import de.greenrobot.event.EventBus;
-
-public class UserInfoActivity extends BaseActivity implements OnClickListener {
-
- private ImageView userinfo_tv_icon;
- private TextView userinfo_tv_nickname, userinfo_tv_sign;
-
- private UserEntity user;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- user = (UserEntity) AppController.get("user", false);
-
- View contentView = View.inflate(this, R.layout.activity_userinfo, null);
-
- init(contentView, "个人设置");
-
- contentView.findViewById(R.id.userinfo_tv_logout).setOnClickListener(
- this);
- contentView.findViewById(R.id.userinfo_ll_icon)
- .setOnClickListener(this);
- contentView.findViewById(R.id.userinfo_ll_nickname).setOnClickListener(
- this);
- contentView.findViewById(R.id.userinfo_ll_account).setOnClickListener(
- this);
- contentView.findViewById(R.id.userinfo_ll_sign)
- .setOnClickListener(this);
-
- TextView userinfo_tv_account = (TextView) findViewById(R.id.userinfo_tv_account);
- userinfo_tv_account.setText(user.getAccount());
-
- ImageUtils.getInstance(getApplicationContext()).display(user.getIcon(),
- userinfo_tv_icon);
- userinfo_tv_nickname.setText(user.getName());
- if (user.getSign() != null) {
- userinfo_tv_sign.setText(user.getSign());
- }
- }
-
- @Override
- public void onClick(View v) {
- int id = v.getId();
- if (id == R.id.userinfo_tv_logout) {
- DialogUtils.showWaitDialog(this, "退出中...");
- SharedPreferences sp = getSharedPreferences(Config.PREFERENCE,
- Context.MODE_PRIVATE);
- Editor editor = sp.edit();
- editor.remove("token");
- editor.remove("token_expire");
- editor.remove("isLogin");
- editor.remove("username");
- editor.remove("password");
- editor.apply();
- AppController.remove("user");
- new Thread() {
- @Override
- public void run() {
- try {
- sleep(1000);
- } catch (InterruptedException e) {
-
- e.printStackTrace();
- }
- EventBus.getDefault().post(new EBLogout(0));
- finish();
- }
- }.start();
- } else if (id == R.id.userinfo_ll_icon) {
- showModifyIconSelectDialog(v);
- } else if (id == R.id.userinfo_ll_nickname) {
- showModifyNicknameDialog(v);
- } else if (id == R.id.userinfo_ll_sign) {
- showModifySignDialog(v);
- }
- }
-
- private void showModifyIconSelectDialog(View view) {
- View contentView = View.inflate(this, R.layout.dialog_modify_select,
- null);
- final PopupWindow popupWindow = new PopupWindow(contentView,
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
- contentView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- }
- });
- contentView.findViewById(R.id.modify_ll_bottom).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- TextView dialog_register_tv_register = (TextView) contentView
- .findViewById(R.id.modify_tv_register);
- dialog_register_tv_register.setText("拍照");
- dialog_register_tv_register
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- openCamera();
- }
- });
- TextView dialog_register_tv_onekey = (TextView) contentView
- .findViewById(R.id.modify_tv_onekey);
- dialog_register_tv_onekey.setText("从相册选择");
- dialog_register_tv_onekey
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- openAlbum();
- }
- });
- contentView.setFocusable(true);
- contentView.setFocusableInTouchMode(true);
- contentView.setOnKeyListener(new View.OnKeyListener() {
- @Override
- public boolean onKey(View v, int keyCode, KeyEvent event) {
-
- if (keyCode == KeyEvent.KEYCODE_BACK
- && event.getRepeatCount() == 0 && popupWindow != null
- && popupWindow.isShowing()) {
- popupWindow.dismiss();
- }
- return false;
- }
- });
- popupWindow.setTouchable(true);
- popupWindow.setFocusable(true);
- popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
- popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
- }
-
- private static final int TAKEAPICTURE = 0x123;
- private static final int OPENALBUM = 0x124;
- private static final int CROPIMAGE = 0x125;
-
- // 打开相机
- private void openCamera() {
- File outFile = new File(FileUtils.getPicPath(this, System.currentTimeMillis() + ".jpg"));
- picturePath = outFile.getAbsolutePath();
- Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
- intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
- startActivityForResult(intent, TAKEAPICTURE);
- }
-
- private String picturePath;
-
- // 打开相册
- private void openAlbum() {
- Intent intent = new Intent(Intent.ACTION_PICK,
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- startActivityForResult(intent, OPENALBUM);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK) {
- if (requestCode == TAKEAPICTURE) {
- Utils.log("picturePath = " + picturePath);
- Intent intent = new Intent(this, CropImageActivity.class);
- intent.putExtra("path", picturePath);
- startActivityForResult(intent, CROPIMAGE);
- } else if (requestCode == OPENALBUM) {
- Uri selectedImage = data.getData();
- String[] filePathColumn = { MediaStore.Images.Media.DATA };
-
- Cursor cursor = getContentResolver().query(selectedImage,
- filePathColumn, null, null, null);
- cursor.moveToFirst();
-
- int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
- String picturePath = cursor.getString(columnIndex);
- cursor.close();
-
- Utils.log("picturePath = " + picturePath);
- Intent intent = new Intent(this, CropImageActivity.class);
- intent.putExtra("path", picturePath);
- startActivityForResult(intent, CROPIMAGE);
- } else if (requestCode == CROPIMAGE) {
- String url = data.getExtras().getString("url");
- user.setIcon(url);
- ImageUtils.getInstance(getApplicationContext()).display(url,
- userinfo_tv_icon);
- }
- }
- }
-
- private void showModifyNicknameDialog(View v) {
- KeyboardLayout contentView = (KeyboardLayout) View.inflate(this,
- R.layout.dialog_modify_nickname, null);
- final PopupWindow popupWindow = new PopupWindow(contentView,
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
-
- final EditText nickname = (EditText) contentView
- .findViewById(R.id.dialog_et_nickname);
- nickname.setHint(userinfo_tv_nickname.getText());
- nickname.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- popupWindow.dismiss();
- if (!TextUtils
- .isEmpty(nickname.getText().toString().trim())) {
- userinfo_tv_nickname.setText(nickname.getText());
- }
- }
- return false;
- }
- });
- nickname.requestFocus();
-
- contentView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- }
- });
- contentView
- .setOnKeyboardChangedListener(new OnKeyboardChangedListener() {
- @Override
- public void OnKeyboardChanged(int w, int h, int oldw,
- int oldh) {
- if (oldh != 0 && h > oldh) {
- if (popupWindow != null && popupWindow.isShowing()) {
- popupWindow.dismiss();
- }
- }
- }
- });
-
- contentView.findViewById(R.id.dialog_tv_modify).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- if (!TextUtils.isEmpty(nickname.getText().toString()
- .trim())) {
- userinfo_tv_nickname.setText(nickname.getText());
- }
- }
- });
-
- popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- getTintManager().setStatusBarTintResource(
- R.color.theme_colors);
- }
- }
- });
-
- popupWindow.setTouchable(true);
- popupWindow.setFocusable(true);
- popupWindow
- .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- popupWindow.showAtLocation(v, Gravity.BOTTOM, 0, 0);
-
- // #0E6295 #0E6195
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- getTintManager().setStatusBarTintColor(0xff0E6295);
- }
-
- }
-
- private void showModifySignDialog(View v) {
- KeyboardLayout contentView = (KeyboardLayout) View.inflate(this,
- R.layout.dialog_modify_sign, null);
- final PopupWindow popupWindow = new PopupWindow(contentView,
- LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, true);
-
- final EditText sign = (EditText) contentView
- .findViewById(R.id.dialog_et_sign);
- sign.requestFocus();
- sign.setHint(userinfo_tv_sign.getText());
- contentView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- }
- });
- contentView
- .setOnKeyboardChangedListener(new OnKeyboardChangedListener() {
- @Override
- public void OnKeyboardChanged(int w, int h, int oldw,
- int oldh) {
- if (oldh != 0 && h > oldh) {
- if (popupWindow != null && popupWindow.isShowing()) {
- popupWindow.dismiss();
- }
- }
- }
- });
-
- contentView.findViewById(R.id.dialog_tv_confirm).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- popupWindow.dismiss();
- if (!TextUtils
- .isEmpty(sign.getText().toString().trim())) {
- userinfo_tv_sign.setText(sign.getText());
- }
- }
- });
-
- contentView.findViewById(R.id.dialog_rl_sign).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
-
- popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
- @Override
- public void onDismiss() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- getTintManager().setStatusBarTintResource(
- R.color.theme_colors);
- }
- }
- });
-
- popupWindow.setTouchable(true);
- popupWindow.setFocusable(true);
- popupWindow
- .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- popupWindow.showAtLocation(v, Gravity.BOTTOM, 0, 0);
-
- // #0E6295 #0E6195
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- getTintManager().setStatusBarTintColor(0xff0E6295);
- }
- }
-
- @Override
- public void finish() {
-
- String nickname = userinfo_tv_nickname.getText().toString().trim();
- String sign = userinfo_tv_sign.getText().toString().trim();
- if ((!TextUtils.isEmpty(nickname) && !nickname.equals(user.getName()))
- || (!TextUtils.isEmpty(sign)) && !sign.equals(user.getSign())) {
- updateUserInfo(nickname, sign);
- } else {
- super.finish();
- }
- }
-
- // 修改用户信息
- private void updateUserInfo(final String name, final String sign) {
- final Dialog dialog = DialogUtils.showWaitDialog(this, "保存中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/info?time="
- + System.currentTimeMillis();
- Map params = new HashMap();
- if (!TextUtils.isEmpty(name)) {
- params.put("name", name);
- }
- if (!TextUtils.isEmpty(sign)) {
- params.put("sign", sign);
- }
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
-
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- dialog.dismiss();
- user.setName(name);
- user.setSign(sign);
- EventBus.getDefault().post(new EBLogout(1));
- toast("保存成功");
- finish();
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- dialog.dismiss();
- toast("保存失败");
- }
- });
- String token = TokenUtils.getToken(UserInfoActivity.this);
- request.addHeader("Auth", token);
- AppController
- .addToRequestQueue(request, UserInfoActivity.class);
- }
- }.start();
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/NewsOrRaidersListAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/NewsOrRaidersListAdapter.java
index 368d6e9374..1a611e9e2d 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/NewsOrRaidersListAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/NewsOrRaidersListAdapter.java
@@ -27,7 +27,6 @@ import com.gh.common.util.GameViewUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.util.TimestampUtils;
-import com.gh.common.util.Utils;
import com.gh.gamecenter.GameDetailsActivity;
import com.gh.gamecenter.NewsOrRaidersActivity;
import com.gh.gamecenter.R;
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read2FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/OriginalAdapter.java
similarity index 87%
rename from app/src/main/java/com/gh/gamecenter/read/Read2FragmentAdapter.java
rename to app/src/main/java/com/gh/gamecenter/adapter/OriginalAdapter.java
index 08e48d5bd4..a3d595fbf3 100644
--- a/app/src/main/java/com/gh/gamecenter/read/Read2FragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/OriginalAdapter.java
@@ -1,4 +1,4 @@
-package com.gh.gamecenter.read;
+package com.gh.gamecenter.adapter;
import android.app.Activity;
import android.content.Context;
@@ -19,8 +19,10 @@ import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.AppController;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.ImageUtils;
+import com.gh.gamecenter.OriginalActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
+import com.gh.gamecenter.adapter.viewholder.OriginalViewHolder;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
import com.google.gson.Gson;
@@ -37,7 +39,7 @@ import java.util.Locale;
/**
* Created by LGT on 2016/6/3.
*/
-public class Read2FragmentAdapter extends RecyclerView.Adapter {
+public class OriginalAdapter extends RecyclerView.Adapter {
private Activity activity;
private Context context;
@@ -51,11 +53,11 @@ public class Read2FragmentAdapter extends RecyclerView.Adapter getNewsList() {
@@ -127,13 +129,13 @@ public class Read2FragmentAdapter extends RecyclerView.Adapter map = new HashMap();
- map.put("location", "数据库");
+ map.put("location", "原创");
map.put("createOn", System.currentTimeMillis() / 1000);
map.put("page", "主页");
DataCollectionManager.onEvent(context, "click-item", map);
-// Toast.makeText(context, "敬请期待", Toast.LENGTH_SHORT).show();
- Intent intent = new Intent(context, DatabaseActivity.class);
+ Intent intent = new Intent(context, OriginalActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
diff --git a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragmentAdapter.java
index b70b17519b..6281651478 100644
--- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragmentAdapter.java
@@ -1,11 +1,7 @@
package com.gh.gamecenter.personal;
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.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ClipDrawable;
@@ -22,26 +18,18 @@ import android.support.v4.widget.ContentLoadingProgressBar;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
-import android.telephony.TelephonyManager;
-import android.text.Editable;
import android.text.Html;
-import android.text.InputType;
import android.text.Spanned;
import android.text.TextUtils;
-import android.text.TextWatcher;
-import android.text.method.NumberKeyListener;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.Gravity;
-import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
-import android.view.WindowManager;
-import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -52,26 +40,20 @@ import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.NoConnectionError;
-import com.android.volley.Request.Method;
import com.android.volley.Response;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;
import com.gh.base.AppController;
import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
-import com.gh.common.util.DeviceUtils;
-import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.MD5Utils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
-import com.gh.common.util.RSEUtils;
import com.gh.common.util.TimestampUtils;
-import com.gh.common.util.TokenUtils;
import com.gh.common.util.TrafficUtils;
-import com.gh.common.util.Utils;
import com.gh.common.view.HorizontalItemDecoration;
import com.gh.common.view.MyGame_LinearLayout;
import com.gh.download.DataWatcher;
@@ -82,9 +64,7 @@ import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.GameDetailsActivity;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
-import com.gh.gamecenter.RetrieveActivity;
import com.gh.gamecenter.SettingActivity;
-import com.gh.gamecenter.UserInfoActivity;
import com.gh.gamecenter.db.info.ConcernInfo;
import com.gh.gamecenter.db.info.GameInfo;
import com.gh.gamecenter.entity.ApkEntity;
@@ -105,7 +85,6 @@ import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
import com.google.gson.Gson;
import com.tendcloud.tenddata.TCAgent;
-import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
@@ -115,7 +94,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.regex.Pattern;
import de.greenrobot.event.EventBus;
@@ -146,24 +124,6 @@ public class PersonalFragmentAdapter extends
public void handleMessage(Message msg) {
if (msg.what == 0) {
notifyDataSetChanged();
- sendEmptyMessageDelayed(2, 500);
- } else if (msg.what == 1) {
- if (countdown == 0) {
- code_tv_send_again.setText("重新获取");
- code_tv_send_again.setClickable(true);
- } else if (countdown > 0) {
- code_tv_send_again.setText("重新获取(" + countdown-- + ")");
- sendEmptyMessageDelayed(1, 1000);
- }
- } else if (msg.what == 2) {
- SharedPreferences sp = fragmentActivity.getSharedPreferences(
- Config.PREFERENCE, Context.MODE_PRIVATE);
- boolean isLogin = sp.getBoolean("isLogin", false);
- if (isLogin) {
- String username = sp.getString("username", null);
- String password = sp.getString("password", null);
- login(username, password);
- }
}
}
};
@@ -464,16 +424,10 @@ public class PersonalFragmentAdapter extends
holder.me_tv_update.setText("" + updateSize);
}
if (user == null) {
- // holder.me_tv_login.setVisibility(View.VISIBLE);
- // holder.me_tv_register.setVisibility(View.VISIBLE);
- // holder.me_cutting_line.setVisibility(View.VISIBLE);
holder.me_tv_nickname.setVisibility(View.INVISIBLE);
holder.me_tv_sign.setVisibility(View.INVISIBLE);
holder.me_iv_icon.setImageResource(R.drawable.me_icon);
} else {
- // holder.me_tv_login.setVisibility(View.GONE);
- // holder.me_tv_register.setVisibility(View.GONE);
- // holder.me_cutting_line.setVisibility(View.GONE);
holder.me_tv_nickname.setVisibility(View.VISIBLE);
holder.me_tv_sign.setVisibility(View.VISIBLE);
holder.me_tv_nickname.setText(user.getName());
@@ -654,8 +608,6 @@ public class PersonalFragmentAdapter extends
private TextView me_tv_download, me_tv_update, me_tv_nickname,
me_tv_sign;
- // private TextView me_tv_login, me_tv_register;
- // private View me_cutting_line;
private ImageView me_iv_icon;
public FunctionViewHolder(View convertView) {
@@ -675,12 +627,6 @@ public class PersonalFragmentAdapter extends
.findViewById(R.id.me_tv_update);
me_iv_icon = (ImageView) convertView.findViewById(R.id.me_iv_icon);
me_iv_icon.setOnClickListener(this);
- // me_tv_login = (TextView)
- // convertView.findViewById(R.id.me_tv_login);
- // me_tv_login.setOnClickListener(this);
- // me_tv_register = (TextView) convertView
- // .findViewById(R.id.me_tv_register);
- // me_tv_register.setOnClickListener(this);
if (Config.isShow) {
convertView.findViewById(R.id.me_ll_download).setVisibility(
View.VISIBLE);
@@ -756,1682 +702,15 @@ public class PersonalFragmentAdapter extends
updateIntent.putExtra("currentItem", 1);
fragmentActivity.startActivity(updateIntent);
}
- // else if (id == R.id.me_tv_login) {
- // showMobileLoginDialog();
- // } else if (id == R.id.me_tv_register) {
- // showOnekeyDialog();
- // } else if (id == R.id.me_iv_icon) {
- // if (user != null) {
- // Intent intent = new Intent(fragmentActivity,
- // UserInfoActivity.class);
- // fragmentActivity.startActivityForResult(intent, 0x123);
- // }
- // }
}
}
- // 登录对话框
- private void showLoginDialog() {
- final Dialog dialog = new Dialog(fragmentActivity);
- View view = View.inflate(fragmentActivity,
- R.layout.dialog_account_login, null);
-
- LinearLayout login_ll_dialog = (LinearLayout) view
- .findViewById(R.id.account_login_ll_dialog);
- DisplayMetrics outMetrics = new DisplayMetrics();
- fragmentActivity.getWindowManager().getDefaultDisplay()
- .getMetrics(outMetrics);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- (int) (outMetrics.widthPixels * 0.8f),
- LayoutParams.WRAP_CONTENT);
- login_ll_dialog.setLayoutParams(lparams);
-
- view.findViewById(R.id.account_login_iv_close).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
-
- TextView forget = (TextView) view
- .findViewById(R.id.account_login_tv_forget_password);
- forget.setText(Html.fromHtml("忘记密码?"));
- forget.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- Intent intent = new Intent(fragmentActivity,
- RetrieveActivity.class);
- fragmentActivity.startActivity(intent);
- }
- });
- final ImageView username_clean = (ImageView) view
- .findViewById(R.id.account_login_iv_username_clean);
- final ImageView password_clean = (ImageView) view
- .findViewById(R.id.account_login_iv_password_clean);
- final ImageView login_iv_username = (ImageView) view
- .findViewById(R.id.account_login_iv_username);
- final View login_username_cutting_line = view
- .findViewById(R.id.account_login_username_cutting_line);
- final ImageView login_iv_password = (ImageView) view
- .findViewById(R.id.account_login_iv_password);
- final View login_password_cutting_line = view
- .findViewById(R.id.account_login_password_cutting_line);
- final EditText username = (EditText) view
- .findViewById(R.id.account_login_et_username);
- final RelativeLayout login_rl_username = (RelativeLayout) view
- .findViewById(R.id.account_login_rl_username);
- username.setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- login_rl_username
- .setBackgroundResource(R.drawable.border_input_dn);
- login_iv_username
- .setImageResource(R.drawable.login_username_dn);
- login_username_cutting_line.setBackgroundColor(0xff1BA4FC);
- if (username.getText().length() != 0) {
- username_clean.setVisibility(View.VISIBLE);
- }
- } else {
- login_rl_username
- .setBackgroundResource(R.drawable.border_input_up);
- login_iv_username
- .setImageResource(R.drawable.login_username_up);
- login_username_cutting_line.setBackgroundColor(0xffDBDBDB);
- username_clean.setVisibility(View.GONE);
- }
- }
- });
- username.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() != 0) {
- username_clean.setVisibility(View.VISIBLE);
- } else {
- username_clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
- }
- });
- username.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_NEXT) {
- String account = username.getText().toString().trim();
- if (TextUtils.isEmpty(account)) {
- Toast.makeText(fragmentActivity, "请输入用户名",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (account.length() < 6 || account.length() > 18) {
- Toast.makeText(fragmentActivity, "用户名长度错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_ACCOUNT,
- account)) {
- Toast.makeText(fragmentActivity, "用户名格式错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- }
- }
- return false;
- }
- });
- username.setKeyListener(new NumberKeyListener() {
- @Override
- public int getInputType() {
-
- return InputType.TYPE_CLASS_TEXT;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return Constants.INPUT_RULE.toCharArray();
- }
- });
- username_clean.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- username.setText("");
- }
- });
- final EditText password = (EditText) view
- .findViewById(R.id.account_login_et_password);
- final RelativeLayout login_rl_password = (RelativeLayout) view
- .findViewById(R.id.account_login_rl_password);
- password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- login_rl_password
- .setBackgroundResource(R.drawable.border_input_dn);
- login_iv_password
- .setImageResource(R.drawable.login_password_dn);
- login_password_cutting_line.setBackgroundColor(0xff1BA4FC);
- if (password.getText().length() != 0) {
- password_clean.setVisibility(View.VISIBLE);
- }
- } else {
- login_rl_password
- .setBackgroundResource(R.drawable.border_input_up);
- login_iv_password
- .setImageResource(R.drawable.login_password_up);
- login_password_cutting_line.setBackgroundColor(0xffDBDBDB);
- password_clean.setVisibility(View.GONE);
- }
- }
- });
- password.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() != 0) {
- password_clean.setVisibility(View.VISIBLE);
- } else {
- password_clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
- }
- });
- password.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String un = username.getText().toString();
- String pw = password.getText().toString();
- if (TextUtils.isEmpty(un)) {
- Toast.makeText(fragmentActivity, "请输入用户名",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (un.length() < 6 || un.length() > 18) {
- Toast.makeText(fragmentActivity, "用户名长度错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_ACCOUNT, un)) {
- Toast.makeText(fragmentActivity, "用户名格式错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (TextUtils.isEmpty(pw)) {
- Toast.makeText(fragmentActivity, "请输入密码",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- return true;
- } else if (pw.length() < 6 || pw.length() > 32) {
- Toast.makeText(fragmentActivity, "密码长度错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_PASSWORD, pw)) {
- Toast.makeText(fragmentActivity, "密码格式错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- return true;
- } else {
- login(dialog, un, pw);
- }
- }
- return false;
- }
- });
- password.setKeyListener(new NumberKeyListener() {
- @Override
- public int getInputType() {
-
- return InputType.TYPE_TEXT_VARIATION_PASSWORD;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return Constants.INPUT_RULE.toCharArray();
- }
- });
- password_clean.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- password.setText("");
- }
- });
- TextView login = (TextView) view
- .findViewById(R.id.account_login_tv_login);
- login.requestFocus();
- login.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- String un = username.getText().toString();
- String pw = password.getText().toString();
- if (TextUtils.isEmpty(un)) {
- Toast.makeText(fragmentActivity, "请输入用户名",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- } else if (un.length() < 6 || un.length() > 18) {
- Toast.makeText(fragmentActivity, "用户名长度错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_ACCOUNT, un)) {
- Toast.makeText(fragmentActivity, "用户名格式错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- } else if (TextUtils.isEmpty(pw)) {
- Toast.makeText(fragmentActivity, "请输入密码",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- } else if (pw.length() < 6 || pw.length() > 32) {
- Toast.makeText(fragmentActivity, "密码长度错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_PASSWORD, pw)) {
- Toast.makeText(fragmentActivity, "密码格式错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- } else {
- login(dialog, un, pw);
- }
- }
- });
- view.findViewById(R.id.account_login_tv_mobile_login)
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showMobileLoginDialog();
- }
- });
- view.findViewById(R.id.account_login_tv_account_register)
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showRegisterDialog();
- }
- });
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- dialog.setContentView(view);
- dialog.show();
- }
-
- private void showMobileLoginDialog() {
- final Dialog dialog = new Dialog(fragmentActivity);
- View view = View.inflate(fragmentActivity,
- R.layout.dialog_mobile_login, null);
-
- // 设置dialog宽度
- LinearLayout login_ll_dialog = (LinearLayout) view
- .findViewById(R.id.mobile_login_ll_dialog);
- DisplayMetrics outMetrics = new DisplayMetrics();
- fragmentActivity.getWindowManager().getDefaultDisplay()
- .getMetrics(outMetrics);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- (int) (outMetrics.widthPixels * 0.8f),
- LayoutParams.WRAP_CONTENT);
- login_ll_dialog.setLayoutParams(lparams);
-
- view.findViewById(R.id.mobile_login_iv_close).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
-
- final EditText mobile = (EditText) view
- .findViewById(R.id.mobile_login_et_mobile);
- mobile.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String mobileNumber = mobile.getText().toString().trim();
- if (TextUtils.isEmpty(mobileNumber)) {
- Toast.makeText(fragmentActivity, "请输入手机号码",
- Toast.LENGTH_SHORT).show();
- return true;
- } else if (mobileNumber.length() != 11) {
- Toast.makeText(fragmentActivity, "手机号码长度错误",
- Toast.LENGTH_SHORT).show();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- Toast.makeText(fragmentActivity, "手机号码格式错误",
- Toast.LENGTH_SHORT).show();
- return true;
- } else {
- login(dialog, mobileNumber);
- }
- }
- return false;
- }
- });
-
- final ImageView clean = (ImageView) view
- .findViewById(R.id.mobile_login_iv_username_clean);
- clean.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mobile.setText("");
- }
- });
- mobile.setKeyListener(new NumberKeyListener() {
- @Override
- public int getInputType() {
-
- return InputType.TYPE_CLASS_PHONE;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return "1234567890".toCharArray();
- }
- });
- mobile.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() != 0) {
- clean.setVisibility(View.VISIBLE);
- } else {
- clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
- }
- });
-
- TextView login = (TextView) view
- .findViewById(R.id.mobile_login_tv_login);
- login.requestFocus();
- login.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- String mobileNumber = mobile.getText().toString().trim();
- if (TextUtils.isEmpty(mobileNumber)) {
- Toast.makeText(fragmentActivity, "请输入手机号码",
- Toast.LENGTH_SHORT).show();
- } else if (mobileNumber.length() != 11) {
- Toast.makeText(fragmentActivity, "手机号码长度错误",
- Toast.LENGTH_SHORT).show();
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- Toast.makeText(fragmentActivity, "手机号码格式错误",
- Toast.LENGTH_SHORT).show();
- } else {
- login(dialog, mobileNumber);
- }
- }
- });
-
- view.findViewById(R.id.mobile_login_tv_account_login)
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showLoginDialog();
- }
- });
- view.findViewById(R.id.mobile_login_tv_mobile_register)
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showOnekeyDialog();
- }
- });
- // 查看是否登录过,获取登录过的账号用以显示
-
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- dialog.setContentView(view);
- dialog.show();
- }
-
- // 手机号码登录
- private void login(final Dialog dialog, final String mobileNumber) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(fragmentActivity,
- "登录中...");
- String url = Config.HOST + "v2/token/mobile?time="
- + System.currentTimeMillis();
- Map params = DeviceUtils
- .getDeviceParams(fragmentActivity);
- params.put("mobile_number", mobileNumber);
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
-
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- dialog.dismiss();
-
- Toast.makeText(fragmentActivity, "登录成功",
- Toast.LENGTH_SHORT).show();
-
- SharedPreferences sp = fragmentActivity
- .getSharedPreferences(Config.PREFERENCE,
- Context.MODE_PRIVATE);
- Editor editor = sp.edit();
- editor.putString("token",
- response.getString("token"));
- editor.putLong("token_expire",
- response.getLong("expire"));
- editor.putBoolean("isLogin", true);
- editor.putString("mobile_number", mobileNumber);
- editor.apply();
-
- user = new UserEntity();
- user.setName(response.getJSONObject("user")
- .getString("name"));
- user.setSign(response.getJSONObject("user")
- .getString("sign"));
- user.setIcon(response.getJSONObject("user")
- .getString("icon"));
- user.setAccount(response.getJSONObject("user")
- .getString("account"));
- user.setMobileNumber(mobileNumber.substring(0, 3)
- + "****" + mobileNumber.substring(7, 11));
- user.setActivation(response.getJSONObject("user")
- .getBoolean("isActivation"));
- AppController.put("user", user);
-
- notifyItemChanged(0);
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("USER_NO_EXIST".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "用户不存在", Toast.LENGTH_SHORT)
- .show();
- return;
- } else if ("DEVICE_ERROR".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "设备错误", Toast.LENGTH_SHORT)
- .show();
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- Toast.makeText(fragmentActivity, "登录失败",
- Toast.LENGTH_SHORT).show();
- }
- });
- AppController.addToRequestQueue(request, PersonalFragment.class);
- }
-
- private void login(String username, String password) {
- String url = Config.HOST + "v2/token/user?time="
- + System.currentTimeMillis();
- login(url, null, username, password);
- }
-
- private void login(Dialog dialog, String username, String password) {
- login(null, dialog, username, password);
- }
-
- private void login(String url, final Dialog dialog, final String username,
- String password) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(fragmentActivity,
- "登录中...");
- if (url == null) {
- url = Config.HOST + "v2/user/login?time="
- + System.currentTimeMillis();
- }
- Map params = DeviceUtils
- .getDeviceParams(fragmentActivity);
- params.put("username", username);
- try {
- String s = RSEUtils.encryptByPublic(password + username
- + System.currentTimeMillis() / 1000);
- Utils.log("加密 = " + s);
- params.put("password", s);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- waitDialog.dismiss();
- try {
- if (dialog != null) {
- dialog.dismiss();
- }
-
- Toast.makeText(fragmentActivity, "登录成功",
- Toast.LENGTH_SHORT).show();
-
- SharedPreferences sp = fragmentActivity
- .getSharedPreferences(Config.PREFERENCE,
- Context.MODE_PRIVATE);
- Editor editor = sp.edit();
- editor.putString("token",
- response.getString("token"));
- editor.putLong("token_expire",
- response.getLong("expire"));
- editor.putBoolean("isLogin", true);
- if (!response.isNull("code")) {
- String code = response.getString("code");
- String ciphertext = RSEUtils
- .decryptByPublic(code);
- editor.putString("username", username);
- editor.putString(
- "password",
- ciphertext.substring(0,
- ciphertext.indexOf(username)));
- }
- editor.apply();
-
- JSONObject jsonObject = response
- .getJSONObject("user");
- user = new UserEntity();
- user.setName(jsonObject.getString("name"));
- user.setIcon(jsonObject.getString("icon"));
- user.setSign(jsonObject.getString("sign"));
- if (!jsonObject.isNull("mobile_number")) {
- user.setMobileNumber(jsonObject
- .getString("mobile_number"));
- }
- user.setAccount(username);
- user.setActivation(true);
- AppController.put("user", user);
-
- notifyItemChanged(0);
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
- waitDialog.dismiss();
- Utils.log(error.toString());
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("USERNAME_NOT_EXIST".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "用户不存在", Toast.LENGTH_SHORT)
- .show();
- return;
- } else if ("PASSWORD_ERROR".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "密码错误", Toast.LENGTH_SHORT)
- .show();
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- Toast.makeText(fragmentActivity, "登录失败",
- Toast.LENGTH_SHORT).show();
- }
- });
- AppController.addToRequestQueue(request, PersonalFragment.class);
- }
-
- private void showRegisterDialog() {
- final Dialog dialog = new Dialog(fragmentActivity);
- View view = View.inflate(fragmentActivity,
- R.layout.dialog_account_register, null);
-
- LinearLayout register_ll_dialog = (LinearLayout) view
- .findViewById(R.id.register_ll_dialog);
- DisplayMetrics outMetrics = new DisplayMetrics();
- fragmentActivity.getWindowManager().getDefaultDisplay()
- .getMetrics(outMetrics);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- (int) (outMetrics.widthPixels * 0.8f),
- LayoutParams.WRAP_CONTENT);
- register_ll_dialog.setLayoutParams(lparams);
-
- view.findViewById(R.id.register_iv_close).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
-
- final ImageView username_clean = (ImageView) view
- .findViewById(R.id.register_iv_username_clean);
- final ImageView password_clean = (ImageView) view
- .findViewById(R.id.register_iv_password_clean);
- final ImageView register_iv_username = (ImageView) view
- .findViewById(R.id.register_iv_username);
- final ImageView register_iv_password = (ImageView) view
- .findViewById(R.id.register_iv_password);
- final View register_username_cutting_line = view
- .findViewById(R.id.register_username_cutting_line);
- final View register_password_cutting_line = view
- .findViewById(R.id.register_password_cutting_line);
- final EditText username = (EditText) view
- .findViewById(R.id.register_et_username);
- final RelativeLayout register_rl_username = (RelativeLayout) view
- .findViewById(R.id.register_rl_username);
- username.setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- register_rl_username
- .setBackgroundResource(R.drawable.border_input_dn);
- register_iv_username
- .setImageResource(R.drawable.login_username_dn);
- register_username_cutting_line
- .setBackgroundColor(0xff1BA4FC);
- if (username.getText().length() != 0) {
- username_clean.setVisibility(View.VISIBLE);
- }
- } else {
- register_rl_username
- .setBackgroundResource(R.drawable.border_input_up);
- register_iv_username
- .setImageResource(R.drawable.login_username_up);
- register_username_cutting_line
- .setBackgroundColor(0xffDBDBDB);
- username_clean.setVisibility(View.GONE);
- }
- }
- });
- username.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() != 0) {
- username_clean.setVisibility(View.VISIBLE);
- } else {
- username_clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
- }
- });
- username.setOnEditorActionListener(new TextView.OnEditorActionListener() {
-
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_NEXT) {
- String un = username.getText().toString();
- if (TextUtils.isEmpty(un)) {
- Toast.makeText(fragmentActivity, "请输入用户名",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (un.length() < 6 || un.length() > 18) {
- Toast.makeText(fragmentActivity, "用户名长度错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_ACCOUNT, un)) {
- Toast.makeText(fragmentActivity, "用户名格式错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- }
- }
- return false;
- }
- });
- username.setKeyListener(new NumberKeyListener() {
- @Override
- public int getInputType() {
-
- return InputType.TYPE_CLASS_TEXT;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return Constants.INPUT_RULE.toCharArray();
- }
- });
- username_clean.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- username.setText("");
- }
- });
- final EditText password = (EditText) view
- .findViewById(R.id.register_et_password);
- final RelativeLayout register_rl_password = (RelativeLayout) view
- .findViewById(R.id.register_rl_password);
- password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- register_rl_password
- .setBackgroundResource(R.drawable.border_input_dn);
- register_iv_password
- .setImageResource(R.drawable.login_password_dn);
- register_password_cutting_line
- .setBackgroundColor(0xff1BA4FC);
- if (password.getText().length() != 0) {
- password_clean.setVisibility(View.VISIBLE);
- }
- } else {
- register_rl_password
- .setBackgroundResource(R.drawable.border_input_up);
- register_iv_password
- .setImageResource(R.drawable.login_password_up);
- register_password_cutting_line
- .setBackgroundColor(0xffDBDBDB);
- password_clean.setVisibility(View.GONE);
- }
- }
- });
- password.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() != 0) {
- password_clean.setVisibility(View.VISIBLE);
- } else {
- password_clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
- }
- });
- password.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String un = username.getText().toString();
- String pw = password.getText().toString();
- if (TextUtils.isEmpty(un)) {
- Toast.makeText(fragmentActivity, "请输入用户名",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (un.length() < 6 || un.length() > 18) {
- Toast.makeText(fragmentActivity, "用户名长度错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_ACCOUNT, un)) {
- Toast.makeText(fragmentActivity, "用户名格式错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- return true;
- } else if (TextUtils.isEmpty(pw)) {
- Toast.makeText(fragmentActivity, "请输入密码",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- return true;
- } else if (pw.length() < 6 || pw.length() > 32) {
- Toast.makeText(fragmentActivity, "密码长度错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_PASSWORD, pw)) {
- Toast.makeText(fragmentActivity, "密码格式错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- return true;
- } else {
- register(dialog, un, pw);
- }
- }
- return false;
- }
- });
- password.setKeyListener(new NumberKeyListener() {
- @Override
- public int getInputType() {
-
- return InputType.TYPE_TEXT_VARIATION_PASSWORD;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return Constants.INPUT_RULE.toCharArray();
- }
- });
- password_clean.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- password.setText("");
- }
- });
- TextView register = (TextView) view
- .findViewById(R.id.register_tv_register);
- register.requestFocus();
- register.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- String un = username.getText().toString();
- String pw = password.getText().toString();
- if (TextUtils.isEmpty(un)) {
- Toast.makeText(fragmentActivity, "请输入用户名",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- } else if (un.length() < 6 || un.length() > 18) {
- Toast.makeText(fragmentActivity, "用户名长度错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_ACCOUNT, un)) {
- Toast.makeText(fragmentActivity, "用户名格式错误",
- Toast.LENGTH_SHORT).show();
- username.requestFocus();
- } else if (TextUtils.isEmpty(pw)) {
- Toast.makeText(fragmentActivity, "请输入密码",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- } else if (pw.length() < 6 || pw.length() > 32) {
- Toast.makeText(fragmentActivity, "密码长度错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- } else if (!Pattern.matches(Constants.REGEX_PASSWORD, pw)) {
- Toast.makeText(fragmentActivity, "密码格式错误",
- Toast.LENGTH_SHORT).show();
- password.requestFocus();
- } else {
- register(dialog, un, pw);
- }
- }
- });
- view.findViewById(R.id.register_tv_login).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showLoginDialog();
- }
- });
- view.findViewById(R.id.register_tv_mobile).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showOnekeyDialog();
- }
- });
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- dialog.setContentView(view);
- dialog.show();
- }
-
- private void showNicknameDialog(final String token) {
- final Dialog dialog = new Dialog(fragmentActivity);
- View view = View.inflate(fragmentActivity, R.layout.dialog_nickname,
- null);
-
- RelativeLayout nickname_rl_dialog = (RelativeLayout) view
- .findViewById(R.id.nickname_rl_dialog);
- DisplayMetrics outMetrics = new DisplayMetrics();
- fragmentActivity.getWindowManager().getDefaultDisplay()
- .getMetrics(outMetrics);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- (int) (outMetrics.widthPixels * 0.8f),
- LayoutParams.WRAP_CONTENT);
- nickname_rl_dialog.setLayoutParams(lparams);
-
- final EditText nickname = (EditText) view
- .findViewById(R.id.nickname_et_nickname);
- nickname.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String name = nickname.getText().toString();
- if (TextUtils.isEmpty(name)) {
- Toast.makeText(fragmentActivity, "请输入昵称",
- Toast.LENGTH_SHORT).show();
- nickname.requestFocus();
- return true;
- } else {
- user.setName(name);
- notifyItemChanged(0);
- dialog.dismiss();
- updateUserInfo(name, null, token);
- }
- }
- return false;
- }
- });
-
- view.findViewById(R.id.nickname_tv_confirm).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- String name = nickname.getText().toString();
- if (TextUtils.isEmpty(name)) {
- Toast.makeText(fragmentActivity, "请输入昵称",
- Toast.LENGTH_SHORT).show();
- nickname.requestFocus();
- } else {
- user.setName(name);
- notifyItemChanged(0);
- dialog.dismiss();
- updateUserInfo(name, null, token);
- }
- }
- });
-
- view.findViewById(R.id.nickname_tv_skip).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- notifyItemChanged(0);
- dialog.dismiss();
- }
- });
-
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- dialog.setContentView(view);
- dialog.show();
- }
-
- // 修改用户信息
- private void updateUserInfo(final String name, final String sign,
- final String token) {
- final Dialog dialog = DialogUtils.showWaitDialog(fragmentActivity,
- "保存中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/info?time="
- + System.currentTimeMillis();
- Map params = new HashMap();
- if (!TextUtils.isEmpty(name)) {
- params.put("name", name);
- }
- if (!TextUtils.isEmpty(sign)) {
- params.put("sign", sign);
- }
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- dialog.dismiss();
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- dialog.dismiss();
- }
- });
- request.addHeader("Auth", token);
- AppController
- .addToRequestQueue(request, UserInfoActivity.class);
- }
- }.start();
- }
-
- private void register(final Dialog dialog, final String username,
- String password) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(fragmentActivity,
- "注册中...");
- String url = Config.HOST + "v2/user/registerV1d0?time="
- + System.currentTimeMillis();
- Map params = DeviceUtils
- .getDeviceParams(fragmentActivity);
- params.put("username", username);
- try {
- String s = RSEUtils.encryptByPublic(password + username
- + System.currentTimeMillis() / 1000);
- Utils.log("加密 = " + s);
- params.put("password", s);
- } catch (Exception e) {
- e.printStackTrace();
- }
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- waitDialog.dismiss();
- Utils.log(response.toString());
- try {
- dialog.dismiss();
- Toast.makeText(fragmentActivity, "注册成功",
- Toast.LENGTH_SHORT).show();
-
- String token = response.getString("token");
- long expire = response.getLong("expire");
- SharedPreferences sp = fragmentActivity
- .getSharedPreferences(Config.PREFERENCE,
- Context.MODE_PRIVATE);
- Editor editor = sp.edit();
- editor.putString("token", token);
- editor.putLong("token_expire", expire);
- editor.putBoolean("isLogin", true);
- String code = response.getString("code");
- String ciphertext = RSEUtils.decryptByPublic(code);
- editor.putString("username", username);
- editor.putString(
- "password",
- ciphertext.substring(0,
- ciphertext.indexOf(username)));
- editor.apply();
-
- user = new UserEntity();
- user.setName(response.getJSONObject("user")
- .getString("name"));
- user.setIcon(response.getJSONObject("user")
- .getString("icon"));
- AppController.put("user", user);
-
- showNicknameDialog(token);
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
- Utils.log(error);
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(error.networkResponse.data));
- Utils.log(response.toString());
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("USER_EXIST".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "用户名已存在", Toast.LENGTH_SHORT)
- .show();
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- Toast.makeText(fragmentActivity, "注册失败",
- Toast.LENGTH_SHORT).show();
- }
- });
- AppController.addToRequestQueue(request, PersonalFragment.class);
- }
-
- private void showOnekeyDialog() {
- final Dialog dialog = new Dialog(fragmentActivity);
-
- View view = View.inflate(fragmentActivity,
- R.layout.dialog_onekey_register, null);
-
- LinearLayout onekey_ll_dialog = (LinearLayout) view
- .findViewById(R.id.onekey_register_ll_dialog);
- DisplayMetrics outMetrics = new DisplayMetrics();
- fragmentActivity.getWindowManager().getDefaultDisplay()
- .getMetrics(outMetrics);
- LayoutParams lparams = new LayoutParams(
- (int) (outMetrics.widthPixels * 0.8f),
- LayoutParams.WRAP_CONTENT);
- onekey_ll_dialog.setLayoutParams(lparams);
-
- view.findViewById(R.id.onekey_register_iv_close).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
-
- final ImageView mobile_clean = (ImageView) view
- .findViewById(R.id.onekey_register_iv_mobile_clean);
- final EditText mobile = (EditText) view
- .findViewById(R.id.onekey_register_et_mobile);
- mobile.addTextChangedListener(new TextWatcher() {
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before,
- int count) {
-
- if (s.length() != 0) {
- mobile_clean.setVisibility(View.VISIBLE);
- } else {
- mobile_clean.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
-
- }
- });
- mobile.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String mobileNumber = mobile.getText().toString();
- if (TextUtils.isEmpty(mobileNumber)) {
- Toast.makeText(fragmentActivity, "手机号码为空",
- Toast.LENGTH_SHORT).show();
- return true;
- } else if (mobileNumber.length() != 11) {
- Toast.makeText(fragmentActivity, "手机号长度错误",
- Toast.LENGTH_SHORT).show();
- return true;
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- Toast.makeText(fragmentActivity, "手机号码格式错误",
- Toast.LENGTH_SHORT).show();
- return true;
- } else {
- getCode(dialog, mobileNumber);
- }
- }
- return false;
- }
- });
- mobile.setKeyListener(new NumberKeyListener() {
- @Override
- public int getInputType() {
-
- return InputType.TYPE_CLASS_PHONE;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return "1234567890".toCharArray();
- }
- });
- mobile_clean.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mobile.setText("");
- }
- });
-
- TelephonyManager tm = (TelephonyManager) fragmentActivity
- .getSystemService(Context.TELEPHONY_SERVICE);
- String number = tm.getLine1Number();// 获取本机号码
- if (!TextUtils.isEmpty(number)) {
- mobile.setText(number);
- mobile.setSelection(number.length());
- }
-
- view.findViewById(R.id.onekey_register_tv_send).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- String mobileNumber = mobile.getText().toString();
- if (TextUtils.isEmpty(mobileNumber)) {
- Toast.makeText(fragmentActivity, "手机号码为空",
- Toast.LENGTH_SHORT).show();
- } else if (mobileNumber.length() != 11) {
- Toast.makeText(fragmentActivity, "手机号长度错误",
- Toast.LENGTH_SHORT).show();
- } else if (!Pattern.matches(Constants.REGEX_MOBILE,
- mobileNumber)) {
- Toast.makeText(fragmentActivity, "手机号码格式错误",
- Toast.LENGTH_SHORT).show();
- } else {
- getCode(dialog, mobileNumber);
- }
- }
- });
- view.findViewById(R.id.onekey_register_tv_mobile_login)
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showMobileLoginDialog();
- }
- });
- view.findViewById(R.id.onekey_register_tv_account_register)
- .setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showRegisterDialog();
- }
- });
-
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- dialog.setContentView(view);
- dialog.show();
- }
-
private TextView code_tv_send_again;
private EditText code_et_code;
private int countdown = 60;
- private void showCodeDialog(final String mobileNumber) {
- final Dialog dialog = new Dialog(fragmentActivity);
- View view = View.inflate(fragmentActivity, R.layout.dialog_code, null);
-
- LinearLayout code_ll_dialog = (LinearLayout) view
- .findViewById(R.id.code_ll_dialog);
- DisplayMetrics outMetrics = new DisplayMetrics();
- fragmentActivity.getWindowManager().getDefaultDisplay()
- .getMetrics(outMetrics);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- (int) (outMetrics.widthPixels * 0.8f),
- LayoutParams.WRAP_CONTENT);
- code_ll_dialog.setLayoutParams(lparams);
-
- view.findViewById(R.id.code_iv_close).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
-
- TextView code_tv_hint = (TextView) view.findViewById(R.id.code_tv_hint);
- code_tv_hint.setText("已向手机号" + mobileNumber + "发送验证码");
-
- code_tv_send_again = (TextView) view
- .findViewById(R.id.code_tv_send_again);
- code_tv_send_again.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- getCode(null, mobileNumber);
- }
- });
- code_tv_send_again.setClickable(false);
-
- code_et_code = (EditText) view.findViewById(R.id.code_et_code);
- code_et_code
- .setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event) {
-
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- String code = code_et_code.getText().toString();
- if (TextUtils.isEmpty(code)) {
- Toast.makeText(fragmentActivity, "验证码为空",
- Toast.LENGTH_SHORT).show();
- return true;
- } else if (code.length() != 6) {
- Toast.makeText(fragmentActivity, "验证码长度错误",
- Toast.LENGTH_SHORT).show();
- return true;
- } else if (!Pattern.matches("^\\d{6}$", code)) {
- Toast.makeText(fragmentActivity, "验证码格式错误",
- Toast.LENGTH_SHORT).show();
- return true;
- } else {
- registerDone(dialog, mobileNumber, code);
- }
- }
- return false;
- }
- });
- view.findViewById(R.id.code_tv_done).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- String code = code_et_code.getText().toString();
- if (TextUtils.isEmpty(code)) {
- Toast.makeText(fragmentActivity, "验证码为空",
- Toast.LENGTH_SHORT).show();
- } else if (code.length() != 6) {
- Toast.makeText(fragmentActivity, "验证码长度错误",
- Toast.LENGTH_SHORT).show();
- } else if (!Pattern.matches("^\\d{6}$", code)) {
- Toast.makeText(fragmentActivity, "验证码格式错误",
- Toast.LENGTH_SHORT).show();
- } else {
- registerDone(dialog, mobileNumber, code);
- }
- }
- });
-
- view.findViewById(R.id.code_tv_mobile).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showLoginDialog();
- }
- });
-
- view.findViewById(R.id.code_tv_register).setOnClickListener(
- new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- showRegisterDialog();
- }
- });
-
- dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- handler.removeMessages(1);
- }
- });
-
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
- | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- dialog.setContentView(view);
- dialog.show();
- }
-
- // 获取验证码
- private void getCode(final Dialog dialog, final String mobileNumber) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(fragmentActivity,
- "发送中...");
- new Thread() {
- @Override
- public void run() {
- String url = Config.HOST + "v2/user/register/code/"
- + mobileNumber + "?time=" + System.currentTimeMillis();
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- url, new Response.Listener() {
-
- @Override
- public void onResponse(JSONObject response) {
-
- waitDialog.dismiss();
- try {
- if ("success".equals(response
- .getString("status"))) {
- Toast.makeText(fragmentActivity,
- "发送成功", Toast.LENGTH_SHORT)
- .show();
- if (code_tv_send_again != null) {
- code_tv_send_again
- .setClickable(false);
- }
- if (dialog != null) {
- dialog.dismiss();
- showCodeDialog(mobileNumber);
- }
- countdown = 60;
- handler.removeMessages(1);
- handler.sendEmptyMessage(1);
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
-
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(
- error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("MOBILE_NUMBER_ERROR"
- .equals(reason)) {
- Toast.makeText(
- fragmentActivity,
- "手机号码错误",
- Toast.LENGTH_SHORT)
- .show();
- return;
- } else if ("USER_EXIST"
- .equals(reason)) {
- Toast.makeText(
- fragmentActivity,
- "用户已存在",
- Toast.LENGTH_SHORT)
- .show();
- return;
- } else if ("TIME_IS_NOT"
- .equals(reason)) {
- Toast.makeText(
- fragmentActivity,
- "稍后再试",
- Toast.LENGTH_SHORT)
- .show();
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- Toast.makeText(fragmentActivity, "发送失败",
- Toast.LENGTH_SHORT).show();
- }
- });
- String token = TokenUtils.getToken(fragmentActivity);
- request.addHeader("Auth", token);
- AppController
- .addToRequestQueue(request, PersonalFragment.class);
- }
- }.start();
- }
-
- // 完成注册
- private void registerDone(final Dialog dialog, String mobileNumber,
- String code) {
- final Dialog waitDialog = DialogUtils.showWaitDialog(fragmentActivity,
- "发送中...");
- String url = Config.HOST + "v2/user/onekey?time="
- + System.currentTimeMillis();
- Map params = DeviceUtils
- .getDeviceParams(fragmentActivity);
- params.put("mobile_number", mobileNumber);
- params.put("code", code);
- JSONObject body = new JSONObject(params);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- Method.POST, url, body.toString(),
- new Response.Listener() {
-
- @Override
- public void onResponse(JSONObject response) {
-
- Utils.log(response.toString());
- waitDialog.dismiss();
- try {
- dialog.dismiss();
- Toast.makeText(fragmentActivity, "注册成功",
- Toast.LENGTH_SHORT).show();
-
- SharedPreferences sp = fragmentActivity
- .getSharedPreferences(Config.PREFERENCE,
- Context.MODE_PRIVATE);
- Editor editor = sp.edit();
- String token = response.getString("token");
- editor.putString("token", token);
- editor.putLong("token_expire",
- response.getLong("expire"));
- editor.putBoolean("isAutoLogin", true);
- editor.apply();
-
- user = new UserEntity();
- user.setName(response.getJSONObject("user")
- .getString("name"));
- user.setIcon(response.getJSONObject("user")
- .getString("icon"));
- AppController.put("user", user);
-
- showNicknameDialog(token);
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- }
- }, new Response.ErrorListener() {
-
- @Override
- public void onErrorResponse(VolleyError error) {
-
- Utils.log(error.toString());
- waitDialog.dismiss();
- try {
- if (error.networkResponse != null) {
- JSONObject response = new JSONObject(
- new String(error.networkResponse.data));
- if (!response.isNull("reason")) {
- String reason = response
- .getString("reason");
- if ("CODE_ERROR".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "验证码错误", Toast.LENGTH_SHORT)
- .show();
- return;
- } else if ("CODE_EXPIRE".equals(reason)) {
- Toast.makeText(fragmentActivity,
- "验证码过期", Toast.LENGTH_SHORT)
- .show();
- return;
- }
- }
- }
- } catch (JSONException e) {
-
- e.printStackTrace();
- }
- Toast.makeText(fragmentActivity, "注册失败",
- Toast.LENGTH_SHORT).show();
- }
- });
- AppController.addToRequestQueue(request, PersonalFragment.class);
- }
-
// 设置获取到的验证码
public void setCode(String code) {
if (code_et_code != null) {
diff --git a/app/src/main/java/com/gh/gamecenter/plugin/Plugin1FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/plugin/Plugin1FragmentAdapter.java
index b10cac5ff4..c116cc7ee8 100644
--- a/app/src/main/java/com/gh/gamecenter/plugin/Plugin1FragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/plugin/Plugin1FragmentAdapter.java
@@ -2,7 +2,6 @@ package com.gh.gamecenter.plugin;
import android.content.Context;
import android.content.Intent;
-import android.os.Handler;
import android.support.v4.util.ArrayMap;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
diff --git a/app/src/main/java/com/gh/gamecenter/plugin/Plugin2FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/plugin/Plugin2FragmentAdapter.java
index 21061b737f..3dc24faddf 100644
--- a/app/src/main/java/com/gh/gamecenter/plugin/Plugin2FragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/plugin/Plugin2FragmentAdapter.java
@@ -2,7 +2,6 @@ package com.gh.gamecenter.plugin;
import android.content.Context;
import android.content.Intent;
-import android.os.Handler;
import android.support.v4.util.ArrayMap;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
diff --git a/app/src/main/java/com/gh/gamecenter/plugin/Plugin3FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/plugin/Plugin3FragmentAdapter.java
index 325447e502..d4c02cf259 100644
--- a/app/src/main/java/com/gh/gamecenter/plugin/Plugin3FragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/plugin/Plugin3FragmentAdapter.java
@@ -2,7 +2,6 @@ package com.gh.gamecenter.plugin;
import android.content.Context;
import android.content.Intent;
-import android.os.Handler;
import android.support.v4.util.ArrayMap;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read1Fragment.java b/app/src/main/java/com/gh/gamecenter/read/Read1Fragment.java
deleted file mode 100644
index 115bc0b22a..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read1Fragment.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.common.view.VerticalItemDecoration;
-import com.gh.gamecenter.R;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read1Fragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
-
- private View view;
- private SwipeRefreshLayout game_swipe_refresh;
- private RecyclerView recyclerview;
- private LinearLayoutManager layoutManager;
- private Read1FragmentAdapter adapter;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- view = View.inflate(getActivity(), R.layout.plugin1_fragment, null);
-
- game_swipe_refresh = (SwipeRefreshLayout) view.findViewById(R.id.game_swipe_refresh);
- game_swipe_refresh.setColorSchemeResources(R.color.theme_colors);
- game_swipe_refresh.setOnRefreshListener(this);
-
- game_pb_loading = (ProgressBarCircularIndeterminate) view.findViewById(R.id.game_pb_loading);
-
- reuse_no_connection = (LinearLayout) view.findViewById(R.id.reuse_no_connection);
- reuse_no_connection.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- game_swipe_refresh.setRefreshing(true);
- recyclerview.setVisibility(View.VISIBLE);
- game_pb_loading.setVisibility(View.VISIBLE);
- reuse_no_connection.setVisibility(View.GONE);
- }
- });
-
- recyclerview = (RecyclerView) view.findViewById(R.id.game_list);
- recyclerview.setHasFixedSize(true);
- layoutManager = new LinearLayoutManager(getActivity());
- recyclerview.setLayoutManager(layoutManager);
- adapter = new Read1FragmentAdapter(getActivity(), game_swipe_refresh, game_pb_loading,
- reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() {
-
- @Override
- public void onScrollStateChanged(RecyclerView recyclerView,
- int newState) {
- super.onScrollStateChanged(recyclerView, newState);
-// if (newState == RecyclerView.SCROLL_STATE_IDLE
-// && layoutManager.findLastVisibleItemPosition() == 1 + adapter.getNewsList().size()) {
-//
-// }
- }
-
- });
- recyclerview.addItemDecoration(new VerticalItemDecoration(getActivity(), 1));
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- if (container != null) {
- container.removeView(view);
- }
- return view;
- }
-
- private Handler handler = new Handler();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- adapter = new Read1FragmentAdapter(getActivity(), game_swipe_refresh, game_pb_loading,
- reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- }
- };
-
- @Override
- public void onRefresh() {
- handler.postDelayed(runnable, 1000);
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read1FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/read/Read1FragmentAdapter.java
deleted file mode 100644
index aba52c2e94..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read1FragmentAdapter.java
+++ /dev/null
@@ -1,370 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.app.Activity;
-import android.content.Context;
-import android.support.v4.view.ViewPager;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.util.DisplayMetrics;
-import android.view.LayoutInflater;
-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.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.base.AppController;
-import com.gh.common.util.DisplayUtils;
-import com.gh.common.util.ImageUtils;
-import com.gh.common.view.AutoScrollViewPager;
-import com.gh.gamecenter.R;
-import com.gh.gamecenter.adapter.RecyclingPagerAdapter;
-import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
-import com.gh.gamecenter.entity.NewsEntity;
-import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import org.json.JSONArray;
-
-import java.lang.reflect.Type;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read1FragmentAdapter extends RecyclerView.Adapter {
-
- private Activity activity;
- private Context context;
- private SwipeRefreshLayout game_swipe_refresh;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- private List slideList;
- private List newsList;
-
- private boolean isLoading;
- private boolean isSlideError;
-
- public Read1FragmentAdapter(Activity act,
- SwipeRefreshLayout swipeRefreshLayout,
- ProgressBarCircularIndeterminate pbLoading,
- LinearLayout noConnection,
- boolean isLoad) {
- activity = act;
- context = activity;
- game_swipe_refresh = swipeRefreshLayout;
- game_pb_loading = pbLoading;
- reuse_no_connection = noConnection;
-
- slideList = new ArrayList();
- newsList = new ArrayList();
-
- isLoading = false;
- isSlideError = false;
-
- if (isLoad) {
- load();
- }
- }
-
- public void load() {
- new Thread(runnable){}.start();
- }
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- initSlide();
- addList(0);
- }
- };
-
- public void addList(final int offset) {
- if (isLoading) {
- return;
- }
- isLoading = true;
- String url = "http://api.ghzhushou.com/gapi/v1d0/game/55097638fc1a6fa45f8b4568/news?limit=20&offset=" + offset;
- JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
- new Response.Listener() {
- @Override
- public void onResponse(JSONArray response) {
- Type listType = new TypeToken>() {}.getType();
- Gson gson = new Gson();
- List list = gson.fromJson(response.toString(), listType);
- for (int i = 0; i < list.size(); i++) {
- newsList.add(list.get(i));
- notifyItemInserted(newsList.size());
- }
-
- if (offset == 0 && game_swipe_refresh.isRefreshing()) {
- game_swipe_refresh.setRefreshing(false);
- }
- if (game_pb_loading.getVisibility() == View.VISIBLE) {
- game_pb_loading.setVisibility(View.GONE);
- }
- isLoading = false;
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- isLoading = false;
- }
- });
- AppController.addToRequestQueue(request, Read1Fragment.class.getSimpleName());
- }
-
- private void initSlide() {
- String url = "http://api.ghzhushou.com/gapi/v1d0/index/slide?game_id=55097638fc1a6fa45f8b4568";
- JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
- new Response.Listener() {
- @Override
- public void onResponse(JSONArray response) {
- Type listType = new TypeToken>() {}.getType();
- Gson gson = new Gson();
- slideList = gson.fromJson(response.toString(), listType);
- if (slideList != null) {
- notifyItemChanged(0);
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- }
- });
- AppController.addToRequestQueue(request, Read1Fragment.class.getSimpleName());
- }
-
- public List getNewsList() {
- return newsList;
- }
-
- public boolean isLoading() {
- return isLoading;
- }
-
- class ReadSlideViewHolder extends RecyclerView.ViewHolder {
- private AutoScrollViewPager viewPager;
- private LinearLayout viewpager_ll_hint;
- private TextView viewpager_tv_failure;
-
- public ReadSlideViewHolder(View v) {
- super(v);
- viewpager_tv_failure = (TextView) v.findViewById(R.id.viewpager_tv_failure);
- viewpager_tv_failure.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- isSlideError = false;
- notifyItemChanged(0);
- initSlide();
- }
- });
- viewpager_ll_hint = (LinearLayout) v.findViewById(R.id.viewpager_ll_hint);
- viewPager = (AutoScrollViewPager) v.findViewById(R.id.view_pager);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
-
- @Override
- public void onPageSelected(int position) {
- for (int i = 0, size = viewpager_ll_hint.getChildCount(); i < size; i++) {
- if (i == position % size) {
- ((ImageView) viewpager_ll_hint.getChildAt(i))
- .setImageResource(R.drawable.oval_white_hint_dn);
- } else {
- ((ImageView) viewpager_ll_hint.getChildAt(i))
- .setImageResource(R.drawable.oval_white_hint_up);
- }
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- // 解决viewpager和SwipeRefreshLayout滑动冲突
- if (state == ViewPager.SCROLL_STATE_DRAGGING) {
- game_swipe_refresh.setEnabled(false);
- } else {
- game_swipe_refresh.setEnabled(true);
- }
- }
- });
- }
-
- }
-
- class ReadSlideAdapter extends RecyclingPagerAdapter {
-
- private Context mContext;
-
- private List mSlideList;
-
- public ReadSlideAdapter(Context context, List list) {
- mContext = context;
- mSlideList = list;
- }
-
- @Override
- public int getCount() {
- return Integer.MAX_VALUE;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup container) {
- ImageView imageView = new ImageView(mContext);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT);
- imageView.setLayoutParams(params);
- ImageUtils.getInstance(mContext).display(mSlideList.get(position % mSlideList.size()),
- imageView, R.drawable.preload);
- return imageView;
- }
-
- }
-
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- if (viewType == 0) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read1_slide, parent, false);
- DisplayMetrics outMetrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
- int height = (int) (outMetrics.widthPixels / 2f);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT, height);
- view.setLayoutParams(params);
- return new ReadSlideViewHolder(view);
- } else if (viewType > 0 && viewType <= newsList.size()) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read_item, parent, false);
- return new ReadViewHolder(view);
- } else {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.refresh_footerview, parent, false);
- return new FooterViewHolder(view);
- }
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder instanceof ReadSlideViewHolder) {
- ReadSlideViewHolder viewHolder = (ReadSlideViewHolder) holder;
- if (isSlideError) {
- viewHolder.viewpager_tv_failure.setVisibility(View.VISIBLE);
- viewHolder.viewPager.setVisibility(View.GONE);
- viewHolder.viewpager_ll_hint.setVisibility(View.GONE);
- } else {
- viewHolder.viewpager_tv_failure.setVisibility(View.GONE);
- viewHolder.viewPager.setVisibility(View.VISIBLE);
- viewHolder.viewpager_ll_hint.setVisibility(View.VISIBLE);
- }
- if (slideList.size() > 0) {
- int currentItem = 0;
- if (viewHolder.viewPager.getAdapter() != null) {
- currentItem = viewHolder.viewPager.getCurrentItem();
- }
- RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- rparams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- viewHolder.viewpager_ll_hint.setLayoutParams(rparams);
- viewHolder.viewpager_ll_hint.removeAllViews();
- for (int i = 0, size = slideList.size(); i < size; i++) {
- ImageView imageView = new ImageView(context);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- DisplayUtils.dip2px(context, 5),
- DisplayUtils.dip2px(context, 5));
- lparams.bottomMargin = DisplayUtils.dip2px(context, 8);
- lparams.rightMargin = DisplayUtils.dip2px(context, 8);
- if (i == currentItem) {
- imageView.setImageResource(R.drawable.oval_white_hint_dn);
- } else {
- imageView.setImageResource(R.drawable.oval_white_hint_up);
- }
- imageView.setLayoutParams(lparams);
- viewHolder.viewpager_ll_hint.addView(imageView);
- }
- viewHolder.viewPager.setAdapter(new ReadSlideAdapter(context, slideList));
- viewHolder.viewPager.setCurrentItem(currentItem);
- viewHolder.viewPager.setInterval(3000);
- viewHolder.viewPager.startAutoScroll();
- }
- } else if (holder instanceof ReadViewHolder) {
- ReadViewHolder viewHolder = (ReadViewHolder) holder;
- NewsEntity newsEntity = newsList.get(position - 1);
- viewHolder.view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- if (TextUtils.isEmpty(newsEntity.getThumb())) {
- String[] urls = {"http://image.ghzhushou.com/pic/56a05b058ab49ecd048b457a.jpg",
- "http://image.ghzhushou.com/pic/56a9dc3b8ab49e58138b457f.jpg",
- "http://image.ghzhushou.com/pic/56ac27e58ab49e47448b456d.jpg",
- "http://image.ghzhushou.com/pic/56b177f68ab49ea9438b4569.jpg",
- "http://image.ghzhushou.com/pic/56b3695a8ab49e1f2d8b4567.jpg"};
- ImageUtils.getInstance(context).display(urls[position % 5], viewHolder.fm_read_iv_thumb);
- } else {
- ImageUtils.getInstance(context).display(newsEntity.getThumb(), viewHolder.fm_read_iv_thumb);
- }
- viewHolder.fm_read_tv_title.setText(newsEntity.getTitle());
- viewHolder.fm_read_tv_time.setText(getTimeAgo(Long.valueOf(newsEntity.getPublishOn())));
- viewHolder.fm_read_tv_read.setText("211次浏览");
- } else if (holder instanceof FooterViewHolder) {
- FooterViewHolder viewHolder = (FooterViewHolder) holder;
- viewHolder.footerview_progressbar.setVisibility(View.GONE);
- viewHolder.footerview_tv_loading.setText("点击加载更多");
- viewHolder.rootView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- addList(newsList.size());
- }
- });
- }
- }
-
- @Override
- public int getItemCount() {
- if (newsList.isEmpty()){
- return 0;
- }
- return 1 + newsList.size() + 1;
- }
-
- @Override
- public int getItemViewType(int position) {
- return position;
- }
-
- //根据提供的时间,返回该时间与当前时间的差距
- private String getTimeAgo(long time) {
- long now = System.currentTimeMillis() / 1000;
- long gap = now - time;
- if (gap <= 60) {
- return "1分钟前";
- } else if (gap > 60 && gap < 3600) {
- return Math.floor(gap / 60) + "分钟前";
- } else if (gap >= 3600 && gap < 86400) {
- return Math.floor(gap / 3600) + "小时前";
- } else {
- SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日", Locale.getDefault());
- return format.format(time * 1000);
- }
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read2Fragment.java b/app/src/main/java/com/gh/gamecenter/read/Read2Fragment.java
deleted file mode 100644
index 7eeba9ea41..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read2Fragment.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.common.view.VerticalItemDecoration;
-import com.gh.gamecenter.R;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read2Fragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
-
- private View view;
- private SwipeRefreshLayout game_swipe_refresh;
- private RecyclerView recyclerview;
- private LinearLayoutManager layoutManager;
- private Read2FragmentAdapter adapter;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- view = View.inflate(getActivity(), R.layout.plugin1_fragment, null);
-
- game_swipe_refresh = (SwipeRefreshLayout) view
- .findViewById(R.id.game_swipe_refresh);
- game_swipe_refresh.setColorSchemeResources(R.color.theme_colors);
- game_swipe_refresh.setOnRefreshListener(this);
-
- game_pb_loading = (ProgressBarCircularIndeterminate) view.findViewById(R.id.game_pb_loading);
-
- reuse_no_connection = (LinearLayout) view.findViewById(R.id.reuse_no_connection);
- reuse_no_connection.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- game_swipe_refresh.setRefreshing(true);
- recyclerview.setVisibility(View.VISIBLE);
- game_pb_loading.setVisibility(View.VISIBLE);
- reuse_no_connection.setVisibility(View.GONE);
- }
- });
-
- recyclerview = (RecyclerView) view.findViewById(R.id.game_list);
- recyclerview.setHasFixedSize(true);
- layoutManager = new LinearLayoutManager(getActivity());
- recyclerview.setLayoutManager(layoutManager);
- adapter = new Read2FragmentAdapter(getActivity(), game_swipe_refresh,
- game_pb_loading, reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() {
-
- @Override
- public void onScrollStateChanged(RecyclerView recyclerView,
- int newState) {
- super.onScrollStateChanged(recyclerView, newState);
-// if (newState == RecyclerView.SCROLL_STATE_IDLE
-// && layoutManager.findLastVisibleItemPosition() == 1 + adapter.getList().size()) {
-//
-// }
- }
-
- });
- recyclerview.addItemDecoration(new VerticalItemDecoration(getActivity(), 1));
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- if (container != null) {
- container.removeView(view);
- }
- return view;
- }
-
- private Handler handler = new Handler();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- adapter = new Read2FragmentAdapter(getActivity(), game_swipe_refresh,
- game_pb_loading, reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- }
- };
-
- @Override
- public void onRefresh() {
- handler.postDelayed(runnable, 1000);
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read3Fragment.java b/app/src/main/java/com/gh/gamecenter/read/Read3Fragment.java
deleted file mode 100644
index 0a246ea846..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read3Fragment.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.common.view.VerticalItemDecoration;
-import com.gh.gamecenter.R;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read3Fragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
-
- private View view;
- private SwipeRefreshLayout game_swipe_refresh;
- private RecyclerView recyclerview;
- private LinearLayoutManager layoutManager;
- private Read3FragmentAdapter adapter;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- view = View.inflate(getActivity(), R.layout.plugin1_fragment, null);
-
- game_swipe_refresh = (SwipeRefreshLayout) view
- .findViewById(R.id.game_swipe_refresh);
- game_swipe_refresh.setColorSchemeResources(R.color.theme_colors);
- game_swipe_refresh.setOnRefreshListener(this);
-
- game_pb_loading = (ProgressBarCircularIndeterminate) view.findViewById(R.id.game_pb_loading);
-
- reuse_no_connection = (LinearLayout) view.findViewById(R.id.reuse_no_connection);
- reuse_no_connection.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- game_swipe_refresh.setRefreshing(true);
- recyclerview.setVisibility(View.VISIBLE);
- game_pb_loading.setVisibility(View.VISIBLE);
- reuse_no_connection.setVisibility(View.GONE);
- }
- });
-
- recyclerview = (RecyclerView) view.findViewById(R.id.game_list);
- recyclerview.setHasFixedSize(true);
- layoutManager = new LinearLayoutManager(getActivity());
- recyclerview.setLayoutManager(layoutManager);
- adapter = new Read3FragmentAdapter(getActivity(), game_swipe_refresh,
- game_pb_loading, reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() {
-
- @Override
- public void onScrollStateChanged(RecyclerView recyclerView,
- int newState) {
- super.onScrollStateChanged(recyclerView, newState);
-// if (newState == RecyclerView.SCROLL_STATE_IDLE
-// && layoutManager.findLastVisibleItemPosition() == 1 + adapter.getList().size()) {
-//
-// }
- }
-
- });
- recyclerview.addItemDecoration(new VerticalItemDecoration(getActivity(), 1));
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- if (container != null) {
- container.removeView(view);
- }
- return view;
- }
-
- private Handler handler = new Handler();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- adapter = new Read3FragmentAdapter(getActivity(), game_swipe_refresh,
- game_pb_loading, reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- }
- };
-
- @Override
- public void onRefresh() {
- handler.postDelayed(runnable, 1000);
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read3FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/read/Read3FragmentAdapter.java
deleted file mode 100644
index 0684c6a6b2..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read3FragmentAdapter.java
+++ /dev/null
@@ -1,368 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.app.Activity;
-import android.content.Context;
-import android.support.v4.view.ViewPager;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.util.DisplayMetrics;
-import android.view.LayoutInflater;
-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.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.base.AppController;
-import com.gh.common.util.DisplayUtils;
-import com.gh.common.util.ImageUtils;
-import com.gh.common.view.AutoScrollViewPager;
-import com.gh.gamecenter.R;
-import com.gh.gamecenter.adapter.RecyclingPagerAdapter;
-import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
-import com.gh.gamecenter.entity.NewsEntity;
-import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import org.json.JSONArray;
-
-import java.lang.reflect.Type;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read3FragmentAdapter extends RecyclerView.Adapter {
-
- private Activity activity;
- private Context context;
- private SwipeRefreshLayout game_swipe_refresh;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- private List slideList;
- private List newsList;
-
- private boolean isLoading;
- private boolean isSlideError;
-
- public Read3FragmentAdapter(Activity act,
- SwipeRefreshLayout swipeRefreshLayout,
- ProgressBarCircularIndeterminate pbLoading,
- LinearLayout noConnection,
- boolean isLoad) {
- activity = act;
- context = activity;
- game_swipe_refresh = swipeRefreshLayout;
- game_pb_loading = pbLoading;
- reuse_no_connection = noConnection;
-
- slideList = new ArrayList();
- newsList = new ArrayList();
-
- isLoading = false;
- isSlideError = false;
-
- if (isLoad) {
- load();
- }
- }
-
- public void load() {
- new Thread(runnable){}.start();
- }
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- initSlide();
- addList(0);
- }
- };
-
- public void addList(final int offset) {
- if (isLoading) {
- return;
- }
- isLoading = true;
- String url = "http://api.ghzhushou.com/gapi/v1d0/game/55097638fc1a6fa45f8b4568/news?limit=20&offset=" + offset;
- JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
- new Response.Listener() {
- @Override
- public void onResponse(JSONArray response) {
- Type listType = new TypeToken>() {}.getType();
- Gson gson = new Gson();
- List list = gson.fromJson(response.toString(), listType);
- for (int i = 0; i < list.size(); i++) {
- newsList.add(list.get(i));
- notifyItemInserted(newsList.size());
- }
-
- if (offset == 0 && game_swipe_refresh.isRefreshing()) {
- game_swipe_refresh.setRefreshing(false);
- }
- if (game_pb_loading.getVisibility() == View.VISIBLE) {
- game_pb_loading.setVisibility(View.GONE);
- }
- isLoading = false;
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- isLoading = false;
- }
- });
- AppController.addToRequestQueue(request, Read3Fragment.class.getSimpleName());
- }
-
- private void initSlide() {
- String url = "http://api.ghzhushou.com/gapi/v1d0/index/slide?game_id=55097638fc1a6fa45f8b4568";
- JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
- new Response.Listener() {
- @Override
- public void onResponse(JSONArray response) {
- Type listType = new TypeToken>() {}.getType();
- Gson gson = new Gson();
- slideList = gson.fromJson(response.toString(), listType);
- if (slideList != null) {
- notifyItemChanged(0);
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- }
- });
- AppController.addToRequestQueue(request, Read3Fragment.class.getSimpleName());
- }
-
- public List getNewsList() {
- return newsList;
- }
-
- public boolean isLoading() {
- return isLoading;
- }
-
- class ReadSlideViewHolder extends RecyclerView.ViewHolder {
- private AutoScrollViewPager viewPager;
- private LinearLayout viewpager_ll_hint;
- private TextView viewpager_tv_failure;
-
- public ReadSlideViewHolder(View v) {
- super(v);
- viewpager_tv_failure = (TextView) v.findViewById(R.id.viewpager_tv_failure);
- viewpager_tv_failure.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- isSlideError = false;
- notifyItemChanged(0);
- initSlide();
- }
- });
- viewpager_ll_hint = (LinearLayout) v.findViewById(R.id.viewpager_ll_hint);
- viewPager = (AutoScrollViewPager) v.findViewById(R.id.view_pager);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
-
- @Override
- public void onPageSelected(int position) {
- for (int i = 0, size = viewpager_ll_hint.getChildCount(); i < size; i++) {
- if (i == position % size) {
- ((ImageView) viewpager_ll_hint.getChildAt(i))
- .setImageResource(R.drawable.oval_white_hint_dn);
- } else {
- ((ImageView) viewpager_ll_hint.getChildAt(i))
- .setImageResource(R.drawable.oval_white_hint_up);
- }
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- // 解决viewpager和SwipeRefreshLayout滑动冲突
- if (state == ViewPager.SCROLL_STATE_DRAGGING) {
- game_swipe_refresh.setEnabled(false);
- } else {
- game_swipe_refresh.setEnabled(true);
- }
- }
- });
- }
-
- }
-
- class ReadSlideAdapter extends RecyclingPagerAdapter {
-
- private Context mContext;
-
- private List mSlideList;
-
- public ReadSlideAdapter(Context context, List list) {
- mContext = context;
- mSlideList = list;
- }
-
- @Override
- public int getCount() {
- return Integer.MAX_VALUE;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup container) {
- ImageView imageView = new ImageView(mContext);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT);
- imageView.setLayoutParams(params);
- ImageUtils.getInstance(mContext).display(mSlideList.get(position % mSlideList.size()),
- imageView, R.drawable.preload);
- return imageView;
- }
-
- }
-
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- if (viewType == 0) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read1_slide, parent, false);
- DisplayMetrics outMetrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
- int height = (int) (outMetrics.widthPixels / 2f);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT, height);
- view.setLayoutParams(params);
- return new ReadSlideViewHolder(view);
- } else if (viewType > 0 && viewType <= newsList.size()) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read_item, parent, false);
- return new ReadViewHolder(view);
- } else {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.refresh_footerview, parent, false);
- return new FooterViewHolder(view);
- }
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder instanceof ReadSlideViewHolder) {
- ReadSlideViewHolder viewHolder = (ReadSlideViewHolder) holder;
- if (isSlideError) {
- viewHolder.viewpager_tv_failure.setVisibility(View.VISIBLE);
- viewHolder.viewPager.setVisibility(View.GONE);
- viewHolder.viewpager_ll_hint.setVisibility(View.GONE);
- } else {
- viewHolder.viewpager_tv_failure.setVisibility(View.GONE);
- viewHolder.viewPager.setVisibility(View.VISIBLE);
- viewHolder.viewpager_ll_hint.setVisibility(View.VISIBLE);
- }
- if (slideList.size() > 0) {
- int currentItem = 0;
- if (viewHolder.viewPager.getAdapter() != null) {
- currentItem = viewHolder.viewPager.getCurrentItem();
- }
- RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
- RelativeLayout.LayoutParams.WRAP_CONTENT);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- rparams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- viewHolder.viewpager_ll_hint.setLayoutParams(rparams);
- viewHolder.viewpager_ll_hint.removeAllViews();
- for (int i = 0, size = slideList.size(); i < size; i++) {
- ImageView imageView = new ImageView(context);
- LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- DisplayUtils.dip2px(context, 5),
- DisplayUtils.dip2px(context, 5));
- lparams.bottomMargin = DisplayUtils.dip2px(context, 8);
- lparams.rightMargin = DisplayUtils.dip2px(context, 8);
- if (i == currentItem) {
- imageView.setImageResource(R.drawable.oval_white_hint_dn);
- } else {
- imageView.setImageResource(R.drawable.oval_white_hint_up);
- }
- imageView.setLayoutParams(lparams);
- viewHolder.viewpager_ll_hint.addView(imageView);
- }
- viewHolder.viewPager.setAdapter(new ReadSlideAdapter(context, slideList));
- viewHolder.viewPager.setCurrentItem(currentItem);
- viewHolder.viewPager.setInterval(3000);
- viewHolder.viewPager.startAutoScroll();
- }
- } else if (holder instanceof ReadViewHolder) {
- ReadViewHolder viewHolder = (ReadViewHolder) holder;
- NewsEntity newsEntity = newsList.get(position - 1);
- viewHolder.view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- if (TextUtils.isEmpty(newsEntity.getThumb())) {
- viewHolder.fm_read_iv_thumb.setVisibility(View.GONE);
- } else {
- viewHolder.fm_read_iv_thumb.setVisibility(View.VISIBLE);
- ImageUtils.getInstance(context).display(newsEntity.getThumb(), viewHolder.fm_read_iv_thumb);
- }
- viewHolder.fm_read_ll_read.setVisibility(View.GONE);
- viewHolder.fm_read_tv_type.setVisibility(View.VISIBLE);
- viewHolder.fm_read_tv_title.setText(newsEntity.getTitle());
- viewHolder.fm_read_tv_time.setText(getTimeAgo(Long.valueOf(newsEntity.getPublishOn())));
- viewHolder.fm_read_tv_read.setText("211次浏览");
- } else if (holder instanceof FooterViewHolder) {
- FooterViewHolder viewHolder = (FooterViewHolder) holder;
- viewHolder.footerview_progressbar.setVisibility(View.GONE);
- viewHolder.footerview_tv_loading.setText("点击加载更多");
- viewHolder.rootView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- addList(newsList.size());
- }
- });
- }
- }
-
- @Override
- public int getItemCount() {
- if (newsList.isEmpty()){
- return 0;
- }
- return 1 + newsList.size() + 1;
- }
-
- @Override
- public int getItemViewType(int position) {
- return position;
- }
-
- //根据提供的时间,返回该时间与当前时间的差距
- private String getTimeAgo(long time) {
- long now = System.currentTimeMillis() / 1000;
- long gap = now - time;
- if (gap <= 60) {
- return "1分钟前";
- } else if (gap > 60 && gap < 3600) {
- return Math.floor(gap / 60) + "分钟前";
- } else if (gap >= 3600 && gap < 86400) {
- return Math.floor(gap / 3600) + "小时前";
- } else {
- SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日", Locale.getDefault());
- return format.format(time * 1000);
- }
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read4Fragment.java b/app/src/main/java/com/gh/gamecenter/read/Read4Fragment.java
deleted file mode 100644
index 972fde16fa..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read4Fragment.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.common.view.VerticalItemDecoration;
-import com.gh.gamecenter.R;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read4Fragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
-
- private View view;
- private SwipeRefreshLayout game_swipe_refresh;
- private RecyclerView recyclerview;
- private LinearLayoutManager layoutManager;
- private Read4FragmentAdapter adapter;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- view = View.inflate(getActivity(), R.layout.plugin1_fragment, null);
-
- game_swipe_refresh = (SwipeRefreshLayout) view
- .findViewById(R.id.game_swipe_refresh);
- game_swipe_refresh.setColorSchemeResources(R.color.theme_colors);
- game_swipe_refresh.setOnRefreshListener(this);
-
- game_pb_loading = (ProgressBarCircularIndeterminate) view.findViewById(R.id.game_pb_loading);
-
- reuse_no_connection = (LinearLayout) view.findViewById(R.id.reuse_no_connection);
- reuse_no_connection.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- game_swipe_refresh.setRefreshing(true);
- recyclerview.setVisibility(View.VISIBLE);
- game_pb_loading.setVisibility(View.VISIBLE);
- reuse_no_connection.setVisibility(View.GONE);
- }
- });
-
- recyclerview = (RecyclerView) view.findViewById(R.id.game_list);
- recyclerview.setHasFixedSize(true);
- layoutManager = new LinearLayoutManager(getActivity());
- recyclerview.setLayoutManager(layoutManager);
- adapter = new Read4FragmentAdapter(getActivity(), game_swipe_refresh,
- game_pb_loading, reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- recyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() {
-
- @Override
- public void onScrollStateChanged(RecyclerView recyclerView,
- int newState) {
- super.onScrollStateChanged(recyclerView, newState);
-// if (newState == RecyclerView.SCROLL_STATE_IDLE
-// && layoutManager.findLastVisibleItemPosition() == 1 + adapter.getList().size()) {
-//
-// }
- }
-
- });
- recyclerview.addItemDecoration(new VerticalItemDecoration(getActivity(), 1));
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- if (container != null) {
- container.removeView(view);
- }
- return view;
- }
-
- private Handler handler = new Handler();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- adapter = new Read4FragmentAdapter(getActivity(), game_swipe_refresh,
- game_pb_loading, reuse_no_connection, true);
- recyclerview.setAdapter(adapter);
- }
- };
-
- @Override
- public void onRefresh() {
- handler.postDelayed(runnable, 1000);
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/Read4FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/read/Read4FragmentAdapter.java
deleted file mode 100644
index 85d58ba665..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/Read4FragmentAdapter.java
+++ /dev/null
@@ -1,458 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.app.Activity;
-import android.content.Context;
-import android.net.Uri;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.support.v7.widget.GridLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.util.DisplayMetrics;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.android.volley.NoConnectionError;
-import com.android.volley.Response;
-import com.android.volley.TimeoutError;
-import com.android.volley.VolleyError;
-import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
-import com.gh.base.AppController;
-import com.gh.common.constant.Config;
-import com.gh.common.constant.Constants;
-import com.gh.common.util.DisplayUtils;
-import com.gh.common.util.ImageUtils;
-import com.gh.common.util.NewsUtils;
-import com.gh.common.util.RandomUtils;
-import com.gh.common.util.TimestampUtils;
-import com.gh.common.util.Utils;
-import com.gh.gamecenter.R;
-import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
-import com.gh.gamecenter.db.info.ConcernInfo;
-import com.gh.gamecenter.db.info.GameInfo;
-import com.gh.gamecenter.entity.ApkEntity;
-import com.gh.gamecenter.entity.GameEntity;
-import com.gh.gamecenter.entity.NewsEntity;
-import com.gh.gamecenter.manager.ConcernManager;
-import com.gh.gamecenter.manager.GameManager;
-import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
-import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class Read4FragmentAdapter extends RecyclerView.Adapter {
-
- private Activity activity;
- private Context context;
- private SwipeRefreshLayout game_swipe_refresh;
- private ProgressBarCircularIndeterminate game_pb_loading;
- private LinearLayout reuse_no_connection;
-
- private List newsList;
- private List myGameList;
- private List allGameList;
- private List likeGameList;
-
- private boolean isLoading;
-
- public Read4FragmentAdapter(Activity act,
- SwipeRefreshLayout swipeRefreshLayout,
- ProgressBarCircularIndeterminate pbLoading,
- LinearLayout noConnection,
- boolean isLoad) {
- activity = act;
- context = act;
- game_swipe_refresh = swipeRefreshLayout;
- game_pb_loading = pbLoading;
- reuse_no_connection = noConnection;
-
- newsList = new ArrayList();
- myGameList = new ArrayList();
- allGameList = new ArrayList();
- likeGameList = new ArrayList();
-
- isLoading = false;
-
- if (isLoad) {
- load();
- }
-
- }
-
- public void load() {
- new Thread(runnable){}.start();
- }
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- initMyGameList();
- initLikeGameList();
- addList(0);
- }
- };
-
- private int result;
-
- private void initMyGameList() {
- ConcernManager concernManager = new ConcernManager(context);
- List installedGame = concernManager.getInstalledGame();
- int size = installedGame.size() > 3 ? 3 : installedGame.size();
- final int count = size;
- result = 0;
- for (int i = 0; i < size; i++) {
- ConcernInfo info = installedGame.get(i);
- JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(
- TimestampUtils.addTimestamp(Config.HOST + "v1d45/game/" + info.getId() + "/digest", Constants.GAME_CD),
- new Response.Listener() {
- @Override
- public void onResponse(JSONObject response) {
- Gson gson = new Gson();
- GameEntity gameEntity = gson.fromJson(response.toString(), GameEntity.class);
- myGameList.add(gameEntity);
- result++;
- if (result == count) {
- if (myGameList.size() == 3) {
- myGameList.add(new GameEntity());
- }
- notifyItemChanged(2);
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- result++;
- if (result == count) {
- if (myGameList.size() == 3) {
- myGameList.add(new GameEntity());
- }
- notifyItemChanged(2);
- }
- }
- });
- AppController.addToRequestQueue(request, Read4Fragment.class);
- }
- }
-
- private void initLikeGameList() {
- JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(
- TimestampUtils.addTimestamp(Config.HOST + "v1d45/game/remenkapai", Constants.GAME_CD),
- new Response.Listener() {
- @Override
- public void onResponse(JSONArray response) {
- Type listType = new TypeToken>() {}.getType();
- Gson gson = new Gson();
- GameManager manager = new GameManager(context.getApplicationContext());
- List gameList = gson.fromJson(response.toString(), listType);
- if (gameList != null && !gameList.isEmpty()) {
- for (GameEntity entity : gameList) {
- for (ApkEntity apkEntity : entity.getApk()) {
- manager.addOrUpdate(new GameInfo(apkEntity.getPackageName(),
- entity.getId(), entity.getName()));
- }
- }
- //去掉已安装的游戏
- ConcernManager concernManager = new ConcernManager(context);
- List installedGame = concernManager.getInstalledGame();
- for (ConcernInfo info : installedGame) {
- for (int i = 0, size = gameList.size(); i < size; i++) {
- if (gameList.get(i).getId().equals(info.getId())) {
- gameList.remove(i);
- break;
- }
- }
- }
- allGameList = gameList;
- }
- if (allGameList.size() > 0) {
- if (allGameList.size() <= 2) {
- likeGameList.addAll(allGameList);
- } else {
- int[] index = RandomUtils.getRandomArray(2, allGameList.size());
- likeGameList.add(allGameList.get(index[0]));
- likeGameList.add(allGameList.get(index[1]));
- }
- notifyItemChanged(4);
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
-
- }
- });
- AppController.addToRequestQueue(request, Read4Fragment.class.getSimpleName());
- }
-
- public void addList(final int offset) {
- if (isLoading) {
- return;
- }
- isLoading = true;
- JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(TimestampUtils.addTimestamp(Config.HOST
- + "v1d45/news?type_group=" + Uri.encode("攻略")
- + "&offset=0&limit=20", Constants.NEWS_CD),
- new Response.Listener() {
- @Override
- public void onResponse(JSONArray response) {
- Type listType = new TypeToken>() {}.getType();
- Gson gson = new Gson();
- List list = gson.fromJson(response.toString(), listType);
- for (int i = 0; i < list.size(); i++) {
- newsList.add(list.get(i));
- notifyItemInserted(getItemCount() - 1);
- }
-
- if (offset == 0 && game_swipe_refresh.isRefreshing()) {
- game_swipe_refresh.setRefreshing(false);
- }
- if (game_pb_loading.getVisibility() == View.VISIBLE) {
- game_pb_loading.setVisibility(View.GONE);
- }
- isLoading = false;
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- isLoading = false;
- }
- });
- AppController.addToRequestQueue(request, Read4Fragment.class.getSimpleName());
- }
-
- public List getNewsList() {
- return newsList;
- }
-
- private class Read4ViewHolder extends RecyclerView.ViewHolder {
-
- private View view;
-
- private TextView fm_read4_tv_label;
-
- private RecyclerView fm_read4_rv_grid;
-
- private TextView news_type, news_title;
-
- public Read4ViewHolder(View itemView) {
- super(itemView);
-
- view = itemView;
-
- int tag = (Integer) itemView.getTag();
- if (tag == 0) {
-
- } else if (tag == 1 || tag == 3 || tag == 5) {
- fm_read4_tv_label = (TextView) itemView.findViewById(R.id.fm_read4_tv_label);
- } else if (tag == 2 || tag == 4) {
- fm_read4_rv_grid = (RecyclerView) itemView.findViewById(R.id.fm_read4_rv_grid);
- fm_read4_rv_grid.setHasFixedSize(true);
- fm_read4_rv_grid.setLayoutManager(new GridLayoutManager(context, 2));
- } else {
- news_type = (TextView) itemView.findViewById(R.id.news_type);
- news_title = (TextView) itemView.findViewById(R.id.news_title);
- }
-
- }
- }
-
- @Override
- public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- RecyclerView.ViewHolder viewHolder;
- if (viewType == 0) {
- ImageView imageView = new ImageView(parent.getContext());
- DisplayMetrics outMetrics = new DisplayMetrics();
- activity.getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
- int height = (int) (outMetrics.widthPixels / 5f);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, height);
- imageView.setLayoutParams(params);
- imageView.setImageResource(R.drawable.hero);
- imageView.setTag(viewType);
- viewHolder = new Read4ViewHolder(imageView);
- } else if (viewType == 1 || viewType == 3 || viewType == 5) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read4_label, parent, false);
- view.setTag(viewType);
- viewHolder = new Read4ViewHolder(view);
- } else if (viewType == 2 || viewType == 4) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read4_grid, parent, false);
- RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.fm_read4_rv_grid);
- int height;
- if (viewType == 2) {
- height = 2 * DisplayUtils.dip2px(context, 66);
- } else {
- height = DisplayUtils.dip2px(context, 66);
- }
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT, height);
- recyclerView.setLayoutParams(params);
- view.setTag(viewType);
- viewHolder = new Read4ViewHolder(view);
- } else if (viewType > 5 && viewType<= newsList.size() + 5) {
- View view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.home_list_item_newsnormal_type, parent, false);
- view.setTag(viewType);
- viewHolder = new Read4ViewHolder(view);
- } else {
- viewHolder = new FooterViewHolder(LayoutInflater.from(parent.getContext()).inflate(
- R.layout.refresh_footerview, parent, false));
- }
- return viewHolder;
- }
-
- @Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
- if (holder instanceof Read4ViewHolder) {
- Read4ViewHolder viewHolder = (Read4ViewHolder) holder;
- if (position == 0) {
-
- } else if (position == 1 || position == 3 || position == 5) {
- String[] label = {"", "我的游戏", "", "猜你喜欢", "", "最新发布"};
- viewHolder.fm_read4_tv_label.setText(label[position]);
- } else if (position == 2 || position == 4) {
- if (position == 2) {
- viewHolder.fm_read4_rv_grid.setAdapter(new Read4GridAdapter(context, myGameList));
- } else {
- viewHolder.fm_read4_rv_grid.setAdapter(new Read4GridAdapter(context, likeGameList));
- }
- } else {
- NewsEntity newsEntity = newsList.get(position - 6);
- viewHolder.news_type.setBackgroundResource(NewsUtils
- .getDrawableIdByType(newsEntity.getType()));
- viewHolder.news_type.setText(newsEntity.getType());
- viewHolder.news_title.setText(newsEntity.getTitle());
- viewHolder.view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- }
- } else if (holder instanceof FooterViewHolder) {
- FooterViewHolder viewHolder = (FooterViewHolder) holder;
- viewHolder.footerview_progressbar.setVisibility(View.GONE);
- viewHolder.footerview_tv_loading.setText("点击加载更多");
- viewHolder.rootView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- addList(newsList.size());
- }
- });
- }
- }
-
- @Override
- public int getItemCount() {
- int count = 1;
- if (myGameList.size() != 0) {
- count += 2;
- }
- if (likeGameList.size() != 0) {
- count += 2;
- }
- if (newsList.size() != 0) {
- count += 1 + newsList.size();
- }
- return count + 1;
- }
-
- @Override
- public int getItemViewType(int position) {
- return position;
- }
-
- private class Read4GridViewHolder extends RecyclerView.ViewHolder {
-
- private View view;
- private ImageView fm_read4_iv_icon;
- private TextView fm_read4_tv_name;
- private TextView fm_read4_tv_des;
-
- public Read4GridViewHolder(View itemView) {
- super(itemView);
-
- view = itemView;
- fm_read4_iv_icon = (ImageView) itemView.findViewById(R.id.fm_read4_iv_icon);
- fm_read4_tv_name = (TextView) itemView.findViewById(R.id.fm_read4_tv_name);
- fm_read4_tv_des = (TextView) itemView.findViewById(R.id.fm_read4_tv_des);
-
- }
- }
-
- private class Read4GridAdapter extends RecyclerView.Adapter {
-
- private Context mContext;
- private List mGameList;
-
- public Read4GridAdapter(Context context, List list) {
- mContext = context;
- mGameList = list;
- }
-
- @Override
- public Read4GridViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View view;
- if (viewType == 3) {
- view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read4_grid_more, parent, false);
- } else {
- view = LayoutInflater.from(parent.getContext()).inflate(
- R.layout.fm_read4_grid_item, parent, false);
- }
- return new Read4GridViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(Read4GridViewHolder holder, int position) {
- if (position != 3) {
- GameEntity gameEntity = mGameList.get(position);
- ImageUtils.getInstance(mContext).display(gameEntity.getIcon(), holder.fm_read4_iv_icon);
- holder.fm_read4_tv_name.setText(gameEntity.getName());
- String des = gameEntity.getBrief();
- holder.fm_read4_tv_des.setText(des.substring(0, des.length() > 8 ? 8 : des.length()));
- holder.view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- } else {
- holder.view.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
-
- }
- });
- }
- }
-
- @Override
- public int getItemCount() {
- return mGameList.size();
- }
-
- @Override
- public int getItemViewType(int position) {
- return position;
- }
- }
-
-}
diff --git a/app/src/main/java/com/gh/gamecenter/read/ReadFragment.java b/app/src/main/java/com/gh/gamecenter/read/ReadFragment.java
deleted file mode 100644
index 2dde5022de..0000000000
--- a/app/src/main/java/com/gh/gamecenter/read/ReadFragment.java
+++ /dev/null
@@ -1,356 +0,0 @@
-package com.gh.gamecenter.read;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.graphics.Rect;
-import android.os.Build;
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.text.TextUtils;
-import android.util.DisplayMetrics;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.PopupWindow;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-import com.gh.common.constant.Config;
-import com.gh.common.util.DisplayUtils;
-import com.gh.download.DownloadManager;
-import com.gh.gamecenter.ConcernActivity;
-import com.gh.gamecenter.DownloadManagerActivity;
-import com.gh.gamecenter.MainActivity;
-import com.gh.gamecenter.R;
-import com.gh.gamecenter.SearchActivity;
-import com.gh.gamecenter.SettingActivity;
-import com.gh.gamecenter.eventbus.EBTopState;
-import com.gh.gamecenter.manager.DataCollectionManager;
-import com.gh.gamecenter.manager.PackageManager;
-import com.tendcloud.tenddata.TCAgent;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import de.greenrobot.event.EventBus;
-
-/**
- * Created by LGT on 2016/6/3.
- */
-public class ReadFragment extends Fragment implements View.OnClickListener, ViewPager.OnPageChangeListener {
-
- private View view;
- private TextView downloadHint, searchHint;
- private View fm_slide_line;
- private TextView fm_read_tuijian, fm_read_yuanchuang, fm_read_zixun, fm_read_gonglue;
- private ViewPager fm_vp_content;
-
- private LinearLayout.LayoutParams lparams;
- private PopupWindow popWindow;
-
- private String hint;
-
- private int width;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- view = View.inflate(getActivity(), R.layout.read_fragment, null);
-
- SharedPreferences sp = getActivity().getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
- LinearLayout home_actionbar = (LinearLayout) view.findViewById(R.id.home_actionbar);
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- sp.getInt("actionbar_height", DisplayUtils.dip2px(getActivity(), 48)));
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- int top = DisplayUtils.getInternalDimensionSize(getResources(), "status_bar_height");
- home_actionbar.setPadding(0, top, 0, 0);
- params.height += top;
- }
- home_actionbar.setLayoutParams(params);
-
- initActionBar();
-
- fm_slide_line = view.findViewById(R.id.fm_slide_line);
- DisplayMetrics outMetrics = new DisplayMetrics();
- getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
- width = outMetrics.widthPixels / 4;
- lparams = new LinearLayout.LayoutParams(width / 2, DisplayUtils.dip2px(getActivity(), 4));
- lparams.leftMargin = width / 4;
- fm_slide_line.setLayoutParams(lparams);
-
- fm_read_tuijian = (TextView) view.findViewById(R.id.fm_read_tuijian);
- fm_read_yuanchuang = (TextView) view.findViewById(R.id.fm_read_yuanchuang);
- fm_read_zixun = (TextView) view.findViewById(R.id.fm_read_zixun);
- fm_read_gonglue = (TextView) view.findViewById(R.id.fm_read_gonglue);
- fm_read_tuijian.setOnClickListener(this);
- fm_read_yuanchuang.setOnClickListener(this);
- fm_read_zixun.setOnClickListener(this);
- fm_read_gonglue.setOnClickListener(this);
-
- fm_vp_content = (ViewPager) view.findViewById(R.id.fm_vp_content);
- fm_vp_content.setAdapter(new FragmentAdapter(getChildFragmentManager()));
- fm_vp_content.addOnPageChangeListener(this);
-
- EventBus.getDefault().register(this);
- }
-
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- if (container != null) {
- container.removeView(view);
- }
- return view;
- }
-
- private void initActionBar() {
- view.findViewById(R.id.actionbar_rl_download).setOnClickListener(this);
- view.findViewById(R.id.actionbar_iv_search).setOnClickListener(this);
- view.findViewById(R.id.actionbar_notification).setOnClickListener(this);
- view.findViewById(R.id.actionbar_overflow).setOnClickListener(this);
-
- searchHint = (TextView) view.findViewById(R.id.actionbar_search_input);
- searchHint.setOnClickListener(this);
- if (!TextUtils.isEmpty(MainActivity.searchHint)) {
- hint = MainActivity.searchHint;
- searchHint.setHint(hint);
- }
-
- if (Config.isShow) {
- view.findViewById(R.id.actionbar_rl_download).setVisibility(View.VISIBLE);
- } else {
- view.findViewById(R.id.actionbar_rl_download).setVisibility(View.GONE);
- }
-
- downloadHint = (TextView) view.findViewById(R.id.action_tip);
- int updateSize = PackageManager.getUpdateListSize();
- int downloadSize = DownloadManager.getInstance(getActivity()).getAll().size();
- if (downloadSize != 0) {
- downloadHint.setVisibility(View.VISIBLE);
- downloadHint.setText(downloadSize + "");
- int width = DisplayUtils.dip2px(getActivity(), 12);
- RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(width, width);
- rparams.topMargin = DisplayUtils.dip2px(getActivity(), 8);
- rparams.rightMargin = DisplayUtils.dip2px(getActivity(), 2);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- downloadHint.setLayoutParams(rparams);
- } else if (updateSize != 0) {
- downloadHint.setText("");
- int width = DisplayUtils.dip2px(getActivity(), 10);
- RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(width, width);
- rparams.topMargin = DisplayUtils.dip2px(getActivity(), 8);
- rparams.rightMargin = DisplayUtils.dip2px(getActivity(), 3);
- rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- downloadHint.setLayoutParams(rparams);
- } else {
- downloadHint.setVisibility(View.GONE);
- }
- }
-
- @Override
- public void onClick(View v) {
- final int id = v.getId();
- if (id == R.id.actionbar_notification) {
- TCAgent.onEvent(getActivity(), "主页", "关注图标");
-
- Map map = new HashMap();
- map.put("location", "关注图标");
- map.put("createOn", System.currentTimeMillis() / 1000);
- map.put("page", "主页");
- DataCollectionManager.onEvent(getActivity(), "click-item", map);
-
- startActivity(new Intent(getActivity(), ConcernActivity.class));
- } else if (id == R.id.actionbar_rl_download) {
- TCAgent.onEvent(getActivity(), "主页", "下载图标");
-
- Map map = new HashMap();
- map.put("location", "下载图标");
- map.put("createOn", System.currentTimeMillis() / 1000);
- map.put("page", "主页");
- DataCollectionManager.onEvent(getActivity(), "click-item", map);
-
- if (downloadHint != null && downloadHint.getVisibility() == View.VISIBLE) {
- downloadHint.setVisibility(View.GONE);
- EventBus.getDefault().post(new EBTopState("隐藏", null));
- }
- startActivity(new Intent(getActivity(), DownloadManagerActivity.class));
- } else if (id == R.id.actionbar_search_input) {
- TCAgent.onEvent(getActivity(), "主页", "搜索框");
-
- Map map = new HashMap();
- map.put("location", "搜索框");
- map.put("createOn", System.currentTimeMillis() / 1000);
- map.put("page", "主页");
- DataCollectionManager.onEvent(getActivity(), "click-item", map);
-
- Intent goSearch = new Intent(getActivity(), SearchActivity.class);
- goSearch.putExtra("clicked", false);
- goSearch.putExtra("hint", hint);
- startActivity(goSearch);
- } else if (id == R.id.actionbar_iv_search) {
- TCAgent.onEvent(getActivity(), "主页", "搜索图标");
-
- Map map = new HashMap();
- map.put("location", "搜索图标");
- map.put("createOn", System.currentTimeMillis() / 1000);
- map.put("page", "主页");
- DataCollectionManager.onEvent(getActivity(), "click-item", map);
-
- Intent searchIntent = new Intent(getActivity(), SearchActivity.class);
- searchIntent.putExtra("clicked", true);
- searchIntent.putExtra("hint", hint);
- startActivity(searchIntent);
- } else if (id == R.id.actionbar_overflow) {
- TCAgent.onEvent(getActivity(), "主页", "更多图标");
-
- Map map = new HashMap();
- map.put("location", "更多图标");
- map.put("createOn", System.currentTimeMillis() / 1000);
- map.put("page", "主页");
- DataCollectionManager.onEvent(getActivity(), "click-item", map);
-
- popUpOverflow(v);
- } else if (id == R.id.menu_rl_set) {
- popWindow.dismiss();
- startActivity(new Intent(getActivity(), SettingActivity.class));
- } else if (id == R.id.fm_read_tuijian) {
- fm_vp_content.setCurrentItem(0);
- } else if (id == R.id.fm_read_yuanchuang) {
- fm_vp_content.setCurrentItem(1);
- } else if (id == R.id.fm_read_zixun) {
- fm_vp_content.setCurrentItem(2);
- } else if (id == R.id.fm_read_gonglue) {
- fm_vp_content.setCurrentItem(3);
- }
- }
-
- private void popUpOverflow(View view) {
-
- Rect frame = new Rect();
- getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
-
- int xOffset = DisplayUtils.dip2px(getActivity(), 5);
- int yOffset = frame.top + DisplayUtils.dip2px(getActivity(), 48) + xOffset;
-
- View popView = View.inflate(getActivity(), R.layout.menu_popwindow, null);
- popView.findViewById(R.id.menu_rl_set).setOnClickListener(this);
- popWindow = new PopupWindow(popView, LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT, true);
-
- popWindow.setOutsideTouchable(true);
- popWindow.setAnimationStyle(android.R.style.Animation_Dialog);
- popWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.shape));
-
- popWindow.showAtLocation(view, Gravity.TOP | Gravity.RIGHT, xOffset, yOffset);
- }
-
- public void onEventMainThread(EBTopState busTen) {
- if ("搜索".equals(busTen.getType())) {
- hint = busTen.getSearchHint();
- searchHint.setHint(busTen.getSearchHint());
- } else if ("显示".equals(busTen.getType())) {
- if (downloadHint != null) {
- downloadHint.setVisibility(View.VISIBLE);
- }
- } else {
- if (downloadHint != null) {
- downloadHint.setVisibility(View.GONE);
- }
- }
- }
-
- private class FragmentAdapter extends FragmentPagerAdapter {
-
- public FragmentAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int position) {
- if (position == 0) {
- return new Read1Fragment();
- } else if (position == 1) {
- return new Read2Fragment();
- } else if (position == 2) {
- return new Read3Fragment();
- } else {
- return new Read4Fragment();
- }
- }
-
- @Override
- public int getCount() {
- return 4;
- }
-
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- if (positionOffset != 0) {
- lparams.leftMargin = (int) (width * (position + positionOffset) + width / 4);
- fm_slide_line.setLayoutParams(lparams);
- }
- }
-
- @Override
- public void onPageSelected(int position) {
- if (position == 0) {
- fm_read_tuijian.setClickable(false);
- fm_read_yuanchuang.setClickable(true);
- fm_read_zixun.setClickable(true);
- fm_read_gonglue.setClickable(true);
- fm_read_tuijian.setTextColor(getResources().getColor(R.color.theme_colors));
- fm_read_yuanchuang.setTextColor(0xFF666666);
- fm_read_zixun.setTextColor(0xFF666666);
- fm_read_gonglue.setTextColor(0xFF666666);
- } else if (position == 1) {
- fm_read_tuijian.setClickable(true);
- fm_read_yuanchuang.setClickable(false);
- fm_read_zixun.setClickable(true);
- fm_read_gonglue.setClickable(true);
- fm_read_tuijian.setTextColor(0xFF666666);
- fm_read_yuanchuang.setTextColor(getResources().getColor(R.color.theme_colors));
- fm_read_zixun.setTextColor(0xFF666666);
- fm_read_gonglue.setTextColor(0xFF666666);
- } else if (position == 2) {
- fm_read_tuijian.setClickable(true);
- fm_read_yuanchuang.setClickable(true);
- fm_read_zixun.setClickable(false);
- fm_read_gonglue.setClickable(true);
- fm_read_tuijian.setTextColor(0xFF666666);
- fm_read_yuanchuang.setTextColor(0xFF666666);
- fm_read_zixun.setTextColor(getResources().getColor(R.color.theme_colors));
- fm_read_gonglue.setTextColor(0xFF666666);
- } else {
- fm_read_tuijian.setClickable(true);
- fm_read_yuanchuang.setClickable(true);
- fm_read_zixun.setClickable(true);
- fm_read_gonglue.setClickable(false);
- fm_read_tuijian.setTextColor(0xFF666666);
- fm_read_yuanchuang.setTextColor(0xFF666666);
- fm_read_zixun.setTextColor(0xFF666666);
- fm_read_gonglue.setTextColor(getResources().getColor(R.color.theme_colors));
- }
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- }
-
-}
diff --git a/app/src/main/res/drawable-hdpi/home4_selected.png b/app/src/main/res/drawable-hdpi/home4_selected.png
deleted file mode 100644
index 55720779f2..0000000000
Binary files a/app/src/main/res/drawable-hdpi/home4_selected.png and /dev/null differ
diff --git a/app/src/main/res/drawable-hdpi/home4_unselected.png b/app/src/main/res/drawable-hdpi/home4_unselected.png
deleted file mode 100644
index a54c3daf35..0000000000
Binary files a/app/src/main/res/drawable-hdpi/home4_unselected.png and /dev/null differ
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index bf0f4cd241..154bf47d40 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -42,30 +42,6 @@
android:textSize="12sp" />
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/home_list_item_navigation.xml b/app/src/main/res/layout/home_list_item_navigation.xml
index ba392966b6..94493130f2 100644
--- a/app/src/main/res/layout/home_list_item_navigation.xml
+++ b/app/src/main/res/layout/home_list_item_navigation.xml
@@ -28,6 +28,26 @@
android:textColor="#333333" />
+
+
+
+
+
+
+
-
-
-
-
-
-
-
\ No newline at end of file