use of android.support.v4.widget.SwipeRefreshLayout in project materialistic by hidroh.
the class ItemFragmentMultiPageTest method testRefreshFailed.
@Test
public void testRefreshFailed() {
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).onError(null);
assertThat((SwipeRefreshLayout) fragment.getView().findViewById(R.id.swipe_layout)).isNotRefreshing();
}
use of android.support.v4.widget.SwipeRefreshLayout in project RoboBinding by RoboBinding.
the class SwipeRefreshAddOnTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
view = new SwipeRefreshLayout(RuntimeEnvironment.application);
viewListeners = new SwipeRefreshLayoutAddOn(view);
}
use of android.support.v4.widget.SwipeRefreshLayout in project Gadgetbridge by Freeyourgadget.
the class ChartsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_charts);
initDates();
IntentFilter filterLocal = new IntentFilter();
filterLocal.addAction(GBApplication.ACTION_QUIT);
filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
Bundle extras = getIntent().getExtras();
if (extras != null) {
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
} else {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.activity_swipe_layout);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
fetchActivityData();
}
});
enableSwipeRefresh(true);
// Set up the ViewPager with the sections adapter.
viewPager = (ViewPager) findViewById(R.id.charts_pager);
viewPager.setAdapter(getPagerAdapter());
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
enableSwipeRefresh(state == ViewPager.SCROLL_STATE_IDLE);
}
});
dateBar = (ViewGroup) findViewById(R.id.charts_date_bar);
mDateControl = (TextView) findViewById(R.id.charts_text_date);
mDateControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String detailedDuration = formatDetailedDuration();
new ShowDurationDialog(detailedDuration, ChartsActivity.this).show();
}
});
mPrevButton = (Button) findViewById(R.id.charts_previous);
mPrevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handlePrevButtonClicked();
}
});
mNextButton = (Button) findViewById(R.id.charts_next);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleNextButtonClicked();
}
});
mPagerTabStrip = (PagerTabStrip) findViewById(R.id.charts_pagerTabStrip);
LinearLayout mainLayout = (LinearLayout) findViewById(R.id.charts_main_layout);
}
use of android.support.v4.widget.SwipeRefreshLayout in project RxBinding by JakeWharton.
the class RxSwipeRefreshLayoutTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
swipeRefreshLayout = new SwipeRefreshLayout(this);
swipeRefreshLayout.setId(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) {
handler.removeCallbacks(stopRefreshing);
handler.postDelayed(stopRefreshing, 300);
}
return false;
}
});
ScrollView scrollView = new ScrollView(this);
LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
swipeRefreshLayout.addView(scrollView, scrollParams);
FrameLayout emptyView = new FrameLayout(this);
LayoutParams emptyParams = new LayoutParams(MATCH_PARENT, 100000);
scrollView.addView(emptyView, emptyParams);
setContentView(swipeRefreshLayout);
}
use of android.support.v4.widget.SwipeRefreshLayout in project WordPress-Android by wordpress-mobile.
the class NotificationsListFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.notifications_fragment_notes_list, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_notes);
mFilterRadioGroup = (RadioGroup) view.findViewById(R.id.notifications_radio_group);
mFilterRadioGroup.setOnCheckedChangeListener(this);
mFilterDivider = view.findViewById(R.id.notifications_filter_divider);
mEmptyView = (ViewGroup) view.findViewById(R.id.empty_view);
mFilterView = view.findViewById(R.id.notifications_filter);
mLinearLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLinearLayoutManager);
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_notifications);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
hideNewNotificationsBar();
fetchNotesFromRemote();
}
});
// bar that appears at bottom after new notes are received and the user is on this screen
mNewNotificationsBar = view.findViewById(R.id.layout_new_notificatons);
mNewNotificationsBar.setVisibility(View.GONE);
mNewNotificationsBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onScrollToTop();
}
});
return view;
}
Aggregations