Permalink
Browse files

Merklisten-Bedienung verbessert

  • Loading branch information...
1 parent ef1b529 commit f08399fb23d953ed0986516787b6ccd1547f1cc6 @raphaelm raphaelm committed Jul 18, 2012
View
2 assets/about.html
@@ -8,7 +8,7 @@
Danke an Céline A.<br />
Die App verwendet <a href='http://jsoup.org'>jsoup</a> und mag es.<br /><br />
<b>ÄNDERUNGSPROTOKOLL</b><br /><br />
-1.2.2:<br />Fehler beim Vorbestellen behoben<br />Korrekturen für Bamberg und Bad Friedrichshall<br /><br />
+1.2.2:<br />Fehler beim Vorbestellen behoben<br />Korrekturen für Bamberg und Bad Friedrichshall<br />Verschönerungen in der Anzeige<br /><br />
1.2.1:<br />Fehler behoben<br /><br />
1.2.0:<br />Teilen von Links zu Medien<br />Android 4.0 Action Bar<br /><br />
1.1.5:<br />Kleine Fehlerkorrekturen<br /><br />
View
BIN res/drawable-hdpi/ic_ab_star_0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-hdpi/ic_ab_star_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/ic_ab_star_0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/ic_ab_star_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-xhdpi/ic_ab_star_0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-xhdpi/ic_ab_star_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
40 src/de/geeksfactory/opacclient/SearchResultDetailsActivity.java
@@ -405,37 +405,55 @@ public boolean onMenuItemClick(MenuItem item) {
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(SearchResultDetailsActivity.this);
String bib = sp.getString("opac_bib", "");
+ String t = title;
try {
bib = java.net.URLEncoder.encode(bib, "UTF-8");
+ t = java.net.URLEncoder.encode(t, "UTF-8");
} catch (UnsupportedEncodingException e) {
}
intent.putExtra(Intent.EXTRA_TEXT,
"http://www.raphaelmichel.de/opacclient/bibproxy.php/go?bib="
- + bib + "&id=" + id);
+ + bib + "&id=" + id + "&title=" + t);
startActivity(Intent.createChooser(intent,
getResources().getString(R.string.share)));
return true;
}
}).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
- menu.add(getString(R.string.star)).setIcon(R.drawable.ic_ab_star)
+ SharedPreferences sp = PreferenceManager
+ .getDefaultSharedPreferences(this);
+ final String bib = sp.getString("opac_bib", "");
+
+ int starIcon = R.drawable.ic_ab_star_0;
+ StarDataSource data = new StarDataSource(this);
+ data.open();
+ if (data.isStarred(bib, id)) {
+ starIcon = R.drawable.ic_ab_star_1;
+ }
+ data.close();
+
+ menu.add(getString(R.string.star)).setIcon(starIcon)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
- SharedPreferences sp = PreferenceManager
- .getDefaultSharedPreferences(SearchResultDetailsActivity.this);
- String bib = sp.getString("opac_bib", "");
StarDataSource star = new StarDataSource(
SearchResultDetailsActivity.this);
star.open();
- star.star(id, title, bib);
+ if (star.isStarred(bib, id)) {
+ star.remove(star.getItem(bib, id));
+ item.setIcon(R.drawable.ic_ab_star_0);
+ } else {
+ star.star(id, title, bib);
+ Toast toast = Toast.makeText(
+ SearchResultDetailsActivity.this,
+ getString(R.string.starred),
+ Toast.LENGTH_SHORT);
+ toast.show();
+ item.setIcon(R.drawable.ic_ab_star_1);
+ }
star.close();
- Toast toast = Toast
- .makeText(SearchResultDetailsActivity.this,
- getString(R.string.starred),
- Toast.LENGTH_SHORT);
- toast.show();
+
return true;
}
}).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
View
24 src/de/geeksfactory/opacclient/StarDataSource.java
@@ -52,6 +52,30 @@ public void star(String nr, String title, String bib) {
return items;
}
+ public Starred getItem(String bib, String id) {
+ String[] selA = { bib, id };
+ Cursor cursor = database.query("starred", allColumns, "bib = ? AND medianr = ?", selA,
+ null, null, null);
+ Starred item = null;
+
+ cursor.moveToFirst();
+ if (!cursor.isAfterLast()) {
+ item = cursorToItem(cursor);
+ cursor.moveToNext();
+ }
+ // Make sure to close the cursor
+ cursor.close();
+ return item;
+ }
+
+ public boolean isStarred(String bib, String id) {
+ List<Starred> items = new ArrayList<Starred>();
+ String[] selA = { bib, id };
+ Cursor cursor = database.query("starred", allColumns, "bib = ? AND medianr = ?", selA,
+ null, null, null);
+ return (cursor.getCount() > 0);
+ }
+
private Starred cursorToItem(Cursor cursor) {
Starred item = new Starred();
item.setId(cursor.getInt(0));

0 comments on commit f08399f

Please sign in to comment.