confirm marking headlines as read from the actionbar
This commit is contained in:
parent
a60225626d
commit
9e71ff1b11
@ -195,4 +195,5 @@
|
||||
<string name="light_theme_is_not_supported_on_honeycomb">Light theme is not supported on Honeycomb</string>
|
||||
<string name="pref_headlines_mark_read_scroll">Mark read on scroll</string>
|
||||
<string name="pref_headlines_mark_read_scroll_long">Headlines will be marked read when scrolling past them</string>
|
||||
<string name="mark_num_headlines_as_read">Mark %1$d article(s) as read?</string>
|
||||
</resources>
|
||||
|
@ -7,6 +7,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
@ -118,7 +119,7 @@ public class CommonActivity extends SherlockFragmentActivity {
|
||||
|
||||
initDatabase();
|
||||
|
||||
m_compatMode = android.os.Build.VERSION.SDK_INT <= 10;
|
||||
m_compatMode = android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB;
|
||||
|
||||
Log.d(TAG, "m_compatMode=" + m_compatMode);
|
||||
|
||||
|
@ -746,32 +746,59 @@ public class OnlineActivity extends CommonActivity {
|
||||
return true;
|
||||
case R.id.headlines_mark_as_read:
|
||||
if (hf != null) {
|
||||
ArticleList articles = hf.getUnreadArticles();
|
||||
|
||||
for (Article a : articles)
|
||||
a.unread = false;
|
||||
int count = hf.getUnreadArticles().size();
|
||||
|
||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||
protected void onPostExecute(JsonElement result) {
|
||||
if (hf.isAdded()) {
|
||||
hf.refresh(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (count > 0) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
OnlineActivity.this)
|
||||
.setMessage(getString(R.string.mark_num_headlines_as_read, count))
|
||||
.setPositiveButton(R.string.catchup,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
final String articleIds = articlesToIdString(articles);
|
||||
ArticleList articles = hf.getUnreadArticles();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
HashMap<String, String> map = new HashMap<String, String>() {
|
||||
{
|
||||
put("sid", getSessionId());
|
||||
put("op", "updateArticle");
|
||||
put("article_ids", articleIds);
|
||||
put("mode", "0");
|
||||
put("field", "2");
|
||||
}
|
||||
};
|
||||
req.execute(map);
|
||||
for (Article a : articles)
|
||||
a.unread = false;
|
||||
|
||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||
protected void onPostExecute(JsonElement result) {
|
||||
if (hf.isAdded()) {
|
||||
hf.refresh(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
final String articleIds = articlesToIdString(articles);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
HashMap<String, String> map = new HashMap<String, String>() {
|
||||
{
|
||||
put("sid", getSessionId());
|
||||
put("op", "updateArticle");
|
||||
put("article_ids", articleIds);
|
||||
put("mode", "0");
|
||||
put("field", "2");
|
||||
}
|
||||
};
|
||||
req.execute(map);
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_cancel,
|
||||
new Dialog.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dlg = builder.create();
|
||||
dlg.show();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case R.id.headlines_view_mode:
|
||||
|
Loading…
Reference in New Issue
Block a user