Java Code Examples for java.util.concurrent.ConcurrentHashMap#Entry
The following examples show how to use
java.util.concurrent.ConcurrentHashMap#Entry .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersonalizationHelper.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
public static void removeAllUserHistoryDictionaries(final Context context) { synchronized (sLangUserHistoryDictCache) { for (final ConcurrentHashMap.Entry<String, SoftReference<UserHistoryDictionary>> entry : sLangUserHistoryDictCache.entrySet()) { if (entry.getValue() != null) { final UserHistoryDictionary dict = entry.getValue().get(); if (dict != null) { dict.clear(); } } } sLangUserHistoryDictCache.clear(); final File filesDir = context.getFilesDir(); if (filesDir == null) { Log.e(TAG, "context.getFilesDir() returned null."); return; } final boolean filesDeleted = FileUtils.deleteFilteredFiles( filesDir, new DictFilter(UserHistoryDictionary.NAME)); if (!filesDeleted) { Log.e(TAG, "Cannot remove dictionary files. filesDir: " + filesDir.getAbsolutePath() + ", dictNamePrefix: " + UserHistoryDictionary.NAME); } } }
Example 2
Source File: PersonalizationHelper.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
public static void removeAllUserHistoryDictionaries(final Context context) { synchronized (sLangUserHistoryDictCache) { for (final ConcurrentHashMap.Entry<String, SoftReference<UserHistoryDictionary>> entry : sLangUserHistoryDictCache.entrySet()) { if (entry.getValue() != null) { final UserHistoryDictionary dict = entry.getValue().get(); if (dict != null) { dict.clear(); } } } sLangUserHistoryDictCache.clear(); final File filesDir = context.getFilesDir(); if (filesDir == null) { Log.e(TAG, "context.getFilesDir() returned null."); return; } final boolean filesDeleted = FileUtils.deleteFilteredFiles( filesDir, new DictFilter(UserHistoryDictionary.NAME)); if (!filesDeleted) { Log.e(TAG, "Cannot remove dictionary files. filesDir: " + filesDir.getAbsolutePath() + ", dictNamePrefix: " + UserHistoryDictionary.NAME); } } }
Example 3
Source File: RxEasyHttpManager.java From EasyHttp with Apache License 2.0 | 6 votes |
/** * Post请求的Rxjava方式. * @param url * @param requestParams * @return */ public <T> Flowable<T> post(String url, EasyRequestParams requestParams, RxEasyConverter<T> rxEasyConverter) { FormBody.Builder builder = new FormBody.Builder(); ConcurrentHashMap<String, String> paramsMap = requestParams.getRequestParams(); for (ConcurrentHashMap.Entry<String, String> entry : paramsMap.entrySet()) { builder.add(entry.getKey(), entry.getValue()); } RequestBody requestBody = builder.build(); final Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Call call = EasyHttpClientManager.getInstance().getOkHttpClient(EasyCacheType.CACHE_TYPE_DEFAULT).newCall(request); return Flowable.create(new CallFlowableOnSubscribe(call,rxEasyConverter), BackpressureStrategy.BUFFER) .subscribeOn(Schedulers.io()); }
Example 4
Source File: RequestParams.java From Android-Basics-Codes with Artistic License 2.0 | 5 votes |
protected List<BasicNameValuePair> getParamsList() { List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>(); for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) { lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } lparams.addAll(getParamsList(null, urlParamsWithObjects)); return lparams; }
Example 5
Source File: PreferencesCookieStore.java From android-open-project-demo with Apache License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor editor = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.getExpiryDate() == null || cookie.isExpired(date)) { // Remove the cookie by name cookies.remove(name); // Clear cookies from persistent store editor.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { editor.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } editor.commit(); return clearedAny; }
Example 6
Source File: PersistentCookieStore.java From Roid-Library with Apache License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.isExpired(date)) { // Clear cookies from local store cookies.remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } prefsWriter.commit(); return clearedAny; }
Example 7
Source File: AjaxParams.java From Android-Basics-Codes with Artistic License 2.0 | 5 votes |
protected List<BasicNameValuePair> getParamsList() { List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>(); for(ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) { lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } return lparams; }
Example 8
Source File: PersistentCookieStore.java From android-project-wo2b with Apache License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.isExpired(date)) { // Clear cookies from local store cookies.remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } prefsWriter.commit(); return clearedAny; }
Example 9
Source File: PersistentCookieStore.java From sealtalk-android with MIT License | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.isExpired(date)) { // Clear cookies from local store cookies.remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } prefsWriter.commit(); return clearedAny; }
Example 10
Source File: PreferencesCookieStore.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor editor = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.getExpiryDate() == null || cookie.isExpired(date)) { // Remove the cookie by name cookies.remove(name); // Clear cookies from persistent store editor.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { editor.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } editor.commit(); return clearedAny; }
Example 11
Source File: RequestParams.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
/** * 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, null, 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; }
Example 12
Source File: PersistentCookieStore.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.isExpired(date)) { // Clear cookies from local store cookies.remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } prefsWriter.commit(); return clearedAny; }
Example 13
Source File: RestVolleyRequestWithBody.java From RestVolley with Apache License 2.0 | 5 votes |
protected List<BasicNameValuePair> getParamsList() { List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>(); for (ConcurrentHashMap.Entry<String, String> entry : mUrlParams.entrySet()) { lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } return lparams; }
Example 14
Source File: RequestParams.java From Android-Basics-Codes with Artistic License 2.0 | 5 votes |
protected List<BasicNameValuePair> getParamsList() { List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>(); for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) { lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } lparams.addAll(getParamsList(null, urlParamsWithObjects)); return lparams; }
Example 15
Source File: PreferencesCookieStore.java From Android-Basics-Codes with Artistic License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for(ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if(cookie.isExpired(date)) { // 清除cookies cookies.remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if(clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } prefsWriter.commit(); return clearedAny; }
Example 16
Source File: UEHttpParams.java From Auie with GNU General Public License v2.0 | 5 votes |
public String toString(){ StringBuffer paramsStr = new StringBuffer(); for(ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()){ if(paramsStr.length() > 0){ paramsStr.append("&"); } paramsStr.append(entry.getKey()); paramsStr.append("="); paramsStr.append(entry.getValue()); } return paramsStr.toString(); }
Example 17
Source File: PersistentCookieStore.java From Mobike with Apache License 2.0 | 5 votes |
@Override public boolean clearExpired(Date date) { boolean clearedAny = false; SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (cookie.isExpired(date)) { // Clear cookies from local store cookies.remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one clearedAny = true; } } // Update names in persistent store if (clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } prefsWriter.commit(); return clearedAny; }
Example 18
Source File: RequestParams.java From android-open-project-demo with Apache License 2.0 | 5 votes |
/** * 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, null, 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; }
Example 19
Source File: RequestParams.java From AsyncOkHttpClient with Apache License 2.0 | 5 votes |
/** * Return the encoded parameter of this request * ready for HttpURLConnection set on OutputStream * @return the parameters encoded */ public String getParams() { StringBuilder result = new StringBuilder(); for(ConcurrentHashMap.Entry<String, String> entry : mParams.entrySet()) { if(result.length() > 0) result.append("&"); result.append(entry.getKey()); result.append("="); result.append(entry.getValue()); } return result.toString(); }
Example 20
Source File: PersistentCookieStore.java From tysq-android with GNU General Public License v3.0 | 5 votes |
/** * 移除失效cookie */ private void clearExpired() { SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); for (String key : this.cookies.keySet()) { boolean changeFlag = false; for (ConcurrentHashMap.Entry<String, Cookie> entry : cookies.get(key).entrySet()) { String name = entry.getKey(); Cookie cookie = entry.getValue(); if (isCookieExpired(cookie)) { // Clear cookies from local store cookies.get(key).remove(name); // Clear cookies from persistent store prefsWriter.remove(COOKIE_NAME_PREFIX + name); // We've cleared at least one changeFlag = true; } } // Update names in persistent store if (changeFlag) { prefsWriter.putString(key, TextUtils.join(",", cookies.keySet())); } } prefsWriter.apply(); }