Browse Source
Complete almost all Profile actions using service
renovate/org.robolectric-robolectric-4.x
Complete almost all Profile actions using service
renovate/org.robolectric-robolectric-4.x
Ammar Githam
4 years ago
14 changed files with 385 additions and 85 deletions
-
13app/src/main/java/awais/instagrabber/activities/SavedViewer.java
-
8app/src/main/java/awais/instagrabber/fragments/directmessages/DirectMessageInboxFragment.java
-
112app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
4app/src/main/java/awais/instagrabber/fragments/settings/helpers/AutoSummaryDropDownPreference.java
-
17app/src/main/java/awais/instagrabber/repositories/FriendshipRepository.java
-
21app/src/main/java/awais/instagrabber/repositories/responses/FriendshipRepoChangeResponseFriendshipStatus.java
-
9app/src/main/java/awais/instagrabber/repositories/responses/FriendshipRepoChangeRootResponse.java
-
40app/src/main/java/awais/instagrabber/repositories/responses/FriendshipRepoRestrictResponseFriendshipStatus.java
-
65app/src/main/java/awais/instagrabber/repositories/responses/FriendshipRepoRestrictResponseUsersItem.java
-
32app/src/main/java/awais/instagrabber/repositories/responses/FriendshipRepoRestrictRootResponse.java
-
25app/src/main/java/awais/instagrabber/repositories/responses/LoginRequiredResponse.java
-
22app/src/main/java/awais/instagrabber/services/BaseService.java
-
73app/src/main/java/awais/instagrabber/services/FriendshipService.java
-
29app/src/main/java/awais/instagrabber/services/LoggingInterceptor.java
@ -1,4 +0,0 @@ |
|||||
package awais.instagrabber.fragments.settings.helpers; |
|
||||
|
|
||||
public class AutoSummaryDropDownPreference { |
|
||||
} |
|
@ -1,15 +1,16 @@ |
|||||
package awais.instagrabber.repositories.responses; |
package awais.instagrabber.repositories.responses; |
||||
|
|
||||
public class FriendshipRepositoryChangeResponseRootObject { |
|
||||
private FriendshipRepositoryChangeResponseFriendshipStatus friendshipStatus; |
|
||||
|
public class FriendshipRepoChangeRootResponse { |
||||
|
private FriendshipRepoChangeResponseFriendshipStatus friendshipStatus; |
||||
private String status; |
private String status; |
||||
|
|
||||
public FriendshipRepositoryChangeResponseRootObject(final FriendshipRepositoryChangeResponseFriendshipStatus friendshipStatus, final String status) { |
|
||||
|
public FriendshipRepoChangeRootResponse(final FriendshipRepoChangeResponseFriendshipStatus friendshipStatus, |
||||
|
final String status) { |
||||
this.friendshipStatus = friendshipStatus; |
this.friendshipStatus = friendshipStatus; |
||||
this.status = status; |
this.status = status; |
||||
} |
} |
||||
|
|
||||
public FriendshipRepositoryChangeResponseFriendshipStatus getFriendshipStatus() { |
|
||||
|
public FriendshipRepoChangeResponseFriendshipStatus getFriendshipStatus() { |
||||
return friendshipStatus; |
return friendshipStatus; |
||||
} |
} |
||||
|
|
@ -0,0 +1,40 @@ |
|||||
|
package awais.instagrabber.repositories.responses; |
||||
|
|
||||
|
import androidx.annotation.NonNull; |
||||
|
|
||||
|
public class FriendshipRepoRestrictResponseFriendshipStatus extends FriendshipRepoChangeResponseFriendshipStatus { |
||||
|
private boolean isRestricted; |
||||
|
|
||||
|
public FriendshipRepoRestrictResponseFriendshipStatus(final boolean following, |
||||
|
final boolean followedBy, |
||||
|
final boolean blocking, |
||||
|
final boolean muting, |
||||
|
final boolean isPrivate, |
||||
|
final boolean incomingRequest, |
||||
|
final boolean outgoingRequest, |
||||
|
final boolean isBestie, |
||||
|
final boolean isRestricted) { |
||||
|
super(following, followedBy, blocking, muting, isPrivate, incomingRequest, outgoingRequest, isBestie); |
||||
|
this.isRestricted = isRestricted; |
||||
|
} |
||||
|
|
||||
|
public boolean isRestricted() { |
||||
|
return isRestricted; |
||||
|
} |
||||
|
|
||||
|
@NonNull |
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "FriendshipRepoRestrictResponseFriendshipStatus{" + |
||||
|
"following=" + isFollowing() + |
||||
|
", followedBy=" + isFollowedBy() + |
||||
|
", blocking=" + isBlocking() + |
||||
|
", muting=" + isMuting() + |
||||
|
", isPrivate=" + isPrivate() + |
||||
|
", incomingRequest=" + isIncomingRequest() + |
||||
|
", outgoingRequest=" + isOutgoingRequest() + |
||||
|
", isBestie=" + isBestie() + |
||||
|
", isRestricted=" + isRestricted() + |
||||
|
'}'; |
||||
|
} |
||||
|
} |
@ -0,0 +1,65 @@ |
|||||
|
package awais.instagrabber.repositories.responses; |
||||
|
|
||||
|
import androidx.annotation.NonNull; |
||||
|
|
||||
|
public class FriendshipRepoRestrictResponseUsersItem { |
||||
|
private long pk; |
||||
|
private String username; |
||||
|
private String fullName; |
||||
|
private boolean isPrivate; |
||||
|
private String profilePicUrl; |
||||
|
private FriendshipRepoRestrictResponseFriendshipStatus friendshipStatus; |
||||
|
private boolean isVerified; |
||||
|
|
||||
|
public FriendshipRepoRestrictResponseUsersItem(final long pk, final String username, final String fullName, final boolean isPrivate, final String profilePicUrl, final FriendshipRepoRestrictResponseFriendshipStatus friendshipStatus, final boolean isVerified) { |
||||
|
this.pk = pk; |
||||
|
this.username = username; |
||||
|
this.fullName = fullName; |
||||
|
this.isPrivate = isPrivate; |
||||
|
this.profilePicUrl = profilePicUrl; |
||||
|
this.friendshipStatus = friendshipStatus; |
||||
|
this.isVerified = isVerified; |
||||
|
} |
||||
|
|
||||
|
public long getPk() { |
||||
|
return pk; |
||||
|
} |
||||
|
|
||||
|
public String getUsername() { |
||||
|
return username; |
||||
|
} |
||||
|
|
||||
|
public String getFullName() { |
||||
|
return fullName; |
||||
|
} |
||||
|
|
||||
|
public boolean isPrivate() { |
||||
|
return isPrivate; |
||||
|
} |
||||
|
|
||||
|
public String getProfilePicUrl() { |
||||
|
return profilePicUrl; |
||||
|
} |
||||
|
|
||||
|
public FriendshipRepoRestrictResponseFriendshipStatus getFriendshipStatus() { |
||||
|
return friendshipStatus; |
||||
|
} |
||||
|
|
||||
|
public boolean isVerified() { |
||||
|
return isVerified; |
||||
|
} |
||||
|
|
||||
|
@NonNull |
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "FriendshipRepoRestrictResponseUsersItem{" + |
||||
|
"pk=" + pk + |
||||
|
", username='" + username + '\'' + |
||||
|
", fullName='" + fullName + '\'' + |
||||
|
", isPrivate=" + isPrivate + |
||||
|
", profilePicUrl='" + profilePicUrl + '\'' + |
||||
|
", friendshipStatus=" + friendshipStatus + |
||||
|
", isVerified=" + isVerified + |
||||
|
'}'; |
||||
|
} |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
package awais.instagrabber.repositories.responses; |
||||
|
|
||||
|
import androidx.annotation.NonNull; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public class FriendshipRepoRestrictRootResponse { |
||||
|
private List<FriendshipRepoRestrictResponseUsersItem> users; |
||||
|
private String status; |
||||
|
|
||||
|
public FriendshipRepoRestrictRootResponse(final List<FriendshipRepoRestrictResponseUsersItem> users, final String status) { |
||||
|
this.users = users; |
||||
|
this.status = status; |
||||
|
} |
||||
|
|
||||
|
public List<FriendshipRepoRestrictResponseUsersItem> getUsers() { |
||||
|
return users; |
||||
|
} |
||||
|
|
||||
|
public String getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
|
||||
|
@NonNull |
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "FriendshipRepoRestrictRootResponse{" + |
||||
|
"users=" + users + |
||||
|
", status='" + status + '\'' + |
||||
|
'}'; |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package awais.instagrabber.repositories.responses; |
||||
|
|
||||
|
public class LoginRequiredResponse { |
||||
|
private String message = "login_required"; |
||||
|
private int logoutReason; |
||||
|
private String status = "fail"; |
||||
|
|
||||
|
public LoginRequiredResponse(final String message, final int logoutReason, final String status) { |
||||
|
this.message = message; |
||||
|
this.logoutReason = logoutReason; |
||||
|
this.status = status; |
||||
|
} |
||||
|
|
||||
|
public String getMessage() { |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public int getLogoutReason() { |
||||
|
return logoutReason; |
||||
|
} |
||||
|
|
||||
|
public String getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package awais.instagrabber.services; |
||||
|
|
||||
|
import android.util.Log; |
||||
|
|
||||
|
import androidx.annotation.NonNull; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
|
||||
|
import okhttp3.Interceptor; |
||||
|
import okhttp3.Request; |
||||
|
import okhttp3.Response; |
||||
|
|
||||
|
class LoggingInterceptor implements Interceptor { |
||||
|
private static final String TAG = "LoggingInterceptor"; |
||||
|
|
||||
|
@NonNull |
||||
|
@Override |
||||
|
public Response intercept(Interceptor.Chain chain) throws IOException { |
||||
|
Request request = chain.request(); |
||||
|
long t1 = System.nanoTime(); |
||||
|
Log.i(TAG, String.format("Sending request %s on %s%n%s", |
||||
|
request.url(), chain.connection(), request.headers())); |
||||
|
Response response = chain.proceed(request); |
||||
|
long t2 = System.nanoTime(); |
||||
|
Log.i(TAG, String.format("Received response for %s in %.1fms%n%s\nbody: %s", |
||||
|
response.request().url(), (t2 - t1) / 1e6d, response.headers(), response.body())); |
||||
|
return response; |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue