private void showLoginOut() { UmenAnalyticsUtility.onEvent(context, ConstantS.UMNEG_LOGIN_OUT); if (null != WyyApplication.getInfo()) { TagUtils.delTag(WyyApplication.getInfo().getId(), context); } delDataBase(); clearPreferences(); startActivity(new Intent(context, LoginActivity.class)); finshAll(); finish(); }
private void showModifySex() { int index = 0; try { index = Integer.valueOf(WyyApplication.getInfo().getGender()); } catch (Exception e) { // TODO: handle exception } if (index == 0) { index = 1; } else { index = 0; } ModifyDialog.modifySex(context, index); }
private void setSex() { switch (WyyApplication.getInfo().getGender()) { case ConstantS.MAN: userSex.setText(R.string.boy); break; case ConstantS.WOMAN: userSex.setText(R.string.gilr); break; default: break; } }
private void setSex() { switch (WyyApplication.getInfo().getGender()) { case ConstantS.MAN: Drawable drawable0 = getResources().getDrawable(R.drawable.sex_man); drawable0.setBounds(0, 0, drawable0.getMinimumWidth(), drawable0.getMinimumHeight()); userAge.setCompoundDrawables(drawable0, null, null, null); break; case ConstantS.WOMAN: Drawable drawable = getResources().getDrawable(R.drawable.sex_woman); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); userAge.setCompoundDrawables(drawable, null, null, null); break; default: break; } }
private void parseJson(JSONObject response) { BingLog.i(TAG, "×¢²á·µ»Ø:" + response); if (JsonUtils.isSuccess(response)) { JSONObject object; try { object = response.getJSONObject("user"); PersonalInfo info = JsonUtils.getInfo(object); if (null != info) { WyyApplication.setInfo(info); SavePersonInfoUtlis.setPersonInfo(info, context); startMainActivity(); } else { Toast.makeText(context, R.string.regeit_failure, Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(context, R.string.regeit_failure, Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(context, R.string.regeit_failure, Toast.LENGTH_SHORT).show(); } }
@Override public void initData() { // TODO Auto-generated method stub if (personalInfo == null) { personalInfo = WyyApplication.getInfo(); } if (personalInfo == null) { return; } userName.setText(personalInfo.getUsername()); userWeima.setText(personalInfo.getIdcode()); userCareer.setText(personalInfo.getJob()); userAge.setText(personalInfo.getAge()); userHeight.setText(personalInfo.getHeight() + "cm"); userWeight.setText(personalInfo.getWeight() + "kg"); userState.setText(personalInfo.getBodyindex()); userBmi.setText("" + PersonUtils.getBmi(personalInfo.getHeight(), personalInfo.getWeight())); userRemarks.setText(personalInfo.getSummary()); LoadImageUtils.loadImage4ImageV( userHeadImageView, HealthHttpClient.IMAGE_URL + personalInfo.getHeadimage()); setSex(); }
/** User: qii Date: 12-8-28 */ public class TimeUtility { private static int MILL_MIN = 1000 * 60; private static int MILL_HOUR = MILL_MIN * 60; private static int MILL_DAY = MILL_HOUR * 24; private static String JUST_NOW = WyyApplication.getInstance().getString(R.string.justnow); private static String MIN = WyyApplication.getInstance().getString(R.string.min); private static String HOUR = WyyApplication.getInstance().getString(R.string.hour); private static String DAY = WyyApplication.getInstance().getString(R.string.day); private static String MONTH = WyyApplication.getInstance().getString(R.string.month); private static String YEAR = WyyApplication.getInstance().getString(R.string.year); private static String YESTER_DAY = WyyApplication.getInstance().getString(R.string.yesterday); private static String THE_DAY_BEFORE_YESTER_DAY = WyyApplication.getInstance().getString(R.string.the_day_before_yesterday); private static String TODAY = WyyApplication.getInstance().getString(R.string.today); private static String DATE_FORMAT = WyyApplication.getInstance().getString(R.string.date_format); private static String YEAR_FORMAT = WyyApplication.getInstance().getString(R.string.year_format); private static Calendar msgCalendar = null; private static java.text.SimpleDateFormat dayFormat = null; private static java.text.SimpleDateFormat dateFormat = null; private static java.text.SimpleDateFormat yearFormat = null; private TimeUtility() {} public static String getListTime(ItemBean bean) { long msg = 0L; if (bean.getMills() != 0) { msg = bean.getMills(); } else { TimeUtility.dealMills(bean); msg = bean.getMills(); } return getListTime(msg); } public static String getListTime(String time) { long ltime = BingDateUtils.getTime(time); return getListTime(ltime); } public static int getday2now(String ltime) { BingLog.i("时间", "时间:" + ltime); long time = BingDateUtils.getTime(ltime); long now = System.currentTimeMillis(); long msg = time; long calcMills = now - msg; long calDay = calcMills / 1000 / 60 / 60 / 24; BingLog.i("时间", "时间:" + calDay); return (int) calDay; } public static String getListTime(long time) { long now = System.currentTimeMillis(); long msg = time; Calendar nowCalendar = Calendar.getInstance(); if (msgCalendar == null) msgCalendar = Calendar.getInstance(); msgCalendar.setTimeInMillis(time); long calcMills = now - msg; long calSeconds = calcMills / 1000; if (calSeconds < 60) { return JUST_NOW; } long calMins = calSeconds / 60; if (calMins < 60) { return new StringBuilder().append(calMins).append(MIN).toString(); } long calHours = calMins / 60; if (calHours < 24 && isSameDay(nowCalendar, msgCalendar)) { if (dayFormat == null) dayFormat = new java.text.SimpleDateFormat("HH:mm"); String result = dayFormat.format(msgCalendar.getTime()); return new StringBuilder().append(TODAY).append(" ").append(result).toString(); } long calDay = calHours / 24; if (calDay < 31) { if (isYesterDay(nowCalendar, msgCalendar)) { if (dayFormat == null) dayFormat = new java.text.SimpleDateFormat("HH:mm"); String result = dayFormat.format(msgCalendar.getTime()); return new StringBuilder(YESTER_DAY).append(" ").append(result).toString(); } else if (isTheDayBeforeYesterDay(nowCalendar, msgCalendar)) { if (dayFormat == null) dayFormat = new java.text.SimpleDateFormat("HH:mm"); String result = dayFormat.format(msgCalendar.getTime()); return new StringBuilder(THE_DAY_BEFORE_YESTER_DAY).append(" ").append(result).toString(); } else { if (dateFormat == null) dateFormat = new java.text.SimpleDateFormat(DATE_FORMAT); String result = dateFormat.format(msgCalendar.getTime()); return new StringBuilder(result).toString(); } } long calMonth = calDay / 31; if (calMonth < 12 && isSameYear(nowCalendar, msgCalendar)) { if (dateFormat == null) dateFormat = new java.text.SimpleDateFormat(DATE_FORMAT); String result = dateFormat.format(msgCalendar.getTime()); return new StringBuilder().append(result).toString(); } if (yearFormat == null) yearFormat = new java.text.SimpleDateFormat(YEAR_FORMAT); String result = yearFormat.format(msgCalendar.getTime()); return new StringBuilder().append(result).toString(); } private static boolean isSameHalfDay(Calendar now, Calendar msg) { int nowHour = now.get(Calendar.HOUR_OF_DAY); int msgHOur = msg.get(Calendar.HOUR_OF_DAY); if (nowHour <= 12 & msgHOur <= 12) { return true; } else if (nowHour >= 12 & msgHOur >= 12) { return true; } else { return false; } } private static boolean isSameDay(Calendar now, Calendar msg) { int nowDay = now.get(Calendar.DAY_OF_YEAR); int msgDay = msg.get(Calendar.DAY_OF_YEAR); return nowDay == msgDay; } private static boolean isYesterDay(Calendar now, Calendar msg) { int nowDay = now.get(Calendar.DAY_OF_YEAR); int msgDay = msg.get(Calendar.DAY_OF_YEAR); return (nowDay - msgDay) == 1; } private static boolean isTheDayBeforeYesterDay(Calendar now, Calendar msg) { int nowDay = now.get(Calendar.DAY_OF_YEAR); int msgDay = msg.get(Calendar.DAY_OF_YEAR); return (nowDay - msgDay) == 2; } private static boolean isSameYear(Calendar now, Calendar msg) { int nowYear = now.get(Calendar.YEAR); int msgYear = msg.get(Calendar.YEAR); return nowYear == msgYear; } public static void dealMills(ItemBean bean) { Date date = new Date(bean.getCreated_at()); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); bean.setMills(calendar.getTimeInMillis()); } }
private void reshInfo() { personalInfo = WyyApplication.getInfo(); initData(); }
private void initPersonInfo() { info = WyyApplication.getInfo(); // if (info == null) { // info = (PersonalInfo) getArguments().getSerializable("info"); // } if (info == null) { WelcomeActivity.getPersonInfo(getActivity()); info = WyyApplication.getInfo(); } if (info == null) { return; } userName.setText(WyyApplication.getInfo().getUsername() + ""); userAge.setText(WyyApplication.getInfo().getAge() + ""); userWeima.setText(WyyApplication.getInfo().getIdcode() + ""); userCareer.setText(WyyApplication.getInfo().getJob() + ""); userHeight.setText(WyyApplication.getInfo().getHeight() + "cm"); userWeight.setText(WyyApplication.getInfo().getWeight() + "kg"); userState.setText(WyyApplication.getInfo().getBodyindex() + ""); userBmi.setText( "" + PersonUtils.getBmi( WyyApplication.getInfo().getHeight(), WyyApplication.getInfo().getWeight())); userRemarks.setText(WyyApplication.getInfo().getSummary() + ""); money.setText(WyyApplication.getInfo().getMoney() + ""); getperBg(); setSex(); if (!TextUtils.isEmpty(info.getHeadimage())) { if (WyyApplication.getHeaderImaList().size() > 0) { for (int i = 0; i < WyyApplication.getHeaderImaList().size(); i++) { if (WyyApplication.getHeaderImaList() .get(i) .getImaname() .equals(WyyApplication.getInfo().getUsername())) { headBitmap = BitmapFactory.decodeFile(WyyApplication.getHeaderImaList().get(i).getImapath()); userHeadImageView.setImageBitmap(headBitmap); return; } } } if (null == headBitmap) { new Thread(loadImgRunnable).start(); } } }