Exemplo n.º 1
0
  @Override
  public void onPostDone(int mode, int status, String message, PostBean postBean) {
    if (status == Constants.STATUS_SUCCESS) {
      if (postProgressDialog != null) {
        postProgressDialog.dismiss(message);
      } else {
        Toast.makeText(mCtx, message, Toast.LENGTH_SHORT).show();
      }

      if (!mAuthorOnly) {
        if (mode != PostAsyncTask.MODE_EDIT_POST) mCurrentPage = mMaxPage;

        int floor = LAST_FLOOR;
        if (!TextUtils.isEmpty(postBean.getFloor()) && TextUtils.isDigitsOnly(postBean.getFloor()))
          floor = Integer.parseInt(postBean.getFloor());
        if (floor == LAST_FLOOR || floor > 0) mFloorOfPage = floor;

        mCache.remove(mCurrentPage);
        showOrLoadPage();
      }

    } else {
      if (postProgressDialog != null) {
        postProgressDialog.dismissError(message);
      } else {
        Toast.makeText(mCtx, message, Toast.LENGTH_LONG).show();
      }
    }
  }
Exemplo n.º 2
0
  // Check if the string can parse to a phone number
  public static boolean isValidNumber(String phoneNumber) {
    if (TextUtils.isEmpty(phoneNumber)) {
      return false;
    }

    return TextUtils.isDigitsOnly(phoneNumber);
  }
Exemplo n.º 3
0
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder = null;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.home_t9_list_item, parent, false);
      holder = new ViewHolder();
      holder.name = (TextView) convertView.findViewById(R.id.name);
      holder.pinyin = (TextView) convertView.findViewById(R.id.pinyin);
      holder.number = (TextView) convertView.findViewById(R.id.number);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.name.setText(list.get(position).getDisplayName());
    String formattedNumber = list.get(position).getPinyin();

    if (null == filterNum || "".equals(filterNum)) {
      //			holder.pinyin.setVisibility(View.INVISIBLE);
      holder.number.setText(list.get(position).getPhoneNum());
    } else {
      //			holder.pinyin.setVisibility(View.VISIBLE);
      holder.number.setText(
          Html.fromHtml(
              list.get(position)
                  .getPhoneNum()
                  .replace(filterNum, "<font color='#cc0000'>" + filterNum + "</font>")));
      if (!TextUtils.isEmpty(filterNum)) {
        for (int i = 0; i < filterNum.length(); i++) {
          char c = filterNum.charAt(i);
          if (TextUtils.isDigitsOnly(String.valueOf(c))) {
            char[] zms = digit2Char(Integer.parseInt(c + ""));
            if (zms != null) {
              for (char c1 : zms) {
                formattedNumber =
                    formattedNumber.replaceAll(
                        String.valueOf(c1).toUpperCase(),
                        "%%" + String.valueOf(c1).toUpperCase() + "@@");
              }
              formattedNumber = formattedNumber.replaceAll("%%", "<font color='#cc0000'>");
              formattedNumber = formattedNumber.replaceAll("@@", "</font>");
            }
          }
        }
        // holder.pinyin.setText(Html.fromHtml(formattedNumber));
      }
    }

    convertView.setTag(holder);
    return convertView;
  }
 public void onRequestFinish(MApiRequest paramMApiRequest, MApiResponse paramMApiResponse)
 {
   if (paramMApiRequest == this.mGetHistoryReq)
   {
     this.mGetHistoryReq = null;
     paramMApiRequest = ((DPObject)paramMApiResponse.result()).getString("BookingUserMobile");
     if ((paramMApiRequest != null) && (paramMApiRequest.trim().length() > 0))
       this.phoneNumEdit.setText(paramMApiRequest);
   }
   do
     return;
   while (paramMApiRequest != this.mGetFuzzyRecommendInfoReq);
   if (this.gaExtra.shop_id == null)
   {
     if ((this.shopId == null) || ("null".equals(this.shopId)) || ("".equals(this.shopId)))
       break label302;
     if (!TextUtils.isDigitsOnly(this.shopId))
       break label288;
     this.gaExtra.shop_id = Integer.valueOf(this.shopId);
   }
   while (true)
   {
     GAHelper.instance().contextStatisticsEvent(getApplicationContext(), "submit_success", this.gaExtra, "tap");
     paramMApiRequest = (DPObject)paramMApiResponse.result();
     this.regions = paramMApiRequest.getStringArray("Regions");
     this.tables = paramMApiRequest.getStringArray("Tables");
     this.prices = paramMApiRequest.getStringArray("Prices");
     this.orderCount = paramMApiRequest.getInt("OrderCount");
     this.promoInfo = paramMApiRequest.getString("PromoInfo");
     this.regionList = paramMApiRequest.getArray("RegionList");
     this.categorys = paramMApiRequest.getStringArray("Categorys");
     this.categoryIdArray = paramMApiRequest.getIntArray("CategoryIds");
     paramMApiRequest = this.regionList;
     int j = paramMApiRequest.length;
     int i = 0;
     while (i < j)
     {
       paramMApiResponse = paramMApiRequest[i];
       this.regionsNames.add(paramMApiResponse.getString("Name"));
       i += 1;
     }
     label288: this.gaExtra.shop_id = Integer.valueOf(0);
     continue;
     label302: this.gaExtra.shop_id = Integer.valueOf(0);
   }
   setupView();
   sendHistoryRequest();
 }
Exemplo n.º 5
0
  public void onTakeEffectClick(View v) {
    String item = (String) effects.getSelectedItem();

    int animId = getResources().getIdentifier(item + "_example", "anim", getPackageName());
    Animation anim = AnimationUtils.loadAnimation(this, animId);
    anim = setInterpolator(anim);
    String durStr = duration.getText().toString();
    if (TextUtils.isDigitsOnly(durStr) && !durStr.isEmpty())
      anim.setDuration(Long.parseLong(durStr));
    Toast.makeText(
            this,
            "Effect: "
                + item
                + ", duration: "
                + durStr
                + ", interpolator: "
                + interpolators.getSelectedItem()
                + ", factory: "
                + factor.getText().toString(),
            Toast.LENGTH_LONG)
        .show();
    img.startAnimation(anim);
  }
Exemplo n.º 6
0
 @Test
 public void testIsDigitsOnly() throws Exception {
   assertThat(TextUtils.isDigitsOnly("123456"), equalTo(true));
   assertThat(TextUtils.isDigitsOnly("124a56"), equalTo(false));
 }
Exemplo n.º 7
0
    protected boolean isValidHelper(String s, String s1)
    {
_L2:
        return false;
        if (TextUtils.isEmpty(s) || TextUtils.isEmpty(s1) || !TextUtils.isDigitsOnly(s) || !TextUtils.isDigitsOnly(s1)) goto _L2; else goto _L1
Exemplo n.º 8
0
  @Override
  protected Void doInBackground(PostBean... postBeans) {

    PostBean postBean = postBeans[0];
    String replyText = postBean.getContent();
    String tid = postBean.getTid();
    String pid = postBean.getPid();
    String fid = postBean.getFid();
    String floor = postBean.getFloor();
    String subject = postBean.getSubject();
    String typeid = postBean.getTypeid();

    int count = 0;
    while (mInfo == null && count < 3) {
      count++;
      mInfo = new PrePostAsyncTask(mCtx, null, mMode).doInBackground(postBean);
    }

    if (!TextUtils.isEmpty(floor) && TextUtils.isDigitsOnly(floor)) mFloor = floor;

    mContent = replyText;

    if (mMode != MODE_EDIT_POST) {
      String tail_text = HiSettingsHelper.getInstance().getTailText();
      if (!tail_text.isEmpty() && HiSettingsHelper.getInstance().isAddTail()) {
        String tail_url = HiSettingsHelper.getInstance().getTailUrl();
        if (!tail_url.isEmpty()) {
          if ((!tail_url.startsWith("http")) && (!tail_url.startsWith("https"))) {
            tail_url = "http://" + tail_url;
          }
          replyText = replyText + "  [url=" + tail_url + "][size=1]" + tail_text + "[/size][/url]";
        } else {
          replyText = replyText + "  [size=1]" + tail_text + "[/size]";
        }
      }
    }

    String url = HiUtils.ReplyUrl + tid + "&replysubmit=yes";
    // do send
    switch (mMode) {
      case MODE_REPLY_THREAD:
      case MODE_QUICK_REPLY:
        doPost(url, replyText, null, null);
        break;
      case MODE_REPLY_POST:
      case MODE_QUOTE_POST:
        doPost(url, mInfo.getText() + "\n\n    " + replyText, null, null);
        break;
      case MODE_NEW_THREAD:
        url = HiUtils.NewThreadUrl + fid + "&typeid=" + typeid + "&topicsubmit=yes";
        doPost(url, replyText, subject, null);
        break;
      case MODE_EDIT_POST:
        url =
            HiUtils.EditUrl
                + "&extra=&editsubmit=yes&mod=&editsubmit=yes"
                + "&fid="
                + fid
                + "&tid="
                + tid
                + "&pid="
                + pid
                + "&page=1";
        doPost(url, replyText, subject, typeid);
        break;
    }

    return null;
  }
Exemplo n.º 9
0
  private void doPost(String url, String replyText, String subject, String typeid) {

    String formhash = mInfo != null ? mInfo.getFormhash() : null;

    if (TextUtils.isEmpty(formhash)) {
      mResult = "发表失败,无法获取必要信息 !";
      mStatus = Constants.STATUS_FAIL;
      return;
    }

    Map<String, String> post_param = new HashMap<>();
    post_param.put("formhash", formhash);
    post_param.put("posttime", String.valueOf(System.currentTimeMillis()));
    post_param.put("wysiwyg", "0");
    post_param.put("checkbox", "0");
    post_param.put("message", replyText);
    for (String attach : mInfo.getAttaches()) {
      post_param.put("attachnew[" + attach + "][description]", attach);
    }
    for (String attach : mInfo.getAttachdel()) {
      post_param.put("attachdel[" + attach + "]", attach);
    }
    for (String attach : mInfo.getUnusedImages()) {
      post_param.put("attachdel[" + attach + "]", attach);
    }
    if (mMode == MODE_NEW_THREAD) {
      post_param.put("subject", subject);
      post_param.put("attention_add", "1");
      mTitle = subject;
    } else if (mMode == MODE_EDIT_POST) {
      if (!TextUtils.isEmpty(subject)) {
        post_param.put("subject", subject);
        mTitle = subject;
        if (!TextUtils.isEmpty(typeid)) {
          post_param.put("typeid", typeid);
        }
      }
    }

    SimpleErrorListener errorListener = VolleyHelper.getInstance().getErrorListener();
    String rsp_str = VolleyHelper.getInstance().synchronousPost(url, post_param, errorListener);

    // when success, volley will follow 302 redirect get the page content
    if (!TextUtils.isEmpty(rsp_str)) {
      String tid = "";
      if (rsp_str.contains("tid = parseInt('")) {
        tid = HttpUtils.getMiddleString(rsp_str, "tid = parseInt('", "'");
      }
      if (!TextUtils.isEmpty(tid)
          && TextUtils.isDigitsOnly(tid)
          && Integer.parseInt(tid) > 0
          && !rsp_str.contains("alert_info")) {
        mTid = tid;
        mResult = "发表成功!";
        mStatus = Constants.STATUS_SUCCESS;
      } else {
        Logger.e(rsp_str);
        mResult = "发表失败! ";
        mStatus = Constants.STATUS_FAIL;

        Document doc = Jsoup.parse(rsp_str);
        Elements error = doc.select("div.alert_info");
        if (error != null && error.size() > 0) {
          mResult += error.text();
        } else {
          if (HiSettingsHelper.getInstance().isErrorReportMode())
            ACRAUtils.acraReport("Error when posting but with response", rsp_str);
        }
      }
    } else {
      Logger.e(errorListener.getError());

      mResult = "发表失败,无返回结果! " + errorListener.getErrorText();
      mStatus = Constants.STATUS_FAIL;

      if (HiSettingsHelper.getInstance().isErrorReportMode())
        ACRAUtils.acraReport(errorListener.getError(), "no response");
    }
  }
Exemplo n.º 10
0
  private boolean refreshAndVerifiyTarget(int mode) {
    String target;
    switch (mode) {
      case SEND_MODE_SMS:
        if (!refreshAndVerifiyText()) {
          return false;
        }
        if (ed_numbertosend == null) {
          return false;
        }
        target = ed_numbertosend.getText().toString();
        if (TextUtils.isEmpty(target)) {
          Toast.makeText(mActivity, mActivity.getString(R.string.enternumber), Toast.LENGTH_SHORT)
              .show();
          return false;
        }
        if (!TextUtils.isDigitsOnly(target)) {
          Toast.makeText(mActivity, mActivity.getString(R.string.numbersonly), Toast.LENGTH_SHORT)
              .show();
          return false;
        }

        numberToSend = target;
        return true;

      case SEND_MODE_DATASMS:
        if (!refreshAndVerifiyText()) {
          return false;
        }
        if (ed_numbertosend == null) {
          return false;
        }
        target = ed_numbertosend.getText().toString();
        if (TextUtils.isEmpty(target)) {
          Toast.makeText(mActivity, mActivity.getString(R.string.enternumber), Toast.LENGTH_SHORT)
              .show();
          return false;
        }
        if (!TextUtils.isDigitsOnly(target)) {
          Toast.makeText(mActivity, mActivity.getString(R.string.numbersonly), Toast.LENGTH_SHORT)
              .show();
          return false;
        }

        numberToSend = target;
        return true;

      case SEND_MODE_EMAIL:
        if (!refreshAndVerifiyText()) {
          return false;
        }
        if (ed_mailtosend == null) {
          return false;
        }
        target = ed_mailtosend.getText().toString();
        if (TextUtils.isEmpty(target) || !Utils.isTextEmailAddress(target)) {
          Toast.makeText(
                  mActivity, mActivity.getString(R.string.enteremailaddress), Toast.LENGTH_SHORT)
              .show();
          return false;
        }

        mailToSend = target;
        return true;

      default:
        break;
    }

    return false;
  }
Exemplo n.º 11
0
 /**
  * 校验整数
  *
  * @param text
  * @return
  */
 protected static boolean isNumeric(String text) {
   return TextUtils.isDigitsOnly(text);
 }
Exemplo n.º 12
0
  private void fetchSimpleList(int type) {
    String url = null;
    switch (type) {
      case TYPE_MYREPLY:
        url = HiUtils.MyReplyUrl + "&page=" + mPage;
        break;
      case TYPE_MYPOST:
        url = HiUtils.MyPostUrl + "&page=" + mPage;
        break;
      case TYPE_SMS:
        url = HiUtils.SMSUrl;
        break;
      case TYPE_THREADNOTIFY:
        url = HiUtils.ThreadNotifyUrl;
        break;
      case TYPE_SMSDETAIL:
        url = HiUtils.SMSDetailUrl + mExtra;
        break;
      case TYPE_SEARCH:
        try {
          String prefixsft = mCtx.getResources().getString(R.string.prefix_search_fulltext);
          if (mExtra.startsWith(prefixsft)) {
            url =
                HiUtils.SearchFullText
                    + URLEncoder.encode(mExtra.substring(prefixsft.length()), "GBK");
            if (mPage > 1) url += "&page=" + mPage;
          } else {
            url = HiUtils.SearchTitle + URLEncoder.encode(mExtra, "GBK");
            if (mPage > 1) url += "&page=" + mPage;
          }
        } catch (UnsupportedEncodingException e) {
          Logger.e("Encoding error", e);
        }
        break;
      case TYPE_SEARCH_USER_THREADS:
        if (TextUtils.isDigitsOnly(mExtra)) {
          // first search, use uid
          url = HiUtils.SearchUserThreads + mExtra + "&page=" + mPage;
        } else {
          // after first seach, searchId is generated
          url = HiUtils.BaseUrl + mExtra;
          // replace page number in url
          int pageIndex = url.indexOf("page=");
          int pageEndIndex = url.indexOf("&", pageIndex + "page=".length());
          if (pageIndex > 0 && pageEndIndex > pageIndex) {
            url = url.substring(0, pageIndex) + "page=" + mPage + url.substring(pageEndIndex);
          } else if (pageEndIndex == -1) {
            url = url.substring(0, pageIndex) + "page=" + mPage;
          }
        }
        break;
      case TYPE_FAVORITES:
        url = HiUtils.FavoritesUrl;
        if (mPage > 1) url += "&page=" + mPage;
        break;
      default:
        break;
    }

    StringRequest sReq =
        new HiStringRequest(url, new ThreadListListener(), new ThreadListErrorListener());
    VolleyHelper.getInstance().add(sReq);
  }
Exemplo n.º 13
0
 @Override
 public boolean test(String content) {
   return TextUtils.isDigitsOnly(content);
 }
Exemplo n.º 14
0
 /**
  * Validate item SKU in Nokia Store. Nokia store item's SKU can contain only digits.
  *
  * @param sku SKU for validate.
  * @throws org.onepf.oms.appstore.nokiaUtils.NokiaSkuFormatException If sku in wrong format for
  *     Nokia Store.
  */
 public static void checkSku(@NonNull String sku) {
   if (!TextUtils.isDigitsOnly(sku)) {
     throw new NokiaSkuFormatException();
   }
 }