Skip to content

Commit

Permalink
remove Color.parseColor as we do processColor now
Browse files Browse the repository at this point in the history
  • Loading branch information
Noitidart committed Mar 13, 2018
1 parent 47c5cba commit dcc7a0b
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.support.v7.app.AlertDialog;
import android.os.Bundle;
import android.graphics.Color;
import android.content.Context;
import android.app.Dialog;
import android.app.DialogFragment;
Expand Down Expand Up @@ -162,7 +161,7 @@ public Dialog createDialog(Context activityContext, Bundle arguments) {
if (arguments.containsKey(ARG_HIGHLIGHT_COLOR)) {
String highlightColor = arguments.getString(ARG_HIGHLIGHT_COLOR);
if (highlightColor != null) {
input.setHighlightColor(Color.parseColor(highlightColor));
input.setHighlightColor(highlightColor);
}
}

Expand All @@ -187,7 +186,7 @@ public Dialog createDialog(Context activityContext, Bundle arguments) {
if (arguments.containsKey(ARG_COLOR)) {
String color = arguments.getString(ARG_COLOR);
if (color != null) {
input.setTextColor(Color.parseColor(color));
input.setTextColor(color);
}
}

Expand All @@ -196,7 +195,7 @@ public Dialog createDialog(Context activityContext, Bundle arguments) {
if (arguments.containsKey(ARG_PLACEHOLDER_COLOR)) {
String placeholderColor = arguments.getString(ARG_PLACEHOLDER_COLOR);
if (placeholderColor != null) {
input.setHintTextColor(Color.parseColor(arguments.getString(ARG_PLACEHOLDER_COLOR)));
input.setHintTextColor(arguments.getString(ARG_PLACEHOLDER_COLOR));
}
}
}
Expand Down Expand Up @@ -239,9 +238,9 @@ public void onStart() {

if (mButtonColor != null && !mButtonColor.isEmpty()) {
AlertDialog d = (AlertDialog) getDialog();
d.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.parseColor(mButtonColor));
d.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.parseColor(mButtonColor));
d.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(Color.parseColor(mButtonColor));
d.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(mButtonColor);
d.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(mButtonColor);
d.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(mButtonColor);
}
}

Expand Down

10 comments on commit dcc7a0b

@jeanregisser
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this compile?
You need to use int instead of string. and hence call arguments.getInt.
Also you might double check that you get the correct behavior when the key is null.

@Noitidart
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok i'm going to test this now, I hadn't tested I was working on something else. I'll give this my full focus.

@Noitidart
Copy link
Author

@Noitidart Noitidart commented on dcc7a0b Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanregisser it seems I can't do:

if (mButtonColor != null) {

even though i marked it as @Nullable, do you know how i can set int to null, how come @Nullable doesn't work?

I get:

C:\Users\Mercurius\Documents\GitHub\did\node_modules\react-native-prompt-android\android\src\main\java\im\shimo\react\prompt\RNPromptFragment.java:236: error: incomparable types: int and <null>
        if (mButtonColor != null) {

Is 0 a valid color? if not I can just test 0.

@jeanregisser
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Integer instead which can be null.

@jeanregisser
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 is transparent.

@Noitidart
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way awesome thank you! I actually never did Java before but needed these changes so was just a bunch of copy paste. Learning a lot here thanks!

@Noitidart
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanregisser apparently when I do options.getInt and it is null, it is giving me an error "Expected type double but got null". I was able to work around this by passing undefined. But is there a way to make options.getInt get a null value? options. I tried options.getInteger` but it says symbol not found:

C:\Users\Mercurius\Documents\GitHub\did\node_modules\react-native-prompt-android\android\src\main\java\im\shimo\react\prompt\RNPromptFragment.java:182: error: cannot find symbol
            Integer color = arguments.getInteger(ARG_COLOR);

@jeanregisser
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check if the key is null options.isNull(yourKey).

@Noitidart
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Thanks so much for the super fast reply!

@Noitidart
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooowee that was a doozie. Just comitted it. :)

Please sign in to comment.