Github user sospartan commented on a diff in the pull request:
https://github.com/apache/incubator-weex/pull/234#discussion_r110518695
--- Diff:
android/sdk/src/main/java/com/taobao/weex/appfram/pickers/WXPickersModule.java
---
@@ -361,6 +402,98 @@ public void onClick(DialogInterface dialog, int which)
{
callback.invoke(ret);
}
})
- .show();
+ .setCustomTitle(makeTitleView(mWXSDKInstance.getContext(),
options))
+ .create();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ dialog.create();
+ }
+
+ final ListView listView = dialog.getListView();
+ listView.setOnItemClickListener(new
AdapterView.OnItemClickListener() {
+ private View previousView;
+ private int selectionColor = getColor(options,
"selectionColor", Color.TRANSPARENT);
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int
position, long id) {
+ selected = position;
+ if (previousView == view) {
+ return;
+ }
+ if (previousView != null) {
+ previousView.setBackgroundColor(Color.TRANSPARENT);
+ if (previousView instanceof Checkable) {
+ ((Checkable) previousView).toggle();
+ }
+ }
+ if (view instanceof Checkable) {
+ ((Checkable) view).toggle();
+ }
+ view.setBackgroundColor(selectionColor);
+ previousView = view;
+ }
+ });
+
+ listView.post(new Runnable() {
+ @Override
+ public void run() {
+ if (selectedView != null) {
+ listView.performItemClick(selectedView, selected,
selectedView.getId());
+ }
+ }
+ });
+
+ dialog.getWindow().getDecorView().post(new Runnable() {
+ @Override
+ public void run() {
+ Button confirm =
dialog.getButton(DialogInterface.BUTTON_POSITIVE);
+ Button cancel =
dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
+
+ if (confirm != null) {
+ String confirmTitle = getOption(options,
"confirmTitle", null);
+ int confirmColor = getColor(options,
"confirmTitleColor", Color.TRANSPARENT);
+
+ if (confirmTitle != null) {
+ confirm.setText(confirmTitle);
+ }
+
+ if (confirmColor != Color.TRANSPARENT) {
+ confirm.setTextColor(confirmColor);
+ }
+ }
+
+ if (cancel != null) {
+ String cancelTitle = getOption(options, "cancelTitle",
null);
+ int cancelColor = getColor(options,
"cancelTitleColor", Color.TRANSPARENT);
+
+ if (cancelTitle != null) {
+ cancel.setText(cancelTitle);
+ }
+
+ if (cancelColor != Color.TRANSPARENT) {
+ cancel.setTextColor(cancelColor);
+ }
+ }
+ }
+ });
+
+ dialog.show();
+ }
+
+ private TextView makeTitleView(Context context, Map<String, Object>
options) {
+ String text = getOption(options, "title", null);
+ if (text == null) {
+ return null;
+ }
+ TextView textView = new TextView(context);
+ textView.setLayoutParams(new
ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
+ int padding = WXViewUtils.dip2px(12);
+ textView.setPadding(padding, padding, padding, padding);
+ textView.getPaint().setFakeBoldText(true);
+ textView.setBackgroundColor(getColor(options,
"titleBackgroundColor", Color.TRANSPARENT));
--- End diff --
Make `"titleBackgroundColor"` constant.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---