Java Code Examples for android.support.v4.widget.SwipeRefreshLayout#setEnabled()

The following examples show how to use android.support.v4.widget.SwipeRefreshLayout#setEnabled() . 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: SelectRecyclerFragment.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
	rootView = inflater.inflate(R.layout.abstract_recycler_fragment, container, false);

	refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
	refreshLayout.setOnRefreshListener(this);

	recyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_recycler);
	fastScroller = (FastScroller) rootView.findViewById(R.id.fragment_fast_scroller);
	setupLayoutManager();

	if(pullToRefresh) {
		setupScrollList(recyclerView);
	} else {
		refreshLayout.setEnabled(false);
	}

	if(objects == null) {
		refresh(false);
	} else {
		recyclerView.setAdapter(adapter = getAdapter(objects));
	}

	return rootView;
}
 
Example 2
Source File: EmptyActivity.java    From LoadingLayout with Apache License 2.0 6 votes vote down vote up
private void initView() {
    mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
    mRefreshLayout.setEnabled(false);
    mLoadingLayout = (LoadingLayout) findViewById(R.id.loading_layout);
    mRecyclerView = (RecyclerView) findViewById(R.id.list);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new RecyclerAdapter();
    mRecyclerView.setAdapter(mAdapter);

    mRetryBtn = (Button) findViewById(R.id.retry_btn);
    mEmptyBtn = (Button) findViewById(R.id.empty_btn);
    mCustomBtn1 = (Button) findViewById(R.id.custom1);
    mCustomBtn2 = (Button) findViewById(R.id.custom2);
    mRetryBtn.setOnClickListener(this);
    mEmptyBtn.setVisibility(View.GONE);
    mCustomBtn1.setVisibility(View.GONE);
    mCustomBtn2.setVisibility(View.GONE);
}
 
Example 3
Source File: RetryActivity.java    From LoadingLayout with Apache License 2.0 6 votes vote down vote up
private void initView() {
    mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
    mRefreshLayout.setEnabled(false);
    mLoadingLayout = (LoadingLayout) findViewById(R.id.loading_layout);
    mRecyclerView = (RecyclerView) findViewById(R.id.list);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new RetryActivity.RecyclerAdapter();
    mRecyclerView.setAdapter(mAdapter);


    mEmptyBtn = (Button) findViewById(R.id.empty_btn);
    mRetryBtn = (Button) findViewById(R.id.retry_btn);
    mCustomBtn1 = (Button) findViewById(R.id.custom1);
    mCustomBtn2 = (Button) findViewById(R.id.custom2);

    mRetryBtn.setVisibility(View.GONE);
    mEmptyBtn.setVisibility(View.GONE);
    mCustomBtn1.setVisibility(View.GONE);
    mCustomBtn2.setVisibility(View.GONE);

    mLoadingLayout.setOnRetryLoadListener(this);
}
 
Example 4
Source File: TableView.java    From SortableTableView with Apache License 2.0 6 votes vote down vote up
private void setupTableDataView(final AttributeSet attributes, final int styleAttributes) {
    final LayoutParams dataViewLayoutParams = new LayoutParams(getWidthAttribute(attributes), LayoutParams.MATCH_PARENT);

    if (isInEditMode()) {
        tableDataAdapter = new EditModeTableDataAdapter(getContext());
    } else {
        tableDataAdapter = new DefaultTableDataAdapter(getContext());
    }
    tableDataAdapter.setRowBackgroundProvider(dataRowBackgroundProvider);

    tableDataView = new ListView(getContext(), attributes, styleAttributes);
    tableDataView.setOnItemClickListener(new InternalDataClickListener());
    tableDataView.setOnItemLongClickListener(new InternalDataLongClickListener());
    tableDataView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    tableDataView.setAdapter(tableDataAdapter);
    tableDataView.setId(R.id.table_data_view);
    tableDataView.setOnScrollListener(new InternalOnScrollListener());

    swipeRefreshLayout = new SwipeRefreshLayout(getContext());
    swipeRefreshLayout.setLayoutParams(dataViewLayoutParams);
    swipeRefreshLayout.addView(tableDataView);
    swipeRefreshLayout.setColorSchemeColors(headerColor);
    swipeRefreshLayout.setEnabled(false);

    addView(swipeRefreshLayout);
}
 
Example 5
Source File: SearchFragment.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
	rootView = inflater.inflate(R.layout.abstract_recycler_fragment, container, false);
	setTitle(R.string.search_title);

	refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
	refreshLayout.setEnabled(false);

	recyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_recycler);
	setupLayoutManager(recyclerView, largeAlbums);

	registerForContextMenu(recyclerView);
	context.onNewIntent(context.getIntent());

	if(searchResult != null) {
		skipSearch = true;
		recyclerView.setAdapter(adapter = new SearchAdapter(context, searchResult, getImageLoader(), largeAlbums, this));
	}

	return rootView;
}
 
Example 6
Source File: XMultiTypeAdapterActivity.java    From XFrame with Apache License 2.0 5 votes vote down vote up
@Override
    public void initView() {
        SwipeRefreshLayout mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
        mSwipeLayout.setEnabled(false);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        recyclerView.addItemDecoration(new DividerDecoration(Color.parseColor("#f2f2f2"),15));

        //解决NestedScrollView嵌套RecycleView的滑动冲突问题
//        recyclerView.setNestedScrollingEnabled(false);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        final MultiTypeAdapter adapter = new MultiTypeAdapter(recyclerView, NewDataSource.getNewsList());
        recyclerView.setAdapter(adapter);

        // StickyHeader
        StickyHeaderDecoration decoration = new StickyHeaderDecoration(new StickyHeaderAdapter(this));
        decoration.setIncludeHeader(false);
        recyclerView.addItemDecoration(decoration);

        adapter.setOnItemClickListener(new XRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                //修改局部item的数据,点击那个修改哪个
                int random = new Random().nextInt(9);
                News news=NewDataSource.getNewsList().get(random);
                adapter.replace(position,news);
            }
        });
    }
 
Example 7
Source File: CacheFragment.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
public View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.common_recyclerview, container, false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.swipe_target);
    mSwipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh);
    mSwipeRefresh.setEnabled(false);
    return view;
}
 
Example 8
Source File: FragmentMain.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //G.chatUpdateStatusUtil.setOnChatUpdateStatusResponse(this);
    this.mView = view;
    mComplete = this;
    tagId = System.currentTimeMillis();

    mainType = (MainType) getArguments().getSerializable(STR_MAIN_TYPE);
    progressBar = (ProgressBar) view.findViewById(R.id.ac_progress_bar_waiting);
    swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.activity_main_swipe_refresh_layout);
    swipeRefreshLayout.setRefreshing(false);
    swipeRefreshLayout.setEnabled(false);
    viewById = view.findViewById(R.id.empty_icon);
    pbLoading = view.findViewById(R.id.pbLoading);
    // pbLoading.setVisibility(View.VISIBLE);

    switcher = String.valueOf(this.toString().charAt(this.toString().lastIndexOf(":") + 1));
    if (switcher.equals("4") && allSwitcher == 0 && mView != null) {
        allSwitcher = 1;
        initRecycleView();
        initListener();
        pbLoading.setVisibility(View.GONE);
    } else if (switcher.equals("0") && allSwitcher == 0 && mView != null) {
        allSwitcher = 1;
        initRecycleView();
        initListener();
        pbLoading.setVisibility(View.GONE);
    }


}
 
Example 9
Source File: UltimateListview.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void initView() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.ultimate_listview_layout, this);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.ultimate_listview_swipe_layout);
    mBasicUltimateListView = (BasicUltimateListView) view.findViewById(R.id.basicUltimateListView);
    mSwipeRefreshLayout.setEnabled(false);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
}
 
Example 10
Source File: UltimateListview.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void initView() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.ultimate_listview_layout, this);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.ultimate_listview_swipe_layout);
    mBasicUltimateListView = (BasicUltimateListView) view.findViewById(R.id.basicUltimateListView);
    mSwipeRefreshLayout.setEnabled(false);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
}
 
Example 11
Source File: HeaderFooterActivity.java    From LightAdapter with Apache License 2.0 5 votes vote down vote up
private void init() {
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.addItemDecoration(new DefaultItemDecoration(
            ContextCompat.getColor(this, R.color.white),
            ContextCompat.getColor(this, R.color.divider),
            getResources().getDimensionPixelSize(R.dimen.zero)));
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter = new LightAdapter());
}
 
Example 12
Source File: ViewUtils.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
/**
 * 下拉刷新成功
 */
public static void setRefreshSuccess(SwipeRefreshLayout swipeRefreshLayout) {
    if (swipeRefreshLayout != null) {
        swipeRefreshLayout.setRefreshing(false);
        swipeRefreshLayout.setEnabled(false);
    }
}
 
Example 13
Source File: ListFragment.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
protected void initView(View view) {
    Bundle arguments = getArguments();
    if (arguments != null) {
        title = arguments.getString(KEY);
    }
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
    mSwipeRefreshLayout.setEnabled(false);

    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    DividerItemDecoration itemDecoration = new DividerItemDecoration(mContext,
            LinearLayoutManager.VERTICAL);
    mRecyclerView.addItemDecoration(itemDecoration);
    mRecyclerView.setLayoutManager(layoutManager);

    for (int i = 0; i < 50; i++) {
        String s = String.format("我是第%d个" + title, i);
        mDatas.add(s);
    }

    mAdapter = new ItemAdapter(mContext, mDatas);
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mSwipeRefreshLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(false);
                    Toast.makeText(mContext, "刷新完成", Toast.LENGTH_SHORT).show();
                }
            }, 1200);
        }
    });


}
 
Example 14
Source File: BaseSuperAbsListview.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void initView() {
    if (isInEditMode()) {
        return;
    }
    View v = LayoutInflater.from(getContext()).inflate(mSuperListViewMainLayout, this);
    mPtrLayout = (SwipeRefreshLayout) v.findViewById(R.id.ptr_layout);
    mPtrLayout.setEnabled(false);

    mProgress = (ViewStub) v.findViewById(android.R.id.progress);

    mProgress.setLayoutResource(mProgressId);
    mProgress.inflate();

    mMoreProgress = (ViewStub) v.findViewById(R.id.more_progress);
    mMoreProgress.setLayoutResource(mMoreProgressId);
    if (mMoreProgressId != 0)
        mMoreProgress.inflate();
    mMoreProgress.setVisibility(View.GONE);

    mEmpty = (ViewStub) v.findViewById(R.id.empty);
    mEmpty.setLayoutResource(mEmptyId);
    if (mEmptyId != 0)
        mEmpty.inflate();
    mEmpty.setVisibility(View.GONE);

    initAbsListView(v);
}
 
Example 15
Source File: RefreshLoadHelper.java    From WanAndroid with GNU General Public License v3.0 4 votes vote down vote up
public static  <T> Observer<RefreshLoadModel<MutableLiveData<Result<PageBean<T>>>>> listener(LifecycleOwner owner, RecyclerView recyclerView, MQQuickAdapter adapter, SwipeRefreshLayout refresh, RefreshLoadViewModel<T> viewModel) {
    return new Observer<RefreshLoadModel<MutableLiveData<Result<PageBean<T>>>>>() {
        @Override
        public void onChanged(@Nullable RefreshLoadModel<MutableLiveData<Result<PageBean<T>>>> mutableLiveDataRefreshLoadModel) {

            if (mutableLiveDataRefreshLoadModel == null) return;
            if (mutableLiveDataRefreshLoadModel.isRefresh) {
                adapter.setEnableLoadMore(false);
            } else {
                refresh.setEnabled(false);
            }

            mutableLiveDataRefreshLoadModel.data.observe(owner, new Observer<Result<PageBean<T>>>() {
                @Override
                public void onChanged(@Nullable Result<PageBean<T>> pageBeanResult) {
                    refresh.setEnabled(true);
                    refresh.setRefreshing(false);

                    if (pageBeanResult == null && adapter.isLoading()) {
                        adapter.loadMoreFail();
                    } else {
                        adapter.setEnableLoadMore(true);
                        adapter.setLoaded(false);
                    }

                    if (pageBeanResult == null || pageBeanResult.getErrorCode() != Net.ZERO) {
                        EmptyViewHelper.setErrEmpty(recyclerView, pageBeanResult != null ? pageBeanResult.getErrorMsg() : null);
                        if (pageBeanResult != null && pageBeanResult.getErrorCode() == Net.NOT_LOGIN) {
                            ToastHelper.error(App.getInstance().getString(R.string.not_login));
                            App.Login.out();
                        }
                        return;
                    }

                    if (pageBeanResult.getData().isOver()) {
                        adapter.setLoaded(true);
                    }

                    if (mutableLiveDataRefreshLoadModel.isRefresh) {
                        viewModel.getList().clear();
                    }
                    viewModel.getList().addAll(pageBeanResult.getData().getDatas());
                }
            });
        }
    };
}
 
Example 16
Source File: FragmentStatusList.java    From Rumble with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    Bundle args = getArguments();
    if(args != null) {
        this.filter_gid = args.getString("GroupID");
        this.filter_uid = args.getString("ContactID");
        this.filter_hashtag = args.getString("Hashtag");
        this.noCoordinatorLayout = args.getBoolean("noCoordinatorLayout");
    }

    /*
     * This fragment is shown in three activities: the HomeActivity, the GroupDetail activity
     * and the ContactDetail activity. For HomeActivity and GroupDetail, I need the floating
     * action button to compose message and I need it to disappear when I scroll down so I need
     * this fragment to embeds it in a CoordinatorLayout to enable this effect.
     *
     * However for ContactDetail activity, I need a CoordinatorLayout for the whole activity
     * in order to hide the collapsingtoolbar whenever I scroll down. Unfortunately it conflicts
     * with the coordinatorlayout I use for this very fragmentStatusList. Because I don't need
     * the compose button to display the status to a specific contact, I created two different
     * layout to avoid conflicts and use the argument noCoordinatorLayout to decide which one.
     */
    if(noCoordinatorLayout) {
        mView = inflater.inflate(R.layout.fragment_status_list_no_coordinatorlayout, container, false);
    } else {
        mView = inflater.inflate(R.layout.fragment_status_list, container, false);
    }

    // the filters
    filters = (ListView) (mView.findViewById(R.id.filter_list));
    filterListAdapter = new FilterListAdapter(getActivity(), this);
    filters.setAdapter(filterListAdapter);
    filters.setClickable(false);
    filters.setVisibility(View.GONE);

    // refreshing the list of status by pulling down, disabled for ContactDetail
    swipeLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_container);
    if(noCoordinatorLayout)
        swipeLayout.setEnabled(false);
    else
        swipeLayout.setOnRefreshListener(this);


    /*
    final float density = getResources().getDisplayMetrics().density;
    final int swipeDistance = Math.round(64 * density);
    swipeLayout.setProgressViewOffset(true, 10, 10+swipeDistance);
    */

    // the compose button, disabled for ContactDetail
    composeFAB = (FloatingActionButton) mView.findViewById(R.id.compose_fab);
    if(noCoordinatorLayout)
        composeFAB.setVisibility(View.GONE);
    else
        composeFAB.setOnClickListener(onFabClicked);

    // the list of status
    mRecyclerView = (RecyclerView) mView.findViewById(R.id.status_list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    statusRecyclerAdapter = new StatusRecyclerAdapter(getActivity(), this);
    mRecyclerView.setAdapter(statusRecyclerAdapter);
    mRecyclerView.addOnScrollListener(loadMore);

    // now get the latest status
    loadingMore = false;
    noMoreStatusToLoad = false;
    refreshStatuses();

    EventBus.getDefault().register(this);

    return mView;
}
 
Example 17
Source File: BaseListDelegate.java    From CoreModule with Apache License 2.0 4 votes vote down vote up
public void setSwipeRefreshLoadedState() {
    SwipeRefreshLayout refreshLayout = get(R.id.swiperefreshlayout);
    refreshLayout.setRefreshing(false);
    refreshLayout.setEnabled(true);
}
 
Example 18
Source File: BaseListDelegate.java    From CoreModule with Apache License 2.0 4 votes vote down vote up
public void setSwipeRefreshLoadingState() {
    SwipeRefreshLayout refreshLayout = get(R.id.swiperefreshlayout);
    refreshLayout.setRefreshing(true);
    refreshLayout.setEnabled(false);
}
 
Example 19
Source File: ArticleFragment.java    From hex with Apache License 2.0 3 votes vote down vote up
private SwipeRefreshLayout setupSwipeRefreshLayout(View rootView) {
    SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh);

    refreshLayout.setEnabled(false);

    return refreshLayout;
}
 
Example 20
Source File: TestFragment.java    From CoordinatorLayoutExample with Apache License 2.0 -5 votes vote down vote up
private void initView(ViewGroup root) {
    mRecyclerView = (RecyclerView) root.findViewById(R.id.test_recycler);
    mSwipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
    mSwipeRefreshLayout.setEnabled(getArguments().getBoolean(REFRESH_SUPPORT));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mSwipeRefreshLayout.setRefreshing(false);
                    Toast.makeText(mContext, "刷新完成", Toast.LENGTH_SHORT).show();
                }
            }, 2000);
        }
    });
}