下面列出了android.os.Bundle#getCharSequenceArrayList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static TestClassBundled unbundle(Bundle bundle, Gson gson) {
return new AutoValue_TestClassBundled(
bundle,
bundle.getByte("some_byte"),
bundle.getBoolean("some_boolean"),
bundle.getShort("some_short"),
bundle.getInt("some_int"),
bundle.getLong("some_long"),
bundle.getChar("some_char"),
bundle.getFloat("some_float"),
bundle.getDouble("some_double"),
bundle.getString("some_string"),
bundle.getCharSequence("some_char_sequence"),
bundle.getParcelable("some_parcelable"),
bundle.getParcelableArrayList("some_parcelable_array_list"),
bundle.getSparseParcelableArray("some_parcelable_sparse_array"),
bundle.getSerializable("some_serializable"),
bundle.getIntegerArrayList("some_integer_array_list"),
bundle.getStringArrayList("some_string_array_list"),
bundle.getCharSequenceArrayList("some_char_sequence_array_list"),
bundle.getByteArray("some_byte_array"),
bundle.getShortArray("some_short_array"),
bundle.getCharArray("some_char_array"),
bundle.getFloatArray("some_float_array"),
gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()),
gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()),
gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType()));
}
public ArrayList<CharSequence> getCharSequenceArrayList(Bundle state, String key) {
return state.getCharSequenceArrayList(key + mBaseKey);
}
@Nullable
@Override
public List<CharSequence> get(@NonNull String key, @NonNull Bundle bundle) {
return bundle.getCharSequenceArrayList(key);
}
public static void bind(@NonNull ExampleActivity target, @NonNull Bundle source) {
if (source.containsKey("type2")) {
target.type2 = (int) source.getInt("type2");
} else {
throw new IllegalStateException("type2 is required, but not found in the bundle.");
}
if (source.containsKey("name")) {
target.setName( (String) source.getString("name") );
} else {
throw new IllegalStateException("name is required, but not found in the bundle.");
}
if (source.containsKey("type1")) {
target.type1 = (int) source.getInt("type1");
}
if (source.containsKey("optionalName")) {
target.setAltName( (String) source.getString("optionalName") );
}
if (source.containsKey("fooList")) {
target.fooList = (ArrayList<CharSequence>) source.getCharSequenceArrayList("fooList");
}
if (source.containsKey("exampleData")) {
ParcelableConverter exampleDataConverter = new ParcelableConverter();
target.exampleData = (ExampleData) exampleDataConverter.original( source.getParcelable("exampleData") );
}
if (source.containsKey("persons")) {
target.persons = source.getParcelableArrayList("persons");
}
if (source.containsKey("exampleData2")) {
ParcelableConverter exampleData2Converter = new ParcelableConverter();
target.setExampleData2( (ExampleData) exampleData2Converter.original( source.getParcelable("exampleData2") ) );
}
if (source.containsKey("integerField")) {
target.integerField = (Integer) source.getInt("integerField");
}
if (source.containsKey("booleanField")) {
target.booleanField = (Boolean) source.getBoolean("booleanField");
}
if (source.containsKey("intOption")) {
target.intOption = (int) source.getInt("intOption");
}
}
@Override
public ArrayList<CharSequence> readFromBundle(Bundle bundle, String key) {
return bundle.getCharSequenceArrayList(key);
}