I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit d2385166 authored by str4d's avatar str4d
Browse files

Fixed race between router binding and onCreateOptionsMenu()

parent ed17d598
No related branches found
No related tags found
No related merge requests found
...@@ -2,9 +2,6 @@ package net.i2p.android.router.addressbook; ...@@ -2,9 +2,6 @@ package net.i2p.android.router.addressbook;
import net.i2p.android.router.I2PActivityBase; import net.i2p.android.router.I2PActivityBase;
import net.i2p.android.router.R; import net.i2p.android.router.R;
import net.i2p.android.router.I2PActivityBase.TabListener;
import net.i2p.android.router.web.WebActivity;
import net.i2p.android.router.web.WebFragment;
import android.app.Activity; import android.app.Activity;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Context; import android.content.Context;
......
...@@ -105,6 +105,11 @@ public class AddressbookFragment extends ListFragment implements ...@@ -105,6 +105,11 @@ public class AddressbookFragment extends ListFragment implements
} }
public void onRouterConnectionReady() { public void onRouterConnectionReady() {
// Show actions
mSearchAddressbook.setVisible(true);
if (mAddToAddressbook != null)
mAddToAddressbook.setVisible(false);
if (mAddWizardData != null) { if (mAddWizardData != null) {
// Save the new entry // Save the new entry
Bundle entryData = mAddWizardData.getExtras().getBundle(ADD_WIZARD_DATA); Bundle entryData = mAddWizardData.getExtras().getBundle(ADD_WIZARD_DATA);
...@@ -130,24 +135,33 @@ public class AddressbookFragment extends ListFragment implements ...@@ -130,24 +135,33 @@ public class AddressbookFragment extends ListFragment implements
mCallback.onAddressSelected(host); mCallback.onAddressSelected(host);
} }
private MenuItem mSearchAddressbook;
private MenuItem mAddToAddressbook;
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_addressbook_actions, menu); inflater.inflate(R.menu.fragment_addressbook_actions, menu);
mSearchAddressbook = menu.findItem(R.id.action_search_addressbook);
mAddToAddressbook = menu.findItem(R.id.action_add_to_addressbook);
// Only allow adding to private book // Hide until needed
if (!PRIVATE_BOOK.equals(mBook)) if (getRouterContext() == null) {
menu.findItem(R.id.action_add_to_addressbook).setVisible(false); mSearchAddressbook.setVisible(false);
mAddToAddressbook.setVisible(false);
}
if (getRouterContext() == null) { // Only allow adding to private book
menu.findItem(R.id.action_search_addressbook).setVisible(false); if (!PRIVATE_BOOK.equals(mBook)) {
menu.findItem(R.id.action_add_to_addressbook).setVisible(false); mAddToAddressbook.setVisible(false);
} mAddToAddressbook = null;
}
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items // Handle presses on the action bar items
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_add_to_addressbook: case R.id.action_add_to_addressbook:
Intent wi = new Intent(getActivity(), AddressbookAddWizardActivity.class); Intent wi = new Intent(getActivity(), AddressbookAddWizardActivity.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment