Java Code Examples for androidx.swiperefreshlayout.widget.SwipeRefreshLayout#post()
The following examples show how to use
androidx.swiperefreshlayout.widget.SwipeRefreshLayout#post() .
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: FavoriteFragment.java From memorize with MIT License | 6 votes |
@Override public void setLoadingIndicator(final boolean active) { if (getView() == null) { return; } final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.fav_swiper); // Make sure setRefreshing() is called after the layout is done with everything else. refreshLayout.post(new Runnable() { @Override public void run() { refreshLayout.setRefreshing(active); } }); }
Example 2
Source File: MobiComQuickConversationFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void onPreExecute() { super.onPreExecute(); isAlreadyLoading = true; if (loadMoreMessages) { if (!messageList.contains(null)) { messageList.add(null); } if (recyclerAdapter != null) { recyclerAdapter.notifyItemInserted(messageList.size() - 1); } } else { if (swipeRefreshLayoutWeakReference != null) { final SwipeRefreshLayout swipeRefreshLayout = swipeRefreshLayoutWeakReference.get(); if (swipeRefreshLayout != null) { swipeRefreshLayout.setEnabled(true); swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); } }); } } } }
Example 3
Source File: WordsFragment.java From memorize with MIT License | 5 votes |
@Override public void setLoadingIndicator(final boolean active) { if (getView() == null) { return; } final SwipeRefreshLayout refreshLayout = getView().findViewById(R.id.swipe_layout); // Make sure setRefreshing() is called after the layout is done with everything else. refreshLayout.post(new Runnable() { @Override public void run() { refreshLayout.setRefreshing(active); } }); }
Example 4
Source File: UIUtils.java From Kore with Apache License 2.0 | 5 votes |
/** * Use this to manually start the swiperefreshlayout refresh animation. * Fixes issue with refresh animation not showing when using appcompat library (from version 20?) * See https://code.google.com/p/android/issues/detail?id=77712 * @param layout */ public static void showRefreshAnimation(@NonNull final SwipeRefreshLayout layout) { layout.post(new Runnable() { @Override public void run() { layout.setRefreshing(true); } }); }
Example 5
Source File: MobiComQuickConversationFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void onPostExecute(Long result) { if (!loadMoreMessages) { if (swipeRefreshLayoutWeakReference != null) { final SwipeRefreshLayout swipeRefreshLayout = swipeRefreshLayoutWeakReference.get(); if (swipeRefreshLayout != null) { swipeRefreshLayout.setEnabled(true); swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(false); } }); } } } if (!loadMoreMessages) { messageList.clear(); latestMessageForEachContact.clear(); } if (!TextUtils.isEmpty(searchString)) { messageList.addAll(nextMessageList); } else { for (Message currentMessage : nextMessageList) { if (currentMessage.isSentToMany()) { continue; } Message recentSms; if (currentMessage.getGroupId() != null) { recentSms = latestMessageForEachContact.get(ConversationUIService.GROUP + currentMessage.getGroupId()); } else { recentSms = latestMessageForEachContact.get(currentMessage.getContactIds()); } if (recentSms != null) { if (currentMessage.getCreatedAtTime() >= recentSms.getCreatedAtTime()) { if (currentMessage.getGroupId() != null) { latestMessageForEachContact.put(ConversationUIService.GROUP + currentMessage.getGroupId(), currentMessage); } else { latestMessageForEachContact.put(currentMessage.getContactIds(), currentMessage); } messageList.remove(recentSms); messageList.add(currentMessage); } } else { if (currentMessage.getGroupId() != null) { latestMessageForEachContact.put(ConversationUIService.GROUP + currentMessage.getGroupId(), currentMessage); } else { latestMessageForEachContact.put(currentMessage.getContactIds(), currentMessage); } messageList.add(currentMessage); } } } if (loadMoreMessages) { if (messageList.contains(null)) { messageList.remove(null); } //progressBar.setVisibility(View.GONE); } if (recyclerAdapter != null) { recyclerAdapter.notifyDataSetChanged(); } if (initial) { if (textViewWeakReference != null) { TextView emptyTextView = textViewWeakReference.get(); if (emptyTextView != null) { emptyTextView.setVisibility(messageList.isEmpty() ? View.VISIBLE : View.GONE); if (!TextUtils.isEmpty(searchString) && messageList.isEmpty()) { emptyTextView.setText(!TextUtils.isEmpty(alCustomizationSettings.getNoSearchFoundForChatMessages()) ? alCustomizationSettings.getNoSearchFoundForChatMessages() : noConversationFound); } else if (TextUtils.isEmpty(searchString) && messageList.isEmpty()) { emptyTextView.setText(!TextUtils.isEmpty(alCustomizationSettings.getNoConversationLabel()) ? alCustomizationSettings.getNoConversationLabel() : conversationLabel); } } } if (!messageList.isEmpty()) { if (recyclerView != null && recyclerAdapter != null) { if (recyclerAdapter.getItemCount() > BroadcastService.lastIndexForChats) { recyclerView.scrollToPosition(BroadcastService.lastIndexForChats); BroadcastService.lastIndexForChats = 0; } else { recyclerView.scrollToPosition(0); } } } } else { if (!loadMoreMessages && recyclerViewWr != null && recyclerViewWr.get() != null) { recyclerViewWr.get().scrollToPosition(firstVisibleItem); } } if (!nextMessageList.isEmpty()) { loadMore = true; } isAlreadyLoading = false; }