Added workarounds for ActionMode/Option menu bugs
This commit is contained in:
parent
5bcfd2c255
commit
7926494d76
|
@ -9,7 +9,6 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.asynctask.ImageLoader;
|
||||
|
@ -21,80 +20,81 @@ import de.danoeh.antennapod.storage.DownloadRequestException;
|
|||
import de.danoeh.antennapod.util.LangUtils;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
||||
|
||||
/** Displays information about a feed. */
|
||||
/**
|
||||
* Displays information about a feed.
|
||||
*/
|
||||
public class FeedInfoActivity extends ActionBarActivity {
|
||||
private static final String TAG = "FeedInfoActivity";
|
||||
private static final String TAG = "FeedInfoActivity";
|
||||
|
||||
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
|
||||
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
|
||||
|
||||
private Feed feed;
|
||||
private Feed feed;
|
||||
|
||||
private ImageView imgvCover;
|
||||
private TextView txtvTitle;
|
||||
private TextView txtvDescription;
|
||||
private TextView txtvLanguage;
|
||||
private TextView txtvAuthor;
|
||||
private ImageView imgvCover;
|
||||
private TextView txtvTitle;
|
||||
private TextView txtvDescription;
|
||||
private TextView txtvLanguage;
|
||||
private TextView txtvAuthor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.feedinfo);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
long feedId = getIntent().getLongExtra(EXTRA_FEED_ID, -1);
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.feedinfo);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
long feedId = getIntent().getLongExtra(EXTRA_FEED_ID, -1);
|
||||
|
||||
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
||||
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
||||
|
||||
@Override
|
||||
protected Feed doInBackground(Long... params) {
|
||||
return DBReader.getFeed(FeedInfoActivity.this, params[0]);
|
||||
}
|
||||
@Override
|
||||
protected Feed doInBackground(Long... params) {
|
||||
return DBReader.getFeed(FeedInfoActivity.this, params[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Feed result) {
|
||||
super.onPostExecute(result);
|
||||
if (result != null) {
|
||||
feed = result;
|
||||
if (feed != null) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Language is " + feed.getLanguage());
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Author is " + feed.getAuthor());
|
||||
imgvCover = (ImageView) findViewById(R.id.imgvCover);
|
||||
txtvTitle = (TextView) findViewById(R.id.txtvTitle);
|
||||
txtvDescription = (TextView) findViewById(R.id.txtvDescription);
|
||||
txtvLanguage = (TextView) findViewById(R.id.txtvLanguage);
|
||||
txtvAuthor = (TextView) findViewById(R.id.txtvAuthor);
|
||||
imgvCover.post(new Runnable() {
|
||||
@Override
|
||||
protected void onPostExecute(Feed result) {
|
||||
super.onPostExecute(result);
|
||||
if (result != null) {
|
||||
feed = result;
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Language is " + feed.getLanguage());
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Author is " + feed.getAuthor());
|
||||
imgvCover = (ImageView) findViewById(R.id.imgvCover);
|
||||
txtvTitle = (TextView) findViewById(R.id.txtvTitle);
|
||||
txtvDescription = (TextView) findViewById(R.id.txtvDescription);
|
||||
txtvLanguage = (TextView) findViewById(R.id.txtvLanguage);
|
||||
txtvAuthor = (TextView) findViewById(R.id.txtvAuthor);
|
||||
imgvCover.post(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ImageLoader.getInstance().loadThumbnailBitmap(
|
||||
feed.getImage(), imgvCover);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
ImageLoader.getInstance().loadThumbnailBitmap(
|
||||
feed.getImage(), imgvCover);
|
||||
}
|
||||
});
|
||||
|
||||
txtvTitle.setText(feed.getTitle());
|
||||
txtvDescription.setText(feed.getDescription());
|
||||
if (feed.getAuthor() != null) {
|
||||
txtvAuthor.setText(feed.getAuthor());
|
||||
}
|
||||
if (feed.getLanguage() != null) {
|
||||
txtvLanguage.setText(LangUtils
|
||||
.getLanguageString(feed.getLanguage()));
|
||||
}
|
||||
supportInvalidateOptionsMenu();
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
}
|
||||
}
|
||||
};
|
||||
loadTask.execute(feedId);
|
||||
}
|
||||
txtvTitle.setText(feed.getTitle());
|
||||
txtvDescription.setText(feed.getDescription());
|
||||
if (feed.getAuthor() != null) {
|
||||
txtvAuthor.setText(feed.getAuthor());
|
||||
}
|
||||
if (feed.getLanguage() != null) {
|
||||
txtvLanguage.setText(LangUtils
|
||||
.getLanguageString(feed.getLanguage()));
|
||||
}
|
||||
supportInvalidateOptionsMenu();
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
} else {
|
||||
Log.e(TAG, "Activity was started with invalid arguments");
|
||||
}
|
||||
}
|
||||
};
|
||||
loadTask.execute(feedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (feed != null) {
|
||||
MenuInflater inflater = new MenuInflater(this);
|
||||
inflater.inflate(R.menu.feedinfo, menu);
|
||||
|
@ -102,32 +102,35 @@ public class FeedInfoActivity extends ActionBarActivity {
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.support_item).setVisible(
|
||||
feed.getPaymentLink() != null);
|
||||
menu.findItem(R.id.share_link_item).setVisible(feed.getLink() != null);
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
if (feed != null) {
|
||||
menu.findItem(R.id.support_item).setVisible(
|
||||
feed.getPaymentLink() != null);
|
||||
menu.findItem(R.id.share_link_item).setVisible(feed.getLink() != null);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
try {
|
||||
return FeedMenuHandler.onOptionsItemClicked(this, item, feed);
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
|
||||
e.getMessage());
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
try {
|
||||
return FeedMenuHandler.onOptionsItemClicked(this, item, feed);
|
||||
} catch (DownloadRequestException e) {
|
||||
e.printStackTrace();
|
||||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(this,
|
||||
e.getMessage());
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
@ -244,10 +245,11 @@ public class FeedlistFragment extends Fragment implements
|
|||
}
|
||||
|
||||
private boolean actionModeDestroyWorkaround = false; // TODO remove this workaround
|
||||
private boolean skipWorkAround = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
if (actionModeDestroyWorkaround) {
|
||||
if (skipWorkAround || actionModeDestroyWorkaround) {
|
||||
mActionMode = null;
|
||||
selectedFeed = null;
|
||||
fla.setSelectedItemIndex(FeedlistAdapter.SELECTION_NONE);
|
||||
|
|
Loading…
Reference in New Issue