Skip to content

Commit

Permalink
Merge pull request #6212 from hieupham007/timob-17482
Browse files Browse the repository at this point in the history
[TIMOB-17482]: Add support for bordered searchView inside tableView
  • Loading branch information
pingwang2011 committed Oct 15, 2014
2 parents 3f39dda + 450444b commit 3eb2259
Showing 1 changed file with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.appcelerator.titanium.TiLifecycle.OnLifecycleEvent;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiBorderWrapperView;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.SearchBarProxy;
Expand All @@ -29,13 +30,16 @@
import android.os.Build;
import android.view.Gravity;
import android.view.View;
import android.view.ViewParent;
import android.widget.ListView;
import android.widget.RelativeLayout;

public class TiUITableView extends TiUIView
implements OnItemClickedListener, OnItemLongClickedListener, OnLifecycleEvent
{
private static final String TAG = "TitaniumTableView";

private static final int SEARCHVIEW_ID = 102;

protected TiTableView tableView;

Expand Down Expand Up @@ -145,16 +149,15 @@ public void processProperties(KrollDict d)
}
if (!(d.containsKey(TiC.PROPERTY_SEARCH_AS_CHILD) && !TiConvert.toBoolean(d.get(TiC.PROPERTY_SEARCH_AS_CHILD)))) {


search.getNativeView().setId(102);
View sView = search.getNativeView();

RelativeLayout layout = new RelativeLayout(proxy.getActivity());
layout.setGravity(Gravity.NO_GRAVITY);
layout.setPadding(0, 0, 0, 0);

RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
p.addRule(RelativeLayout.ALIGN_PARENT_TOP);
p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
Expand All @@ -167,15 +170,26 @@ public void processProperties(KrollDict d)
}
p.height = rawHeight.getAsPixels(layout);

layout.addView(search.getNativeView(), p);
//Check to see if searchView has a border
ViewParent parent = sView.getParent();
if (parent instanceof TiBorderWrapperView) {
TiBorderWrapperView v = (TiBorderWrapperView) parent;
v.setId(SEARCHVIEW_ID);
layout.addView(v, p);
} else if (parent == null) {
sView.setId(SEARCHVIEW_ID);
layout.addView(sView, p);
} else {
Log.e(TAG, "Searchview already has parent, cannot add to tableview.", Log.DEBUG_MODE);
}

p = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
p.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
p.addRule(RelativeLayout.BELOW, 102);
p.addRule(RelativeLayout.BELOW, SEARCHVIEW_ID);
layout.addView(tableView, p);
setNativeView(layout);
} else {
Expand Down

0 comments on commit 3eb2259

Please sign in to comment.