Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17621]: Add support for dividerHeight property. #6793

Merged
merged 2 commits into from Apr 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -37,7 +37,8 @@
TiC.PROPERTY_SEARCH_VIEW,
TiC.PROPERTY_CASE_INSENSITIVE_SEARCH,
TiC.PROPERTY_HEADER_DIVIDERS_ENABLED,
TiC.PROPERTY_FOOTER_DIVIDERS_ENABLED
TiC.PROPERTY_FOOTER_DIVIDERS_ENABLED,
TiC.PROPERTY_DIVIDER_HEIGHT
})
public class ListViewProxy extends TiViewProxy {

Expand Down
Expand Up @@ -35,7 +35,6 @@
import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar;
import ti.modules.titanium.ui.widget.searchbar.TiUISearchBar.OnSearchChangeListener;
import ti.modules.titanium.ui.widget.searchview.TiUISearchView;
import ti.modules.titanium.ui.widget.tableview.TiTableView;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
Expand All @@ -48,13 +47,13 @@
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.AbsListView.OnScrollListener;

public class TiListView extends TiUIView implements OnSearchChangeListener {

Expand All @@ -74,6 +73,7 @@ public class TiListView extends TiUIView implements OnSearchChangeListener {
private int headerFooterId;
public static LayoutInflater inflater;
private int titleId;
private int dividerHeight;
private ArrayList<Pair<Integer,Integer>> markers = new ArrayList<Pair<Integer,Integer>>();
private View headerView;
private View footerView;
Expand Down Expand Up @@ -480,6 +480,15 @@ public void processProperties(KrollDict d) {
this.caseInsensitive = TiConvert.toBoolean(d, TiC.PROPERTY_CASE_INSENSITIVE_SEARCH, true);
}

if (d.containsKey(TiC.PROPERTY_DIVIDER_HEIGHT)) {
TiDimension dHeight = TiConvert.toTiDimension(d.get(TiC.PROPERTY_DIVIDER_HEIGHT), -1);
int height = dHeight.getAsPixels(listView);
if (height > 0) {
dividerHeight = height;
listView.setDividerHeight(height);
}
}

if (d.containsKey(TiC.PROPERTY_SEPARATOR_COLOR)) {
String color = TiConvert.toString(d, TiC.PROPERTY_SEPARATOR_COLOR);
setSeparatorColor(color);
Expand Down Expand Up @@ -687,6 +696,13 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
} else if (key.equals(TiC.PROPERTY_SEPARATOR_COLOR)) {
String color = TiConvert.toString(newValue);
setSeparatorColor(color);
} else if (key.equals(TiC.PROPERTY_DIVIDER_HEIGHT)) {
TiDimension dHeight = TiConvert.toTiDimension(newValue, -1);
int height = dHeight.getAsPixels(listView);
if (height > 0) {
dividerHeight = height;
listView.setDividerHeight(height);
}
} else {
super.propertyChanged(key, oldValue, newValue, proxy);
}
Expand All @@ -703,9 +719,14 @@ private void setSearchListener(TiViewProxy searchView, TiUIView search)

private void setSeparatorColor(String color) {
int sepColor = TiColorHelper.parseColor(color);
int dividerHeight = listView.getDividerHeight();
int dHeight = 0;
if (dividerHeight == 0) {
dHeight = listView.getDividerHeight();
} else {
dHeight = dividerHeight;
}
listView.setDivider(new ColorDrawable(sepColor));
listView.setDividerHeight(dividerHeight);
listView.setDividerHeight(dHeight);
}

private void refreshItems() {
Expand Down
5 changes: 5 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Expand Up @@ -1127,6 +1127,11 @@ public class TiC
*/
public static final String PROPERTY_DISPLAY_ADDRESS = "displayAddress";

/**
* @module.api
*/
public static final String PROPERTY_DIVIDER_HEIGHT = "dividerHeight";

/**
* @module.api
*/
Expand Down
9 changes: 9 additions & 0 deletions apidoc/Titanium/UI/ListView.yml
Expand Up @@ -529,6 +529,15 @@ properties:
type: [String, Number]
default: Titanium.UI.LIST_ITEM_TEMPLATE_DEFAULT

- name: dividerHeight
summary: height of the ListView divider.
description: |
Height of the ListView divider, in platform-specific units. If undefined, default native height will be used.
Numerical inputs are treated as pixels. For example, 3 and "3px" are equivalent.
type: [String, Number]
since: "4.1.0"
platforms: [android]

- name: footerDividersEnabled
summary: When set to false, the ListView will not draw the divider before the footer view.
type: Boolean
Expand Down