編輯:關於Android編程
StringBuilder sb = new StringBuilder(); if (!url.contains("?")) { url = url + "?"; } else { if (!url.endsWith("?")) { url = url + "&"; } } Iteratoriterotor = paramsMap.keySet().iterator(); while (iterotor.hasNext()) { String key = (String) iterotor.next(); try { sb.append(key).append("=").append(URLEncoder.encode(paramsMap.get(key), "utf-8")).append("&"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } if (sb.lastIndexOf("&") == sb.length() - 1) { sb.deleteCharAt(sb.length() - 1); }
@Override protected MapgetParams() throws AuthFailureError { ParamsEngine engine = new ParamsEngine(mContext); Map p = engine.generateRequestParams(paramsMap); return p; }
String urlString = request.getUrl(); if(urlString.trim().toLowerCase().startsWith("file")){ try { // 如果加載的是本地圖片,不放入disk-cache目錄中 request.setShouldCache(false); return new NetworkResponse(getFromFile(new URI(urlString).getPath())); } catch (URISyntaxException e) { e.printStackTrace(); } }else if(urlString.trim().toLowerCase().startsWith("/")){ request.setShouldCache(false); return new NetworkResponse(getFromFile(urlString)); }
private byte[] getFromFile(String urlString) throws IOException { File file = new File(urlString); PoolingByteArrayOutputStream bytes = new PoolingByteArrayOutputStream(mPool, (int) file.length()); byte[] buffer = null; // 得到文件的輸入流 InputStream in = null; try { buffer = mPool.getBuf(1024); in = new FileInputStream(new File(urlString)); int count; while ((count = in.read(buffer)) != -1) { bytes.write(buffer, 0, count); } return bytes.toByteArray(); } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } mPool.returnBuf(buffer); try { bytes.close(); } catch (IOException e) { e.printStackTrace(); } } }
DiskLruCache DiskLruCache是一套硬盤緩存的解決方案,算法同LruCache基於LRU算法。DiskLruCache不是由Google官方編寫的,這
拿到美工效果圖,咱們程序員就得畫得一模一樣。 為了不被老板噴,只能多練啊。聽說你覺得前面幾篇都so easy,那今天就帶你做個相對比較復雜的。今天的效果圖如下(左邊是ui
一種使用OpenGL渲染文字的常用方法,是計算出一個包含了顯示文字的紋理圖片,這通常是使用相當復雜的打包算法來最小化紋理中的冗余部分,在創建這樣的圖片之前必須清楚應用運行
版本:1.0 日期:2014.11.25 2014.11.26版權:©kince特別推薦:泡在網上的日子一、概述 一般Launcher都帶有壁紙設置的功能,A