/** * 读取 String数据 * * @param key * @return String 数据 */ public String getAsString(String key) { File file = mCache.get(key); if (!file.exists()) return null; boolean removeFile = false; BufferedReader in = null; try { in = new BufferedReader(new FileReader(file)); String readString = ""; String currentLine; while ((currentLine = in.readLine()) != null) { readString += currentLine; } LogUtils.e("boolean" + cacheUtils.isExpire(readString)); if (!cacheUtils.isExpire(readString)) { return cacheUtils.clearDateInfo(readString); } else { removeFile = true; return null; } } catch (IOException e) { e.printStackTrace(); LogUtils.e("文件错误" + e.toString()); return null; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } if (removeFile) remove(key); } }
public void addItem(List<MessageBean> list) { LogUtils.e("list.size = " + list.size()); if (this.list == null) { return; } this.list.addAll(list); LogUtils.e("list.size = " + this.list.size()); notifyDataSetChanged(); }
@Override public void onStopTrackingTouch(SeekBar seekBar) { if (methods.length < 3 || methods[2] == null) { LogUtils.w("onStopTrackingTouch not implement"); return; } try { methods[2].invoke(handler, seekBar); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onNothingSelected(AdapterView<?> parent) { if (methods.length < 2 || methods[1] == null) { LogUtils.w("onNothingSelected not implement"); return; } try { methods[1].invoke(handler, parent); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onScroll(AbsListView absListView, int i, int i2, int i3) { if (methods.length < 2 || methods[1] == null) { LogUtils.w("onScroll not implement"); return; } try { methods[1].invoke(handler, absListView, i, i2, i3); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public boolean onTouchEvent(MotionEvent event) { float y = event.getY(); clickIndex = (int) ((y - paddingTop) / itemHeight); switch (event.getAction()) { case MotionEvent.ACTION_UP: is_select = false; break; case MotionEvent.ACTION_DOWN: is_select = true; break; case MotionEvent.ACTION_SCROLL: is_select = true; break; } invalidate(); if (null != listener && clickIndex > -1) { try { listener.onDataChange(indexStr[clickIndex], is_select); } catch (ArrayIndexOutOfBoundsException e) { LogUtils.e(" array index out of bound error clickIndex =" + clickIndex); } } return true; }
/** Returns an HttpEntity containing all request parameters */ public HttpEntity getEntity() { if (bodyEntity != null) { return bodyEntity; } HttpEntity result = null; if (fileParams != null && !fileParams.isEmpty()) { MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.STRICT, boundary, Charset.forName(charset)); if (bodyParams != null && !bodyParams.isEmpty()) { for (NameValuePair param : bodyParams) { try { multipartEntity.addPart(param.getName(), new StringBody(param.getValue())); } catch (UnsupportedEncodingException e) { LogUtils.e(e.getMessage(), e); } } } for (ConcurrentHashMap.Entry<String, ContentBody> entry : fileParams.entrySet()) { multipartEntity.addPart(entry.getKey(), entry.getValue()); } result = multipartEntity; } else if (bodyParams != null && !bodyParams.isEmpty()) { result = new BodyParamsEntity(bodyParams, charset); } return result; }
@Override public boolean onLongClick(View v) { LogUtils.e("position = " + position); commonDialog.show(AnimType.centerScale); SingleChatAdapter.this.position = position; return true; }
@Override public void succeed(String name) { String city = name; LogUtils.i(city); String url = SHApi.WEATHER_URL + city; loadData( HttpMethod.GET, url, null, new RequestCallBack<String>() { @Override public void onSuccess(ResponseInfo<String> info) { LogUtils.i(info.result); WeatherInfo weatherInfo = WeatherParser.parser(info.result, WeatherInfo.class); ((MainActivity) ct).getMenuFragment().initWeatherInfo(weatherInfo); dialog.dismiss(); } @Override public void onFailure(HttpException arg0, String arg1) { showToast(ct.getResources().getString(R.string.networkno)); dialog.dismiss(); } }); }
@Override public void onPlayer(MediaStatus mediaStatus, int code, String message) { LogUtils.e("mediaStatus = " + mediaStatus + " code = " + code + " message = " + message); if ((MediaStatus.playComplete == mediaStatus) && (playerAnim != null)) { playerAnim.stop(); } }
private static synchronized DbUtils getInstance(DaoConfig daoConfig) { DbUtils dao = daoMap.get(daoConfig.getDbName()); if (dao == null) { dao = new DbUtils(daoConfig); daoMap.put(daoConfig.getDbName(), dao); } else { dao.daoConfig = daoConfig; } // update the database if needed SQLiteDatabase database = dao.database; int oldVersion = database.getVersion(); int newVersion = daoConfig.getDbVersion(); if (oldVersion != newVersion) { if (oldVersion != 0) { DbUpgradeListener upgradeListener = daoConfig.getDbUpgradeListener(); if (upgradeListener != null) { upgradeListener.onUpgrade(dao, oldVersion, newVersion); } else { try { dao.dropDb(); } catch (DbException e) { LogUtils.e(e.getMessage(), e); } } } database.setVersion(newVersion); } return dao; }
public void handleMessage(Message msg) { if (msg.what == 1) { LogUtils.i("go thread..."); } super.handleMessage(msg); }
protected void loadData( HttpRequest.HttpMethod method, String url, RequestParams params, RequestCallBack<String> callback) { HttpUtils http = new HttpUtils(); http.configCurrentHttpCacheExpiry(1000 * 1); LogUtils.allowD = true; if (params != null) { if (params.getQueryStringParams() != null) LogUtils.d(url + params.getQueryStringParams().toString()); } else { params = new RequestParams(); } // 设备ID // params.addHeader("x-deviceid", app.deviceId); // 渠道,统计用 // params.addHeader("x-channel", app.channel); if (0 == CommonUtil.isNetworkAvailable(ct)) { showToast("无网络,请检查网络连接!"); http.send(method, url, params, callback); } else { http.send(method, url, params, callback); } }
@Override public void onFocusChange(View view, boolean b) { try { methods[0].invoke(handler, view, b); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { try { methods[0].invoke(handler, buttonView, isChecked); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onStopTrackingTouch(SeekBar seekBar) { try { methods[2].invoke(handler, seekBar); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
// #region SeekBar.OnSeekBarChangeListener @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { try { methods[0].invoke(handler, seekBar, progress, fromUser); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onNothingSelected(AdapterView<?> parent) { try { methods[1].invoke(handler, parent); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onScroll(AbsListView absListView, int i, int i2, int i3) { try { methods[1].invoke(handler, absListView, i, i2, i3); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
// #region AbsListView.OnScrollListener @Override public void onScrollStateChanged(AbsListView absListView, int i) { try { methods[0].invoke(handler, absListView, i); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onScrollChanged() { try { methods[0].invoke(handler); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onTabChanged(String tabId) { try { methods[0].invoke(handler, tabId); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onGroupExpand(int i) { try { methods[0].invoke(handler, i); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onClick(View v) { try { methods[0].invoke(handler, v); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
// #region OnItemSelectedListener @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { try { methods[0].invoke(handler, parent, view, position, id); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { try { methods[0].invoke(handler, group, checkedId); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { try { return (Boolean) methods[0].invoke(handler, preference, newValue); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } return false; }
@Override public boolean onKey(View view, int i, KeyEvent keyEvent) { try { return (Boolean) methods[0].invoke(handler, view, i, keyEvent); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } return false; }
@Override public boolean onLongClick(View v) { try { return (Boolean) methods[0].invoke(handler, v); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } return false; }
protected void onPostExecute(JSONObject result) { LogUtils.e("--------onPostExecute---------" + result.toString()); String buses = result.optString("buses"); Gson gson = new Gson(); Buses bus = gson.fromJson(buses, new TypeToken<Buses>() {}.getType()); mListView.setAdapter(mAdapter); mList.addAll(bus.getBus()); mAdapter.notifyDataSetChanged(); }