Ejemplo n.º 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_send) {
      if (noSetDateAndTime()) {
        return true;
      }
      String timing = host.getDate() + " " + host.getTime();
      Date postDate = TimeUtils.stringToDate(timing, "yyyy/MM/dd HH:mm");
      Date currentDate = TimeUtils.stringToDate(TimeUtils.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
      if (postDate.before(currentDate)) {
        Toast.makeText(BaseInfoPostActivity.this, "发布已过期的无效时间,请重新选择时间", Toast.LENGTH_SHORT).show();
        return true;
      }

      if (mFragmentIndex == FragmentIndex.CARPOOL) {
        postCarpoolingInfo();
      } else if (mFragmentIndex == FragmentIndex.DATE) {
        postDateInfo();
      }
      return true;
    }
    return super.onOptionsItemSelected(item);
  }
Ejemplo n.º 2
0
 private boolean noSetDateAndTime() {
   if (TextUtils.isEmpty(host.getDate())) {
     Toast.makeText(BaseInfoPostActivity.this, "未设置日期", Toast.LENGTH_SHORT).show();
     return true;
   }
   if (TextUtils.isEmpty(host.getTime())) {
     Toast.makeText(BaseInfoPostActivity.this, "未设置时间", Toast.LENGTH_SHORT).show();
     return true;
   }
   return false;
 }
Ejemplo n.º 3
0
 private void initCommonInfo() {
   host.setName(SPUtils.getString(LoginActivity.INFOS[0]));
   host.setTel(SPUtils.getString(LoginActivity.INFOS[1]));
   host.setShortTel(SPUtils.getString(LoginActivity.INFOS[2]));
   host.setWechat(SPUtils.getString(LoginActivity.INFOS[3]));
   host.setImei(AppInfoUtils.getImei());
   host.setFlag("host");
   host.setUniquecode(AppInfoUtils.getUniqueCode());
 }