Java Code Examples for androidx.swiperefreshlayout.widget.SwipeRefreshLayout#setColorSchemeResources()

The following examples show how to use androidx.swiperefreshlayout.widget.SwipeRefreshLayout#setColorSchemeResources() . 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: ItemFragment.java    From materialistic with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable final Bundle savedInstanceState) {
    if (isNewInstance()) {
        mFragmentView = inflater.inflate(R.layout.fragment_item, container, false);
        mEmptyView = mFragmentView.findViewById(R.id.empty);
        mRecyclerView = (RecyclerView) mFragmentView.findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(getActivity(), true));
        mItemDecoration = new CommentItemDecoration(getActivity());
        mRecyclerView.addItemDecoration(mItemDecoration);
        mSwipeRefreshLayout = (SwipeRefreshLayout) mFragmentView.findViewById(R.id.swipe_layout);
        mSwipeRefreshLayout.setColorSchemeResources(R.color.white);
        mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.redA200);
        mSwipeRefreshLayout.setOnRefreshListener(() -> {
            if (TextUtils.isEmpty(mItemId)) {
                return;
            }
            mCacheMode = ItemManager.MODE_NETWORK;
            if (mAdapter != null) {
                mAdapter.setCacheMode(mCacheMode);
            }
            loadKidData();
        });
    }
    return mFragmentView;
}
 
Example 2
Source File: MainFragment.java    From ui with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View myView = inflater.inflate(R.layout.fragment_main, container, false);

    mSwipeRefreshLayout = (SwipeRefreshLayout) myView.findViewById(R.id.activity_main_swipe_refresh_layout);
    mListView = (ListView) myView.findViewById(R.id.ListView01);
    String[] fakelist = getRandomList();
    mAdapter = new ArrayAdapter<String>(
            getActivity(),
            android.R.layout.simple_list_item_1, fakelist);
    mListView.setAdapter(mAdapter);

    //setup some colors for the refresh circle.
    mSwipeRefreshLayout.setColorSchemeResources(R.color.orange, R.color.green, R.color.blue);
    //now setup the swiperefrestlayout listener where the main work is done.
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            //where we call the refresher parts.  normally some kind of networking async task or web service.
            //this is a bad way to do this, I'm just redoing the adapter, normally, the adapter would update
            //and then use the mAdapter.notifyDataSetChanged();

            /* normally something like this... but I want to slow it down for demo purposes, so
             *   it's commented out.
            String[] fakelist = getRandomList();
            mAdapter = new ArrayAdapter<String>(
                    getActivity(),
                    android.R.layout.simple_list_item_1, fakelist);
            mListView.setAdapter(mAdapter);
            //new turn off the refresh.
            mSwipeRefreshLayout.setRefreshing(false);
            */
            refreshslower();  //this will be slower, for the demo.
        }
    });
    return myView;
}
 
Example 3
Source File: NotificationsFragment.java    From guanggoo-android with Apache License 2.0 4 votes vote down vote up
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) {
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.main);
}
 
Example 4
Source File: TopicListFragment.java    From guanggoo-android with Apache License 2.0 4 votes vote down vote up
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) {
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.main);
}
 
Example 5
Source File: ReplyListFragment.java    From guanggoo-android with Apache License 2.0 4 votes vote down vote up
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) {
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.main);
}
 
Example 6
Source File: BlockedUserListFragment.java    From guanggoo-android with Apache License 2.0 4 votes vote down vote up
private void initSwipeLayout(SwipeRefreshLayout swipeRefreshLayout) {
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.main);
}
 
Example 7
Source File: UiUtil.java    From edx-app-android with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the color scheme of the provided {@link SwipeRefreshLayout}.
 *
 * @param swipeRefreshLayout The SwipeRefreshLayout to set the color scheme of.
 */
public static void setSwipeRefreshLayoutColors(@NonNull SwipeRefreshLayout swipeRefreshLayout) {
    swipeRefreshLayout.setColorSchemeResources(R.color.edx_brand_primary_accent,
            R.color.edx_brand_gray_x_back);
}