mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Modified Sub classes & added Latch
This commit is contained in:
parent
73c6cbcc75
commit
d44869443e
1 changed files with 21 additions and 11 deletions
|
|
@ -53,7 +53,7 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
private OnCategoriesSaveHandler onCategoriesSaveHandler;
|
private OnCategoriesSaveHandler onCategoriesSaveHandler;
|
||||||
|
|
||||||
protected HashMap<String, ArrayList<String>> categoriesCache;
|
protected HashMap<String, ArrayList<String>> categoriesCache;
|
||||||
private final Set<CategoryItem> results = new LinkedHashSet<CategoryItem>();
|
private final Set<String> results = new LinkedHashSet<String>();
|
||||||
|
|
||||||
private ContentProviderClient client;
|
private ContentProviderClient client;
|
||||||
|
|
||||||
|
|
@ -335,7 +335,6 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
private class PrefixUpdaterSub extends PrefixUpdater {
|
private class PrefixUpdaterSub extends PrefixUpdater {
|
||||||
|
|
@ -345,17 +344,24 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void doInBackground() {
|
protected ArrayList<String> doInBackground(Void... voids) {
|
||||||
super.doInBackground();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
latch.await();
|
try {
|
||||||
|
result = super.doInBackground();
|
||||||
|
latch.await();
|
||||||
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onPostExecute(ResultSet result) {
|
protected void onPostExecute(ArrayList<String> result) {
|
||||||
super.onPostExecute(result):
|
super.onPostExecute(result);
|
||||||
|
|
||||||
results.addAll(result);
|
results.addAll(result);
|
||||||
adapter.notifyDataSetComplete();
|
categoriesAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,12 +373,12 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onPostExecute(ResultSet result) {
|
protected void onPostExecute(ArrayList<String> result) {
|
||||||
super.onPostExecute(result):
|
super.onPostExecute(result);
|
||||||
|
|
||||||
results.clear();
|
results.clear();
|
||||||
results.addAll(result);
|
results.addAll(result);
|
||||||
adapter.notifyDataSetComplete();
|
categoriesAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
@ -380,6 +386,10 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
|
|
||||||
|
|
||||||
private void startUpdatingCategoryList() {
|
private void startUpdatingCategoryList() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (lastUpdater != null) {
|
if (lastUpdater != null) {
|
||||||
lastUpdater.cancel(true);
|
lastUpdater.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue