Merge "Revert "Add search bar to SearchActivity."" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
37f87b6c64
@@ -213,8 +213,7 @@
|
|||||||
<activity android:name=".search2.SearchActivity"
|
<activity android:name=".search2.SearchActivity"
|
||||||
android:label="@string/search_settings"
|
android:label="@string/search_settings"
|
||||||
android:icon="@drawable/ic_search_history"
|
android:icon="@drawable/ic_search_history"
|
||||||
android:parentActivityName="Settings"
|
android:parentActivityName="Settings">
|
||||||
android:theme="@style/Theme.Settings.NoActionBar">
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Top-level settings -->
|
<!-- Top-level settings -->
|
||||||
|
@@ -20,4 +20,5 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/main_content"
|
android:id="@+id/main_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="match_parent"/>
|
android:layout_width="match_parent"
|
||||||
|
android:background="@color/material_grey_300"/>
|
||||||
|
@@ -15,22 +15,39 @@
|
|||||||
-->
|
-->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/search_panel"
|
android:id="@+id/search_panel"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/search_panel_list_background">
|
android:background="@drawable/search_panel_list_background">
|
||||||
|
|
||||||
<FrameLayout
|
<LinearLayout android:id="@+id/layout_recent_searches"
|
||||||
android:id="@+id/layout_results"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_alignParentTop="true">
|
||||||
|
|
||||||
|
<!-- Padding is included in the background -->
|
||||||
|
<android.support.v7.widget.RecyclerView android:id="@+id/list_recent_searches"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:paddingStart="@dimen/dashboard_padding_start"
|
||||||
|
android:paddingEnd="@dimen/dashboard_padding_end"
|
||||||
|
android:paddingTop="@dimen/dashboard_padding_top"
|
||||||
|
android:paddingBottom="@dimen/dashboard_padding_bottom"
|
||||||
|
android:scrollbarStyle="outsideOverlay"
|
||||||
|
android:headerDividersEnabled="false"
|
||||||
|
android:elevation="@dimen/search_panel_elevation"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:id="@+id/layout_results"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
android:layout_above="@id/feedback_popup"
|
android:layout_above="@id/feedback_popup"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- Padding is included in the background -->
|
<!-- Padding is included in the background -->
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView android:id="@+id/list_results"
|
||||||
android:id="@+id/list_results"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="@dimen/dashboard_padding_start"
|
android:paddingStart="@dimen/dashboard_padding_start"
|
||||||
@@ -44,14 +61,10 @@
|
|||||||
android:id="@+id/no_results_layout"
|
android:id="@+id/no_results_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingTop="96dp"
|
android:paddingTop="80dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?android:attr/actionBarSize"/>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_height="160dp"
|
android:layout_height="160dp"
|
||||||
android:layout_width="160dp"
|
android:layout_width="160dp"
|
||||||
@@ -65,30 +78,8 @@
|
|||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:text="@string/search_settings_no_results"
|
android:text="@string/search_settings_no_results"
|
||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
|
||||||
android:id="@+id/search_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="@dimen/search_bar_margin"
|
|
||||||
app:cardCornerRadius="2dp"
|
|
||||||
app:cardBackgroundColor="?android:attr/colorBackground"
|
|
||||||
app:cardElevation="2dp">
|
|
||||||
|
|
||||||
<SearchView
|
|
||||||
android:id="@+id/search_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:iconifiedByDefault="false"
|
|
||||||
android:imeOptions="actionSearch|flagNoExtractUi"
|
|
||||||
android:theme="?android:attr/actionBarTheme"/>
|
|
||||||
|
|
||||||
</android.support.v7.widget.CardView>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/search_feedback"/>
|
<include layout="@layout/search_feedback"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -165,12 +165,6 @@
|
|||||||
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.SubSettings</item>
|
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.SubSettings</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Variant of the settings theme with no action bar. -->
|
|
||||||
<style name="Theme.Settings.NoActionBar">
|
|
||||||
<item name="android:windowActionBar">false</item>
|
|
||||||
<item name="android:windowNoTitle">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Theme.ProvisioningActivity" parent="@android:style/Theme.Translucent.NoTitleBar">
|
<style name="Theme.ProvisioningActivity" parent="@android:style/Theme.Translucent.NoTitleBar">
|
||||||
<item name="android:windowAnimationStyle">@null</item>
|
<item name="android:windowAnimationStyle">@null</item>
|
||||||
<item name="android:windowIsTranslucent">true</item>
|
<item name="android:windowIsTranslucent">true</item>
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.search2;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
public class HeaderDecorator extends RecyclerView.ItemDecoration {
|
|
||||||
@Override
|
|
||||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
|
|
||||||
RecyclerView.State state) {
|
|
||||||
super.getItemOffsets(outRect, view, parent, state);
|
|
||||||
if (parent.getChildAdapterPosition(view) > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Context context = view.getContext();
|
|
||||||
TypedArray ta = context.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
|
|
||||||
outRect.top = ta.getDimensionPixelSize(0, 0);
|
|
||||||
ta.recycle();
|
|
||||||
|
|
||||||
outRect.top += 2 * context.getResources().getDimensionPixelSize(R.dimen.search_bar_margin);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.search2;
|
package com.android.settings.search2;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.LoaderManager;
|
import android.app.LoaderManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -31,6 +32,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.LinearLayout.LayoutParams;
|
||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
@@ -58,6 +60,9 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
|||||||
LoaderManager.LoaderCallbacks<List<? extends SearchResult>>, IndexingCallback {
|
LoaderManager.LoaderCallbacks<List<? extends SearchResult>>, IndexingCallback {
|
||||||
private static final String TAG = "SearchFragment";
|
private static final String TAG = "SearchFragment";
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int SEARCH_TAG = "SearchViewTag".hashCode();
|
||||||
|
|
||||||
// State values
|
// State values
|
||||||
private static final String STATE_QUERY = "state_query";
|
private static final String STATE_QUERY = "state_query";
|
||||||
private static final String STATE_SHOWING_SAVED_QUERY = "state_showing_saved_query";
|
private static final String STATE_SHOWING_SAVED_QUERY = "state_showing_saved_query";
|
||||||
@@ -90,12 +95,12 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SavedQueryController mSavedQueryController;
|
SavedQueryController mSavedQueryController;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||||
SearchFeatureProvider mSearchFeatureProvider;
|
SearchFeatureProvider mSearchFeatureProvider;
|
||||||
|
|
||||||
private SearchResultsAdapter mSearchAdapter;
|
private SearchResultsAdapter mSearchAdapter;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||||
RecyclerView mResultsRecyclerView;
|
RecyclerView mResultsRecyclerView;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SearchView mSearchView;
|
SearchView mSearchView;
|
||||||
@@ -144,6 +149,13 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
|
final ActionBar actionBar = activity.getActionBar();
|
||||||
|
mSearchView = makeSearchView(actionBar, mQuery);
|
||||||
|
actionBar.setCustomView(mSearchView);
|
||||||
|
actionBar.setDisplayShowCustomEnabled(true);
|
||||||
|
actionBar.setDisplayShowTitleEnabled(false);
|
||||||
|
mSearchView.requestFocus();
|
||||||
|
|
||||||
// Run the Index update only if we have some space
|
// Run the Index update only if we have some space
|
||||||
if (!Utils.isLowStorage(activity)) {
|
if (!Utils.isLowStorage(activity)) {
|
||||||
mSearchFeatureProvider.updateIndex(activity, this /* indexingCallback */);
|
mSearchFeatureProvider.updateIndex(activity, this /* indexingCallback */);
|
||||||
@@ -160,14 +172,8 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
|||||||
mResultsRecyclerView.setAdapter(mSearchAdapter);
|
mResultsRecyclerView.setAdapter(mSearchAdapter);
|
||||||
mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||||
mResultsRecyclerView.addOnScrollListener(mScrollListener);
|
mResultsRecyclerView.addOnScrollListener(mScrollListener);
|
||||||
mResultsRecyclerView.addItemDecoration(new HeaderDecorator());
|
|
||||||
|
|
||||||
mNoResultsView = view.findViewById(R.id.no_results_layout);
|
mNoResultsView = view.findViewById(R.id.no_results_layout);
|
||||||
|
|
||||||
mSearchView = view.findViewById(R.id.search_view);
|
|
||||||
mSearchView.setQuery(mQuery, false /* submitQuery */);
|
|
||||||
mSearchView.setOnQueryTextListener(this);
|
|
||||||
mSearchView.requestFocus();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +347,19 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
|||||||
onQueryTextChange(query);
|
onQueryTextChange(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||||
|
SearchView makeSearchView(ActionBar actionBar, String query) {
|
||||||
|
final SearchView searchView = new SearchView(actionBar.getThemedContext());
|
||||||
|
searchView.setIconifiedByDefault(false);
|
||||||
|
searchView.setQuery(query, false /* submitQuery */);
|
||||||
|
searchView.setOnQueryTextListener(this);
|
||||||
|
searchView.setTag(SEARCH_TAG, searchView);
|
||||||
|
final LayoutParams lp =
|
||||||
|
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||||
|
searchView.setLayoutParams(lp);
|
||||||
|
return searchView;
|
||||||
|
}
|
||||||
|
|
||||||
private void hideKeyboard() {
|
private void hideKeyboard() {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@@ -28,13 +28,11 @@ import org.junit.runner.RunWith;
|
|||||||
import static android.support.test.espresso.Espresso.onView;
|
import static android.support.test.espresso.Espresso.onView;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.hasFocus;
|
import static android.support.test.espresso.matcher.ViewMatchers.hasFocus;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
|
import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
import static android.support.test.espresso.matcher.ViewMatchers.withTagKey;
|
||||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.core.AllOf.allOf;
|
import static org.hamcrest.core.AllOf.allOf;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -45,7 +43,7 @@ public class SearchFragmentEspressoTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_OpenKeyboardOnSearchLaunch() {
|
public void test_OpenKeyboardOnSearchLaunch() {
|
||||||
onView(allOf(hasFocus(), withId(R.id.search_view)))
|
onView(allOf(hasFocus(), withTagKey(SearchFragment.SEARCH_TAG)))
|
||||||
.check(matches(withClassName(containsString(SearchView.class.getName()))));
|
.check(matches(withClassName(containsString(SearchView.class.getName()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,10 +93,6 @@ public class SettingsRobolectricTestRunner extends RobolectricTestRunner {
|
|||||||
getPackageName(),
|
getPackageName(),
|
||||||
Fs.fileFromPath("./frameworks/support/v7/appcompat/res"),
|
Fs.fileFromPath("./frameworks/support/v7/appcompat/res"),
|
||||||
null));
|
null));
|
||||||
paths.add(new ResourcePath(
|
|
||||||
getPackageName(),
|
|
||||||
Fs.fileFromPath("./frameworks/support/v7/cardview/res"),
|
|
||||||
null));
|
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.search2;
|
|
||||||
|
|
||||||
import android.app.LoaderManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Loader;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SettingsRobolectricTestRunner;
|
|
||||||
import com.android.settings.TestConfig;
|
|
||||||
import com.android.settings.search.IndexingCallback;
|
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Answers;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.Robolectric;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
import org.robolectric.util.ActivityController;
|
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.anyString;
|
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
|
||||||
public class HeaderDecoratorTest {
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
||||||
private View mView;
|
|
||||||
@Mock
|
|
||||||
private RecyclerView mRecyclerView;
|
|
||||||
@Mock
|
|
||||||
private RecyclerView.LayoutParams mLayoutParams;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
when(mView.getLayoutParams()).thenReturn(mLayoutParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testgetItemOffsets_positionZero_headerAdded() {
|
|
||||||
HeaderDecorator decorator = new HeaderDecorator();
|
|
||||||
Rect outRect = new Rect();
|
|
||||||
when(mRecyclerView.getChildAdapterPosition(any(View.class))).thenReturn(0);
|
|
||||||
when(mView.getContext().obtainStyledAttributes(any(int[].class))
|
|
||||||
.getDimensionPixelSize(0, 0)).thenReturn(20);
|
|
||||||
when(mView.getContext().getResources().getDimensionPixelSize(R.dimen.search_bar_margin))
|
|
||||||
.thenReturn(5);
|
|
||||||
|
|
||||||
decorator.getItemOffsets(outRect, mView, mRecyclerView, null);
|
|
||||||
|
|
||||||
assertThat(outRect).isEqualTo(new Rect(0, 30, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testgetItemOffsets_positionGreaterThanZero_noDecoration() {
|
|
||||||
HeaderDecorator decorator = new HeaderDecorator();
|
|
||||||
Rect outRect = new Rect();
|
|
||||||
when(mRecyclerView.getChildAdapterPosition(any(View.class))).thenReturn(1);
|
|
||||||
|
|
||||||
decorator.getItemOffsets(outRect, mView, mRecyclerView, null);
|
|
||||||
|
|
||||||
assertThat(outRect).isEqualTo(new Rect(0, 0, 0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user