Fix ClassCastException

Summary: Closes https://github.com/facebook/react-native/pull/7225

Differential Revision: D3234878

Pulled By: dmmiller

fb-gh-sync-id: 00f36f3c45e3492026729175e393812879149773
fbshipit-source-id: 00f36f3c45e3492026729175e393812879149773
This commit is contained in:
Thomas Leplus 2016-04-28 03:18:39 -07:00 committed by Facebook Github Bot 9
parent 1af47603cf
commit f323b02eff
2 changed files with 11 additions and 1 deletions

View File

@ -289,7 +289,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
} }
} }
if (!list.isEmpty()) { if (!list.isEmpty()) {
newFilters = (InputFilter[]) list.toArray(); newFilters = (InputFilter[]) list.toArray(new InputFilter[list.size()]);
} }
} }
} else { } else {

View File

@ -12,6 +12,7 @@ package com.facebook.react.views.textinput;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.text.InputType; import android.text.InputType;
import android.text.InputFilter;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Gravity; import android.view.Gravity;
import android.widget.EditText; import android.widget.EditText;
@ -330,4 +331,13 @@ public class ReactTextInputPropertyTest {
buildStyles("textAlign", null, "textAlignVertical", null)); buildStyles("textAlign", null, "textAlignVertical", null));
assertThat(view.getGravity()).isEqualTo(defaultGravity); assertThat(view.getGravity()).isEqualTo(defaultGravity);
} }
@Test
public void testMaxLength() {
ReactEditText view = mManager.createViewInstance(mThemedContext);
InputFilter[] filters = new InputFilter[] { new InputFilter.AllCaps() };
view.setFilters(filters);
mManager.setMaxLength(view, null);
assertThat(view.getFilters()).isEqualTo(filters);
}
} }