mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +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>
|
<configuration>
|
||||||
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/target/generated-sources/r" />
|
<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="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="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="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="APK_PATH" value="/target/commons.apk" />
|
||||||
<option name="LIBRARY_PROJECT" value="false" />
|
|
||||||
<option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" 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>
|
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
|
||||||
<additionalNativeLibs />
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</facet>
|
</facet>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -239,16 +239,21 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
}
|
}
|
||||||
|
|
||||||
private Category lookupCategory(String name) {
|
private Category lookupCategory(String name) {
|
||||||
Cursor cursor = getActivity().getContentResolver().query(
|
try {
|
||||||
|
Cursor cursor = client.query(
|
||||||
CategoryContentProvider.BASE_URI,
|
CategoryContentProvider.BASE_URI,
|
||||||
Category.Table.ALL_FIELDS,
|
Category.Table.ALL_FIELDS,
|
||||||
Category.Table.COLUMN_NAME + "=?",
|
Category.Table.COLUMN_NAME + "=?",
|
||||||
new String[] {name},
|
new String[] {name},
|
||||||
null);
|
null);
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToFirst()) {
|
||||||
Category cat = Category.fromCursor(cursor);
|
Category cat = Category.fromCursor(cursor);
|
||||||
return cat;
|
return cat;
|
||||||
}
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// This feels lazy, but to hell with checked exceptions. :)
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
// Newly used category...
|
// Newly used category...
|
||||||
Category cat = new Category();
|
Category cat = new Category();
|
||||||
|
|
@ -257,13 +262,28 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
cat.setTimesUsed(0);
|
cat.setTimesUsed(0);
|
||||||
return cat;
|
return cat;
|
||||||
}
|
}
|
||||||
private void updateCategoryCount(String name) {
|
|
||||||
|
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);
|
Category cat = lookupCategory(name);
|
||||||
cat.incTimesUsed();
|
cat.incTimesUsed();
|
||||||
|
|
||||||
cat.setContentProviderClient(client);
|
cat.setContentProviderClient(client);
|
||||||
cat.save();
|
cat.save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCategoryCount(String name) {
|
||||||
|
Utils.executeAsyncTask(new CategoryCountUpdater(name), executor);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
@ -299,7 +319,6 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
CategoryItem item = (CategoryItem) adapterView.getAdapter().getItem(index);
|
CategoryItem item = (CategoryItem) adapterView.getAdapter().getItem(index);
|
||||||
item.selected = !item.selected;
|
item.selected = !item.selected;
|
||||||
checkedView.setChecked(item.selected);
|
checkedView.setChecked(item.selected);
|
||||||
// fixme do this asynchronously?
|
|
||||||
if (item.selected) {
|
if (item.selected) {
|
||||||
updateCategoryCount(item.name);
|
updateCategoryCount(item.name);
|
||||||
}
|
}
|
||||||
|
|
@ -348,9 +367,8 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
client.release();
|
|
||||||
client = null;
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
client.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,6 @@ import org.wikimedia.commons.contributions.ContributionsContentProvider;
|
||||||
|
|
||||||
import java.util.Date;
|
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 {
|
public class Category {
|
||||||
private ContentProviderClient client;
|
private ContentProviderClient client;
|
||||||
private Uri contentUri;
|
private Uri contentUri;
|
||||||
|
|
@ -33,8 +26,8 @@ public class Category {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name_) {
|
public void setName(String name) {
|
||||||
name = name_;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getLastUsed() {
|
public Date getLastUsed() {
|
||||||
|
|
@ -42,9 +35,9 @@ public class Category {
|
||||||
return (Date)lastUsed.clone();
|
return (Date)lastUsed.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastUsed(Date lastUsed_) {
|
public void setLastUsed(Date lastUsed) {
|
||||||
// warning: Date objects are mutable.
|
// warning: Date objects are mutable.
|
||||||
lastUsed = (Date)lastUsed_.clone();
|
this.lastUsed = (Date)lastUsed.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void touch() {
|
public void touch() {
|
||||||
|
|
@ -55,8 +48,8 @@ public class Category {
|
||||||
return timesUsed;
|
return timesUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimesUsed(int timesUsed_) {
|
public void setTimesUsed(int timesUsed) {
|
||||||
timesUsed = timesUsed_;
|
this.timesUsed = timesUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incTimesUsed() {
|
public void incTimesUsed() {
|
||||||
|
|
@ -119,7 +112,7 @@ public class Category {
|
||||||
private static final String CREATE_TABLE_STATEMENT = "CREATE TABLE " + TABLE_NAME + " ("
|
private static final String CREATE_TABLE_STATEMENT = "CREATE TABLE " + TABLE_NAME + " ("
|
||||||
+ COLUMN_ID + " INTEGER PRIMARY KEY,"
|
+ COLUMN_ID + " INTEGER PRIMARY KEY,"
|
||||||
+ COLUMN_NAME + " STRING,"
|
+ COLUMN_NAME + " STRING,"
|
||||||
+ COLUMN_LAST_USED + " INTEGER," // Will this roll over in 2038? :)
|
+ COLUMN_LAST_USED + " INTEGER,"
|
||||||
+ COLUMN_TIMES_USED + " INTEGER"
|
+ COLUMN_TIMES_USED + " INTEGER"
|
||||||
+ ");";
|
+ ");";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,9 @@ import android.util.Log;
|
||||||
import org.wikimedia.commons.CommonsApplication;
|
import org.wikimedia.commons.CommonsApplication;
|
||||||
import org.wikimedia.commons.data.DBOpenHelper;
|
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 {
|
public class CategoryContentProvider extends ContentProvider {
|
||||||
|
|
||||||
// ????
|
// For URI matcher
|
||||||
private static final int CATEGORIES = 1;
|
private static final int CATEGORIES = 1;
|
||||||
private static final int CATEGORIES_ID = 2;
|
private static final int CATEGORIES_ID = 2;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue