android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener Java Examples
The following examples show how to use
android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener.
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: ActivityBase.java From ghwatch with Apache License 2.0 | 6 votes |
/** * Init SwipeRefreshLayout in the activity. A {@link #swipeLayout} is filled with object. * * @param listener called on refresh swipe */ protected void initSwipeLayout(OnRefreshListener listener) { contentExistsLayout = (View) findViewById(R.id.swipe_around); swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); if(contentExistsLayout == null) contentExistsLayout = swipeLayout; if (swipeLayout != null) { swipeLayout.setOnRefreshListener(listener); swipeLayout.setColorSchemeResources(android.R.color.holo_red_light, R.color.apptheme_colorPrimary, android.R.color.holo_orange_light, R.color.apptheme_colorPrimary); } swipeLayout2 = (SwipeRefreshLayout) findViewById(R.id.swipe_container_2); if (swipeLayout2 != null) { swipeLayout2.setOnRefreshListener(listener); swipeLayout2.setColorSchemeResources(android.R.color.holo_red_light, R.color.apptheme_colorPrimary, android.R.color.holo_orange_light, R.color.apptheme_colorPrimary); } initialProgressBar = findViewById(R.id.initial_progress); }
Example #2
Source File: FindListFragment.java From school_shop with MIT License | 6 votes |
private void initView() { pubBtn = (FloatingActionButton) mView.findViewById(R.id.find_list_floatButton); recyclerView = (RecyclerView) mView.findViewById(R.id.find_list_recyclerView); swipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.find_list_swipeRefreshLayout); init(); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); loadData(); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { } }); pubBtn.setColor(getResources().getColor(R.color.statusbar_bg)); pubBtn.setOnClickListener(this); recyclerView.setOnTouchListener(new ShowHideOnScroll(pubBtn)); }
Example #3
Source File: MainActivity.java From bleTester with Apache License 2.0 | 6 votes |
private void init() { // TODO Auto-generated method stub listView = (ListView) findViewById(R.id.lv_deviceList); listView.setEmptyView(findViewById(R.id.pb_empty)); swagLayout = (SwipeRefreshLayout) findViewById(R.id.swagLayout); swagLayout.setVisibility(View.VISIBLE); swagLayout.setOnRefreshListener(new OnRefreshListener() { @SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onRefresh() { // TODO Auto-generated method stub mBleDeviceListAdapter.clear(); mBluetoothAdapter.startLeScan(mLeScanCallback); swagLayout.setRefreshing(false); } }); mBleDeviceListAdapter = new BleDeviceListAdapter(this); listView.setAdapter(mBleDeviceListAdapter); setListItemListener(); }
Example #4
Source File: NotificationFragment.java From umeng_community_android with MIT License | 6 votes |
@Override protected void initWidgets() { mRefreshLayout = findViewById(ResFinder.getId("umeng_comm_swipe_layout")); mRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mPresenter.loadDataFromServer(); } }); mRefreshLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { mPresenter.loadMoreData(); } }); // 添加footer mRefreshLayout.setDefaultFooterView(); mListView = findViewById(ResFinder.getId("umeng_comm_notify_listview")); mAdapter = new NotifyAdapter(getActivity()); mListView.setAdapter(mAdapter); }
Example #5
Source File: SwipeRefreshLayoutManager.java From react-native-GPay with MIT License | 5 votes |
@Override protected void addEventEmitters( final ThemedReactContext reactContext, final ReactSwipeRefreshLayout view) { view.setOnRefreshListener( new OnRefreshListener() { @Override public void onRefresh() { reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher() .dispatchEvent(new RefreshEvent(view.getId())); } }); }
Example #6
Source File: MyProfileFragment.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_my_profile, container, false); mSwipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.ptr_layout); mList = (ListView) mSwipeRefreshLayout.findViewById(R.id.list_of_fields); mProgressBar = (ProgressBar) root.findViewById(R.id.progress_bar); ViewUtils.hideAndDisableViews(mList, mProgressBar); OnRefreshListener listener = new OnRefreshListener() { @Override public void onRefresh() { if (!mIsRefreshing) { startUpdate(); } } }; int blue = R.color.actionbar_blue; int grey = R.color.light_grey; mSwipeRefreshLayout.setOnRefreshListener(listener); mSwipeRefreshLayout.setColorSchemeResources(blue, grey, blue); // restoring previous state of fragment restoreFromPreviousState(savedInstanceState); return root; }
Example #7
Source File: RecommendTopicFragment.java From umeng_community_android with MIT License | 5 votes |
/** * 初始化刷新相关的view跟事件</br> * * @param rootView */ protected void initRefreshView(View rootView) { int refreshResId = ResFinder.getId("umeng_comm_topic_refersh"); mRefreshLvLayout = (RefreshLvLayout) rootView.findViewById(refreshResId); // 推荐用户页面无加载更多跟下拉刷新 if (fromRecommedTopic) { mRefreshLvLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mPresenter.loadDataFromServer(); } }); mRefreshLvLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { mPresenter.loadMoreData(); } }); } int listViewResId = ResFinder.getId("umeng_comm_topic_listview"); mTopicListView = mRefreshLvLayout.findRefreshViewById(listViewResId); initAdapter(); if (!mSaveButtonVisiable) { // 目前推荐话题不需要刷新跟加载更多,因此暂时设置不可用 // mRefreshLvLayout.setEnabled(false); } else { mRefreshLvLayout.setDefaultFooterView(); } mBaseView = (BaseView) rootView.findViewById(ResFinder.getId("umeng_comm_baseview")); mBaseView.setEmptyViewText(ResFinder.getString("umeng_comm_no_recommend_topic")); }
Example #8
Source File: TopicPickerFragment.java From umeng_community_android with MIT License | 5 votes |
@Override protected void initWidgets() { int refreshResId = ResFinder.getId("umeng_comm_topic_lv_layout"); int topicListViewResId = ResFinder.getId("umeng_comm_topic_listview"); mRefreshLvLayout = (RefreshLvLayout) mRootView.findViewById(refreshResId); mRefreshLvLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mPresenter.loadDataFromServer(); } }); mRefreshLvLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { loadMore(); } }); mTopicListView = mRefreshLvLayout.findRefreshViewById(topicListViewResId); // mTopicListView = (ListView) // mRootView.findViewById(topicListViewResId); mTopicListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // 对于原来的值取反 setItemSelected(view, position); } }); mSelectedTopics.clear(); mAdapter = new TopicPickerAdater(getActivity()); mRefreshLvLayout.setAdapter(mAdapter); }
Example #9
Source File: TweetListFragment.java From Onosendai with Apache License 2.0 | 4 votes |
@Override public View onCreateView (final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { this.columnId = getArguments().getInt(ARG_COLUMN_ID); this.columnPosition = getArguments().getInt(ARG_COLUMN_POSITION); this.isLaterColumn = getArguments().getBoolean(ARG_COLUMN_IS_LATER, false); this.inlineMediaStyle = InlineMediaStyle.parseJson(getArguments().getString(ARG_COLUMN_SHOW_INLINEMEDIA)); this.showFiltered = getArguments().getBoolean(ARG_SHOW_FILTERED, false); this.log.setPrefix("C" + this.columnId); this.log.d("onCreateView()"); this.mainActivity = (MainActivity) getActivity(); this.conf = this.mainActivity.getConf(); this.friendlyDateTimeFormat = new FriendlyDateTimeFormat(this.mainActivity); this.imageLoader = ImageLoaderUtils.fromActivity(getActivity()); this.tweetLoader = new LinkedTweetLoader(this.mainActivity, getLocalEs(), getNetEs(), getExecutorEventListener(), this.conf, this.mainActivity, getColumn().isHdMedia()); /* * Fragment life cycles are strange. onCreateView() is called multiple * times before onSaveInstanceState() is called. Do not overwrite * perfectly good stated stored in member var. */ if (this.scrollState == null) { this.scrollState = ScrollState.fromBundle(savedInstanceState); } final View rootView = inflater.inflate(R.layout.tweetlist, container, false); this.sidebar = (SidebarLayout) rootView.findViewById(R.id.tweetListLayout); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new SidebarLayout.BackButtonListener(this.sidebar)); updateScrollLabelToIdle(); this.tweetListEmptyRefresh = (Button) rootView.findViewById(R.id.tweetListEmptyRefresh); this.tweetListEmptyRefresh.setOnClickListener(this.refreshClickListener); this.tweetListSwiper = (SwipeRefreshLayout) rootView.findViewById(R.id.tweetListListSwiper); this.tweetList = (ListView) rootView.findViewById(R.id.tweetListList); this.adapter = new TweetListCursorAdapter(container.getContext(), this.inlineMediaStyle, this.imageLoader, this.tweetLoader, this.tweetList); this.tweetList.setAdapter(this.adapter); this.tweetList.setOnItemClickListener(this.tweetItemClickedListener); this.tweetList.setEmptyView(this.tweetListEmptyRefresh); if (this.inlineMediaStyle == InlineMediaStyle.SEAMLESS) this.tweetList.setDrawSelectorOnTop(true); this.refreshUiHandler = new RefreshUiHandler(this); final ListView lstTweetPayload = (ListView) rootView.findViewById(R.id.tweetDetailPayloadList); this.lstTweetPayloadAdaptor = new PayloadListAdapter(container.getContext(), this.imageLoader, lstTweetPayload, this.payloadClickListener); lstTweetPayload.setAdapter(this.lstTweetPayloadAdaptor); final PayloadListClickListener payloadListClickListener = new PayloadListClickListener(this.payloadClickListener); lstTweetPayload.setOnItemClickListener(payloadListClickListener); lstTweetPayload.setOnItemLongClickListener(payloadListClickListener); ((Button) rootView.findViewById(R.id.tweetDetailClose)).setOnClickListener(new SidebarLayout.ToggleSidebarListener(this.sidebar)); this.btnDetailsLater = (Button) rootView.findViewById(R.id.tweetDetailLater); this.scrollIndicator = ScrollIndicator.attach(getActivity(), (ViewGroup) rootView.findViewById(R.id.tweetListView), this.tweetList, this.tweetListScrollListener); this.tweetListSwiper.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh () { if (!getMainActivity().scheduleRefreshInteractive(getColumnId())) { TweetListFragment.this.tweetListSwiper.setRefreshing(false); } } }); this.tweetListStatus = (TextView) rootView.findViewById(R.id.tweetListStatus); this.tweetListStatus.setOnClickListener(this.tweetListStatusClickListener); return rootView; }
Example #10
Source File: PickerDialog.java From umeng_community_android with MIT License | 4 votes |
/** * Parse the dialog's content view and fill datas, and so on. * * @param mContext the context * @return the dialog's content view */ protected View createContentView() { int layout = ResFinder.getLayout("umeng_comm_at_friends_layout"); int listViewResId = ResFinder.getId("umeng_comm_friend_listview"); int searchTvResId = ResFinder.getId("search_tv"); int searchlasteTvResId = ResFinder.getId("search_lastes_btn"); int backBtnResId = ResFinder.getId("search_back_btn"); int okBtnResId = ResFinder.getId("search_ok_btn"); int refreshLayoutResId = ResFinder.getId("umeng_comm_at_friend_listview"); mRootView = LayoutInflater.from(getContext()).inflate( layout, null, false); // mRefreshLvLayout = (RefreshLvLayout) mRootView .findViewById(refreshLayoutResId); mRefreshLvLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { loadDataFromServer(); } }); mRefreshLvLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { loadMore(); } }); // listview // mListView = (ListView) mRootView // .findViewById(listViewResId); mListView = mRefreshLvLayout.findRefreshViewById(listViewResId); // mListView.requestFocus(); // 文本 mTitleTextView = (TextView) mRootView.findViewById(searchTvResId); mRootView.findViewById(searchlasteTvResId).setVisibility(View.GONE); setupAdater(); setupLvOnItemClickListener(); initSearchEdit(); mRootView.findViewById(backBtnResId).setOnClickListener(this); mRootView.findViewById(okBtnResId).setOnClickListener(this); mRootView.findViewById(okBtnResId).setVisibility(View.GONE); return mRootView; }
Example #11
Source File: AlbumActivity.java From umeng_community_android with MIT License | 4 votes |
private void initTitleLayout() { ViewFinder viewFinder = new ViewFinder(getWindow().getDecorView()); Button settingButton = viewFinder.findViewById(ResFinder.getId("umeng_comm_save_bt")); // 目前将设置功能移到发现页面,此时暂时隐藏设置按钮 settingButton.setVisibility(View.INVISIBLE); findViewById(ResFinder.getId("umeng_comm_setting_back")).setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { finish(); } }); TextView titleTextView = (TextView) findViewById(ResFinder .getId("umeng_comm_setting_title")); titleTextView.setText("相册"); // 初始化下拉刷新Layout mRefreshGvLayout = viewFinder .findViewById(ResFinder.getId("umeng_comm_album_swipe_layout")); mRefreshGvLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mPresenter.loadDataFromServer(); } }); mRefreshGvLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { mPresenter.loadMore(); } }); // 初始化GridView mAlbumGridView = viewFinder.findViewById(ResFinder.getId("umeng_comm_user_albun_gv")); mAlbumGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { jumpToImageBrowser(mImageAdapter.getDataSource(), position); } }); mImageAdapter = new UserAlbumAdapter(getApplicationContext()); mAlbumGridView.setAdapter(mImageAdapter); }
Example #12
Source File: RecommendUserFragment.java From umeng_community_android with MIT License | 4 votes |
@Override protected void initWidgets() { super.initWidgets(); Button button = (Button) mRootView.findViewById(ResFinder.getId("umeng_comm_save_bt")); button.setOnClickListener(this); button.setText(ResFinder.getString("umeng_comm_skip")); button.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); button.setTextColor(ResFinder.getColor("umeng_comm_skip_text_color")); if (!mSaveButtonVisiable) { button.setVisibility(View.GONE); mRootView.findViewById(ResFinder.getId("umeng_comm_setting_back")).setOnClickListener( this); mAdapter.setFromFindPage(!mSaveButtonVisiable); } else { mRootView.findViewById(ResFinder.getId("umeng_comm_setting_back")).setVisibility( View.GONE); } mTitleTextView = (TextView) mRootView.findViewById(ResFinder .getId("umeng_comm_setting_title")); mTitleTextView.setText(ResFinder.getString("umeng_comm_recommend_user")); mTitleTextView.setTextColor(Color.BLACK); mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); mRootView.findViewById(ResFinder.getId("umeng_comm_title_bar_root")) .setBackgroundColor(Color.WHITE); mRefreshLvLayout.setEnabled(true); mViewStub = (ViewStub) mRootView.findViewById(ResFinder.getId("umeng_comm_empty")); mRefreshLvLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { mPresenter.loadMoreData(); } }); mRefreshLvLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mPresenter.loadDataFromServer(); } }); }
Example #13
Source File: FollowedUserFragment.java From umeng_community_android with MIT License | 4 votes |
@Override protected void initWidgets() { int refershResId = ResFinder.getId("umeng_comm_user_swipe_layout"); int gvResId = ResFinder.getId("umeng_comm_user_gridview"); mViewFinder = new ViewFinder(mRootView); mRefreshGvLayout = mViewFinder .findViewById(refershResId); // 设置颜色 mRefreshGvLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { mPresenter.loadDataFromServer(); } }); mRefreshGvLayout.setOnLoadListener(new OnLoadListener() { @Override public void onLoad() { mPresenter.loadMoreData(); } }); mGridView = mViewFinder.findViewById(gvResId); mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); // 跳转到用户信息页面 mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { CommonUtils.checkLoginAndFireCallback(getActivity(), new SimpleFetchListener<LoginResponse>() { @Override public void onComplete(LoginResponse response) { if (response.errCode != ErrorCode.NO_ERROR) { ToastMsg.showShortMsgByResName("umeng_comm_login_failed"); return; } Intent userIntent = new Intent(getActivity(), UserInfoActivity.class); userIntent.putExtra(Constants.TAG_USER, mAdapter.getItem(position)); startActivity(userIntent); } }); } }); Log.d(getTag(), "### 屏幕宽度 : " + Constants.SCREEN_WIDTH); if (Constants.SCREEN_WIDTH > 800) { mGridView.setNumColumns(Constants.SCREEN_WIDTH / 200); } mGridView.setHorizontalSpacing(20); mGridView.setVerticalSpacing(10); mAdapter = new UserAdapter(getActivity()); mGridView.setAdapter(mAdapter); mBaseView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_baseview")); mBaseView.setEmptyViewText(ResFinder.getString("umeng_comm_no_followed_user")); if (mAnimationResultListener != null) { mRefreshGvLayout.setOnScrollDirectionListener(new OnResultListener() { @Override public void onResult(int status) { // 1:向上滑动且第一项显示 (up) // 0:向下且大于第一项 (down) int firstVisible = mGridView.getFirstVisiblePosition(); if ((status == 1 && firstVisible >= 0) || (status == 0 && firstVisible == 0)) { mAnimationResultListener.onResult(status); } } }); } }
Example #14
Source File: EaseChatFragment.java From nono-android with GNU General Public License v3.0 | 4 votes |
protected void setRefreshLayoutListener() { swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == EaseConstant.CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { messageList.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(getActivity(), getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 600); } }); }
Example #15
Source File: EaseChatFragment.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
protected void setRefreshLayoutListener() { swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == EaseConstant.CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { messageList.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(getActivity(), getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 600); } }); }
Example #16
Source File: EaseChatFragment.java From monolog-android with MIT License | 4 votes |
protected void setRefreshLayoutListener() { swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == EaseConstant.CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { messageList.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(getActivity(), getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 600); } }); }
Example #17
Source File: EaseChatFragment.java From Social with Apache License 2.0 | 4 votes |
protected void setRefreshLayoutListener() { swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == EaseConstant.CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreMsgFromDB(messageList.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { messageList.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(getActivity(), getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 600); } }); }