Austin Huang
4 years ago
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
19 changed files with 91 additions and 228 deletions
-
4app/src/main/java/awais/instagrabber/activities/MainActivity.java
-
10app/src/main/java/awais/instagrabber/adapters/viewholder/NotificationViewHolder.java
-
66app/src/main/java/awais/instagrabber/asyncs/NotificationsFetcher.java
-
19app/src/main/java/awais/instagrabber/fragments/NotificationsViewerFragment.java
-
6app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
4app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java
-
36app/src/main/java/awais/instagrabber/models/enums/NotificationType.java
-
11app/src/main/java/awais/instagrabber/repositories/NewsRepository.java
-
4app/src/main/java/awais/instagrabber/repositories/responses/Notification.java
-
46app/src/main/java/awais/instagrabber/services/ActivityCheckerService.java
-
2app/src/main/java/awais/instagrabber/utils/Constants.java
-
98app/src/main/java/awais/instagrabber/webservices/NewsService.java
-
1app/src/main/res/navigation/direct_messages_nav_graph.xml
-
1app/src/main/res/navigation/discover_nav_graph.xml
-
1app/src/main/res/navigation/feed_nav_graph.xml
-
1app/src/main/res/navigation/more_nav_graph.xml
-
5app/src/main/res/navigation/notification_viewer_nav_graph.xml
-
1app/src/main/res/navigation/profile_nav_graph.xml
-
3app/src/main/res/values/strings.xml
@ -1,66 +0,0 @@ |
|||||
package awais.instagrabber.asyncs; |
|
||||
|
|
||||
import android.os.AsyncTask; |
|
||||
import android.util.Log; |
|
||||
|
|
||||
import java.util.ArrayList; |
|
||||
import java.util.List; |
|
||||
|
|
||||
import awais.instagrabber.BuildConfig; |
|
||||
import awais.instagrabber.interfaces.FetchListener; |
|
||||
import awais.instagrabber.repositories.responses.Notification; |
|
||||
import awais.instagrabber.webservices.NewsService; |
|
||||
import awais.instagrabber.webservices.ServiceCallback; |
|
||||
import awaisomereport.LogCollector; |
|
||||
|
|
||||
import static awais.instagrabber.utils.Utils.logCollector; |
|
||||
|
|
||||
public final class NotificationsFetcher extends AsyncTask<Void, Void, List<Notification>> { |
|
||||
private static final String TAG = "NotificationsFetcher"; |
|
||||
|
|
||||
private final FetchListener<List<Notification>> fetchListener; |
|
||||
private final NewsService newsService; |
|
||||
private final boolean markAsSeen; |
|
||||
private boolean fetchedWeb = false; |
|
||||
|
|
||||
public NotificationsFetcher(final boolean markAsSeen, |
|
||||
final FetchListener<List<Notification>> fetchListener) { |
|
||||
this.markAsSeen = markAsSeen; |
|
||||
this.fetchListener = fetchListener; |
|
||||
newsService = NewsService.getInstance(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected List<Notification> doInBackground(final Void... voids) { |
|
||||
List<Notification> notificationModels = new ArrayList<>(); |
|
||||
|
|
||||
newsService.fetchAppInbox(markAsSeen, new ServiceCallback<List<Notification>>() { |
|
||||
@Override |
|
||||
public void onSuccess(final List<Notification> result) { |
|
||||
if (result == null) return; |
|
||||
notificationModels.addAll(result); |
|
||||
if (fetchedWeb) { |
|
||||
fetchListener.onResult(notificationModels); |
|
||||
} |
|
||||
else { |
|
||||
fetchedWeb = true; |
|
||||
newsService.fetchWebInbox(this); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void onFailure(final Throwable t) { |
|
||||
// Log.e(TAG, "onFailure: ", t); |
|
||||
if (fetchListener != null) { |
|
||||
fetchListener.onFailure(t); |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
return notificationModels; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected void onPreExecute() { |
|
||||
if (fetchListener != null) fetchListener.doBefore(); |
|
||||
} |
|
||||
} |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue