Merge pull request #8 from misaochan/display-categories

Needs to be tidied up, but will do that after receiving feedback. Will remove debugging messages and uncomment the UploadController statement once considered almost ready for merge
This commit is contained in:
Josephine Lim 2015-12-25 19:51:29 +13:00
commit c732f75d6b
3 changed files with 26 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import android.os.*;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.*;
import android.widget.*;
import com.actionbarsherlock.app.SherlockFragment;
@ -18,6 +19,7 @@ import org.mediawiki.api.ApiResult;
import org.mediawiki.api.MWApi;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.upload.MwVolleyApi;
import java.io.IOException;
import java.util.ArrayList;
@ -112,6 +114,11 @@ public class CategorizationFragment extends SherlockFragment{
items.add(new CategoryItem(category, false));
}
}
//TODO: Remove this later
Log.d("Cat", "I am still called when upload is commented out");
categoriesAdapter.setItems(items);
categoriesAdapter.notifyDataSetInvalidated();
categoriesSearchInProgress.setVisibility(View.GONE);
@ -132,6 +139,8 @@ public class CategorizationFragment extends SherlockFragment{
protected ArrayList<String> doInBackground(Void... voids) {
if(TextUtils.isEmpty(filter)) {
ArrayList<String> items = new ArrayList<String>();
ArrayList<String> mergedItems= new ArrayList<String>();
try {
Cursor cursor = client.query(
CategoryContentProvider.BASE_URI,
@ -144,11 +153,23 @@ public class CategorizationFragment extends SherlockFragment{
Category cat = Category.fromCursor(cursor);
items.add(cat.getName());
}
} catch (RemoteException e) {
if (MwVolleyApi.gpsCatExists){
Log.d("Cat", "GPS cats found in CategorizationFragment.java" + MwVolleyApi.getGpsCat().toString());
ArrayList<String> gpsItems = new ArrayList<String>(MwVolleyApi.getGpsCat());
Log.d("Cat", "GPS items: " + gpsItems.toString());
mergedItems.addAll(items);
mergedItems.addAll(gpsItems);
Log.d("Cat", "Merged items: " + mergedItems.toString());
}
}
catch (RemoteException e) {
// faaaail
throw new RuntimeException(e);
}
return items;
return mergedItems;
}
if(categoriesCache.containsKey(filter)) {
return categoriesCache.get(filter);

View file

@ -30,6 +30,7 @@ public class MwVolleyApi {
private Context context;
protected static HashSet<String> categorySet;
//To check later on whether any nearby categories were found
public static boolean gpsCatExists;
@ -39,7 +40,7 @@ public class MwVolleyApi {
}
//To get the list of categories for display
public ArrayList<String> getGpsCat() {
public static ArrayList<String> getGpsCat() {
ArrayList<String> list = new ArrayList<String>(categorySet);
return list;
}

View file

@ -140,7 +140,7 @@ public class UploadController {
@Override
protected void onPostExecute(Contribution contribution) {
super.onPostExecute(contribution);
uploadService.queue(UploadService.ACTION_UPLOAD_FILE, contribution);
//uploadService.queue(UploadService.ACTION_UPLOAD_FILE, contribution);
onComplete.onUploadStarted(contribution);
}
});