Пример #1
0
 public static String toCharset(final String str, final String charset, int judgeCharsetLength) {
   try {
     String oldCharset = getEncoding(str, judgeCharsetLength);
     return new String(str.getBytes(oldCharset), charset);
   } catch (Throwable ex) {
     LogUtils.w(ex);
     return str;
   }
 }
Пример #2
0
 private int getSelectedCount() {
   int num = -1;
   if (mTodosListAdapter.getEditType() == TodosListAdapter.EDIT_TODOS) {
     num = mTodosListAdapter.getSeletedTodosNumber();
   } else if (mTodosListAdapter.getEditType() == TodosListAdapter.EDIT_DONES) {
     num = mTodosListAdapter.getSeletedDonesNumber();
   } else {
     LogUtils.w(
         TAG,
         "mTodosListAdapter.getEditType():+mTodosListAdapter.getEditType()"
             + ",may be has error.");
   }
   return num;
 }
  /**
   * {@link AsyncTask#execute(Object...)}は,API level 11以降ではシリアルに実行されます.<br>
   * (複数個登録した場合,1つ終わらないと次が開始されない)<br>
   * このメソッドを介して呼んだ場合,パラレルに実行されます.<br>
   *
   * @param task
   * @param params
   * @see <a href="http://daichan4649.hatenablog.jp/entry/20120125/1327467103">参考ページ</a>
   */
  @SuppressLint("NewApi")
  public static <T> void executeTask(AsyncTask<T, ?, ?> task, T... params) {
    try {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
      } else {
        task.execute(params);
      }

    } catch (RejectedExecutionException e) {
      LogUtils.d("Pool is full. Retrying...");
      executeTask(task, params);
    } catch (IllegalStateException e) {
      LogUtils.w("This Task may be already runnning. " + e.toString());
    }
  }