mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fixups per Yuvi's notes
This commit is contained in:
parent
8b351d94a3
commit
290ac00767
4 changed files with 43 additions and 56 deletions
|
|
@ -5,28 +5,11 @@
|
|||
<configuration>
|
||||
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/target/generated-sources/r" />
|
||||
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/target/generated-sources/aidl" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/assets" />
|
||||
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/src/main/native" />
|
||||
<option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
|
||||
<option name="CUSTOM_APK_RESOURCE_FOLDER" value="/target/generated-sources/combined-resources/res" />
|
||||
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
|
||||
<option name="CUSTOM_COMPILER_MANIFEST" value="" />
|
||||
<option name="APK_PATH" value="/target/commons.apk" />
|
||||
<option name="LIBRARY_PROJECT" value="false" />
|
||||
<option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" value="false" />
|
||||
<option name="GENERATE_UNSIGNED_APK" value="false" />
|
||||
<option name="CUSTOM_DEBUG_KEYSTORE_PATH" value="" />
|
||||
<option name="PACK_TEST_CODE" value="false" />
|
||||
<option name="RUN_PROGUARD" value="false" />
|
||||
<option name="PROGUARD_CFG_PATH" value="/proguard-project.txt" />
|
||||
<resOverlayFolders>
|
||||
<path>/res-overlay</path>
|
||||
</resOverlayFolders>
|
||||
<includeSystemProguardFile>true</includeSystemProguardFile>
|
||||
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
|
||||
<additionalNativeLibs />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -239,15 +239,20 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
}
|
||||
|
||||
private Category lookupCategory(String name) {
|
||||
Cursor cursor = getActivity().getContentResolver().query(
|
||||
CategoryContentProvider.BASE_URI,
|
||||
Category.Table.ALL_FIELDS,
|
||||
Category.Table.COLUMN_NAME + "=?",
|
||||
new String[] {name},
|
||||
null);
|
||||
if (cursor.moveToNext()) {
|
||||
Category cat = Category.fromCursor(cursor);
|
||||
return cat;
|
||||
try {
|
||||
Cursor cursor = client.query(
|
||||
CategoryContentProvider.BASE_URI,
|
||||
Category.Table.ALL_FIELDS,
|
||||
Category.Table.COLUMN_NAME + "=?",
|
||||
new String[] {name},
|
||||
null);
|
||||
if (cursor.moveToFirst()) {
|
||||
Category cat = Category.fromCursor(cursor);
|
||||
return cat;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// This feels lazy, but to hell with checked exceptions. :)
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// Newly used category...
|
||||
|
|
@ -257,12 +262,27 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
cat.setTimesUsed(0);
|
||||
return cat;
|
||||
}
|
||||
private void updateCategoryCount(String name) {
|
||||
Category cat = lookupCategory(name);
|
||||
cat.incTimesUsed();
|
||||
|
||||
cat.setContentProviderClient(client);
|
||||
cat.save();
|
||||
private class CategoryCountUpdater extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private String name;
|
||||
|
||||
public CategoryCountUpdater(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInBackground(Void... voids) {
|
||||
Category cat = lookupCategory(name);
|
||||
cat.incTimesUsed();
|
||||
|
||||
cat.setContentProviderClient(client);
|
||||
cat.save();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCategoryCount(String name) {
|
||||
Utils.executeAsyncTask(new CategoryCountUpdater(name), executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -299,7 +319,6 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
CategoryItem item = (CategoryItem) adapterView.getAdapter().getItem(index);
|
||||
item.selected = !item.selected;
|
||||
checkedView.setChecked(item.selected);
|
||||
// fixme do this asynchronously?
|
||||
if (item.selected) {
|
||||
updateCategoryCount(item.name);
|
||||
}
|
||||
|
|
@ -348,9 +367,8 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
client.release();
|
||||
client = null;
|
||||
super.onDestroy();
|
||||
client.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -13,13 +13,6 @@ import org.wikimedia.commons.contributions.ContributionsContentProvider;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: brion
|
||||
* Date: 4/22/13
|
||||
* Time: 3:37 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class Category {
|
||||
private ContentProviderClient client;
|
||||
private Uri contentUri;
|
||||
|
|
@ -33,8 +26,8 @@ public class Category {
|
|||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name_) {
|
||||
name = name_;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getLastUsed() {
|
||||
|
|
@ -42,9 +35,9 @@ public class Category {
|
|||
return (Date)lastUsed.clone();
|
||||
}
|
||||
|
||||
public void setLastUsed(Date lastUsed_) {
|
||||
public void setLastUsed(Date lastUsed) {
|
||||
// warning: Date objects are mutable.
|
||||
lastUsed = (Date)lastUsed_.clone();
|
||||
this.lastUsed = (Date)lastUsed.clone();
|
||||
}
|
||||
|
||||
public void touch() {
|
||||
|
|
@ -55,8 +48,8 @@ public class Category {
|
|||
return timesUsed;
|
||||
}
|
||||
|
||||
public void setTimesUsed(int timesUsed_) {
|
||||
timesUsed = timesUsed_;
|
||||
public void setTimesUsed(int timesUsed) {
|
||||
this.timesUsed = timesUsed;
|
||||
}
|
||||
|
||||
public void incTimesUsed() {
|
||||
|
|
@ -119,7 +112,7 @@ public class Category {
|
|||
private static final String CREATE_TABLE_STATEMENT = "CREATE TABLE " + TABLE_NAME + " ("
|
||||
+ COLUMN_ID + " INTEGER PRIMARY KEY,"
|
||||
+ COLUMN_NAME + " STRING,"
|
||||
+ COLUMN_LAST_USED + " INTEGER," // Will this roll over in 2038? :)
|
||||
+ COLUMN_LAST_USED + " INTEGER,"
|
||||
+ COLUMN_TIMES_USED + " INTEGER"
|
||||
+ ");";
|
||||
|
||||
|
|
|
|||
|
|
@ -12,16 +12,9 @@ import android.util.Log;
|
|||
import org.wikimedia.commons.CommonsApplication;
|
||||
import org.wikimedia.commons.data.DBOpenHelper;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: brion
|
||||
* Date: 4/22/13
|
||||
* Time: 4:09 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class CategoryContentProvider extends ContentProvider {
|
||||
|
||||
// ????
|
||||
// For URI matcher
|
||||
private static final int CATEGORIES = 1;
|
||||
private static final int CATEGORIES_ID = 2;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue