本文整理汇总了Java中android.support.v4.widget.SwipeRefreshLayout.setOnRefreshListener方法的典型用法代码示例。如果您正苦于以下问题:Java SwipeRefreshLayout.setOnRefreshListener方法的具体用法?Java SwipeRefreshLayout.setOnRefreshListener怎么用?Java SwipeRefreshLayout.setOnRefreshListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.widget.SwipeRefreshLayout
的用法示例。
在下文中一共展示了SwipeRefreshLayout.setOnRefreshListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fagment_bookmarks, container, false);
refreshLayout =
(SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh_bookmarks);
RecyclerView recyclerView =
(RecyclerView) rootView.findViewById(R.id.bookmark_recycler_view);
mAdapter = new BookmarksRecyclerViewAdapter(getActivity());
recyclerView.setAdapter(mAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if(onRequestReloadListener != null) {
onRequestReloadListener.requestReload();
}
}
});
return rootView;
}
示例2: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_dialogs, container, false);
mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView = (RecyclerView) view.findViewById(R.id.dialogs_recycler);
recyclerView.setLayoutManager(mLayoutManager);
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.dialogs_swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);
setHasOptionsMenu(true);
return view;
}
示例3: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
rootLayout = (LinearLayout) rootView.findViewById(R.id.root_layout);
replaceLayout = (ViewStubCompat) rootView.findViewById(R.id.replace_layout);
multiStateView = (MultiStateView) rootView.findViewById(R.id.multiStateView);
if (inflateExtraView() != -1) {
replaceLayout.setLayoutResource(inflateExtraView());
replaceLayout.inflate();
}
swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefresh);
swipeRefresh.setOnRefreshListener(onRefreshListener());
multiStateView.setStateListener(onStateListener());
return view;
}
示例4: initView
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
private void initView(Context context) {
mContext = context;
View view = LayoutInflater.from(context).inflate(com.wuxiaolong.pullloadmorerecyclerview.R.layout.pull_loadmore_layout, null);
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));
mRecyclerView = (RecyclerView) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.recycler_view);
mRecyclerView.setVerticalScrollBarEnabled(true);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addOnScrollListener(new RecyclerViewOnScroll(this));
mRecyclerView.setOnTouchListener(new onTouchRecyclerView());
mFooterView = view.findViewById(R.id.footerView);
loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);
mFooterView.setVisibility(View.GONE);
this.addView(view);
}
示例5: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
listView = (RecyclerView) view.findViewById(R.id.list);
listView.setHasFixedSize(true);
listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
List<ItemList> lists = new ArrayList<ItemList>();
videoadapter = new VideoAdapter(lists);
listView.setAdapter(videoadapter);
mPresent = new VideoPresenter((VideoData.View) this);
srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
srfLayout.setOnRefreshListener(this);
srfLayout.post(() -> onRefresh());
return view;
}
示例6: UpdatesViewBinder
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
public UpdatesViewBinder(final AppCompatActivity activity, FrameLayout parent) {
View view = activity.getLayoutInflater().inflate(R.layout.main_tab_updates, parent, true);
adapter = new UpdatesAdapter(activity);
adapter.registerAdapterDataObserver(adapterChangeListener);
list = (RecyclerView) view.findViewById(R.id.list);
list.setHasFixedSize(true);
list.setLayoutManager(new LinearLayoutManager(activity));
list.setAdapter(adapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(new UpdatesItemTouchCallback(activity, adapter));
touchHelper.attachToRecyclerView(list);
emptyState = (TextView) view.findViewById(R.id.empty_state);
emptyImage = (ImageView) view.findViewById(R.id.image);
final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_to_refresh);
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeToRefresh.setRefreshing(false);
UpdateService.updateNow(activity);
}
});
}
示例7: prepareSwipeRefreshLayout
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
private void prepareSwipeRefreshLayout(SavedStoriesCardAdapter savedStoriesCardAdapter) {
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.saved_stories_swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(() -> {
loadSavedStories(savedStoriesCardAdapter, mService);
mSwipeRefreshLayout.setRefreshing(false);
});
}
示例8: WhatsNewViewBinder
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
WhatsNewViewBinder(final AppCompatActivity activity, FrameLayout parent) {
this.activity = activity;
View whatsNewView = activity.getLayoutInflater().inflate(R.layout.main_tab_whats_new, parent, true);
whatsNewAdapter = new WhatsNewAdapter(activity);
GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
layoutManager.setSpanSizeLookup(new WhatsNewAdapter.SpanSizeLookup());
emptyState = (TextView) whatsNewView.findViewById(R.id.empty_state);
appList = (RecyclerView) whatsNewView.findViewById(R.id.app_list);
appList.setHasFixedSize(true);
appList.setLayoutManager(layoutManager);
appList.setAdapter(whatsNewAdapter);
final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) whatsNewView
.findViewById(R.id.swipe_to_refresh);
swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swipeToRefresh.setRefreshing(false);
UpdateService.updateNow(activity);
}
});
FloatingActionButton searchFab = (FloatingActionButton) whatsNewView.findViewById(R.id.btn_search);
searchFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(new Intent(activity, AppListActivity.class));
}
});
activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
}
示例9: onCreate
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
final LogPersistence logPersistence = new LogPersistence(this);
ListView logListView = (ListView) findViewById(R.id.log_list);
List<LogResult> logs = logPersistence.getLogs();
logListViewAdapter = new LogListViewAdapter(logs, this);
logListView.setAdapter(logListViewAdapter);
final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.log_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
List<LogResult> refreshLogs = logPersistence.getLogs();
logListViewAdapter.updateLogs(refreshLogs);
swipeRefreshLayout.setRefreshing(false);
}
});
boolean loggingOn = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(GENEARL_LOG_KEY, false);
if (!loggingOn) {
Toast.makeText(this, R.string.logging_turned_off_message, Toast.LENGTH_LONG).show();
}
}
示例10: initSwipeRefresh
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
private void initSwipeRefresh() {
swipeRefreshLayout = (SwipeRefreshLayout) contentView.findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setColorSchemeColors(ExtraUtil.fetchColor(getContext(), R.attr.colorAccent));
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
(new LoadAppsTask()).execute(true);
}
});
}
示例11: onCreate
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
url = getIntent().getStringExtra(URL_KEY);
detailContentParsable = new DetailContentParsable(url);
setContentView(R.layout.activity_view_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setTitle(getIntent().getStringExtra(TITLE_KEY));
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppUtil.openWebPageAndShowSnackbarIfFail(ViewDetailActivity.this, url, view);
}
});
toolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
AppUtil.setupSwipeRefreshLayoutColors(swipeRefreshLayout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshAsync();
}
});
detailWebView = (WebView) findViewById(R.id.detail_web_view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
refreshAsync();
}
示例12: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
@Nullable
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tencent_shehui, container, false);
refreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
listView = (ListView) view.findViewById(R.id.list_view);
adapter = new MyBaseAdapter<Map<String, Object>>(getActivity(), data) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_tencent_news, position);
Map<String, Object> map = data.get(position);
holder.setText(R.id.title, map.get("title").toString())
.setText(R.id.abstract_content, map.get("abstract").toString())
.setText(R.id.time, FormatUtil.getRelativeTimeSpanString(
new Date((long) (((double) map.get("timestamp")) * 1000))
));
holder.setNetImage(R.id.thumbnails, ((List) map.get("thumbnails_qqnews")).get(0).toString());
return holder.getConvertView();
}
};
listView.setAdapter(adapter);
loadMoreFooter = new LoadMoreFooter(getActivity(), listView, this);
refreshLayout.setOnRefreshListener(this);
listView.setOnItemClickListener(this);
refreshLayout.setRefreshing(true);
return view;
}
示例13: onCreate
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zhihu_daily);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.zhihu_daily);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ZhiHuDailyActivity.this.finish();
}
});
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
listView = (ListView) findViewById(R.id.list_view);
refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
adapter = new MyBaseAdapter<Story>(this, data) {
List<Integer> positions = new ArrayList<>();
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = ViewHolder.get(context, convertView, parent, R.layout.list_view_item_zhihudaily, position);
Story story = _data.get(position);
holder.setText(R.id.title, story.getTitle());
if (story.getImages().size() > 0) {
positions.add(holder.getPosition());
} else {
positions.remove((Integer) holder.getPosition());
}
if (positions.contains(holder.getPosition())) {
holder.setNetImage(R.id.image, story.getImages().get(0));
}
return holder.getConvertView();
}
};
listView.setAdapter(adapter);
loadMoreFooter = new LoadMoreFooter(this, listView, this);
refreshLayout.setOnRefreshListener(this);
listView.setOnItemClickListener(this);
refreshLayout.setRefreshing(true);
initData();
}
示例14: onCreate
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cnode);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.cnode);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CNodeActivity.this.finish();
}
});
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
recylerView = (RecyclerView) findViewById(R.id.recylerView);
recylerView.setLayoutManager(new LinearLayoutManager(this));
recylerView.addItemDecoration(new MyRecylerViewAdapter.DividerItemDecoration(this, MyRecylerViewAdapter.DividerItemDecoration.VERTICAL_LIST));
refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
adapter = new MyRecylerViewAdapter<Data>(this, data) {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case -1:
return new TypeViewHolder(inflater.inflate(R.layout.recylerview_footer_load_more, parent, false)) {
@Override
public void bindHolder(Data model) {
}
};
case 0:
return new TypeViewHolder(inflater.inflate(R.layout.list_view_item_cnode, parent, false)) {
@Override
public void bindHolder(Data model) {
this.setText(R.id.title, model.getTitle())
.setText(R.id.time, FormatUtil.getRelativeTimeSpanString(model.getCreate_at()))
.setText(R.id.replyCount, String.valueOf(model.getReply_count()));
this.setNetImage(R.id.avatar, model.getAuthor().getAvatar_url());
}
};
}
return null;
}
@Override
public int getItemViewType(int position) {
if (super.list.get(position) == null) return -1;
return 0;
}
};
adapter.setOnItemClickListener(this);
recylerView.setAdapter(adapter);
recylerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
int totalItemCount = layoutManager.getItemCount();
int lastVisibleItem = layoutManager.findLastVisibleItemPosition();
if (!loading && totalItemCount < lastVisibleItem + 3) {
page++;
initData();
loading = true;
}
}
});
refreshLayout.setOnRefreshListener(this);
refreshLayout.setRefreshing(true);
initData();
}
示例15: initViews
import android.support.v4.widget.SwipeRefreshLayout; //导入方法依赖的package包/类
protected void initViews(){
messageBoxView = (ChatMessageBoxView) findViewById(R.id.chat_sdk_message_box);
messageBoxView.setAlertToast(chatSDKUiHelper.getAlertToast());
chatSDKChatHelper.setMessageBoxView(messageBoxView);
progressBar = (ProgressBar) findViewById(R.id.chat_sdk_progressbar);
chatSDKChatHelper.setProgressBar(progressBar);
final SwipeRefreshLayout mSwipeRefresh = (SwipeRefreshLayout)findViewById(R.id.ptr_layout);
mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (DEBUG) Timber.d("onRefreshStarted");
BNetworkManager.sharedManager().getNetworkAdapter().loadMoreMessagesForThread(thread)
.done(new DoneCallback<List<BMessage>>() {
@Override
public void onDone(List<BMessage> bMessages) {
if (DEBUG)
Timber.d("New messages are loaded, Amount: %s", (bMessages == null ? "No messages" : bMessages.size()));
if (bMessages.size() < 2)
showToast(getString(R.string.chat_activity_no_more_messages_to_load_toast));
else {
// Saving the position in the list so we could back to it after the update.
chatSDKChatHelper.loadMessages(true, false, -1, messagesListAdapter.getCount() + bMessages.size());
}
mSwipeRefresh.setRefreshing(false);
}
})
.fail(new FailCallback<Void>() {
@Override
public void onFail(Void aVoid) {
mSwipeRefresh.setRefreshing(false);
}
});
}
});
listMessages = (ListView) findViewById(R.id.list_chat);
chatSDKChatHelper.setListMessages(listMessages);
if (messagesListAdapter == null)
messagesListAdapter = new ChatSDKMessagesListAdapter(ChatSDKAbstractChatActivity.this, BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel().getId());
listMessages.setAdapter(messagesListAdapter);
chatSDKChatHelper.setMessagesListAdapter(messagesListAdapter);
}