Search in sources :

Example 1 with SwipeRefreshLayout

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();
}
Also used : ShadowSwipeRefreshLayout(io.github.hidroh.materialistic.test.shadow.ShadowSwipeRefreshLayout) Bundle(android.os.Bundle) WebItem(io.github.hidroh.materialistic.data.WebItem) Fragment(android.support.v4.app.Fragment) ShadowSwipeRefreshLayout(io.github.hidroh.materialistic.test.shadow.ShadowSwipeRefreshLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Example 2 with SwipeRefreshLayout

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);
}
Also used : SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) Before(org.junit.Before)

Example 3 with SwipeRefreshLayout

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);
}
Also used : IntentFilter(android.content.IntentFilter) Bundle(android.os.Bundle) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ViewPager(android.support.v4.view.ViewPager) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 4 with SwipeRefreshLayout

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);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ScrollView(android.widget.ScrollView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 5 with 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;
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)113 View (android.view.View)64 RecyclerView (android.support.v7.widget.RecyclerView)53 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)41 TextView (android.widget.TextView)31 Bundle (android.os.Bundle)21 Intent (android.content.Intent)20 Handler (android.os.Handler)17 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)16 AdapterView (android.widget.AdapterView)15 ListView (android.widget.ListView)15 ArrayList (java.util.ArrayList)15 Toolbar (android.support.v7.widget.Toolbar)13 ImageView (android.widget.ImageView)11 Context (android.content.Context)9 LayoutInflater (android.view.LayoutInflater)9 ViewGroup (android.view.ViewGroup)9 GridLayoutManager (android.support.v7.widget.GridLayoutManager)7 FrameLayout (android.widget.FrameLayout)7 PandaRecyclerView (com.instructure.pandarecycler.PandaRecyclerView)7