Java Code Examples for android.view.AbsSavedState#EMPTY_STATE

The following examples show how to use android.view.AbsSavedState#EMPTY_STATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuidanceStreetLabelViewTest.java    From msdkui-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testPanelDataIsParcelable() {
    final GuidanceStreetLabelData data = createData(STREET_NAME, COLOR);
    GuidanceStreetLabelView.SavedState savedState = new GuidanceStreetLabelView.SavedState(AbsSavedState.EMPTY_STATE);
    savedState.setStateToSave(data);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceStreetLabelView.SavedState createdFromParcel = GuidanceStreetLabelView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getSavedState());

    // test for null
    savedState.setStateToSave(null);
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    createdFromParcel = GuidanceStreetLabelView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getSavedState());
}
 
Example 2
Source File: GuidanceSpeedViewTest.java    From msdkui-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testViewDataIsParcelable() {
    final GuidanceSpeedData data = new GuidanceSpeedData(VELOCITY, SPEED_LIMIT);
    GuidanceSpeedView.SavedState savedState = new GuidanceSpeedView.SavedState(
            AbsSavedState.EMPTY_STATE);
    savedState.setStateToSave(data, RED_COLOR, BLUE_COLOR);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceSpeedView.SavedState createdFromParcel = GuidanceSpeedView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getSavedSpeedData());
    assertThat(createdFromParcel.getSavedValueTextColor(), is(RED_COLOR));
    assertThat(createdFromParcel.getSavedUnitTextColor(), is(BLUE_COLOR));
}
 
Example 3
Source File: GuidanceManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testPanelDataIsParcelable() {
    final GuidanceManeuverData data = createData(mIconId, mDistance, mInfo1, mInfo2);
    GuidanceManeuverView.SavedState savedState = new GuidanceManeuverView.SavedState(AbsSavedState.EMPTY_STATE);
    savedState.setViewState(new GuidanceManeuverView.State(data));
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceManeuverView.SavedState createdFromParcel = GuidanceManeuverView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getViewState());
}
 
Example 4
Source File: GuidanceManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testPanelNoDataIsParcelable() {
    GuidanceManeuverView.SavedState savedState = new GuidanceManeuverView.SavedState(AbsSavedState.EMPTY_STATE);
    savedState.setViewState(GuidanceManeuverView.State.NO_DATA);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceManeuverView.SavedState createdFromParcel = GuidanceManeuverView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getViewState());
    assertThat(createdFromParcel.getViewState(), equalTo(GuidanceManeuverView.State.NO_DATA));
}
 
Example 5
Source File: GuidanceManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testPanelUpdatingStateIsParcelable() {
    GuidanceManeuverView.SavedState savedState = new GuidanceManeuverView.SavedState(AbsSavedState.EMPTY_STATE);
    savedState.setViewState(GuidanceManeuverView.State.UPDATING);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceManeuverView.SavedState createdFromParcel = GuidanceManeuverView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getViewState());
    assertThat(createdFromParcel.getViewState(), equalTo(GuidanceManeuverView.State.UPDATING));
}
 
Example 6
Source File: GuidanceEstimatedArrivalViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewDataIsParcelable() {
    final GuidanceEstimatedArrivalViewData data = new GuidanceEstimatedArrivalViewData(ETA_DATE, DISTANCE, DURATION);
    GuidanceEstimatedArrivalView.SavedState savedState = new GuidanceEstimatedArrivalView.SavedState(
            AbsSavedState.EMPTY_STATE);
    savedState.setStateToSave(data);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceEstimatedArrivalView.SavedState createdFromParcel = GuidanceEstimatedArrivalView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getSavedState());
}
 
Example 7
Source File: GuidanceSpeedLimitViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewDataIsParcelable() {
    final GuidanceSpeedData data = new GuidanceSpeedData(VELOCITY, SPEED_LIMIT);
    GuidanceSpeedLimitView.SavedState savedState = new GuidanceSpeedLimitView.SavedState(AbsSavedState.EMPTY_STATE);
    savedState.setStateToSave(data);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceSpeedLimitView.SavedState createdFromParcel = GuidanceSpeedLimitView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getSavedState());
}
 
Example 8
Source File: GuidanceNextManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testPanelDataIsParcelable() {
    final GuidanceNextManeuverData data = createData(mIconId, mDistance, mStreetName);
    GuidanceNextManeuverView.SavedState savedState = new GuidanceNextManeuverView.SavedState(AbsSavedState.EMPTY_STATE);
    savedState.setStateToSave(data);
    Parcel parcel = Parcel.obtain();
    savedState.writeToParcel(parcel, savedState.describeContents());
    parcel.setDataPosition(0);

    GuidanceNextManeuverView.SavedState createdFromParcel = GuidanceNextManeuverView.SavedState.CREATOR.createFromParcel(
            parcel);
    assertNotNull(createdFromParcel.getSavedState());
}
 
Example 9
Source File: ExpandableSavedStateTest.java    From ExpandableLayout with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteToParcel() {
    final Parcelable parcelable = new View.BaseSavedState(AbsSavedState.EMPTY_STATE);
    final ExpandableSavedState ss = new ExpandableSavedState(parcelable);
    ss.setSize(1000);
    ss.setWeight(0.5f);

    final Parcel parcel = Parcel.obtain();
    ss.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);

    final ExpandableSavedState target = ExpandableSavedState.CREATOR.createFromParcel(parcel);
    assertThat(target.getSize(), is(1000));
    assertThat(target.getWeight(), is(0.5f));
}
 
Example 10
Source File: SavedStateTest.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public void testGridViewSavedState() throws Throwable {
    Parcel parcel = Parcel.obtain();
    ObservableGridView.SavedState state1 = new ObservableGridView.SavedState(AbsSavedState.EMPTY_STATE);
    state1.prevFirstVisiblePosition = 1;
    state1.prevFirstVisibleChildHeight = 2;
    state1.prevScrolledChildrenHeight = 3;
    state1.prevScrollY = 4;
    state1.scrollY = 5;
    state1.childrenHeights = new SparseIntArray();
    state1.childrenHeights.put(0, 10);
    state1.childrenHeights.put(1, 20);
    state1.childrenHeights.put(2, 30);
    state1.writeToParcel(parcel, 0);

    parcel.setDataPosition(0);

    ObservableGridView.SavedState state2 = ObservableGridView.SavedState.CREATOR.createFromParcel(parcel);
    assertNotNull(state2);
    assertEquals(state1.prevFirstVisiblePosition, state2.prevFirstVisiblePosition);
    assertEquals(state1.prevFirstVisibleChildHeight, state2.prevFirstVisibleChildHeight);
    assertEquals(state1.prevScrolledChildrenHeight, state2.prevScrolledChildrenHeight);
    assertEquals(state1.prevScrollY, state2.prevScrollY);
    assertEquals(state1.scrollY, state2.scrollY);
    assertNotNull(state1.childrenHeights);
    assertEquals(3, state1.childrenHeights.size());
    assertEquals(10, state1.childrenHeights.get(0));
    assertEquals(20, state1.childrenHeights.get(1));
    assertEquals(30, state1.childrenHeights.get(2));
}
 
Example 11
Source File: SavedStateTest.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public void testListViewSavedState() throws Throwable {
    Parcel parcel = Parcel.obtain();
    ObservableListView.SavedState state1 = new ObservableListView.SavedState(AbsSavedState.EMPTY_STATE);
    state1.prevFirstVisiblePosition = 1;
    state1.prevFirstVisibleChildHeight = 2;
    state1.prevScrolledChildrenHeight = 3;
    state1.prevScrollY = 4;
    state1.scrollY = 5;
    state1.childrenHeights = new SparseIntArray();
    state1.childrenHeights.put(0, 10);
    state1.childrenHeights.put(1, 20);
    state1.childrenHeights.put(2, 30);
    state1.writeToParcel(parcel, 0);

    parcel.setDataPosition(0);

    ObservableListView.SavedState state2 = ObservableListView.SavedState.CREATOR.createFromParcel(parcel);
    assertNotNull(state2);
    assertEquals(state1.prevFirstVisiblePosition, state2.prevFirstVisiblePosition);
    assertEquals(state1.prevFirstVisibleChildHeight, state2.prevFirstVisibleChildHeight);
    assertEquals(state1.prevScrolledChildrenHeight, state2.prevScrolledChildrenHeight);
    assertEquals(state1.prevScrollY, state2.prevScrollY);
    assertEquals(state1.scrollY, state2.scrollY);
    assertNotNull(state1.childrenHeights);
    assertEquals(3, state1.childrenHeights.size());
    assertEquals(10, state1.childrenHeights.get(0));
    assertEquals(20, state1.childrenHeights.get(1));
    assertEquals(30, state1.childrenHeights.get(2));
}
 
Example 12
Source File: SavedStateTest.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public void testRecyclerViewSavedState() throws Throwable {
    Parcel parcel = Parcel.obtain();
    ObservableRecyclerView.SavedState state1 = new ObservableRecyclerView.SavedState(AbsSavedState.EMPTY_STATE);
    state1.prevFirstVisiblePosition = 1;
    state1.prevFirstVisibleChildHeight = 2;
    state1.prevScrolledChildrenHeight = 3;
    state1.prevScrollY = 4;
    state1.scrollY = 5;
    state1.childrenHeights = new SparseIntArray();
    state1.childrenHeights.put(0, 10);
    state1.childrenHeights.put(1, 20);
    state1.childrenHeights.put(2, 30);
    state1.writeToParcel(parcel, 0);

    parcel.setDataPosition(0);

    ObservableRecyclerView.SavedState state2 = ObservableRecyclerView.SavedState.CREATOR.createFromParcel(parcel);
    assertNotNull(state2);
    assertEquals(state1.prevFirstVisiblePosition, state2.prevFirstVisiblePosition);
    assertEquals(state1.prevFirstVisibleChildHeight, state2.prevFirstVisibleChildHeight);
    assertEquals(state1.prevScrolledChildrenHeight, state2.prevScrolledChildrenHeight);
    assertEquals(state1.prevScrollY, state2.prevScrollY);
    assertEquals(state1.scrollY, state2.scrollY);
    assertNotNull(state1.childrenHeights);
    assertEquals(3, state1.childrenHeights.size());
    assertEquals(10, state1.childrenHeights.get(0));
    assertEquals(20, state1.childrenHeights.get(1));
    assertEquals(30, state1.childrenHeights.get(2));
}
 
Example 13
Source File: SavedStateTest.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public void testScrollViewSavedState() throws Throwable {
    Parcel parcel = Parcel.obtain();
    ObservableScrollView.SavedState state1 = new ObservableScrollView.SavedState(AbsSavedState.EMPTY_STATE);
    state1.prevScrollY = 1;
    state1.scrollY = 2;
    state1.writeToParcel(parcel, 0);

    parcel.setDataPosition(0);

    ObservableScrollView.SavedState state2 = ObservableScrollView.SavedState.CREATOR.createFromParcel(parcel);
    assertNotNull(state2);
    assertEquals(state1.prevScrollY, state2.prevScrollY);
    assertEquals(state1.scrollY, state2.scrollY);
}
 
Example 14
Source File: SavedStateTest.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public void testWebViewSavedState() throws Throwable {
    Parcel parcel = Parcel.obtain();
    ObservableWebView.SavedState state1 = new ObservableWebView.SavedState(AbsSavedState.EMPTY_STATE);
    state1.prevScrollY = 1;
    state1.scrollY = 2;
    state1.writeToParcel(parcel, 0);

    parcel.setDataPosition(0);

    ObservableWebView.SavedState state2 = ObservableWebView.SavedState.CREATOR.createFromParcel(parcel);
    assertNotNull(state2);
    assertEquals(state1.prevScrollY, state2.prevScrollY);
    assertEquals(state1.scrollY, state2.scrollY);
}