This commit is contained in:
nuclearfog 2020-11-01 16:11:32 +01:00
parent 66cdcec840
commit bb4c51b64a
No known key found for this signature in database
GPG Key ID: D5490E4A81F97B14
4 changed files with 12 additions and 9 deletions

View File

@ -32,6 +32,8 @@ public abstract class ListFragment extends Fragment implements OnRefreshListener
private SwipeRefreshLayout reload;
private GlobalSettings settings;
private boolean isRefreshing = false;
@Override
public final View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent, @Nullable Bundle param) {
@ -56,11 +58,12 @@ public abstract class ListFragment extends Fragment implements OnRefreshListener
* @param enable true to enable swipe view delayed, false to stop immediately
*/
protected void setRefresh(boolean enable) {
isRefreshing = enable;
if (enable) {
reload.postDelayed(new Runnable() {
@Override
public void run() {
if (!reload.isRefreshing()) {
if (isRefreshing) {
reload.setRefreshing(true);
}
}

View File

@ -153,7 +153,7 @@ public class MessageFragment extends ListFragment implements OnRefreshListener,
@Override
public void onConfirm(DialogBuilder.DialogType type) {
messageTask = new MessageListLoader(MessageFragment.this, MessageListLoader.Action.DEL);
messageTask = new MessageListLoader(this, MessageListLoader.Action.DEL);
messageTask.execute(deleteId);
}

View File

@ -77,7 +77,7 @@ public class TrendFragment extends ListFragment implements OnRefreshListener, Tr
@Override
public void onTrendClick(TwitterTrend trend) {
if (!isRefreshing()) {
Intent intent = new Intent(getContext(), SearchPage.class);
Intent intent = new Intent(requireContext(), SearchPage.class);
intent.putExtra(KEY_SEARCH_QUERY, trend.getSearchString());
startActivity(intent);
}
@ -108,8 +108,8 @@ public class TrendFragment extends ListFragment implements OnRefreshListener, Tr
* @param error Twitter exception
*/
public void onError(EngineException error) {
if (getContext() != null)
ErrorHandler.handleFailure(getContext(), error);
if (error != null)
ErrorHandler.handleFailure(requireContext(), error);
setRefresh(false);
}

View File

@ -128,10 +128,10 @@ public class TweetFragment extends ListFragment implements OnRefreshListener, Tw
@Override
public void onTweetClick(Tweet tweet) {
if (getContext() != null && !isRefreshing()) {
if (!isRefreshing()) {
if (tweet.getEmbeddedTweet() != null)
tweet = tweet.getEmbeddedTweet();
Intent tweetIntent = new Intent(getContext(), TweetActivity.class);
Intent tweetIntent = new Intent(requireContext(), TweetActivity.class);
tweetIntent.putExtra(KEY_TWEET_ID, tweet.getId());
tweetIntent.putExtra(KEY_TWEET_NAME, tweet.getUser().getScreenname());
startActivityForResult(tweetIntent, REQUEST_TWEET_CHANGED);
@ -169,8 +169,8 @@ public class TweetFragment extends ListFragment implements OnRefreshListener, Tw
* @param error Twitter exception
*/
public void onError(@Nullable EngineException error) {
if (getContext() != null && error != null)
ErrorHandler.handleFailure(getContext(), error);
if (error != null)
ErrorHandler.handleFailure(requireContext(), error);
adapter.disableLoading();
setRefresh(false);
}