Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
修复 hashmap的实现。
Browse files Browse the repository at this point in the history
  • Loading branch information
jiechic committed Nov 3, 2017
1 parent e1acd91 commit 6ed589f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

def final String VERSION_NAME = "0.12.1-SNAPSHOT"
def final String VERSION_NAME = "0.12.2-SNAPSHOT"
def final int VERSION_CODE = 14

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
buildToolsVersion '26.0.2'

defaultConfig {
minSdkVersion 15
Expand Down
2 changes: 1 addition & 1 deletion library/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.12.1
VERSION_NAME=0.12.2
POM_NAME=Android Tray
POM_ARTIFACT_ID=tray
POM_GROUP=com.jiechic.android.library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ public void onChange(final boolean selfChange, Uri uri) {
final List<TrayItem> trayItems = mProviderHelper.queryProviderSafe(uri);

// clone to get around ConcurrentModificationException
final Set<Map.Entry<OnTrayPreferenceChangeListener, Handler>> entries
= new HashSet<>(mListeners.entrySet());
final Set<Map.Entry<OnTrayPreferenceChangeListener, Handler>> entries;
synchronized (ContentProviderStorage.class) {
entries = new HashSet<>(mListeners.entrySet());
}


// notify all registered listeners
for (final Map.Entry<OnTrayPreferenceChangeListener, Handler> entry : entries) {
Expand Down Expand Up @@ -285,9 +288,13 @@ public synchronized void registerOnTrayPreferenceChangeListener(
handler = new Handler(looper);
}
//noinspection ConstantConditions
mListeners.put(listener, handler);

final Collection<OnTrayPreferenceChangeListener> listeners = mListeners.keySet();
final Collection<OnTrayPreferenceChangeListener> listeners;

synchronized (ContentProviderStorage.class) {
mListeners.put(listener, handler);
listeners = mListeners.keySet();
}

if (listeners.size() == 1) {

Expand Down Expand Up @@ -357,7 +364,9 @@ public void unregisterOnTrayPreferenceChangeListener(
if (listener == null) {
return;
}
mListeners.remove(listener);
synchronized (ContentProviderStorage.class) {
mListeners.remove(listener);
}

if (mListeners.size() == 0) {
mContext.getContentResolver().unregisterContentObserver(mObserver);
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
buildToolsVersion '26.0.2'

defaultConfig {
applicationId "net.grandcentrix.tray.sample"
Expand Down

0 comments on commit 6ed589f

Please sign in to comment.