Browse Source

Convert to kotlin

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
c18e1ddb93
  1. 2
      app/src/main/java/awais/instagrabber/managers/InboxManager.java
  2. 18
      app/src/main/java/awais/instagrabber/managers/ThreadManager.java
  3. 114
      app/src/main/java/awais/instagrabber/repositories/requests/UploadFinishOptions.java
  4. 27
      app/src/main/java/awais/instagrabber/repositories/requests/UploadFinishOptions.kt
  5. 31
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectBadgeCount.java
  6. 8
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectBadgeCount.kt
  7. 62
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInbox.java
  8. 15
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInbox.kt
  9. 64
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInboxResponse.java
  10. 14
      app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInboxResponse.kt
  11. 12
      app/src/main/java/awais/instagrabber/webservices/MediaService.java

2
app/src/main/java/awais/instagrabber/managers/InboxManager.java

@ -220,7 +220,7 @@ public final class InboxManager {
}
this.inbox.postValue(Resource.success(inbox));
cursor = inbox.getOldestCursor();
hasOlder = inbox.hasOlder();
hasOlder = inbox.getHasOlder();
pendingRequestsTotal.postValue(response.getPendingRequestsTotal());
}

18
app/src/main/java/awais/instagrabber/managers/ThreadManager.java

@ -40,6 +40,7 @@ import awais.instagrabber.models.Resource.Status;
import awais.instagrabber.models.UploadVideoOptions;
import awais.instagrabber.models.enums.DirectItemType;
import awais.instagrabber.repositories.requests.UploadFinishOptions;
import awais.instagrabber.repositories.requests.VideoOptions;
import awais.instagrabber.repositories.requests.directmessages.ThreadIdOrUserIds;
import awais.instagrabber.repositories.responses.FriendshipChangeResponse;
import awais.instagrabber.repositories.responses.FriendshipRestrictResponse;
@ -694,9 +695,11 @@ public final class ThreadManager {
public void onUploadComplete(final MediaUploader.MediaUploadResponse response) {
// Log.d(TAG, "onUploadComplete: " + response);
if (handleInvalidResponse(data, response)) return;
final UploadFinishOptions uploadFinishOptions = new UploadFinishOptions()
.setUploadId(uploadDmVoiceOptions.getUploadId())
.setSourceType("4");
final UploadFinishOptions uploadFinishOptions = new UploadFinishOptions(
uploadDmVoiceOptions.getUploadId(),
"4",
null
);
final Call<String> uploadFinishRequest = mediaService.uploadFinish(uploadFinishOptions);
uploadFinishRequest.enqueue(new Callback<String>() {
@Override
@ -1082,10 +1085,11 @@ public final class ThreadManager {
public void onUploadComplete(final MediaUploader.MediaUploadResponse response) {
// Log.d(TAG, "onUploadComplete: " + response);
if (handleInvalidResponse(data, response)) return;
final UploadFinishOptions uploadFinishOptions = new UploadFinishOptions()
.setUploadId(uploadDmVideoOptions.getUploadId())
.setSourceType("2")
.setVideoOptions(new UploadFinishOptions.VideoOptions().setLength(duration / 1000f));
final UploadFinishOptions uploadFinishOptions = new UploadFinishOptions(
uploadDmVideoOptions.getUploadId(),
"2",
new VideoOptions(duration / 1000f, Collections.emptyList(), 0, false)
);
final Call<String> uploadFinishRequest = mediaService.uploadFinish(uploadFinishOptions);
uploadFinishRequest.enqueue(new Callback<String>() {
@Override

114
app/src/main/java/awais/instagrabber/repositories/requests/UploadFinishOptions.java

@ -1,114 +0,0 @@
package awais.instagrabber.repositories.requests;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
public class UploadFinishOptions {
private String uploadId;
private String sourceType;
private VideoOptions videoOptions;
public String getUploadId() {
return uploadId;
}
public UploadFinishOptions setUploadId(final String uploadId) {
this.uploadId = uploadId;
return this;
}
public String getSourceType() {
return sourceType;
}
public UploadFinishOptions setSourceType(final String sourceType) {
this.sourceType = sourceType;
return this;
}
public VideoOptions getVideoOptions() {
return videoOptions;
}
public UploadFinishOptions setVideoOptions(final VideoOptions videoOptions) {
this.videoOptions = videoOptions;
return this;
}
public static class VideoOptions {
private float length;
private List<Clip> clips;
private int posterFrameIndex;
private boolean audioMuted;
public float getLength() {
return length;
}
public VideoOptions setLength(final float length) {
this.length = length;
return this;
}
public List<Clip> getClips() {
return clips;
}
public VideoOptions setClips(final List<Clip> clips) {
this.clips = clips;
return this;
}
public int getPosterFrameIndex() {
return posterFrameIndex;
}
public VideoOptions setPosterFrameIndex(final int posterFrameIndex) {
this.posterFrameIndex = posterFrameIndex;
return this;
}
public boolean isAudioMuted() {
return audioMuted;
}
public VideoOptions setAudioMuted(final boolean audioMuted) {
this.audioMuted = audioMuted;
return this;
}
public Map<String, Object> getMap() {
return ImmutableMap.of(
"length", length,
"clips", clips,
"poster_frame_index", posterFrameIndex,
"audio_muted", audioMuted
);
}
}
public static class Clip {
private float length;
private String sourceType;
public float getLength() {
return length;
}
public Clip setLength(final float length) {
this.length = length;
return this;
}
public String getSourceType() {
return sourceType;
}
public Clip setSourceType(final String sourceType) {
this.sourceType = sourceType;
return this;
}
}
}

27
app/src/main/java/awais/instagrabber/repositories/requests/UploadFinishOptions.kt

@ -0,0 +1,27 @@
package awais.instagrabber.repositories.requests
data class UploadFinishOptions(
val uploadId: String,
val sourceType: String,
val videoOptions: VideoOptions? = null
)
data class VideoOptions(
val length: Float = 0f,
var clips: List<Clip> = emptyList(),
val posterFrameIndex: Int = 0,
val isAudioMuted: Boolean = false
) {
val map: Map<String, Any>
get() = mapOf(
"length" to length,
"clips" to clips,
"poster_frame_index" to posterFrameIndex,
"audio_muted" to isAudioMuted
)
}
data class Clip(
val length: Float = 0f,
val sourceType: String
)

31
app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectBadgeCount.java

@ -1,31 +0,0 @@
package awais.instagrabber.repositories.responses.directmessages;
public class DirectBadgeCount {
private final long userId;
private final int badgeCount;
private final long badgeCountAtMs;
private final String status;
public DirectBadgeCount(final long userId, final int badgeCount, final long badgeCountAtMs, final String status) {
this.userId = userId;
this.badgeCount = badgeCount;
this.badgeCountAtMs = badgeCountAtMs;
this.status = status;
}
public long getUserId() {
return userId;
}
public int getBadgeCount() {
return badgeCount;
}
public long getBadgeCountAtMs() {
return badgeCountAtMs;
}
public String getStatus() {
return status;
}
}

8
app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectBadgeCount.kt

@ -0,0 +1,8 @@
package awais.instagrabber.repositories.responses.directmessages
data class DirectBadgeCount(
val userId: Long = 0,
val badgeCount: Int = 0,
val badgeCountAtMs: Long = 0,
val status: String? = null
)

62
app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInbox.java

@ -1,62 +0,0 @@
package awais.instagrabber.repositories.responses.directmessages;
import androidx.annotation.NonNull;
import java.util.List;
public class DirectInbox implements Cloneable {
private List<DirectThread> threads;
private final boolean hasOlder;
private final int unseenCount;
private final String unseenCountTs;
private final String oldestCursor;
private final boolean blendedInboxEnabled;
public DirectInbox(final List<DirectThread> threads,
final boolean hasOlder,
final int unseenCount,
final String unseenCountTs,
final String oldestCursor,
final boolean blendedInboxEnabled) {
this.threads = threads;
this.hasOlder = hasOlder;
this.unseenCount = unseenCount;
this.unseenCountTs = unseenCountTs;
this.oldestCursor = oldestCursor;
this.blendedInboxEnabled = blendedInboxEnabled;
}
public List<DirectThread> getThreads() {
return threads;
}
public void setThreads(final List<DirectThread> threads) {
this.threads = threads;
}
public boolean hasOlder() {
return hasOlder;
}
public int getUnseenCount() {
return unseenCount;
}
public String getUnseenCountTs() {
return unseenCountTs;
}
public String getOldestCursor() {
return oldestCursor;
}
public boolean isBlendedInboxEnabled() {
return blendedInboxEnabled;
}
@NonNull
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}

15
app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInbox.kt

@ -0,0 +1,15 @@
package awais.instagrabber.repositories.responses.directmessages
data class DirectInbox(
var threads: List<DirectThread>? = emptyList(),
val hasOlder: Boolean = false,
val unseenCount: Int = 0,
val unseenCountTs: String? = null,
val oldestCursor: String? = null,
val blendedInboxEnabled: Boolean
) : Cloneable {
@Throws(CloneNotSupportedException::class)
public override fun clone(): Any {
return super.clone()
}
}

64
app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInboxResponse.java

@ -1,64 +0,0 @@
package awais.instagrabber.repositories.responses.directmessages;
import awais.instagrabber.repositories.responses.User;
public class DirectInboxResponse {
private final User viewer;
private final DirectInbox inbox;
private final long seqId;
private final long snapshotAtMs;
private final int pendingRequestsTotal;
private final boolean hasPendingTopRequests;
private final User mostRecentInviter;
private final String status;
public DirectInboxResponse(final User viewer,
final DirectInbox inbox,
final long seqId,
final long snapshotAtMs,
final int pendingRequestsTotal,
final boolean hasPendingTopRequests,
final User mostRecentInviter,
final String status) {
this.viewer = viewer;
this.inbox = inbox;
this.seqId = seqId;
this.snapshotAtMs = snapshotAtMs;
this.pendingRequestsTotal = pendingRequestsTotal;
this.hasPendingTopRequests = hasPendingTopRequests;
this.mostRecentInviter = mostRecentInviter;
this.status = status;
}
public User getViewer() {
return viewer;
}
public DirectInbox getInbox() {
return inbox;
}
public long getSeqId() {
return seqId;
}
public long getSnapshotAtMs() {
return snapshotAtMs;
}
public int getPendingRequestsTotal() {
return pendingRequestsTotal;
}
public boolean hasPendingTopRequests() {
return hasPendingTopRequests;
}
public User getMostRecentInviter() {
return mostRecentInviter;
}
public String getStatus() {
return status;
}
}

14
app/src/main/java/awais/instagrabber/repositories/responses/directmessages/DirectInboxResponse.kt

@ -0,0 +1,14 @@
package awais.instagrabber.repositories.responses.directmessages
import awais.instagrabber.repositories.responses.User
data class DirectInboxResponse(
val viewer: User? = null,
val inbox: DirectInbox? = null,
val seqId: Long = 0,
val snapshotAtMs: Long = 0,
val pendingRequestsTotal: Int = 0,
val hasPendingTopRequests: Boolean = false,
val mostRecentInviter: User? = null,
val status: String? = null,
)

12
app/src/main/java/awais/instagrabber/webservices/MediaService.java

@ -21,7 +21,9 @@ import java.util.UUID;
import awais.instagrabber.models.Comment;
import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.repositories.MediaRepository;
import awais.instagrabber.repositories.requests.Clip;
import awais.instagrabber.repositories.requests.UploadFinishOptions;
import awais.instagrabber.repositories.requests.VideoOptions;
import awais.instagrabber.repositories.responses.LikersResponse;
import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.repositories.responses.MediaInfoResponse;
@ -443,13 +445,9 @@ public class MediaService extends BaseService {
public Call<String> uploadFinish(@NonNull final UploadFinishOptions options) {
if (options.getVideoOptions() != null) {
final UploadFinishOptions.VideoOptions videoOptions = options.getVideoOptions();
if (videoOptions.getClips() == null) {
videoOptions.setClips(Collections.singletonList(
new UploadFinishOptions.Clip()
.setLength(videoOptions.getLength())
.setSourceType(options.getSourceType())
));
final VideoOptions videoOptions = options.getVideoOptions();
if (videoOptions.getClips().isEmpty()) {
videoOptions.setClips(Collections.singletonList(new Clip(videoOptions.getLength(), options.getSourceType())));
}
}
final String timezoneOffset = String.valueOf(DateUtils.getTimezoneOffset());

Loading…
Cancel
Save