PageRenderTime 57ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/dateLoveInternational/src/main/java/com/datelove/online/International/activity/UserInfoDetailActivity.java

https://bitbucket.org/juzhiwiscom/datelove
Java | 1785 lines | 1354 code | 129 blank | 302 comment | 230 complexity | 5524d910bc35f1cc0d0ef46ed1fd8128 MD5 | raw file

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

  1. package com.datelove.online.International.activity;
  2. import android.app.Activity;
  3. import android.app.Dialog;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.graphics.Bitmap;
  9. import android.graphics.BitmapFactory;
  10. import android.graphics.Color;
  11. import android.os.AsyncTask;
  12. import android.os.Build;
  13. import android.os.Bundle;
  14. import android.os.Handler;
  15. import android.os.Message;
  16. import android.os.Vibrator;
  17. import android.support.design.widget.CollapsingToolbarLayout;
  18. import android.support.design.widget.FloatingActionButton;
  19. import android.support.v7.app.ActionBar;
  20. import android.support.v7.app.AppCompatActivity;
  21. import android.support.v7.widget.LinearLayoutManager;
  22. import android.support.v7.widget.Toolbar;
  23. import android.text.TextUtils;
  24. import android.util.Log;
  25. import android.view.Menu;
  26. import android.view.MenuItem;
  27. import android.view.View;
  28. import android.view.ViewTreeObserver;
  29. import android.view.WindowManager;
  30. import android.view.animation.Animation;
  31. import android.view.animation.AnimationUtils;
  32. import android.widget.AdapterView;
  33. import android.widget.Button;
  34. import android.widget.FrameLayout;
  35. import android.widget.ImageView;
  36. import android.widget.LinearLayout;
  37. import android.widget.RelativeLayout;
  38. import android.widget.TextView;
  39. import com.alibaba.fastjson.JSON;
  40. import com.alibaba.fastjson.JSONObject;
  41. import com.datelove.online.International.R;
  42. import com.datelove.online.International.bean.FateUser;
  43. import com.datelove.online.International.bean.HeadMsgNotice;
  44. import com.datelove.online.International.bean.Image;
  45. import com.datelove.online.International.bean.MsgBox;
  46. import com.datelove.online.International.bean.NewHeadMsgNotice;
  47. import com.datelove.online.International.bean.RecommendUser;
  48. import com.datelove.online.International.bean.SayHello;
  49. import com.datelove.online.International.bean.User;
  50. import com.datelove.online.International.bean.UserBase;
  51. import com.datelove.online.International.bean.UserDetail;
  52. import com.datelove.online.International.constant.CommonData;
  53. import com.datelove.online.International.constant.IConfigConstant;
  54. import com.datelove.online.International.constant.IUrlConstant;
  55. import com.datelove.online.International.dialog.ReportDialog;
  56. import com.datelove.online.International.event.HeadMsgEvent;
  57. import com.datelove.online.International.event.MessageChangedEvent;
  58. import com.datelove.online.International.event.SayHelloEvent;
  59. import com.datelove.online.International.event.UnlikeEvent;
  60. import com.datelove.online.International.event.UpdateCareEvent;
  61. import com.datelove.online.International.event.UpdateNextUser;
  62. import com.datelove.online.International.haoping.ActionSheetDialog;
  63. import com.datelove.online.International.haoping.OnOperItemClickL;
  64. import com.datelove.online.International.utils.Cheeses;
  65. import com.datelove.online.International.utils.CommonRequestUtil;
  66. import com.datelove.online.International.utils.FastBlurUtil;
  67. import com.datelove.online.International.utils.ParallaxListView;
  68. import com.datelove.online.International.utils.ParamsUtils;
  69. import com.datelove.online.International.utils.Utils;
  70. import com.datelove.online.International.xml.PlatformInfoXml;
  71. import com.datelove.online.International.xml.UserInfoXml;
  72. import com.library.adapter.recyclerview.CommonRecyclerViewAdapter;
  73. import com.library.adapter.recyclerview.RecyclerViewHolder;
  74. import com.library.imageloader.CircleTransformation;
  75. import com.library.imageloader.ImageLoader;
  76. import com.library.imageloader.ImageLoaderUtil;
  77. import com.library.utils.HeightUtils;
  78. import com.library.utils.LogUtil;
  79. import com.library.utils.SharedPreferenceUtil;
  80. import com.library.utils.ToastUtil;
  81. import com.library.utils.Util;
  82. import com.library.widgets.CircleImageView;
  83. import com.library.widgets.CollapsingTextView;
  84. import com.zhy.http.okhttp.OkHttpUtils;
  85. import com.zhy.http.okhttp.callback.Callback;
  86. import com.zhy.http.okhttp.callback.StringCallback;
  87. import org.greenrobot.eventbus.EventBus;
  88. import org.greenrobot.eventbus.Subscribe;
  89. import org.greenrobot.eventbus.ThreadMode;
  90. import java.io.IOException;
  91. import java.io.InputStream;
  92. import java.lang.ref.WeakReference;
  93. import java.net.HttpURLConnection;
  94. import java.net.MalformedURLException;
  95. import java.net.URL;
  96. import java.util.ArrayList;
  97. import java.util.HashMap;
  98. import java.util.List;
  99. import java.util.Map;
  100. import java.util.Random;
  101. import butterknife.BindView;
  102. import butterknife.ButterKnife;
  103. import butterknife.OnClick;
  104. import okhttp3.Call;
  105. import okhttp3.Response;
  106. /**
  107. * 用户详情页
  108. * Created by zhangdroid on 2016/10/22.
  109. */
  110. public class UserInfoDetailActivity extends AppCompatActivity {
  111. public static final String INTENT_KEY_UID = "intent_key_uId";
  112. public static final String INTENT_KEY_ISRECORD = "intent_key_isRecord";
  113. public static final String INTENT_KEY_SOURCETAG = "intent_key_sourceTag";
  114. /**
  115. * 缘分页面
  116. */
  117. public static final String SOURCE_FROM_FATE = "1";
  118. /**
  119. * 搜索页面
  120. */
  121. public static final String SOURCE_FROM_SEARCH = "2";
  122. /**
  123. * 聊天列表页面
  124. */
  125. public static final String SOURCE_FROM_CHAT_LIST = "3";
  126. /**
  127. * 聊天内容页面
  128. */
  129. public static final String SOURCE_FROM_CHAT_CONTENT = "4";
  130. /**
  131. * 附近页面
  132. */
  133. public static final String SOURCE_FROM_NEARBY = "5";
  134. /**
  135. * 谁看过我
  136. */
  137. public static final String SOURCE_FROM_SEEME = "6";
  138. /**
  139. * 关注
  140. */
  141. public static final String SOURCE_CARE = "7";
  142. /**
  143. * 頁眉
  144. */
  145. public static final String SOURCE_HEAD_MSG = "8";
  146. /**
  147. * 推荐用户
  148. */
  149. public static final String SOURCE_FROM_RECOMMEND_USER = "9";
  150. private static Integer bitmapNum;
  151. static List<Bitmap> getBitmapList = new ArrayList<Bitmap>();
  152. @BindView(R.id.userDetail_CollapsingToolbarLayout)
  153. CollapsingToolbarLayout mCollapsingToolbarLayout;
  154. @BindView(R.id.userDetail_toolbar)
  155. Toolbar mToolbar;
  156. // FAB 下一位用户
  157. @BindView(R.id.userDetail_fab_next)
  158. FloatingActionButton mFabNext;
  159. // 用户头像和照片墙
  160. @BindView(R.id.userDetail_avatar)
  161. ImageView mIvUserAvatar;
  162. @BindView(R.id.userDetail_pic_wall)
  163. ParallaxListView mPicRecyclerView;
  164. // 展示的基本信息
  165. @BindView(R.id.userDetail_base_info)
  166. TextView mTvBaseInfo;
  167. // 关注、打招呼和聊天
  168. @BindView(R.id.userDetail_un_like)
  169. Button mBtnFollow;
  170. @BindView(R.id.userDetail_sayHello)
  171. Button mBtnSayHello;
  172. @BindView(R.id.userDetail_chat)
  173. Button mBtnChat;
  174. // 内心独白
  175. @BindView(R.id.userDetail_monologue_ll)
  176. LinearLayout mLlMonologue;
  177. @BindView(R.id.userDetail_monologue)
  178. CollapsingTextView mMonologue;
  179. // 用户个人资料
  180. // 国家
  181. @BindView(R.id.userDetail_country_ll)
  182. LinearLayout mLlCountry;
  183. @BindView(R.id.userDetail_country)
  184. TextView mTvCountry;
  185. @BindView(R.id.userDetail_country_divider)
  186. View mCountryDivider;
  187. // 地区
  188. @BindView(R.id.userDetail_area_ll)
  189. LinearLayout mLlArea;
  190. @BindView(R.id.userDetail_area)
  191. TextView mTvArea;
  192. @BindView(R.id.userDetail_area_divider)
  193. View mAreaDivider;
  194. // 星座
  195. @BindView(R.id.userDetail_sign_ll)
  196. LinearLayout mLlSign;
  197. @BindView(R.id.userDetail_sign)
  198. TextView mTvSign;
  199. @BindView(R.id.userDetail_sign_divider)
  200. View mSignDivider;
  201. // 学历
  202. @BindView(R.id.userDetail_education_ll)
  203. LinearLayout mLlEducation;
  204. @BindView(R.id.userDetail_education)
  205. TextView mTvEducation;
  206. @BindView(R.id.userDetail_education_divider)
  207. View mEducationDivider;
  208. // 收入
  209. @BindView(R.id.userDetail_income_ll)
  210. LinearLayout mLlIncome;
  211. @BindView(R.id.userDetail_income)
  212. TextView mTvIncome;
  213. @BindView(R.id.userDetail_income_divider)
  214. View mIncomeDivider;
  215. // 职业
  216. @BindView(R.id.userDetail_occupation_ll)
  217. LinearLayout mLlOccupation;
  218. @BindView(R.id.userDetail_occupation)
  219. TextView mTvOccupation;
  220. @BindView(R.id.userDetail_occupation_divider)
  221. View mOccupationDivider;
  222. // 是否想要小孩
  223. @BindView(R.id.userDetail_wantBaby_ll)
  224. LinearLayout mLlWantBaby;
  225. @BindView(R.id.userDetail_wantBaby)
  226. TextView mTvWantBaby;
  227. @BindView(R.id.userDetail_want_baby_divider)
  228. View mWantBabyDivider;
  229. // 喜欢的运动
  230. @BindView(R.id.userDetail_sport_ll)
  231. LinearLayout mLlSport;
  232. @BindView(R.id.userDetail_sport)
  233. TextView mTvSport;
  234. @BindView(R.id.userDetail_sport_divider)
  235. View mSportDivider;
  236. // 喜欢的宠物
  237. @BindView(R.id.userDetail_pets_ll)
  238. LinearLayout mLlPets;
  239. @BindView(R.id.userDetail_pets)
  240. TextView mTvPets;
  241. @BindView(R.id.userDetail_pets_divider)
  242. View mPetsDivider;
  243. // 种族
  244. @BindView(R.id.userDetail_ethnicity_ll)
  245. LinearLayout mLlEthnicity;
  246. @BindView(R.id.userDetail_ethnicity)
  247. TextView mTvEthnicity;
  248. @BindView(R.id.userDetail_ethnicity_divider)
  249. View mEthnicityDivider;
  250. // 锻炼习惯
  251. @BindView(R.id.userDetail_exerciseHabits_ll)
  252. LinearLayout mLlExerciseHabits;
  253. @BindView(R.id.userDetail_exerciseHabits)
  254. TextView mTvExerciseHabits;
  255. @BindView(R.id.userDetail_exerciseHabits_divider)
  256. View mExerciseHabitsDivider;
  257. // 兴趣爱好
  258. @BindView(R.id.userDetail_hobby_ll)
  259. LinearLayout mLlHobby;
  260. @BindView(R.id.userDetail_hobby)
  261. TextView mTvHobby;
  262. @BindView(R.id.userDetail_hobby_divider)
  263. View mHobbyDivider;
  264. // 页眉
  265. @BindView(R.id.head_msg_container)
  266. RelativeLayout mRlHeadMsgContainer;
  267. @BindView(R.id.head_msg_content)
  268. TextView mTvHeadMsgContent;
  269. @BindView(R.id.head_msg_clear)
  270. ImageView mIvHeadMsgClear;
  271. // 新页眉
  272. @BindView(R.id.headMsg_container)
  273. FrameLayout mFlHeadMsgNew;
  274. @BindView(R.id.headMsg_unread)
  275. RelativeLayout mRlHeadMsgUnread;
  276. @BindView(R.id.headMsg_avatar)
  277. CircleImageView mIvHeadMsgAvatar;
  278. @BindView(R.id.headMsg_nickname)
  279. TextView mTvNickname;
  280. @BindView(R.id.headMsg_age)
  281. TextView mTvAge;
  282. @BindView(R.id.headMsg_height)
  283. TextView mTvHeight;
  284. @BindView(R.id.headMsg_content)
  285. TextView mTvMsgContent;
  286. @BindView(R.id.headMsg_check)
  287. TextView mTvMsgCheck;
  288. // 访客
  289. @BindView(R.id.headMsg_visitor)
  290. RelativeLayout mRlHeadMsgVisitor;
  291. @BindView(R.id.visitor_avatar)
  292. CircleImageView mIvVisitorAvatar;
  293. @BindView(R.id.visitor_content)
  294. TextView mTvVisitorContent;
  295. @BindView(R.id.visitor_ignore)
  296. TextView mTvVisitorIgnore;
  297. @BindView(R.id.visitor_look)
  298. TextView mTvVisitorLook;
  299. // 推荐用户
  300. @BindView(R.id.recommend_user_container)
  301. LinearLayout mLlRecommendUser;
  302. @BindView(R.id.recommend_user_avatar)
  303. CircleImageView mIvRecommendAvatar;
  304. @BindView(R.id.recommend_user_content)
  305. TextView mTvRecommendContent;
  306. @BindView(R.id.recommend_user_ignore)
  307. TextView mTvRecommendIgnore;
  308. @BindView(R.id.recommend_user_look)
  309. TextView mTvRecommendLook;
  310. // @BindView(R.id.iv_loading_heart)
  311. // ImageView ivLoadingHeart;
  312. @BindView(R.id.fl_loading)
  313. FloatingActionButton flLoading;
  314. // @BindView(R.id.tv_loading)
  315. // TextView tvLoading;
  316. @BindView(R.id.tv_introduce)
  317. TextView tvIntroduce;
  318. @BindView(R.id.rl_introduce)
  319. RelativeLayout rlIntroduce;
  320. @BindView(R.id.fl_bottom)
  321. FrameLayout mFlBootm;
  322. private String isRecord;
  323. private String sourceTag;
  324. private String uId;
  325. private String nickname;
  326. private String avatarUrl;
  327. private String country;
  328. /**
  329. * 进度加载对话框
  330. */
  331. private Dialog mLoadingDialog;
  332. private ImageWallAdapter mImageWallAdapter;
  333. private int mIsFollow=0;
  334. private int mIsSayHello=0;
  335. private int pageNum = 0;
  336. private final String pageSize = "1";
  337. private static final int HEAD_MSG_REFRESH_PERIOD = 20 * 1000;
  338. private static final int MSG_TYPE_LOAD_DATA = 1;
  339. private static final int MSG_TYPE_HEAD_MSG = 2;
  340. private static final int MSG_TYPE_HEAD_MSG_NEW = 3;
  341. private static final int MSG_TYPE_RECOMMEND_USER = 4;
  342. private static final int MSG_TYPE_SHOW_UNREAD_MSG = 5;
  343. private static final int MSG_TYPE_DISMISS_UNREAD_MSG = 6;
  344. private static final int MSG_TYPE_DISMISS_VISITOR = 7;
  345. private static final int MSG_TYPE_HIDE_RECOMMEND_USER = 8;
  346. private boolean mReceiverTag = false; //广播接受者标识
  347. /**
  348. * 页眉对象缓存
  349. */
  350. private HeadMsgNotice mHeadMsgNotice;
  351. /**
  352. * 新页眉对象缓存
  353. */
  354. private NewHeadMsgNotice mNewHeadMsgNotice;
  355. /**
  356. * 推荐用户对象缓存
  357. */
  358. private RecommendUser mRecommendUser;
  359. /**
  360. * 新页眉最后一条未读消息毫秒数
  361. */
  362. private long mLastMsgTime;
  363. /**
  364. * 推荐用户轮询周期(秒)
  365. */
  366. private int cycle;
  367. /**
  368. * 新页眉中当前正在显示的未读消息索引
  369. */
  370. private int mCurrDisplayItem = 0;
  371. private TimerHandler mTimerHandler;
  372. private Vibrator vibrator;
  373. boolean isShake = true;
  374. //用来判断是否第一次进入此类,如果是,就使用通过eventBus传过来的mCurrDisplayItem值
  375. private int count;
  376. private boolean isIntercept;
  377. private String getCountry=PlatformInfoXml.getPlatformInfo().getCountry().trim();
  378. private int isBlack=0;
  379. private User newUser;
  380. private class TimerHandler extends Handler {
  381. private WeakReference<UserInfoDetailActivity> mWeakReference;
  382. public TimerHandler(UserInfoDetailActivity userInfoDetailActivity) {
  383. this.mWeakReference = new WeakReference<UserInfoDetailActivity>(userInfoDetailActivity);
  384. }
  385. @Override
  386. public void handleMessage(Message msg) {
  387. if (null == this) { //走到了onDestory,则不再进行后续消息处理
  388. return;
  389. }
  390. if (UserInfoDetailActivity.this.isFinishing()) { //Activity正在停止,则不再后续处理
  391. return;
  392. }
  393. final UserInfoDetailActivity userInfoDetailActivity = mWeakReference.get();
  394. switch (msg.what) {
  395. case MSG_TYPE_LOAD_DATA:// 加载数据
  396. if (userInfoDetailActivity != null) {
  397. userInfoDetailActivity.loadData();
  398. }
  399. break;
  400. case MSG_TYPE_HEAD_MSG:// 页眉刷新
  401. // if (userInfoDetailActivity != null) {
  402. // userInfoDetailActivity.getHeadMsg();
  403. // }
  404. // sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG, HEAD_MSG_REFRESH_PERIOD);
  405. break;
  406. case MSG_TYPE_HEAD_MSG_NEW:// 新页眉刷新
  407. if (userInfoDetailActivity != null) {
  408. userInfoDetailActivity.getNewHeadMsg();
  409. }
  410. break;
  411. case MSG_TYPE_RECOMMEND_USER:// 推荐用户刷新
  412. int cycle = 0;
  413. if (userInfoDetailActivity != null) {
  414. userInfoDetailActivity.getRecommendUsr();
  415. cycle = userInfoDetailActivity.cycle;
  416. }
  417. // sendEmptyMessageDelayed(MSG_TYPE_RECOMMEND_USER, cycle < 20 ? HEAD_MSG_REFRESH_PERIOD : cycle * 1000);
  418. break;
  419. case MSG_TYPE_SHOW_UNREAD_MSG:// 显示未读消息页眉
  420. // 先隐藏上一条
  421. if (userInfoDetailActivity != null) {
  422. userInfoDetailActivity.dismissWithAnim(userInfoDetailActivity.mFlHeadMsgNew, userInfoDetailActivity.mRlHeadMsgUnread);
  423. userInfoDetailActivity.mFlHeadMsgNew.postDelayed(new Runnable() {
  424. @Override
  425. public void run() {
  426. // 如果存在下一条,则显示
  427. if (userInfoDetailActivity.mNewHeadMsgNotice != null && userInfoDetailActivity.mCurrDisplayItem < userInfoDetailActivity.mNewHeadMsgNotice.getUnreadMsgBoxList().size() - 1) {
  428. userInfoDetailActivity.mCurrDisplayItem++;
  429. userInfoDetailActivity.setNewHeadMsg();
  430. } else {// 继续轮询
  431. sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  432. }
  433. }
  434. }, 500);
  435. }
  436. break;
  437. case MSG_TYPE_DISMISS_UNREAD_MSG:// 隐藏未读消息页眉
  438. if (userInfoDetailActivity != null) {
  439. userInfoDetailActivity.dismissWithAnim(userInfoDetailActivity.mFlHeadMsgNew, userInfoDetailActivity.mRlHeadMsgUnread);
  440. }
  441. break;
  442. case MSG_TYPE_HIDE_RECOMMEND_USER://隐藏推荐用户页眉
  443. if (userInfoDetailActivity != null) {
  444. userInfoDetailActivity.dismissWithAnim(userInfoDetailActivity.mLlRecommendUser, userInfoDetailActivity.mLlRecommendUser);
  445. }
  446. sendEmptyMessageDelayed(MSG_TYPE_RECOMMEND_USER, HEAD_MSG_REFRESH_PERIOD);
  447. break;
  448. case MSG_TYPE_DISMISS_VISITOR:// 隐藏访客页眉
  449. if (userInfoDetailActivity != null) {
  450. userInfoDetailActivity.dismissWithAnim(userInfoDetailActivity.mFlHeadMsgNew, userInfoDetailActivity.mRlHeadMsgVisitor);
  451. }
  452. sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  453. break;
  454. }
  455. }
  456. }
  457. public static void toUserInfoDetailActivity(Activity from, String uId, String isRecord, String sourceTag) {
  458. Map<String, String> map = new HashMap<String, String>();
  459. map.put(INTENT_KEY_UID, uId);
  460. map.put(INTENT_KEY_ISRECORD, TextUtils.isEmpty(isRecord) ? "0" : isRecord);
  461. map.put(INTENT_KEY_SOURCETAG, sourceTag);
  462. Util.gotoActivity(from, UserInfoDetailActivity.class, false, map);
  463. }
  464. @Override
  465. protected void onCreate(Bundle savedInstanceState) {
  466. super.onCreate(savedInstanceState);
  467. EventBus.getDefault().register(this);
  468. setContentView(R.layout.activity_user_info);
  469. ButterKnife.bind(this);
  470. // 透明状态栏
  471. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {// 5.0及以上
  472. View decorView = getWindow().getDecorView();
  473. decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
  474. // 设置状态栏背景
  475. getWindow().setStatusBarColor(Color.TRANSPARENT);
  476. } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {// 4.4
  477. getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  478. }
  479. setSupportActionBar(mToolbar);
  480. ActionBar actionBar = getSupportActionBar();
  481. if (actionBar != null) {
  482. actionBar.setDisplayShowHomeEnabled(true);
  483. }
  484. Intent intent = getIntent();
  485. if (intent != null) {
  486. uId = intent.getStringExtra(INTENT_KEY_UID);
  487. isRecord = intent.getStringExtra(INTENT_KEY_ISRECORD);
  488. sourceTag = intent.getStringExtra(INTENT_KEY_SOURCETAG);
  489. }
  490. // 初始化照片墙RecyclerView
  491. LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
  492. linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
  493. mPicRecyclerView.setLayoutManager(linearLayoutManager);
  494. mImageWallAdapter = new ImageWallAdapter(this, R.layout.item_pic_wall);
  495. mPicRecyclerView.setAdapter(mImageWallAdapter);
  496. // 已付费男用户和女用户显示聊天
  497. mBtnChat.setVisibility(View.GONE);
  498. if (UserInfoXml.isMale()) {
  499. if (UserInfoXml.isMonthly()) {
  500. mBtnFollow.setVisibility(View.GONE);
  501. mBtnSayHello.setVisibility(View.GONE);
  502. // mBtnChat.setVisibility(View.VISIBLE);
  503. } else {
  504. mBtnFollow.setVisibility(View.VISIBLE);
  505. mBtnSayHello.setVisibility(View.VISIBLE);
  506. // mBtnChat.setVisibility(View.GONE);
  507. }
  508. } else {
  509. mBtnFollow.setVisibility(View.GONE);
  510. mBtnSayHello.setVisibility(View.GONE);
  511. // mBtnChat.setVisibility(View.VISIBLE);
  512. }
  513. addListeners();
  514. // 加载用户详情
  515. showLoad();
  516. loadUserDetailInfo();
  517. // 延时加载数据
  518. mTimerHandler = new TimerHandler(this);
  519. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_LOAD_DATA, 1000 * 3);
  520. //注册广播
  521. // registerReceiver(mHomeKeyEventReceiver, new IntentFilter(
  522. // Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
  523. if (!mReceiverTag){ //在注册广播接受者的时候 判断是否已被注册,避免重复多次注册广播
  524. IntentFilter mFileter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
  525. mReceiverTag = true; //标识值 赋值为 true 表示广播已被注册
  526. this.registerReceiver(mHomeKeyEventReceiver, mFileter);
  527. }
  528. // 当布局完成之后才能获取到控件高度
  529. mIvUserAvatar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  530. @Override
  531. public void onGlobalLayout() {
  532. mIvUserAvatar.getViewTreeObserver().removeGlobalOnLayoutListener(this);
  533. System.out.println("MainActivity.onGlobalLayout,");
  534. mPicRecyclerView.setParallaxImageView(mIvUserAvatar);// 设置要被视差效果处理的控件
  535. }
  536. });
  537. /**加载读信拦截对话框**/
  538. isIntercept = SharedPreferenceUtil.getBooleanValue(Utils.getContext(), "INTERCEPT_DIALOG", "DIALOG", true);
  539. if (CommonData.getCountryList().contains(PlatformInfoXml.getCountry())) {
  540. getSelfIntroduce();
  541. }
  542. }
  543. /**
  544. * 加载页眉和推荐用户
  545. */
  546. private void loadData() {
  547. // 获取页眉
  548. // if (UserInfoXml.isShowHeadMsg()) {
  549. // getHeadMsg();
  550. // mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG, HEAD_MSG_REFRESH_PERIOD);
  551. // }
  552. // 获取新页眉
  553. if (UserInfoXml.isShowHeadMsgNew()) {
  554. getNewHeadMsg();
  555. }
  556. // 获取推荐用户
  557. if (UserInfoXml.isShowRecommendUser()) {
  558. getRecommendUsr();
  559. // mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_RECOMMEND_USER, HEAD_MSG_REFRESH_PERIOD);
  560. }
  561. }
  562. private void getHeadMsg() {
  563. CommonRequestUtil.getHeadMsg(new CommonRequestUtil.OnGetHeadMsgListener() {
  564. @Override
  565. public void onSuccess(HeadMsgNotice headMsgNotice) {
  566. if (headMsgNotice != null) {
  567. mHeadMsgNotice = headMsgNotice;
  568. String message = headMsgNotice.getMessage();
  569. if (!TextUtils.isEmpty(message)) {
  570. mRlHeadMsgContainer.setVisibility(View.VISIBLE);
  571. mTvHeadMsgContent.setText(message);
  572. } else {
  573. mRlHeadMsgContainer.setVisibility(View.GONE);
  574. }
  575. String noticeType = headMsgNotice.getNoticeType();
  576. if (!TextUtils.isEmpty(noticeType) && "1".equals(noticeType)) {
  577. // 有未读消息时刷新消息列表
  578. EventBus.getDefault().post(new MessageChangedEvent());
  579. }
  580. }
  581. }
  582. @Override
  583. public void onFail() {
  584. }
  585. });
  586. }
  587. /**
  588. * 获取新页眉
  589. */
  590. private void getNewHeadMsg() {
  591. String lastMsgTime = new SharedPreferenceUtil(UserInfoDetailActivity.this).takeLastTime();
  592. if (!TextUtils.isEmpty(lastMsgTime)) {
  593. mLastMsgTime = Long.parseLong(lastMsgTime);
  594. }
  595. CommonRequestUtil.getNewHeadMsg(mLastMsgTime, new CommonRequestUtil.OnGetNewHeadMsgListener() {
  596. @Override
  597. public void onSuccess(NewHeadMsgNotice newHeadMsgNotice) {
  598. if (newHeadMsgNotice != null) {
  599. mNewHeadMsgNotice = newHeadMsgNotice;
  600. mLastMsgTime = newHeadMsgNotice.getLastMsgTime();
  601. //将时间戳保存下来
  602. new SharedPreferenceUtil(UserInfoDetailActivity.this).saveLastTime(mLastMsgTime);
  603. // if(i!=0){
  604. mCurrDisplayItem = 0;
  605. // }
  606. // i++;
  607. String noticeType = newHeadMsgNotice.getNoticeType();
  608. if (!TextUtils.isEmpty(noticeType)) {
  609. switch (noticeType) {
  610. case "0":// 没有页眉,继续轮询
  611. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  612. break;
  613. case "1":// 未读消息
  614. // 刷新聊天列表
  615. EventBus.getDefault().post(new MessageChangedEvent());
  616. setNewHeadMsg();
  617. break;
  618. case "2":// 访客
  619. FateUser fateUser = newHeadMsgNotice.getRemoteYuanfenUserBase();
  620. if (fateUser != null) {
  621. UserBase userBase = fateUser.getUserBaseEnglish();
  622. if (userBase != null) {
  623. ImageLoaderUtil.getInstance().loadImage(UserInfoDetailActivity.this, new ImageLoader.Builder()
  624. .url(userBase.getImage().getThumbnailUrl()).imageView(mIvVisitorAvatar).build());
  625. mTvVisitorContent.setText(getString(R.string.visitor_tip, userBase.getNickName()));
  626. }
  627. }
  628. mRlHeadMsgUnread.setVisibility(View.GONE);
  629. mRlHeadMsgVisitor.setVisibility(View.VISIBLE);
  630. showWithAnim(mFlHeadMsgNew);
  631. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_DISMISS_VISITOR, newHeadMsgNotice.getDisplaySecond() * 1000);
  632. break;
  633. }
  634. }
  635. }
  636. }
  637. @Override
  638. public void onFail() {
  639. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HEAD_MSG_NEW, HEAD_MSG_REFRESH_PERIOD);
  640. }
  641. });
  642. }
  643. /**
  644. * 按照未读消息列表顺序显示未读信
  645. */
  646. private void setNewHeadMsg() {
  647. if (mNewHeadMsgNotice != null) {
  648. List<MsgBox> msgBoxList = mNewHeadMsgNotice.getUnreadMsgBoxList();
  649. if (!Util.isListEmpty(msgBoxList) && mCurrDisplayItem < msgBoxList.size()) {
  650. MsgBox msgBox = msgBoxList.get(mCurrDisplayItem);
  651. if (msgBox != null) {
  652. UserBase userBase = msgBox.getUserBaseEnglish();
  653. if (userBase != null) {
  654. Image image = userBase.getImage();
  655. if (image != null) {
  656. ImageLoaderUtil.getInstance().loadImage(UserInfoDetailActivity.this, new ImageLoader.Builder()
  657. .url(image.getThumbnailUrl()).imageView(mIvHeadMsgAvatar).build());
  658. }
  659. mTvNickname.setText(userBase.getNickName());
  660. mTvAge.setText(TextUtils.concat(String.valueOf(userBase.getAge())));
  661. mTvAge.setSelected(userBase.getSex() == 0);
  662. if (userBase.getSex() == 0) {
  663. mTvAge.setBackgroundResource(R.drawable.shape_round_rectangle_blue_bg);
  664. } else {
  665. mTvAge.setBackgroundResource(R.drawable.shape_notification_age_women);
  666. }
  667. mTvHeight.setText(HeightUtils.getInchCmByCm(userBase.getHeightCm()));
  668. }
  669. String msgContent = msgBox.getMsg();
  670. if (!TextUtils.isEmpty(msgContent)) {
  671. // mTvMsgContent.setText(msgContent);
  672. mTvMsgContent.setText(getString(R.string.get_msg));
  673. }
  674. mRlHeadMsgUnread.setVisibility(View.VISIBLE);
  675. mRlHeadMsgVisitor.setVisibility(View.GONE);
  676. showWithAnim(mFlHeadMsgNew);
  677. }
  678. // 一段时间后显示下一条未读消息
  679. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_SHOW_UNREAD_MSG, mNewHeadMsgNotice.getDisplaySecond() * 1000);
  680. }
  681. }
  682. }
  683. private void showWithAnim(View view) {
  684. if (isShake) {
  685. view.setVisibility(View.VISIBLE);
  686. vibrator = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
  687. vibrator.vibrate(200);
  688. view.startAnimation(AnimationUtils.loadAnimation(UserInfoDetailActivity.this, R.anim.anim_in));
  689. }
  690. }
  691. private void dismissWithAnim(final View view, final View view2) {
  692. Animation outAnimation = AnimationUtils.loadAnimation(UserInfoDetailActivity.this, R.anim.anim_out);
  693. view.startAnimation(outAnimation);
  694. outAnimation.setAnimationListener(new Animation.AnimationListener() {
  695. @Override
  696. public void onAnimationStart(Animation animation) {
  697. }
  698. @Override
  699. public void onAnimationEnd(Animation animation) {
  700. view.setVisibility(View.GONE);
  701. view2.setVisibility(View.GONE);
  702. }
  703. @Override
  704. public void onAnimationRepeat(Animation animation) {
  705. }
  706. });
  707. }
  708. /**
  709. * 获取推荐用户
  710. */
  711. private void getRecommendUsr() {
  712. CommonRequestUtil.getRecommendUser(cycle, new CommonRequestUtil.OnGetRecommendUserListener() {
  713. @Override
  714. public void onSuccess(RecommendUser recommendUser) {
  715. if (recommendUser != null) {
  716. mRecommendUser = recommendUser;
  717. cycle = recommendUser.getCycle();
  718. User user = recommendUser.getUser();
  719. if (user != null) {
  720. UserBase userBase = user.getUserBaseEnglish();
  721. if (userBase != null) {
  722. // 显示推荐用户
  723. mLlRecommendUser.setVisibility(View.VISIBLE);
  724. mTvRecommendContent.setText(TextUtils.concat(userBase.getNickName(), " ", recommendUser.getSentence()));
  725. ImageLoaderUtil.getInstance().loadImage(UserInfoDetailActivity.this, new ImageLoader.Builder()
  726. .url(userBase.getImage().getThumbnailUrl()).imageView(mIvRecommendAvatar).build());
  727. showWithAnim(mLlRecommendUser);
  728. }
  729. }
  730. }
  731. // 一段时间后隐藏推荐用户
  732. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HIDE_RECOMMEND_USER, 5 * 1000);
  733. }
  734. @Override
  735. public void onFail() {
  736. // 一段时间后隐藏推荐用户
  737. mTimerHandler.sendEmptyMessageDelayed(MSG_TYPE_HIDE_RECOMMEND_USER, 5 * 1000);
  738. }
  739. });
  740. }
  741. @Override
  742. public boolean onCreateOptionsMenu(Menu menu) {
  743. getMenuInflater().inflate(R.menu.menu_tool_bar, menu);
  744. return true;
  745. }
  746. @Override
  747. public boolean onOptionsItemSelected(MenuItem item) {
  748. switch (item.getItemId()) {
  749. case R.id.menu_report:// 举报
  750. actionSheetDialogNoTitle();
  751. // ReportDialog.newInstance(getString(R.string.report_title) + nickname, uId).show(getSupportFragmentManager(), "report");
  752. break;
  753. }
  754. return super.onOptionsItemSelected(item);
  755. }
  756. private void addListeners() {
  757. // 左菜单点击事件处理
  758. mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
  759. @Override
  760. public void onClick(View v) {
  761. finish();
  762. }
  763. });
  764. // 点击查看图片大图
  765. // 延迟两秒钟显示,为了防止在mainActivity中多次快速点击时误入
  766. new Handler().postDelayed(new Runnable() {
  767. @Override
  768. public void run() {
  769. mIvUserAvatar.setOnClickListener(new View.OnClickListener() {
  770. @Override
  771. public void onClick(View v) {
  772. int size = getBitmapList.size();
  773. PictureBrowseActivity.toPictureBrowseActivity(UserInfoDetailActivity.this, 0, mImageWallAdapter.getAdapterData());
  774. }
  775. });
  776. }
  777. },2000);
  778. mImageWallAdapter.setOnItemClickListener(new CommonRecyclerViewAdapter.OnItemClickListener() {
  779. @Override
  780. public void onItemClick(View view, int position, RecyclerViewHolder viewHolder) {
  781. boolean interceptLock = SharedPreferenceUtil.getBooleanValue(Utils.getContext(), "INTERCEPT_DIALOG", "DIALOG", true);
  782. if (interceptLock && position!=0) {
  783. BuyServiceActivity.toBuyServiceActivity(UserInfoDetailActivity.this, BuyServiceActivity.INTENT_FROM_MONTH,
  784. IConfigConstant.PAY_TAG_FROM_DETAIL, IConfigConstant.PAY_WAY_MONTH);
  785. } else {
  786. PictureBrowseActivity.toPictureBrowseActivity(UserInfoDetailActivity.this, position, mImageWallAdapter.getAdapterData());
  787. }
  788. }
  789. });
  790. // 查看页眉消息
  791. mRlHeadMsgContainer.setOnClickListener(new View.OnClickListener() {
  792. @Override
  793. public void onClick(View v) {
  794. if (mHeadMsgNotice != null) {
  795. mRlHeadMsgContainer.setVisibility(View.GONE);
  796. String noticeType = mHeadMsgNotice.getNoticeType();
  797. if (!TextUtils.isEmpty(noticeType)) {
  798. switch (noticeType) {
  799. case "1": // 未读消息
  800. // 切换到聊天tab
  801. EventBus.getDefault().post(new HeadMsgEvent());
  802. new Handler().postDelayed(new Runnable() {
  803. @Override
  804. public void run() {
  805. finish();
  806. }
  807. }, 200);
  808. break;
  809. case "2":// 正在看我
  810. showLoad();
  811. uId = mHeadMsgNotice.getRemoteUserId();
  812. sourceTag = SOURCE_HEAD_MSG;
  813. loadUserDetailInfo();
  814. break;
  815. }
  816. }
  817. }
  818. }
  819. });
  820. mIvHeadMsgClear.setOnClickListener(new View.OnClickListener() {
  821. @Override
  822. public void onClick(View v) {
  823. mRlHeadMsgContainer.setVisibility(View.GONE);
  824. }
  825. });
  826. // 新页眉
  827. mRlHeadMsgUnread.setOnClickListener(new View.OnClickListener() {
  828. @Override
  829. public void onClick(View v) {
  830. // 查看未读消息,进入聊天页面
  831. mFlHeadMsgNew.setVisibility(View.GONE);
  832. if (mNewHeadMsgNotice != null && mCurrDisplayItem < mNewHeadMsgNotice.getUnreadMsgBoxList().size()) {
  833. List<MsgBox> msgBoxList = mNewHeadMsgNotice.getUnreadMsgBoxList();
  834. if (!Util.isListEmpty(msgBoxList)) {
  835. MsgBox msgBox = msgBoxList.get(mCurrDisplayItem);
  836. if (msgBox != null) {
  837. UserBase userBase = msgBox.getUserBaseEnglish();
  838. if (userBase != null) {
  839. ChatActivity.toChatActivity(UserInfoDetailActivity.this, userBase.getId(), userBase.getNickName(), userBase.getImage().getThumbnailUrl());
  840. finish();
  841. }
  842. }
  843. }
  844. }
  845. }
  846. });
  847. mTvVisitorLook.setOnClickListener(new View.OnClickListener() {
  848. @Override
  849. public void onClick(View v) {
  850. // 隐藏新页眉
  851. mRlHeadMsgVisitor.setVisibility(View.GONE);
  852. mFlHeadMsgNew.setVisibility(View.GONE);
  853. // 查看用户详情
  854. if (mNewHeadMsgNotice != null) {
  855. FateUser fateUser = mNewHeadMsgNotice.getRemoteYuanfenUserBase();
  856. if (fateUser != null) {
  857. UserBase userBase = fateUser.getUserBaseEnglish();
  858. if (userBase != null) {
  859. showLoad();
  860. uId = userBase.getId();
  861. sourceTag = SOURCE_HEAD_MSG;
  862. loadUserDetailInfo();
  863. }
  864. }
  865. }
  866. }
  867. });
  868. mTvVisitorIgnore.setOnClickListener(new View.OnClickListener() {
  869. @Override
  870. public void onClick(View v) {
  871. // 隐藏新页眉
  872. mRlHeadMsgVisitor.setVisibility(View.GONE);
  873. mFlHeadMsgNew.setVisibility(View.GONE);
  874. }
  875. });
  876. // 推荐用户
  877. mTvRecommendLook.setOnClickListener(new View.OnClickListener() {
  878. @Override
  879. public void onClick(View v) {
  880. if (mRecommendUser != null) {
  881. UserBase userBase = mRecommendUser.getUser().getUserBaseEnglish();
  882. if (userBase != null) {
  883. // 隐藏推荐用户
  884. mLlRecommendUser.setVisibility(View.GONE);
  885. Image image = userBase.getImage();
  886. if (UserInfoXml.isMale()) {
  887. if (UserInfoXml.isMonthly()) {// 已付费男用户进入聊天页
  888. ChatActivity.toChatActivity(UserInfoDetailActivity.this, userBase.getId(), userBase.getNickName(),
  889. image == null ? null : image.getThumbnailUrl());
  890. } else {// 未付费男用户,进入对方空间页
  891. showLoad();
  892. uId = userBase.getId();
  893. sourceTag = SOURCE_FROM_RECOMMEND_USER;
  894. loadUserDetailInfo();
  895. }
  896. } else {// 女用户进入聊天页
  897. ChatActivity.toChatActivity(UserInfoDetailActivity.this, userBase.getId(), userBase.getNickName(),
  898. image == null ? null : image.getThumbnailUrl());
  899. }
  900. }
  901. }
  902. }
  903. });
  904. mTvRecommendIgnore.setOnClickListener(new View.OnClickListener() {
  905. @Override
  906. public void onClick(View v) {
  907. // 隐藏推荐用户
  908. mLlRecommendUser.setVisibility(View.GONE);
  909. }
  910. });
  911. }
  912. /**
  913. * 显示加载对话框
  914. */
  915. // protected void showLoad() {
  916. // mLoadingDialog = Utils.showLoadDialog(this, true);
  917. // }
  918. private void showLoad() {
  919. // flLoading.setVisibility(View.GONE);
  920. // Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(UserInfoDetailActivity.this, R.anim.anim_show_loading);
  921. // flLoading.startAnimation(hyperspaceJumpAnimation);
  922. }
  923. /**
  924. * 隐藏加载对话框
  925. */
  926. // protected void dismissLoad() {
  927. // if (mLoadingDialog != null && mLoadingDialog.isShowing()) {
  928. // mLoadingDialog.dismiss();
  929. // }
  930. // }
  931. private void dismissLoad() {
  932. new Handler().postDelayed(new Runnable() {
  933. @Override
  934. public void run() {
  935. flLoading.setVisibility(View.GONE);
  936. // tvLoading.setVisibility(View.GONE);
  937. }
  938. }, 500);
  939. }
  940. @OnClick({R.id.userDetail_fab_next, R.id.userDetail_un_like, R.id.userDetail_sayHello, R.id.userDetail_chat})
  941. public void onClick(View view) {
  942. switch (view.getId()) {
  943. case R.id.userDetail_fab_next:// 下一位用户
  944. if(!(getCountry.equals(getString(R.string.united_states).trim()) || getCountry.equals("America"))){
  945. count++;
  946. if(count>=10 && isIntercept){
  947. // 弹出拦截对话框
  948. interceptDialog();
  949. }else {
  950. loadNextUser();
  951. }
  952. }else{
  953. loadNextUser();
  954. }
  955. /**加载读信拦截对话框**/
  956. isIntercept = SharedPreferenceUtil.getBooleanValue(Utils.getContext(), "INTERCEPT_DIALOG", "DIALOG", true);
  957. if (CommonData.getCountryList().contains(PlatformInfoXml.getCountry())) {
  958. getSelfIntroduce();
  959. }
  960. break;
  961. case R.id.userDetail_un_like:
  962. CommonRequestUtil.unLike(uId,new CommonRequestUtil.OnCommonListener() {
  963. @Override
  964. public void onSuccess() {
  965. }
  966. @Override
  967. public void onFail() {
  968. }
  969. });
  970. EventBus.getDefault().post(new UnlikeEvent());
  971. EventBus.getDefault().post(new UpdateNextUser(false));
  972. finish();
  973. // if (mIsFollow == 1) {// 取消关注
  974. // CommonRequestUtil.cancelFollow(uId, true, new CommonRequestUtil.OnCommonListener() {
  975. // @Override
  976. // public void onSuccess() {
  977. // mIsFollow = 0;
  978. // mBtnFollow.setSelected(false);
  979. // mBtnFollow.setText(getString(R.string.follow));
  980. //// 更新关注列表
  981. // EventBus.getDefault().post(new UpdateCareEvent());
  982. // }
  983. //
  984. // @Override
  985. // public void onFail() {
  986. //
  987. // }
  988. // });
  989. // } else {// 关注
  990. // CommonRequestUtil.follow(uId, true, new CommonRequestUtil.OnCommonListener() {
  991. // @Override
  992. // public void onSuccess() {
  993. // mIsFollow = 1;
  994. // mBtnFollow.setSelected(true);
  995. // mBtnFollow.setText(getString(R.string.cancel_follow));
  996. // EventBus.getDefault().post(new UpdateCareEvent());
  997. //
  998. // }
  999. //
  1000. // @Override
  1001. // public void onFail() {
  1002. //
  1003. // }
  1004. // });
  1005. // }
  1006. break;
  1007. case R.id.userDetail_sayHello:// 打招呼
  1008. if(mIsSayHello==1){
  1009. finish();
  1010. }else{
  1011. CommonRequestUtil.sayHello(this, uId, CommonRequestUtil.SAY_HELLO_TYPE_USER_INFO, true, new CommonRequestUtil.OnSayHelloListener() {
  1012. @Override
  1013. public void onSuccess(SayHello sayHello) {
  1014. if(sayHello.getIsSucceed().equals("1")){
  1015. ToastUtil.showShortToast(UserInfoDetailActivity.this, getString(R.string.sayHello_success));
  1016. // 发送事件,更新状态
  1017. EventBus.getDefault().post(new SayHelloEvent());
  1018. EventBus.getDefault().post(new UpdateNextUser(true));
  1019. }
  1020. mIsSayHello = 1;
  1021. mBtnSayHello.setSelected(true);
  1022. finish();
  1023. }
  1024. @Override
  1025. public void onFail() {
  1026. finish();
  1027. }
  1028. });
  1029. }
  1030. break;
  1031. case R.id.userDetail_chat:// 聊天
  1032. ChatActivity.toChatActivity(this, uId, nickname, avatarUrl);
  1033. break;
  1034. }
  1035. }
  1036. /**
  1037. * 设置用户信息
  1038. */
  1039. private void setUserInfo(User user) {
  1040. if (user != null) {
  1041. UserBase userBase = user.getUserBaseEnglish();
  1042. if (userBase != null) {
  1043. // 更新ID
  1044. uId = userBase.getId();
  1045. // 设置用户名为标题
  1046. nickname = userBase.getNickName();
  1047. if (!TextUtils.isEmpty(nickname)) {
  1048. mCollapsingToolbarLayout.setTitle(nickname);
  1049. }
  1050. // 设置头像
  1051. Image image = userBase.getImage();
  1052. if (image != null) {
  1053. String imgUrl = image.getImageUrl();
  1054. if (!TextUtils.isEmpty(imgUrl)) {
  1055. ImageLoaderUtil.getInstance().loadImage(UserInfoDetailActivity.this, new ImageLoader.Builder()
  1056. .url(imgUrl).imageView(mIvUserAvatar).build());
  1057. } else {
  1058. mIvUserAvatar.setImageResource(IConfigConstant.COMMON_DEFAULT_AVATAR);
  1059. }
  1060. } else {
  1061. mIvUserAvatar.setImageResource(IConfigConstant.COMMON_DEFAULT_AVATAR);
  1062. }
  1063. // 设置年龄,身高,婚姻状况为展示基本信息
  1064. StringBuilder stringBuilder = new StringBuilder();
  1065. int age = userBase.getAge();
  1066. if (age < 18) {
  1067. age = 18;
  1068. }
  1069. stringBuilder.append(age);
  1070. // .append(getString(R.string.years));
  1071. String heightCm = userBase.getHeightCm();
  1072. if (!TextUtils.isEmpty(heightCm)) {
  1073. stringBuilder.append(" | ")
  1074. .append(HeightUtils.getInchCmByCm(heightCm));
  1075. }
  1076. if(ParamsUtils.getMarriageMap()!=null){
  1077. String marriage = ParamsUtils.getMarriageMap().get(String.valueOf(userBase.getMaritalStatus()));
  1078. if (!TextUtils.isEmpty(marriage)) {
  1079. if (!TextUtils.isEmpty(heightCm)) {
  1080. stringBuilder.append(" | ");
  1081. }
  1082. stringBuilder.append(marriage);
  1083. }
  1084. }
  1085. mTvBaseInfo.setText(stringBuilder.toString());
  1086. // 国家
  1087. country = userBase.getCountry();
  1088. if ("America".equals(country)) {
  1089. country = "United States";
  1090. }
  1091. if (country.contains(" ")) {
  1092. country = country.replaceAll(" ", "");
  1093. }
  1094. for(int i = 0; i< Cheeses.EN_GOUNTRY.length; i++){
  1095. if(country.equals(Cheeses.EN_GOUNTRY[i])){
  1096. country=Cheeses.EN_GOUNTRY[i];
  1097. }
  1098. }
  1099. setTextInfo(mLlCountry, mTvCountry, mCountryDivider, country);
  1100. // 内心独白
  1101. String monologue = userBase.getMonologue();
  1102. if (!TextUtils.isEmpty(monologue)) {
  1103. if (CommonData.getCountryList().contains(country) || CommonData.getSpanishCountryList().contains(country)) {
  1104. mMonologue.setText(monologue);
  1105. mLlMonologue.setVisibility(View.VISIBLE);
  1106. }else{
  1107. mLlMonologue.setVisibility(View.GONE);
  1108. }
  1109. } else {
  1110. mLlMonologue.setVisibility(View.GONE);
  1111. }
  1112. // 地区
  1113. setTextInfo(mLlArea, mTvArea, mAreaDivider, userBase.getArea().getProvinceName());
  1114. // 星座
  1115. setTextInfo(mLlSign, mTvSign, mSignDivider, ParamsUtils.getConstellationMap().get(String.valueOf(userBase.getSign())));
  1116. // 学历
  1117. // setTextInfo(mLlEducation, mTvEducation, mEducationDivider, ParamsUtils.getEducationMap().get(String.valueOf(userBase.getEducation())));
  1118. // 收入
  1119. setTextInfo(mLlIncome, mTvIncome, mIncomeDivider, ParamsUtils.getIncomeMap().get(String.valueOf(userBase.getIncome())));
  1120. // 职业
  1121. setTextInfo(mLlOccupation, mTvOccupation, mOccu

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