PageRenderTime 73ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/yueai/src/main/java/com/yueai/activity/MainActivity.java

https://bitbucket.org/juzhiwiscom/datelove
Java | 2083 lines | 904 code | 159 blank | 1020 comment | 147 complexity | 3de966df17849e9e192bc5a1e472aeb9 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. package com.yueai.activity;
  2. import android.Manifest;
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.content.IntentFilter;
  7. import android.content.pm.PackageManager;
  8. import android.location.Location;
  9. import android.location.LocationListener;
  10. import android.location.LocationManager;
  11. import android.os.Build;
  12. import android.os.Bundle;
  13. import android.os.Handler;
  14. import android.os.Message;
  15. import android.os.Vibrator;
  16. import android.support.annotation.NonNull;
  17. import android.support.v4.app.ActivityCompat;
  18. import android.support.v4.app.Fragment;
  19. import android.support.v4.app.FragmentManager;
  20. import android.support.v4.app.FragmentPagerAdapter;
  21. import android.support.v4.content.ContextCompat;
  22. import android.support.v4.view.ViewPager;
  23. import android.text.TextUtils;
  24. import android.util.Log;
  25. import android.view.View;
  26. import android.view.WindowManager;
  27. import android.view.animation.Animation;
  28. import android.view.animation.AnimationUtils;
  29. import android.widget.FrameLayout;
  30. import android.widget.ImageView;
  31. import android.widget.LinearLayout;
  32. import android.widget.RelativeLayout;
  33. import android.widget.TextView;
  34. import com.alibaba.fastjson.JSON;
  35. import com.alibaba.fastjson.JSONArray;
  36. import com.alibaba.fastjson.JSONObject;
  37. import com.library.imageloader.ImageLoader;
  38. import com.library.imageloader.ImageLoaderUtil;
  39. import com.library.utils.HeightUtils;
  40. import com.library.utils.LogUtil;
  41. import com.library.utils.SharedPreferenceUtil;
  42. import com.library.utils.Util;
  43. import com.library.widgets.CircleImageView;
  44. import com.library.widgets.ScrollControlViewPager;
  45. import com.yueai.R;
  46. import com.yueai.base.BaseFragmentActivity;
  47. import com.yueai.bean.BaseModel;
  48. import com.yueai.bean.FateUser;
  49. import com.yueai.bean.HeadMsgNotice;
  50. import com.yueai.bean.Image;
  51. import com.yueai.bean.LocationInfo;
  52. import com.yueai.bean.MsgBox;
  53. import com.yueai.bean.NewHeadMsgNotice;
  54. import com.yueai.bean.RecommendUser;
  55. import com.yueai.bean.User;
  56. import com.yueai.bean.UserBase;
  57. import com.yueai.constant.IUrlConstant;
  58. import com.yueai.event.BaseOpenMailFragmentEvent;
  59. import com.yueai.event.CloseMainActivityEvent;
  60. import com.yueai.event.HeadMsgEvent;
  61. import com.yueai.event.MatchInfoChangeEvent;
  62. import com.yueai.event.MessageChangedEvent;
  63. import com.yueai.event.NoSeeMeEvent;
  64. import com.yueai.event.OpenMailFragmentEvent;
  65. import com.yueai.event.RegistEvent;
  66. import com.yueai.event.UpdateMessageCountEvent;
  67. import com.yueai.event.UpdateUserProvince;
  68. import com.yueai.fragment.FateCardFragment;
  69. import com.yueai.fragment.MeFragment;
  70. import com.yueai.fragment.MessageFragment;
  71. import com.yueai.fragment.NearbyFragment;
  72. import com.yueai.fragment.SearchFragment;
  73. import com.yueai.utils.CommonRequestUtil;
  74. import com.yueai.xml.PlatformInfoXml;
  75. import com.yueai.xml.UserInfoXml;
  76. import com.zhy.http.okhttp.OkHttpUtils;
  77. import com.zhy.http.okhttp.callback.Callback;
  78. import com.zhy.http.okhttp.callback.StringCallback;
  79. import org.greenrobot.eventbus.EventBus;
  80. import org.greenrobot.eventbus.Subscribe;
  81. import java.lang.ref.WeakReference;
  82. import java.util.ArrayList;
  83. import java.util.HashMap;
  84. import java.util.List;
  85. import java.util.Map;
  86. import butterknife.BindView;
  87. import butterknife.OnClick;
  88. import okhttp3.Call;
  89. import okhttp3.Response;
  90. import static com.yueai.utils.GoogleUtil.getGoogleProviceL1Key;
  91. /**
  92. * modified by zhangdroid on 2017-02-28
  93. */
  94. public class MainActivity extends BaseFragmentActivity {
  95. @BindView(R.id.viewPager)
  96. ScrollControlViewPager mViewPager;
  97. // 页眉
  98. @BindView(R.id.head_msg_container)
  99. RelativeLayout mRlHeadMsgContainer;
  100. @BindView(R.id.head_msg_content)
  101. TextView mTvHeadMsgContent;
  102. @BindView(R.id.head_msg_clear)
  103. ImageView mIvHeadMsgClear;
  104. // 新页眉
  105. @BindView(R.id.headMsg_container)
  106. FrameLayout mFlHeadMsgNew;
  107. @BindView(R.id.headMsg_unread)
  108. RelativeLayout mRlHeadMsgUnread;
  109. @BindView(R.id.headMsg_avatar)
  110. CircleImageView mIvHeadMsgAvatar;
  111. @BindView(R.id.headMsg_nickname)
  112. TextView mTvNickname;
  113. @BindView(R.id.headMsg_age)
  114. TextView mTvAge;
  115. @BindView(R.id.headMsg_height)
  116. TextView mTvHeight;
  117. @BindView(R.id.headMsg_content)
  118. TextView mTvMsgContent;
  119. @BindView(R.id.headMsg_check)
  120. TextView mTvMsgCheck;
  121. // 访客
  122. @BindView(R.id.headMsg_visitor)
  123. RelativeLayout mRlHeadMsgVisitor;
  124. @BindView(R.id.visitor_avatar)
  125. CircleImageView mIvVisitorAvatar;
  126. @BindView(R.id.visitor_content)
  127. TextView mTvVisitorContent;
  128. @BindView(R.id.visitor_ignore)
  129. TextView mTvVisitorIgnore;
  130. @BindView(R.id.visitor_look)
  131. TextView mTvVisitorLook;
  132. // 推荐用户
  133. @BindView(R.id.recommend_user_container)
  134. LinearLayout mLlRecommendUser;
  135. @BindView(R.id.recommend_user_avatar)
  136. CircleImageView mIvRecommendAvatar;
  137. @BindView(R.id.recommend_user_content)
  138. TextView mTvRecommendContent;
  139. @BindView(R.id.recommend_user_ignore)
  140. TextView mTvRecommendIgnore;
  141. @BindView(R.id.recommend_user_look)
  142. TextView mTvRecommendLook;
  143. // tab页
  144. @BindView(R.id.main_tab_fate)
  145. TextView mTvTabFate;
  146. @BindView(R.id.main_tab_search)
  147. TextView mTvTabSearch;
  148. @BindView(R.id.main_tab_mail)
  149. TextView mTvTabMail;
  150. @BindView(R.id.unread_msg_count)
  151. TextView mTvUnreadMsgCount;// 未读消息数
  152. @BindView(R.id.main_tab_nearby)
  153. TextView mTvTabNearby;
  154. @BindView(R.id.main_tab_me)
  155. TextView mTvTabMe;
  156. private static final int TAB_INDEX_FATE = 0;
  157. private static final int TAB_INDEX_SEARCH = 1;
  158. private static final int TAB_INDEX_MAIL = 2;
  159. private static final int TAB_INDEX_NEARBY = 3;
  160. private static final int TAB_INDEX_ME = 4;
  161. private static final int HEAD_MSG_REFRESH_PERIOD = 20 * 1000;
  162. private static final int MSG_TYPE_LOAD_DATA = 1;
  163. private static final int MSG_TYPE_HEAD_MSG = 2;
  164. private static final int MSG_TYPE_HEAD_MSG_NEW = 3;
  165. private static final int MSG_TYPE_RECOMMEND_USER = 4;
  166. private static final int MSG_TYPE_SHOW_UNREAD_MSG = 5;
  167. private static final int MSG_TYPE_DISMISS_UNREAD_MSG = 6;
  168. private static final int MSG_TYPE_DISMISS_VISITOR = 7;
  169. private static final int MSG_TYPE_HIDE_RECOMMEND_USER = 8;
  170. private static final int PERMISSION_CODE_ACCESS_FINE_LOCATION = 0;
  171. private LocationManager mLocationManager;
  172. /**
  173. * 页眉对象缓存
  174. */
  175. private HeadMsgNotice mHeadMsgNotice;
  176. /**
  177. * 新页眉对象缓存
  178. */
  179. private NewHeadMsgNotice mNewHeadMsgNotice;
  180. /**
  181. * 推荐用户对象缓存
  182. */
  183. private RecommendUser mRecommendUser;
  184. /**
  185. * 新页眉最后一条未读消息毫秒数
  186. */
  187. private long mLastMsgTime;
  188. /**
  189. * 推荐用户轮询周期(秒)
  190. */
  191. private int cycle;
  192. /**
  193. * 新页眉中当前正在显示的未读消息索引
  194. */
  195. private int mCurrDisplayItem = 0;
  196. private TimerHandler mTimerHandler;
  197. private Context mContext;
  198. private Vibrator vibrator;
  199. private boolean isShake = true;
  200. private MainAdapter mainAdapter;
  201. private int currentUnreadMsgCount;
  202. private boolean isFirstInto=true;
  203. private boolean getProvince=false;
  204. private String getLatitude;
  205. private String getLongitude;
  206. private boolean LocationSuccess=true;
  207. @Override
  208. protected int getLayoutResId() {
  209. return R.layout.activity_main;
  210. }
  211. @Override
  212. protected void initViewsAndVariables() {
  213. // 设置状态栏
  214. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {// 5.0及以上
  215. View decorView = getWindow().getDecorView();
  216. decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
  217. // 设置状态栏背景
  218. getWindow().setStatusBarColor(getResources().getColor(R.color.main_color));
  219. } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {// 4.4
  220. getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  221. }
  222. // 获取位置信息并上传
  223. requestLocation();
  224. getAdapter();
  225. // 延时加载数据
  226. mTimerHandler = new TimerHandler(this);
  227. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_LOAD_DATA,1000*15);
  228. //注册广播
  229. registerReceiver(mHomeKeyEventReceiver, new IntentFilter(
  230. Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
  231. }
  232. private void getAdapter() {
  233. if(isFirstInto){
  234. isFirstInto=false;
  235. mainAdapter = new MainAdapter(getSupportFragmentManager());
  236. mViewPager.setAdapter(mainAdapter);
  237. mViewPager.setCanScroll(false);
  238. mViewPager.setOffscreenPageLimit(4);
  239. mViewPager.setCurrentItem(TAB_INDEX_FATE);
  240. mTvTabFate.setSelected(true);
  241. /**对viewPage的界面改变进行监听,当刷新聊天列表的界面开始刷新,刷出聊天列表界面停止刷新**/
  242. mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  243. @Override
  244. public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  245. }
  246. @Override
  247. public void onPageSelected(int position) {
  248. MessageFragment item = (MessageFragment)mainAdapter.getItem(2);
  249. if(position!=2){
  250. item.stopRefish();
  251. }else{
  252. item.startFirstRefish();
  253. }
  254. }
  255. @Override
  256. public void onPageScrollStateChanged(int state) {
  257. }
  258. });
  259. }
  260. }
  261. /**
  262. * 加载页眉和推荐用户
  263. */
  264. private void loadData() {
  265. // // 获取页眉
  266. // if (UserInfoXml.isShowHeadMsg()) {
  267. // getHeadMsg();
  268. // mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG, HEAD_MSG_REFRESH_PERIOD);
  269. // }
  270. // 获取新页眉
  271. if (UserInfoXml.isShowHeadMsgNew()) {
  272. getNewHeadMsg();
  273. }
  274. // 获取推荐用户
  275. if (UserInfoXml.isShowRecommendUser()) {
  276. getRecommendUsr();
  277. // mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_RECOMMEND_USER, HEAD_MSG_REFRESH_PERIOD);
  278. }
  279. }
  280. /**
  281. * 获取页眉
  282. */
  283. private void getHeadMsg() {
  284. CommonRequestUtil.getHeadMsg(new CommonRequestUtil.OnGetHeadMsgListener() {
  285. @Override
  286. public void onSuccess(HeadMsgNotice headMsgNotice) {
  287. if (headMsgNotice != null) {
  288. mHeadMsgNotice = headMsgNotice;
  289. String message = headMsgNotice.getMessage();
  290. if (mViewPager.getCurrentItem() != TAB_INDEX_MAIL && !TextUtils.isEmpty(message)) {
  291. mRlHeadMsgContainer.setVisibility(View.VISIBLE);
  292. mTvHeadMsgContent.setText(message);
  293. } else {
  294. mRlHeadMsgContainer.setVisibility(View.GONE);
  295. }
  296. String noticeType = headMsgNotice.getNoticeType();
  297. if (!TextUtils.isEmpty(noticeType) && "1".equals(noticeType)) {
  298. // 有未读消息时刷新消息列表
  299. EventBus.getDefault().post(new MessageChangedEvent());
  300. }
  301. }
  302. }
  303. @Override
  304. public void onFail() {
  305. }
  306. });
  307. }
  308. /**
  309. * 获取新页眉
  310. */
  311. private void getNewHeadMsg() {
  312. String lastMsgTime=new SharedPreferenceUtil(MainActivity.this).takeLastTime();
  313. if(!TextUtils.isEmpty(lastMsgTime)){
  314. mLastMsgTime=Long.parseLong(lastMsgTime);
  315. }
  316. CommonRequestUtil.getNewHeadMsg(mLastMsgTime, new CommonRequestUtil.OnGetNewHeadMsgListener() {
  317. @Override
  318. public void onSuccess(NewHeadMsgNotice newHeadMsgNotice) {
  319. if (newHeadMsgNotice != null) {
  320. mNewHeadMsgNotice = newHeadMsgNotice;
  321. mLastMsgTime = newHeadMsgNotice.getLastMsgTime();
  322. mCurrDisplayItem = 0;
  323. //将时间戳保存下来
  324. new SharedPreferenceUtil(MainActivity.this).saveLastTime(mLastMsgTime);
  325. String noticeType = newHeadMsgNotice.getNoticeType();
  326. if (!TextUtils.isEmpty(noticeType)) {
  327. switch (noticeType) {
  328. case "0":// 没有页眉,继续轮询
  329. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  330. break;
  331. case "1"://未读消息
  332. // 刷新聊天列表
  333. EventBus.getDefault().post(new MessageChangedEvent());
  334. setNewHeadMsg();
  335. break;
  336. case "2":// 访客
  337. FateUser fateUser = newHeadMsgNotice.getRemoteYuanfenUserBase();
  338. if (fateUser != null) {
  339. UserBase userBase = fateUser.getUserBaseEnglish();
  340. if (userBase != null) {
  341. ImageLoaderUtil.getInstance().loadImage(MainActivity.this, new ImageLoader.Builder()
  342. .url(userBase.getImage().getThumbnailUrl()).imageView(mIvVisitorAvatar).build());
  343. mTvVisitorContent.setText(getString(R.string.visitor_tip, userBase.getNickName()));
  344. }
  345. }
  346. mRlHeadMsgUnread.setVisibility(View.GONE);
  347. mRlHeadMsgVisitor.setVisibility(View.VISIBLE);
  348. showWithAnim(mFlHeadMsgNew);
  349. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_DISMISS_VISITOR, newHeadMsgNotice.getDisplaySecond() * 1000);
  350. break;
  351. }
  352. }
  353. }
  354. }
  355. @Override
  356. public void onFail() {
  357. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  358. }
  359. });
  360. }
  361. /**
  362. * 按照未读消息列表顺序显示未读信
  363. */
  364. private void setNewHeadMsg() {
  365. if (mNewHeadMsgNotice != null) {
  366. List<MsgBox> msgBoxList = mNewHeadMsgNotice.getUnreadMsgBoxList();
  367. if (!Util.isListEmpty(msgBoxList) && mCurrDisplayItem < msgBoxList.size()) {
  368. MsgBox msgBox = msgBoxList.get(mCurrDisplayItem);
  369. if (msgBox != null) {
  370. UserBase userBase = msgBox.getUserBaseEnglish();
  371. if (userBase != null) {
  372. Image image = userBase.getImage();
  373. if (image != null) {
  374. ImageLoaderUtil.getInstance().loadImage(MainActivity.this, new ImageLoader.Builder()
  375. .url(image.getThumbnailUrl()).imageView(mIvHeadMsgAvatar).build());
  376. }
  377. mTvNickname.setText(userBase.getNickName());
  378. if(userBase.getSex() ==0){
  379. mTvAge.setBackgroundResource(R.drawable.shape_round_rectangle_blue_bg);
  380. }
  381. mTvAge.setText(TextUtils.concat(String.valueOf(userBase.getAge())));
  382. mTvAge.setSelected(userBase.getSex() == 0);
  383. mTvHeight.setText(HeightUtils.getInchCmByCm(userBase.getHeightCm()));
  384. }
  385. String msgContent = msgBox.getMsg();
  386. if (!TextUtils.isEmpty(msgContent)) {
  387. // mTvMsgContent.setText(getString(R.string.get_msg));
  388. mTvMsgContent.setText(msgContent);
  389. }
  390. mRlHeadMsgUnread.setVisibility(View.VISIBLE);
  391. mRlHeadMsgVisitor.setVisibility(View.GONE);
  392. showWithAnim(mFlHeadMsgNew);
  393. }
  394. // 一段时间后显示下一条未读消息
  395. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_SHOW_UNREAD_MSG, mNewHeadMsgNotice.getDisplaySecond() * 1000);
  396. }
  397. }
  398. }
  399. private void showWithAnim(View view) {
  400. if (isShake) {
  401. view.setVisibility(View.VISIBLE);
  402. vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  403. vibrator.vibrate(200);
  404. view.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim_in));
  405. }
  406. // view.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.push_bottom_in));
  407. }
  408. private void dismissWithAnim(final View view, final View view2) {
  409. // Animation outAnimation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.push_bottom_out);
  410. Animation outAnimation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim_out);
  411. view.startAnimation(outAnimation);
  412. outAnimation.setAnimationListener(new Animation.AnimationListener() {
  413. @Override
  414. public void onAnimationStart(Animation animation) {
  415. }
  416. @Override
  417. public void onAnimationEnd(Animation animation) {
  418. view.setVisibility(View.GONE);
  419. view2.setVisibility(View.GONE);
  420. }
  421. @Override
  422. public void onAnimationRepeat(Animation animation) {
  423. }
  424. });
  425. }
  426. /**
  427. * 获取推荐用户
  428. */
  429. private void getRecommendUsr() {
  430. CommonRequestUtil.getRecommendUser(cycle, new CommonRequestUtil.OnGetRecommendUserListener() {
  431. @Override
  432. public void onSuccess(RecommendUser recommendUser) {
  433. if (recommendUser != null) {
  434. mRecommendUser = recommendUser;
  435. cycle = recommendUser.getCycle();
  436. User user = recommendUser.getUser();
  437. if (user != null) {
  438. UserBase userBase = user.getUserBaseEnglish();
  439. if (userBase != null) {
  440. // 显示推荐用户
  441. mLlRecommendUser.setVisibility(View.VISIBLE);
  442. mTvRecommendContent.setText(TextUtils.concat(userBase.getNickName(), " ", recommendUser.getSentence()));
  443. ImageLoaderUtil.getInstance().loadImage(MainActivity.this, new ImageLoader.Builder()
  444. .url(userBase.getImage().getThumbnailUrl()).imageView(mIvRecommendAvatar).build());
  445. showWithAnim(mLlRecommendUser);
  446. }
  447. }
  448. }
  449. // 一段时间后隐藏推荐用户
  450. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HIDE_RECOMMEND_USER, 5 * 1000);
  451. }
  452. @Override
  453. public void onFail() {
  454. // 一段时间后隐藏推荐用户
  455. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HIDE_RECOMMEND_USER, 5 * 1000);
  456. }
  457. });
  458. }
  459. @Override
  460. protected void addListeners() {
  461. mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  462. @Override
  463. public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  464. }
  465. @Override
  466. public void onPageSelected(int position) {
  467. switch (position) {
  468. case TAB_INDEX_FATE:
  469. mTvTabFate.setSelected(true);
  470. mTvTabSearch.setSelected(false);
  471. mTvTabMail.setSelected(false);
  472. mTvTabNearby.setSelected(false);
  473. mTvTabMe.setSelected(false);
  474. break;
  475. case TAB_INDEX_SEARCH:
  476. mTvTabFate.setSelected(false);
  477. mTvTabSearch.setSelected(true);
  478. mTvTabMail.setSelected(false);
  479. mTvTabNearby.setSelected(false);
  480. mTvTabMe.setSelected(false);
  481. break;
  482. case TAB_INDEX_MAIL:
  483. mTvTabFate.setSelected(false);
  484. mTvTabSearch.setSelected(false);
  485. mTvTabMail.setSelected(true);
  486. mTvTabNearby.setSelected(false);
  487. mTvTabMe.setSelected(false);
  488. // 信箱tab页不显示页眉
  489. if (mRlHeadMsgContainer.isShown()) {
  490. mRlHeadMsgContainer.setVisibility(View.GONE);
  491. }
  492. // 隐藏新页眉
  493. if (mFlHeadMsgNew.isShown()) {
  494. mFlHeadMsgNew.setVisibility(View.GONE);
  495. if (mTimerHandler != null) {
  496. mTimerHandler.removeMessages(MSG_TYPE_SHOW_UNREAD_MSG);
  497. }
  498. }
  499. break;
  500. case TAB_INDEX_NEARBY:
  501. mTvTabFate.setSelected(false);
  502. mTvTabSearch.setSelected(false);
  503. mTvTabMail.setSelected(false);
  504. mTvTabNearby.setSelected(true);
  505. mTvTabMe.setSelected(false);
  506. break;
  507. case TAB_INDEX_ME:
  508. mTvTabFate.setSelected(false);
  509. mTvTabSearch.setSelected(false);
  510. mTvTabMail.setSelected(false);
  511. mTvTabNearby.setSelected(false);
  512. mTvTabMe.setSelected(true);
  513. break;
  514. }
  515. }
  516. @Override
  517. public void onPageScrollStateChanged(int state) {
  518. }
  519. });
  520. // 查看页眉消息
  521. mRlHeadMsgContainer.setOnClickListener(new View.OnClickListener() {
  522. @Override
  523. public void onClick(View v) {
  524. if (mHeadMsgNotice != null) {
  525. mRlHeadMsgContainer.setVisibility(View.GONE);
  526. String noticeType = mHeadMsgNotice.getNoticeType();
  527. if (!TextUtils.isEmpty(noticeType)) {
  528. switch (noticeType) {
  529. case "1": // 未读消息
  530. if (mViewPager.getCurrentItem() != TAB_INDEX_MAIL) {
  531. mViewPager.setCurrentItem(TAB_INDEX_MAIL, false);
  532. }
  533. break;
  534. case "2":// 正在看我
  535. UserInfoDetailActivity.toUserInfoDetailActivity(MainActivity.this, mHeadMsgNotice.getRemoteUserId(), null, UserInfoDetailActivity.SOURCE_HEAD_MSG);
  536. break;
  537. }
  538. }
  539. }
  540. }
  541. });
  542. mIvHeadMsgClear.setOnClickListener(new View.OnClickListener() {
  543. @Override
  544. public void onClick(View v) {
  545. mRlHeadMsgContainer.setVisibility(View.GONE);
  546. }
  547. });
  548. // 新页眉
  549. mRlHeadMsgUnread.setOnClickListener(new View.OnClickListener() {
  550. @Override
  551. public void onClick(View v) {
  552. // 查看未读消息,进入聊天页面
  553. mFlHeadMsgNew.setVisibility(View.GONE);
  554. if (mNewHeadMsgNotice != null && mCurrDisplayItem < mNewHeadMsgNotice.getUnreadMsgBoxList().size()) {
  555. List<MsgBox> msgBoxList = mNewHeadMsgNotice.getUnreadMsgBoxList();
  556. if (!Util.isListEmpty(msgBoxList)) {
  557. MsgBox msgBox = msgBoxList.get(mCurrDisplayItem);
  558. if (msgBox != null) {
  559. UserBase userBase = msgBox.getUserBaseEnglish();
  560. if (userBase != null) {
  561. ChatActivity.toChatActivity(MainActivity.this, userBase.getId(), userBase.getNickName(), userBase.getImage().getThumbnailUrl());
  562. }
  563. }
  564. }
  565. }
  566. }
  567. });
  568. mTvVisitorLook.setOnClickListener(new View.OnClickListener() {
  569. @Override
  570. public void onClick(View v) {
  571. // 隐藏新页眉
  572. mRlHeadMsgVisitor.setVisibility(View.GONE);
  573. mFlHeadMsgNew.setVisibility(View.GONE);
  574. // 查看用户详情
  575. if (mNewHeadMsgNotice != null) {
  576. FateUser fateUser = mNewHeadMsgNotice.getRemoteYuanfenUserBase();
  577. if (fateUser != null) {
  578. UserBase userBase = fateUser.getUserBaseEnglish();
  579. if (userBase != null) {
  580. UserInfoDetailActivity.toUserInfoDetailActivity(MainActivity.this, userBase.getId(), null, UserInfoDetailActivity.SOURCE_HEAD_MSG);
  581. }
  582. }
  583. }
  584. }
  585. });
  586. mTvVisitorIgnore.setOnClickListener(new View.OnClickListener() {
  587. @Override
  588. public void onClick(View v) {
  589. // 隐藏新页眉
  590. mRlHeadMsgVisitor.setVisibility(View.GONE);
  591. mFlHeadMsgNew.setVisibility(View.GONE);
  592. }
  593. });
  594. // 推荐用户
  595. mTvRecommendLook.setOnClickListener(new View.OnClickListener() {
  596. @Override
  597. public void onClick(View v) {
  598. if (mRecommendUser != null) {
  599. UserBase userBase = mRecommendUser.getUser().getUserBaseEnglish();
  600. if (userBase != null) {
  601. // 隐藏推荐用户
  602. mLlRecommendUser.setVisibility(View.GONE);
  603. Image image = userBase.getImage();
  604. if (UserInfoXml.isMale()) {
  605. if (UserInfoXml.isMonthly()) {// 已付费男用户进入聊天页
  606. ChatActivity.toChatActivity(MainActivity.this, userBase.getId(), userBase.getNickName(),
  607. image == null ? null : image.getThumbnailUrl());
  608. } else {// 未付费男用户,进入对方空间页
  609. UserInfoDetailActivity.toUserInfoDetailActivity(MainActivity.this, userBase.getId(), null, UserInfoDetailActivity.SOURCE_FROM_RECOMMEND_USER);
  610. }
  611. } else {// 女用户进入聊天页
  612. ChatActivity.toChatActivity(MainActivity.this, userBase.getId(), userBase.getNickName(),
  613. image == null ? null : image.getThumbnailUrl());
  614. }
  615. }
  616. }
  617. }
  618. });
  619. mTvRecommendIgnore.setOnClickListener(new View.OnClickListener() {
  620. @Override
  621. public void onClick(View v) {
  622. // 隐藏推荐用户
  623. mLlRecommendUser.setVisibility(View.GONE);
  624. }
  625. });
  626. }
  627. @OnClick({R.id.main_tab_fate, R.id.main_tab_search, R.id.main_tab_mail, R.id.main_tab_nearby, R.id.main_tab_me})
  628. public void onClick(View view) {
  629. switch (view.getId()) {
  630. case R.id.main_tab_fate:
  631. mViewPager.setCurrentItem(TAB_INDEX_FATE);
  632. break;
  633. case R.id.main_tab_search:
  634. mViewPager.setCurrentItem(TAB_INDEX_SEARCH);
  635. break;
  636. case R.id.main_tab_mail:
  637. mViewPager.setCurrentItem(TAB_INDEX_MAIL);
  638. break;
  639. case R.id.main_tab_nearby:
  640. mViewPager.setCurrentItem(TAB_INDEX_NEARBY);
  641. break;
  642. case R.id.main_tab_me:
  643. mViewPager.setCurrentItem(TAB_INDEX_ME);
  644. break;
  645. }
  646. }
  647. /**
  648. * 请求定位信息
  649. */
  650. private void requestLocation() {
  651. mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  652. if (ContextCompat.checkSelfPermission(MainActivity.this,
  653. Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED) {
  654. // 请求android.permission.ACCESS_FINE_LOCATION
  655. ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_CODE_ACCESS_FINE_LOCATION);
  656. } else {
  657. if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {// Network定位
  658. mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 2000, 5, mLocationListener);
  659. } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {// GPS定位
  660. uploadLocation(mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER));
  661. }
  662. }
  663. }
  664. private LocationListener mLocationListener = new LocationListener() {
  665. @Override
  666. public void onLocationChanged(Location location) {
  667. uploadLocation(location);
  668. }
  669. @Override
  670. public void onStatusChanged(String provider, int status, Bundle extras) {
  671. }
  672. @Override
  673. public void onProviderEnabled(String provider) {
  674. }
  675. @Override
  676. public void onProviderDisabled(String provider) {
  677. }
  678. };
  679. @Override
  680. public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  681. if (requestCode == PERMISSION_CODE_ACCESS_FINE_LOCATION) {
  682. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {// 申请权限成功
  683. if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {// Network定位
  684. if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  685. // TODO: Consider calling
  686. // ActivityCompat#requestPermissions
  687. // here to request the missing permissions, and then overriding
  688. // public void onRequestPermissionsResult(int requestCode, String[] permissions,
  689. // int[] grantResults)
  690. // to handle the case where the user grants the permission. See the documentation
  691. // for ActivityCompat#requestPermissions for more details.
  692. return;
  693. }
  694. mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 2000, 5, mLocationListener);
  695. } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {// GPS定位
  696. uploadLocation(mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER));
  697. }
  698. }
  699. }
  700. }
  701. /**
  702. * 上传位置信息
  703. *
  704. * @param location 定位成功后的信息
  705. */
  706. private void uploadLocation(Location location) {
  707. if (location != null) {
  708. getLatitude = String.valueOf(location.getLatitude());
  709. getLongitude = String.valueOf(location.getLongitude());
  710. String country = UserInfoXml.getCountry();
  711. getAddress(getLatitude, getLongitude,"English", country);
  712. // Map<String, String> googleAddress = GoogleUtil.getGoogleAddress(getLatitude, getLongitude, "zh-TW", "Taiwan");
  713. // String province = googleAddress.get("province");
  714. // if(!TextUtils.isEmpty(province)){
  715. // if (!province.equals(UserInfoXml.getProvinceName())) {
  716. // UserInfoXml.setProvinceName(province);
  717. // getProvince = true;
  718. // }
  719. // }
  720. }else{
  721. // getAdapter();
  722. }
  723. }
  724. // 获取城市
  725. private void getAddress(String getLatitude, String getLongitude, final String language, final String country) {
  726. // 本地
  727. String url = "http://ditu.google.cn/maps/api/geocode/json?latlng="+ getLatitude + "," + getLongitude + "&&sensor=false&&language=";
  728. // 线上
  729. // String url = "http://ditu.google.com/maps/api/geocode/json?latlng="+ lat + "," + lng + "&&sensor=false&&language=";
  730. //获取国际化参数
  731. String localInfo = "en_US";
  732. url += localInfo; //拼接url地址
  733. String charset = "UTF-8";
  734. OkHttpUtils.get()
  735. .url(url)
  736. .build()
  737. .execute(new StringCallback() {
  738. @Override
  739. public void onError(Call call, Exception e, int id) {
  740. Log.v("Exception",e.toString());
  741. }
  742. @Override
  743. public void onResponse(String response, int id) {
  744. if (null != response) {
  745. JSONObject json = JSON.parseObject(response);// 转换为json数据
  746. JSONArray jsonArray = json.getJSONArray("results");
  747. Map<String, String> map = null;
  748. if (null != jsonArray && jsonArray.size() > 0) {// 增加验证
  749. JSONObject objResult = (JSONObject) jsonArray.get(0);
  750. JSONArray addressComponents = objResult.getJSONArray("address_components");
  751. //解析结果
  752. getByGoogleMap(addressComponents, objResult, language, country);
  753. }
  754. }
  755. }
  756. });
  757. }
  758. private void getByGoogleMap(JSONArray addressComponents, JSONObject objResult, String language, String country) {
  759. String countryResult="";
  760. String province="";
  761. String city="";
  762. if(addressComponents!=null&&addressComponents.size()>0){
  763. for(int i=0;i<addressComponents.size();i++){
  764. JSONObject obj = (JSONObject) addressComponents
  765. .get(i);
  766. JSONArray types = obj.getJSONArray("types");
  767. String type = (String)types.get(0);
  768. //获取目标解析单位的key
  769. String proviceKey = getGoogleProviceL1Key(country);
  770. if(type.equals(proviceKey)){
  771. province = obj.getString("long_name");// 州
  772. }else if(type.equals("administrative_area_level_2")){
  773. city = obj.getString("long_name");// 城市
  774. }else if (type.equals("country")){ //国家
  775. countryResult = obj.getString("long_name");
  776. }
  777. }
  778. // if(StringUtils.isBlank(province)){ //不是一级城市 取二级城市
  779. if(TextUtils.isEmpty(province)){ //不是一级城市 取二级城市
  780. province = city;
  781. }
  782. }
  783. String formatted_address = objResult.getString("formatted_address");
  784. Map<String, String> map = new HashMap<String, String>();
  785. map.put("city", city);
  786. map.put("formatted_address", formatted_address);
  787. map.put("province", province);
  788. map.put("country", countryResult);
  789. if (map != null) {
  790. String province2 = map.get("province");
  791. // 英国城市为空。。。
  792. if (!TextUtils.isEmpty(province2) && !province.equals(UserInfoXml.getProvinceName())) {
  793. UserInfoXml.setProvinceName(province2);
  794. getProvince = true;
  795. }
  796. if(LocationSuccess){
  797. LocationSuccess=false;
  798. getLocation(getLatitude, getLongitude, province);
  799. }
  800. }
  801. }
  802. private void getLocation(String getLatitude, String getLongitude, String province) {
  803. LocationInfo locationInfo = new LocationInfo();
  804. locationInfo.setAddrStr("");
  805. locationInfo.setProvince(province);
  806. locationInfo.setCity("");
  807. locationInfo.setCityCode("");
  808. locationInfo.setDistrict("");
  809. locationInfo.setStreet("");
  810. locationInfo.setStreetNumber("");
  811. locationInfo.setLatitude(getLatitude);
  812. locationInfo.setLongitude(getLongitude);
  813. Map<String, LocationInfo> map = new HashMap<String, LocationInfo>();
  814. map.put("locationInfo", locationInfo);
  815. OkHttpUtils.post()
  816. .url(IUrlConstant.URL_UPLOAD_LOCATION)
  817. .addHeader("token", PlatformInfoXml.getToken())
  818. .addParams("platformInfo", PlatformInfoXml.getPlatformJsonString())
  819. .addParams("locationInfo", JSON.toJSONString(map))
  820. .build()
  821. .execute(new Callback<BaseModel>() {
  822. @Override
  823. public BaseModel parseNetworkResponse(Response response, int id) throws Exception {
  824. String resultJson = response.body().string();
  825. if (!TextUtils.isEmpty(resultJson)) {
  826. return JSON.parseObject(resultJson, BaseModel.class);
  827. }
  828. return null;
  829. }
  830. @Override
  831. public void onError(Call call, Exception e, int id) {
  832. }
  833. @Override
  834. public void onResponse(BaseModel response, int id) {
  835. if (response != null) {
  836. String isSucceed = response.getIsSucceed();
  837. if (!TextUtils.isEmpty(isSucceed) && "1".equals(isSucceed)) {// 上传成功
  838. LogUtil.i(LogUtil.TAG_ZL, "上传位置信息成功");
  839. // getAdapter();
  840. // 发送事件,更新位置信息
  841. if(getProvince){
  842. EventBus.getDefault().post(new UpdateUserProvince());
  843. EventBus.getDefault().post(new MatchInfoChangeEvent());
  844. }
  845. }
  846. }
  847. }
  848. });
  849. }
  850. @Override
  851. protected void doRegister() {
  852. super.doRegister();
  853. EventBus.getDefault().register(this);
  854. }
  855. @Override
  856. protected void unregister() {
  857. super.unregister();
  858. EventBus.getDefault().unregister(this);
  859. }
  860. @Subscribe
  861. public void onEvent(NoSeeMeEvent event) {
  862. mViewPager.setCurrentItem(TAB_INDEX_FATE, false);
  863. }
  864. @Subscribe
  865. public void onEvent(OpenMailFragmentEvent event) {
  866. mViewPager.setCurrentItem(TAB_INDEX_MAIL, false);
  867. }
  868. @Subscribe
  869. public void onEvent(HeadMsgEvent event) {
  870. mViewPager.setCurrentItem(TAB_INDEX_MAIL, false);
  871. }
  872. @Subscribe
  873. public void onEvent(BaseOpenMailFragmentEvent event) {
  874. mViewPager.setCurrentItem(TAB_INDEX_MAIL, false);
  875. }
  876. @Subscribe
  877. public void onEvent(RegistEvent event) {
  878. finish();
  879. }
  880. @Subscribe
  881. public void onEvent(UpdateMessageCountEvent event) {
  882. int unreadMsgCount = event.getUnreadMsgCount();
  883. /**有未读消息进行刷新**/
  884. // if(unreadMsgCount>currentUnreadMsgCount){
  885. // MessageFragment item = (MessageFragment)mainAdapter.getItem(2);
  886. // item.startFirstRefish();
  887. // }
  888. if (unreadMsgCount > 0) {
  889. mTvUnreadMsgCount.setVisibility(View.VISIBLE);
  890. mTvUnreadMsgCount.setText(String.valueOf(unreadMsgCount>99?99:unreadMsgCount));
  891. currentUnreadMsgCount=unreadMsgCount;
  892. } else {
  893. mTvUnreadMsgCount.setVisibility(View.GONE);
  894. }
  895. }
  896. @Subscribe
  897. public void onEvent(CloseMainActivityEvent event) {
  898. mTimerHandler.removeMessages(MSG_TYPE_HEAD_MSG);
  899. mTimerHandler.removeMessages(MSG_TYPE_HEAD_MSG_NEW);
  900. mTimerHandler.removeMessages(MSG_TYPE_RECOMMEND_USER);
  901. mTimerHandler.removeMessages(MSG_TYPE_HIDE_RECOMMEND_USER);
  902. finish();
  903. }
  904. private static class TimerHandler extends Handler {
  905. private WeakReference<MainActivity> mWeakReference;
  906. public TimerHandler(MainActivity mainActivity) {
  907. this.mWeakReference = new WeakReference<MainActivity>(mainActivity);
  908. }
  909. @Override
  910. public void handleMessage(Message msg) {
  911. final MainActivity mainActivity = mWeakReference.get();
  912. switch (msg.what) {
  913. case MSG_TYPE_LOAD_DATA:// 加载数据
  914. if (mainActivity != null) {
  915. mainActivity.loadData();
  916. }
  917. break;
  918. // case MSG_TYPE_HEAD_MSG:// 页眉刷新
  919. // if (mainActivity != null) {
  920. // mainActivity.getHeadMsg();
  921. // }
  922. // sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG, HEAD_MSG_REFRESH_PERIOD);
  923. // break;
  924. case MSG_TYPE_HEAD_MSG_NEW:// 新页眉刷新
  925. if (mainActivity != null) {
  926. mainActivity.getNewHeadMsg();
  927. }
  928. break;
  929. case MSG_TYPE_RECOMMEND_USER:// 推荐用户刷新
  930. int cycle = 0;
  931. if (mainActivity != null) {
  932. mainActivity.getRecommendUsr();
  933. cycle = mainActivity.cycle;
  934. }
  935. // sendEmptyMessageDelayed(MSG_TYPE_RECOMMEND_USER, cycle < 20 ? HEAD_MSG_REFRESH_PERIOD : cycle * 1000);
  936. break;
  937. case MSG_TYPE_SHOW_UNREAD_MSG:// 显示未读消息页眉
  938. // 先隐藏上一条
  939. if (mainActivity != null) {
  940. mainActivity.dismissWithAnim(mainActivity.mFlHeadMsgNew, mainActivity.mRlHeadMsgUnread);
  941. mainActivity.mFlHeadMsgNew.postDelayed(new Runnable() {
  942. @Override
  943. public void run() {
  944. // 如果存在下一条,则显示
  945. if (mainActivity.mNewHeadMsgNotice != null && mainActivity.mCurrDisplayItem < mainActivity.mNewHeadMsgNotice.getUnreadMsgBoxList().size() - 1) {
  946. mainActivity.mCurrDisplayItem++;
  947. mainActivity.setNewHeadMsg();
  948. } else {
  949. // 继续轮询
  950. sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  951. }
  952. }
  953. }, 500);
  954. }
  955. break;
  956. case MSG_TYPE_DISMISS_UNREAD_MSG:// 隐藏未读消息页眉
  957. if (mainActivity != null) {
  958. mainActivity.dismissWithAnim(mainActivity.mFlHeadMsgNew, mainActivity.mRlHeadMsgUnread);
  959. }
  960. break;
  961. case MSG_TYPE_HIDE_RECOMMEND_USER:// 隐藏推荐用户页眉
  962. // 隐藏上一条
  963. if (mainActivity != null) {
  964. mainActivity.dismissWithAnim(mainActivity.mLlRecommendUser, mainActivity.mLlRecommendUser);
  965. }
  966. sendEmptyMessageDelayed(MSG_TYPE_RECOMMEND_USER, HEAD_MSG_REFRESH_PERIOD);
  967. break;
  968. case MSG_TYPE_DISMISS_VISITOR:// 隐藏访客页眉
  969. if (mainActivity != null) {
  970. mainActivity.dismissWithAnim(mainActivity.mFlHeadMsgNew, mainActivity.mRlHeadMsgVisitor);
  971. }
  972. sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  973. break;
  974. }
  975. }
  976. }
  977. private static class MainAdapter extends FragmentPagerAdapter {
  978. private List<Fragment> fragments = new ArrayList<>();
  979. public MainAdapter(FragmentManager fm) {
  980. super(fm);
  981. fragments.add(new FateCardFragment());
  982. fragments.add(new SearchFragment());
  983. fragments.add(new MessageFragment());
  984. fragments.add(new NearbyFragment());
  985. fragments.add(new MeFragment());
  986. }
  987. @Override
  988. public Fragment getItem(int position) {
  989. return fragments.get(position);
  990. }
  991. @Override
  992. public int getCount() {
  993. return fragments.size();
  994. }
  995. }
  996. @Override
  997. protected void onStart() {
  998. super.onStart();
  999. isShake = true;
  1000. }
  1001. @Override
  1002. protected void onPause() {
  1003. super.onPause();
  1004. isShake = false;
  1005. }
  1006. @Override
  1007. protected void onRestart() {
  1008. super.onRestart();
  1009. isShake = true;
  1010. }
  1011. @Override
  1012. protected void onResume() {
  1013. super.onResume();
  1014. isShake = true;
  1015. }
  1016. // @Override
  1017. // protected void onStop() {
  1018. // super.onStop();
  1019. // isShake=false;
  1020. // }
  1021. /**
  1022. * 监听是否点击了home键将客户端推到后台
  1023. */
  1024. private BroadcastReceiver mHomeKeyEventReceiver = new BroadcastReceiver() {
  1025. String SYSTEM_REASON = "reason";
  1026. String SYSTEM_HOME_KEY = "homekey";
  1027. String SYSTEM_HOME_KEY_LONG = "recentapps";
  1028. @Override
  1029. public void onReceive(Context context, Intent intent) {
  1030. String action = intent.getAction();
  1031. if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
  1032. String reason = intent.getStringExtra(SYSTEM_REASON);
  1033. if (TextUtils.equals(reason, SYSTEM_HOME_KEY)) {
  1034. //表示按了home键,程序到了后台
  1035. isShake = false;
  1036. } else if (TextUtils.equals(reason, SYSTEM_HOME_KEY_LONG)) {
  1037. //表示长按home键,显示最近使用的程序列表
  1038. }
  1039. }
  1040. }
  1041. };
  1042. }
  1043. //
  1044. ///**
  1045. // * modified by zhangdroid on 2017-02-28
  1046. // */
  1047. //public class MainActivity extends BaseFragmentActivity {
  1048. // @BindView(R.id.viewPager)
  1049. // ScrollControlViewPager mViewPager;
  1050. // // 页眉
  1051. // @BindView(R.id.head_msg_container)
  1052. // RelativeLayout mRlHeadMsgContainer;
  1053. // @BindView(R.id.head_msg_content)
  1054. // TextView mTvHeadMsgContent;
  1055. // @BindView(R.id.head_msg_clear)
  1056. // ImageView mIvHeadMsgClear;
  1057. // // 新页眉
  1058. // @BindView(R.id.headMsg_container)
  1059. // FrameLayout mFlHeadMsgNew;
  1060. // @BindView(R.id.headMsg_unread)
  1061. // RelativeLayout mRlHeadMsgUnread;
  1062. // @BindView(R.id.headMsg_avatar)
  1063. // CircleImageView mIvHeadMsgAvatar;
  1064. // @BindView(R.id.headMsg_nickname)
  1065. // TextView mTvNickname;
  1066. // @BindView(R.id.headMsg_age)
  1067. // TextView mTvAge;
  1068. // @BindView(R.id.headMsg_height)
  1069. // TextView mTvHeight;
  1070. // @BindView(R.id.headMsg_content)
  1071. // TextView mTvMsgContent;
  1072. // @BindView(R.id.headMsg_check)
  1073. // TextView mTvMsgCheck;
  1074. // // 访客
  1075. // @BindView(R.id.headMsg_visitor)
  1076. // RelativeLayout mRlHeadMsgVisitor;
  1077. // @BindView(R.id.visitor_avatar)
  1078. // CircleImageView mIvVisitorAvatar;
  1079. // @BindView(R.id.visitor_content)
  1080. // TextView mTvVisitorContent;
  1081. // @BindView(R.id.visitor_ignore)
  1082. // TextView mTvVisitorIgnore;
  1083. // @BindView(R.id.visitor_look)
  1084. // TextView mTvVisitorLook;
  1085. // // 推荐用户
  1086. // @BindView(R.id.recommend_user_container)
  1087. // LinearLayout mLlRecommendUser;
  1088. // @BindView(R.id.recommend_user_avatar)
  1089. // CircleImageView mIvRecommendAvatar;
  1090. // @BindView(R.id.recommend_user_content)
  1091. // TextView mTvRecommendContent;
  1092. // @BindView(R.id.recommend_user_ignore)
  1093. // TextView mTvRecommendIgnore;
  1094. // @BindView(R.id.recommend_user_look)
  1095. // TextView mTvRecommendLook;
  1096. // // tab页
  1097. // @BindView(R.id.main_tab_fate)
  1098. // TextView mTvTabFate;
  1099. // @BindView(R.id.main_tab_search)
  1100. // TextView mTvTabSearch;
  1101. // @BindView(R.id.main_tab_mail)
  1102. // TextView mTvTabMail;
  1103. // @BindView(R.id.unread_msg_count)
  1104. // TextView mTvUnreadMsgCount;// 未读消息数
  1105. // @BindView(R.id.main_tab_nearby)
  1106. // TextView mTvTabNearby;
  1107. // @BindView(R.id.main_tab_me)
  1108. // TextView mTvTabMe;
  1109. //
  1110. // private static final int TAB_INDEX_FATE = 0;
  1111. // private static final int TAB_INDEX_SEARCH = 1;
  1112. // private static final int TAB_INDEX_MAIL = 2;
  1113. // private static final int TAB_INDEX_NEARBY = 3;
  1114. // private static final int TAB_INDEX_ME = 4;
  1115. // private boolean isShake = true;
  1116. // private static final int HEAD_MSG_REFRESH_PERIOD = 20 * 1000;
  1117. // private static final int MSG_TYPE_LOAD_DATA = 1;
  1118. // private static final int MSG_TYPE_HEAD_MSG = 2;
  1119. // private static final int MSG_TYPE_HEAD_MSG_NEW = 3;
  1120. // private static final int MSG_TYPE_RECOMMEND_USER = 4;
  1121. // private static final int MSG_TYPE_SHOW_UNRE…

Large files files are truncated, but you can click here to view the full file