Added workarounds for ActionMode/Option menu bugs

This commit is contained in:
daniel oeh 2013-09-05 14:39:53 +02:00
parent 5bcfd2c255
commit 7926494d76
2 changed files with 97 additions and 92 deletions

View File

@ -9,7 +9,6 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.asynctask.ImageLoader; import de.danoeh.antennapod.asynctask.ImageLoader;
@ -21,7 +20,9 @@ import de.danoeh.antennapod.storage.DownloadRequestException;
import de.danoeh.antennapod.util.LangUtils; import de.danoeh.antennapod.util.LangUtils;
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler; import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
/** Displays information about a feed. */ /**
* Displays information about a feed.
*/
public class FeedInfoActivity extends ActionBarActivity { public class FeedInfoActivity extends ActionBarActivity {
private static final String TAG = "FeedInfoActivity"; private static final String TAG = "FeedInfoActivity";
@ -55,7 +56,6 @@ public class FeedInfoActivity extends ActionBarActivity {
super.onPostExecute(result); super.onPostExecute(result);
if (result != null) { if (result != null) {
feed = result; feed = result;
if (feed != null) {
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Language is " + feed.getLanguage()); Log.d(TAG, "Language is " + feed.getLanguage());
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
@ -84,7 +84,7 @@ public class FeedInfoActivity extends ActionBarActivity {
.getLanguageString(feed.getLanguage())); .getLanguageString(feed.getLanguage()));
} }
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
}
} else { } else {
Log.e(TAG, "Activity was started with invalid arguments"); Log.e(TAG, "Activity was started with invalid arguments");
} }
@ -106,11 +106,14 @@ public class FeedInfoActivity extends ActionBarActivity {
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
if (feed != null) {
menu.findItem(R.id.support_item).setVisible( menu.findItem(R.id.support_item).setVisible(
feed.getPaymentLink() != null); feed.getPaymentLink() != null);
menu.findItem(R.id.share_link_item).setVisible(feed.getLink() != null); menu.findItem(R.id.share_link_item).setVisible(feed.getLink() != null);
return true; return true;
} else {
return false;
}
} }
@Override @Override

View File

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity; 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 actionModeDestroyWorkaround = false; // TODO remove this workaround
private boolean skipWorkAround = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH;
@Override @Override
public void onDestroyActionMode(ActionMode mode) { public void onDestroyActionMode(ActionMode mode) {
if (actionModeDestroyWorkaround) { if (skipWorkAround || actionModeDestroyWorkaround) {
mActionMode = null; mActionMode = null;
selectedFeed = null; selectedFeed = null;
fla.setSelectedItemIndex(FeedlistAdapter.SELECTION_NONE); fla.setSelectedItemIndex(FeedlistAdapter.SELECTION_NONE);