Skip to content

Instantly share code, notes, and snippets.

@jasonpolites
Created January 23, 2012 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonpolites/1665636 to your computer and use it in GitHub Desktop.
Save jasonpolites/1665636 to your computer and use it in GitHub Desktop.
Reload Action Bar With Create Entity
// Create a class to handle the callback from the action bar
public class MyActionBarListener implements ActionBarListener {
private ActionBarView actionBarView;
@Override
public void onCreate(ActionBarView actionBar) {
// Store a reference to the actionBar view
this.actionBarView = actionBar;
}
public ActionBarView getActionBarView() {
return actionBarView;
}
}
// In the activity that renders the action bar, set the listener
public class ActionBarReloadActivity extends Activity {
// Setup a listener to retain a reference
MyActionBarListener listener = new MyActionBarListener();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String entityKey = "your_key";
// Use the listener when you show the action bar
SocializeUI.getInstance().showActionBar(this, R.layout.your_layout, entityKey, listener);
}
}
// Later (After the action bar has loaded!), you can reference the view to refresh
final ActionBarView view = listener.getActionBarView();
if(view != null) {
Socialize.getSocialize().addEntity("new_entity", "new_entity_name", new EntityAddListener() {
@Override
public void onError(SocializeException error) {
// Handle error
}
@Override
public void onCreate(Entity entity) {
view.setEntityKey(entity.getKey());
view.refresh();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment