use of android.support.v4.widget.SwipeRefreshLayout in project materialistic by hidroh.
the class ListFragmentTest method testOnCreate.
@Test
public void testOnCreate() {
Bundle args = new Bundle();
args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
activity.getSupportFragmentManager().beginTransaction().add(android.R.id.list, Fragment.instantiate(activity, ListFragment.class.getName(), args)).commit();
assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isRefreshing();
controller.pause().stop().destroy();
}
use of android.support.v4.widget.SwipeRefreshLayout in project materialistic by hidroh.
the class ListFragmentTest method testEmptyResponse.
@Test
public void testEmptyResponse() {
Bundle args = new Bundle();
args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
activity.getSupportFragmentManager().beginTransaction().add(android.R.id.list, Fragment.instantiate(activity, ListFragment.class.getName(), args)).commit();
verify(itemManager).getStories(any(), eq(ItemManager.MODE_DEFAULT), listener.capture());
listener.getValue().onResponse(new Item[0]);
assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isNotRefreshing();
Assertions.assertThat(activity.findViewById(R.id.empty)).isNotVisible();
controller.pause().stop().destroy();
}
use of android.support.v4.widget.SwipeRefreshLayout in project materialistic by hidroh.
the class ListFragmentTest method testErrorResponse.
@Test
public void testErrorResponse() {
Bundle args = new Bundle();
args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
activity.getSupportFragmentManager().beginTransaction().add(android.R.id.list, Fragment.instantiate(activity, ListFragment.class.getName(), args)).commit();
verify(itemManager).getStories(any(), eq(ItemManager.MODE_DEFAULT), listener.capture());
listener.getValue().onError(null);
assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isNotRefreshing();
Assertions.assertThat(activity.findViewById(R.id.empty)).isVisible();
controller.pause().stop().destroy();
}
use of android.support.v4.widget.SwipeRefreshLayout in project materialistic by hidroh.
the class ItemFragmentMultiPageTest method testRefresh.
@Test
public void testRefresh() {
WebItem webItem = mock(WebItem.class);
when(webItem.getId()).thenReturn("1");
Bundle args = new Bundle();
args.putParcelable(ItemFragment.EXTRA_ITEM, webItem);
Fragment fragment = Fragment.instantiate(RuntimeEnvironment.application, ItemFragment.class.getName(), args);
makeVisible(fragment);
ShadowSwipeRefreshLayout shadowSwipeRefreshLayout = (ShadowSwipeRefreshLayout) ShadowExtractor.extract(fragment.getView().findViewById(R.id.swipe_layout));
shadowSwipeRefreshLayout.getOnRefreshListener().onRefresh();
verify(hackerNewsClient).getItem(eq("1"), eq(ItemManager.MODE_DEFAULT), listener.capture());
verify(hackerNewsClient).getItem(eq("1"), eq(ItemManager.MODE_NETWORK), listener.capture());
listener.getAllValues().get(1).onResponse(new TestHnItem(1L));
assertThat((SwipeRefreshLayout) fragment.getView().findViewById(R.id.swipe_layout)).isNotRefreshing();
verify(((TestItemActivity) fragment.getActivity()).itemChangedListener).onItemChanged(any(Item.class));
}
use of android.support.v4.widget.SwipeRefreshLayout in project SeriesGuide by UweTrottmann.
the class TraktCommentsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_comments, container, false);
unbinder = ButterKnife.bind(this, v);
swipeRefreshLayout.setSwipeableChildren(R.id.scrollViewComments, R.id.listViewShouts);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshCommentsWithNetworkCheck();
}
});
swipeRefreshLayout.setProgressViewOffset(false, getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_start_margin), getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_end_margin));
Utils.setSwipeRefreshLayoutColors(getActivity().getTheme(), swipeRefreshLayout);
list.setOnItemClickListener(mOnClickListener);
list.setEmptyView(emptyView);
buttonShout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
comment();
}
});
// disable comment button by default, enable if comment entered
buttonShout.setEnabled(false);
editTextShout.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
buttonShout.setEnabled(!TextUtils.isEmpty(s));
}
@Override
public void afterTextChanged(Editable s) {
}
});
// set initial view states
showProgressBar(true);
return v;
}
Aggregations