Пример #1
0
 /** 更新显示界面 */
 private void updateView() {
   try {
     String teachDate = null;
     String week = null;
     tvName.setText(studentBean.getChild().getName());
     if (currentCourse != null) {
       String strBT = currentCourse.getTeachTime().get(0).get("beginTime");
       String strET = currentCourse.getTeachTime().get(0).get("endTime");
       week = currentCourse.getTeachTime().get(0).get("week");
       tvToTime.setText(strET.substring(0, strET.lastIndexOf(":")));
       tvFromTime.setText(strBT.substring(0, strBT.lastIndexOf(":")));
       teachDate = currentCourse.getTeachDate();
       tvClassName.setText(currentCourse.getName());
     } else {
       teachDate = DateUtil.datetimeToString(new Date(), "yyyy-MM-dd");
       week = DateUtil.datetimeToString(new Date(), "EEEE");
     }
     ToastUtil.log(TAG, teachDate + " " + week);
     tvClassInfo.setText(
         "今天 "
             + teachDate
                 .replace("-", ".")
                 .substring(teachDate.indexOf("-") + 1, teachDate.length())
             + " "
             + week);
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
 }
Пример #2
0
 @Override
 public View getView(final int position, View convertView, ViewGroup parent) {
   VH vh = null;
   try {
     if (convertView == null) {
       convertView = View.inflate(context, R.layout.adapter_view_index_last_info, null);
       vh = new VH();
       vh.tvName = (TextView) convertView.findViewById(R.id.index_last_info_tv_course_name);
       vh.tvDay = (TextView) convertView.findViewById(R.id.index_last_info_tv_day);
       vh.tvWeek = (TextView) convertView.findViewById(R.id.index_last_info_tv_week);
       vh.tvTime = (TextView) convertView.findViewById(R.id.index_last_info_tv_time);
       vh.ivCourseLogo =
           (ImageView) convertView.findViewById(R.id.index_last_info_iv_course_logo);
       convertView.setTag(vh);
     } else {
       vh = (VH) convertView.getTag();
     }
     final HMCourseBean bean = courseBeans.get(position);
     vh.update(bean);
     convertView.setOnClickListener(
         new OnClickListener() {
           @Override
           public void onClick(View v) {
             Bundle bundle = new Bundle();
             bundle.putString("courseId", bean.getId());
             bundle.putString("courseName", bean.getName());
             HMNavUtil.goToNewAct(context, HMCourseDetailAct.class, bundle);
           }
         });
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
   return convertView;
 }
Пример #3
0
 @Override
 public void setRequestSuc(String url, int statusCode, Header[] headers, JsonObject jo) {
   super.setRequestSuc(url, statusCode, headers, jo);
   try {
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
 }
 @Override
 public void setRequestNotSuc(String url, int statusCode, Header[] headers, JsonObject jo) {
   super.setRequestNotSuc(url, statusCode, headers, jo);
   ToastUtil.toastAlways(this, jo.getAsJsonPrimitive(HMApi.KEY_MSG).getAsString());
   if (url.equals(HMApiUser.CAPTCHA)) {
     setCaptchaAble();
   }
 }
Пример #5
0
 private void dealAdapterViews(ViewHolder holder, List<String> datas, int position) {
   String bean = datas.get(position);
   try {
     TextView tvName = holder.getViewById(R.id.chat_index_contacts_tv_name, TextView.class);
     tvName.setText(bean);
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
 }
 @Override
 public void setRequestErr(
     String url, int statusCode, Header[] headers, String str, Throwable throwable) {
   super.setRequestErr(url, statusCode, headers, str, throwable);
   ToastUtil.toastAlways(this, str);
   if (url.equals(HMApiUser.CAPTCHA)) {
     setCaptchaAble();
   }
 }
  /**
   * 获取验证码
   *
   * @param v
   */
  @OnClick(R.id.register_captcha_tv_get_captcha)
  public void onGetCaptcha(View v) {
    if (StringUtil.isEmpty(etPhone.getText().toString())) {
      ToastUtil.getInstance().showShortToast(this, "请输入手机号码");
      return;
    }
    if (!StringUtil.isMobileNumber(etPhone.getText().toString())) {
      ToastUtil.getInstance().showShortToast(this, "请输入正确的号码");
      return;
    }
    phone = etPhone.getText().toString();
    RequestParams params = new RequestParams();
    params.put("phone", phone);
    params.put("identity", HMApi.IDENTITY);
    HMApiUser.getInstance().postCaptcha(this, params);

    tvGetCaptcha.setClickable(false);
    timer = new Timer();
    timer.schedule(
        new TimerTask() {

          @Override
          public void run() {
            timeHandler.post(
                new Runnable() {

                  @Override
                  public void run() {
                    if (count > 0) {
                      tvGetCaptcha.setText("" + count);
                      count--;
                    } else {
                      setCaptchaAble();
                    }
                  }
                });
          }
        },
        0,
        1000);
  }
Пример #8
0
 public IndexLastInfoView(Context context, HMStudentBean studentBean) {
   super();
   this.context = context;
   this.studentBean = studentBean;
   try {
     view = View.inflate(context, R.layout.view_index_last_info, null);
     init();
     initListener();
     updateView();
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   try {
     long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
     DownloadManager downloadManager = FileManager.getDownloadManager(context);
     Uri uri = downloadManager.getUriForDownloadedFile(downloadId);
     FileManager.apkInstall(context, new File(uri.getPath()));
     PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0);
     FileManager.sendNotification(context, "学苗", "下载已完成", R.mipmap.logo, pi);
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
 }
Пример #10
0
 public OnPageChangeListener(ViewPager viewPager) {
   try {
     Field leftEdgeField = viewPager.getClass().getDeclaredField("mLeftEdge");
     Field rightEdgeField = viewPager.getClass().getDeclaredField("mRightEdge");
     if (leftEdgeField != null && rightEdgeField != null) {
       leftEdgeField.setAccessible(true);
       rightEdgeField.setAccessible(true);
       leftEdge = (EdgeEffectCompat) leftEdgeField.get(viewPager);
       rightEdge = (EdgeEffectCompat) rightEdgeField.get(viewPager);
     }
   } catch (Exception e) {
     ToastUtil.printErr(e);
   }
 }
Пример #11
0
  private void init() {
    try {
      names = HMApiChat.getInstance().userList();
      adapter =
          new CommonAdapter<String>(getActivity(), names, R.layout.chat_adapter_index_contacts) {

            @Override
            public void dealViews(ViewHolder holder, List<String> datas, int position) {
              dealAdapterViews(holder, datas, position);
            }
          };
      lvSession.setAdapter(adapter);
    } catch (Exception e) {
      ToastUtil.printErr(e);
    }
  }
Пример #12
0
  /**
   * 提交验证码
   *
   * @param v
   */
  @OnClick(R.id.register_captcha_tv_submit)
  public void onRegister(View v) {
    String captcha = etCaptcha.getText().toString().trim();
    password = etPassword.getText().toString().trim();
    String psComfirm = etPasswordComfirm.getText().toString().trim();
    phone = etPhone.getText().toString().trim();

    if (StringUtil.isEmpty(etPhone.getText().toString())) {
      ToastUtil.getInstance().showShortToast(this, "请输入手机号码");
      return;
    }
    if (!StringUtil.isMobileNumber(etPhone.getText().toString())) {
      ToastUtil.getInstance().showShortToast(this, "请输入正确的号码");
      return;
    }
    if (StringUtil.isEmpty(captcha)) {
      ToastUtil.getInstance().showShortToast(this, "请输入验证码");
      return;
    }
    if (StringUtil.isEmpty(password)) {
      ToastUtil.getInstance().showShortToast(this, "请输入密码");
      return;
    }
    if (StringUtil.isEmpty(psComfirm)) {
      ToastUtil.getInstance().showShortToast(this, "请输入确认密码");
      return;
    }
    if (!password.matches(BaseConfig.PATTERN_PASSWORD)) {
      ToastUtil.toastAlways(this, "请输入正确的密码格式");
      return;
    }
    if (!password.equals(psComfirm)) {
      ToastUtil.getInstance().showShortToast(this, "密码不一致");
      return;
    }
    showLoading();
    RequestParams params = new RequestParams();
    params.put("phone", phone);
    params.put("password", password);
    params.put("code", captcha);
    params.put("identity", HMApi.IDENTITY);
    HMApiUser.getInstance().postRegister(this, params);
  }
Пример #13
0
 @Override
 public void setRequestNotSuc(String url, int statusCode, Header[] headers, JsonObject jo) {
   super.setRequestNotSuc(url, statusCode, headers, jo);
   ToastUtil.toastAlways(getActivity(), jo.getAsJsonPrimitive(HMApi.KEY_MSG).getAsString());
 }
Пример #14
0
 @Override
 public void setRequestErr(
     String url, int statusCode, Header[] headers, String str, Throwable throwable) {
   super.setRequestErr(url, statusCode, headers, str, throwable);
   ToastUtil.toastAlways(getActivity(), str);
 }