mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Put sub classes into startUpdatingCategoryList() method
This commit is contained in:
parent
d44869443e
commit
0203a9cdec
1 changed files with 47 additions and 57 deletions
|
|
@ -335,60 +335,59 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
|
|
||||||
private class PrefixUpdaterSub extends PrefixUpdater {
|
|
||||||
|
|
||||||
public PrefixUpdaterSub() {
|
|
||||||
super(CategorizationFragment.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ArrayList<String> doInBackground(Void... voids) {
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
|
||||||
try {
|
|
||||||
result = super.doInBackground();
|
|
||||||
latch.await();
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(ArrayList<String> result) {
|
|
||||||
super.onPostExecute(result);
|
|
||||||
|
|
||||||
results.addAll(result);
|
|
||||||
categoriesAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private class MethodAUpdaterSub extends MethodAUpdater {
|
|
||||||
|
|
||||||
public MethodAUpdaterSub() {
|
|
||||||
super(CategorizationFragment.this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(ArrayList<String> result) {
|
|
||||||
super.onPostExecute(result);
|
|
||||||
|
|
||||||
results.clear();
|
|
||||||
results.addAll(result);
|
|
||||||
categoriesAdapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void startUpdatingCategoryList() {
|
private void startUpdatingCategoryList() {
|
||||||
|
|
||||||
|
|
||||||
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
class PrefixUpdaterSub extends PrefixUpdater {
|
||||||
|
|
||||||
|
public PrefixUpdaterSub() {
|
||||||
|
super(CategorizationFragment.this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ArrayList<String> doInBackground(Void... voids) {
|
||||||
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
try {
|
||||||
|
result = super.doInBackground();
|
||||||
|
latch.await();
|
||||||
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(ArrayList<String> result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
|
||||||
|
results.addAll(result);
|
||||||
|
categoriesAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class MethodAUpdaterSub extends MethodAUpdater {
|
||||||
|
|
||||||
|
public MethodAUpdaterSub() {
|
||||||
|
super(CategorizationFragment.this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(ArrayList<String> result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
|
||||||
|
results.clear();
|
||||||
|
results.addAll(result);
|
||||||
|
categoriesAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (lastUpdater != null) {
|
if (lastUpdater != null) {
|
||||||
lastUpdater.cancel(true);
|
lastUpdater.cancel(true);
|
||||||
|
|
@ -404,15 +403,6 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
|
|
||||||
Utils.executeAsyncTask(prefixUpdaterSub);
|
Utils.executeAsyncTask(prefixUpdaterSub);
|
||||||
Utils.executeAsyncTask(methodAUpdaterSub);
|
Utils.executeAsyncTask(methodAUpdaterSub);
|
||||||
/*
|
|
||||||
ArrayList<CategoryItem> itemList = new ArrayList<CategoryItem>(itemSet);
|
|
||||||
|
|
||||||
methodAUpdater = new MethodAUpdater();
|
|
||||||
lastUpdater = new PrefixUpdater();
|
|
||||||
|
|
||||||
Utils.executeAsyncTask(lastUpdater, executor);
|
|
||||||
Utils.executeAsyncTask(methodAUpdater, executor);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue