Skip to content

Commit

Permalink
Merge pull request #3191 from joshthecoder/timob-11340
Browse files Browse the repository at this point in the history
[TIMOB-11340] Android: Can't add menu items to ActionBar-style tab group
  • Loading branch information
hieupham007 committed Oct 13, 2012
2 parents ab56add + eafaaa3 commit f6eab19
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ti.modules.titanium.ui;

import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.proxy.ActivityProxy;

import ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTab;

/**
* A special view for the content of a tab.
* @see {@link TiUIAbstractTab#getContentView()}
*/
@Kroll.proxy(parentModule=UIModule.class)
public class TabContentViewProxy extends ViewProxy {
@Kroll.getProperty(name="_internalActivity")
@Override
public ActivityProxy getActivityProxy() {
return super.getActivityProxy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ protected void handleOpen(KrollDict options)
public void windowCreated(TiBaseActivity activity) {
tabGroupActivity = new WeakReference<Activity>(activity);
activity.setWindowProxy(this);
setActivity(activity);

// Use the navigation tabs if this platform supports the action bar.
// Otherwise we will fall back to using the TabHost implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
import org.appcelerator.titanium.proxy.TiWindowProxy;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.TabContentViewProxy;
import ti.modules.titanium.ui.TabProxy;
import ti.modules.titanium.ui.ViewProxy;
import android.app.Activity;
import android.graphics.Color;
import android.view.View;


public abstract class TiUIAbstractTab extends TiUIView {
private TiUIView contentView;
private TabContentViewProxy contentView;

public TiUIAbstractTab(TabProxy proxy) {
super(proxy);
Expand Down Expand Up @@ -47,17 +48,22 @@ public View getContentView() {
return emptyContent;
}

ViewProxy contentViewProxy = new ViewProxy();
contentViewProxy.setActivity(windowProxy.getActivity());
//Assign parent so events bubble up correctly.
contentViewProxy.setParent(proxy);
contentView = contentViewProxy.getOrCreateView();
contentView = new TabContentViewProxy();

// A tab's window should be bound to the tab group's activity.
// In order for the 'activity' property to work correctly
// we need to set the content view's activity to that of the group.
Activity tabGroupActivity = ((TabProxy) proxy).getTabGroup().getActivity();
contentView.setActivity(tabGroupActivity);

// Assign parent so events bubble up correctly.
contentView.setParent(proxy);

// Allow the window to fill the content view with its children.
windowProxy.getKrollObject().setWindow(contentViewProxy);
windowProxy.getKrollObject().setWindow(contentView);
}

return contentView.getNativeView();
return contentView.getOrCreateView().getNativeView();
}

private TiWindowProxy getWindowProxy() {
Expand Down

0 comments on commit f6eab19

Please sign in to comment.