正在查看: OLX India v19.42.007 应用的 PostingIntentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: OLX India v19.42.007 应用的 PostingIntentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.olxgroup.panamera.app.common.services;
import android.app.Notification;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import androidx.core.app.a0;
import com.olxgroup.panamera.domain.buyers.common.entity.ad.AdItem;
import com.olxgroup.panamera.domain.buyers.common.entity.ad.Status;
import com.olxgroup.panamera.domain.seller.posting.entity.AdValidationResults;
import com.olxgroup.panamera.domain.seller.posting.entity.PostingDraft;
import com.olxgroup.panamera.domain.seller.posting.entity.PostingStatusUpdate;
import com.olxgroup.panamera.domain.seller.posting.entity.exception.PostingException;
import com.olxgroup.panamera.domain.seller.posting.repository.PostingDraftRepository;
import com.olxgroup.panamera.domain.seller.posting.repository.PostingPhotoUploadRepository;
import com.olxgroup.panamera.domain.seller.posting.repository.PostingPhotoUploadStatus;
import com.olxgroup.panamera.domain.seller.posting.repository.PostingRepository;
import com.olxgroup.panamera.domain.shell.LoggerDomainContract;
import com.olxgroup.panamera.domain.users.common.repository.PhotoRepository;
import olx.com.delorean.domain.utils.EventBus;
public class PostingIntentService extends f {
PostingRepository d;
PostingPhotoUploadRepository e;
PostingDraftRepository f;
PhotoRepository g;
EventBus h;
LoggerDomainContract i;
private Handler j;
private boolean k;
private int l;
class a extends io.reactivex.observers.b {
a() {
}
public void onNext(PostingPhotoUploadStatus postingPhotoUploadStatus) {
if (postingPhotoUploadStatus instanceof PostingPhotoUploadStatus.EmptyPhotosException) {
dispose();
PostingIntentService.this.i.log("PostingIntentService - observePhotoUploadStatus : photos empty");
PostingIntentService.this.z();
return;
}
if (postingPhotoUploadStatus instanceof PostingPhotoUploadStatus.PostingPhotoUploadException) {
PostingPhotoUploadStatus.PostingPhotoUploadException postingPhotoUploadException = (PostingPhotoUploadStatus.PostingPhotoUploadException) postingPhotoUploadStatus;
if (PostingIntentService.this.n(postingPhotoUploadException)) {
PostingIntentService.this.B();
return;
} else {
dispose();
PostingIntentService.this.p(postingPhotoUploadException);
return;
}
}
if (postingPhotoUploadStatus instanceof PostingPhotoUploadStatus.PostingPhotoUploadSuccess) {
PostingIntentService.this.A((PostingPhotoUploadStatus.PostingPhotoUploadSuccess) postingPhotoUploadStatus);
} else if (postingPhotoUploadStatus instanceof PostingPhotoUploadStatus.PhotosUploadDone) {
dispose();
PostingIntentService.this.e.reset();
PostingIntentService.this.i.log("PostingIntentService - observePhotoUploadStatus : All Photos Uploaded");
PostingIntentService.this.z();
}
}
public void onComplete() {
}
public void onError(Throwable th) {
PostingIntentService.this.i.log("PostingIntentService - observePhotoUploadStatus : OnError");
}
}
public PostingIntentService() {
super("PostingService");
this.j = new Handler(Looper.getMainLooper());
this.l = 0;
}
public void A(PostingPhotoUploadStatus.PostingPhotoUploadSuccess postingPhotoUploadSuccess) {
this.h.postEvent(postingPhotoUploadSuccess.getPostingStatusUpdate());
}
public void B() {
PostingDraft postingDraft = this.f.getPostingDraft();
if (postingDraft != null) {
this.l++;
this.i.log("PostingIntentService - retryUploadPhotos");
this.e.uploadPhotos(postingDraft.getPhotos());
}
}
private void C(final String str) {
this.j.post(new Runnable() {
@Override
public final void run() {
PostingIntentService.this.s(str);
}
});
}
private void D(final AdValidationResults adValidationResults) {
this.j.post(new Runnable() {
@Override
public final void run() {
PostingIntentService.this.t(adValidationResults);
}
});
}
private void E(final Status status) {
this.j.post(new Runnable() {
@Override
public final void run() {
PostingIntentService.this.u(status);
}
});
}
private void F() {
this.j.post(new Runnable() {
@Override
public final void run() {
PostingIntentService.this.v();
}
});
}
public boolean n(PostingPhotoUploadStatus.PostingPhotoUploadException postingPhotoUploadException) {
return postingPhotoUploadException.getPostingException().getStatus() == Status.NETWORK_ERROR && this.l == 0;
}
private io.reactivex.observers.b o() {
return new a();
}
public void p(PostingPhotoUploadStatus.PostingPhotoUploadException postingPhotoUploadException) {
this.i.log("PostingIntentService - observePhotoUploadStatus : PostingPhotoUploadException");
this.h.postEvent(new PostingStatusUpdate(PostingStatusUpdate.Type.POSTING_EXCEPTION, postingPhotoUploadException.getPostingException(), this.k));
F();
}
private void q(PostingException postingException) {
if (!postingException.isValidationError() || Status.NETWORK_ERROR.equals(postingException.getStatus())) {
E(Status.NETWORK_ERROR);
} else {
E(Status.VALIDATION_ERROR);
D(postingException.getAdValidationResults());
}
this.h.postEvent(new PostingStatusUpdate(PostingStatusUpdate.Type.POSTING_EXCEPTION, postingException, this.k));
F();
}
public void r(AdItem adItem) {
this.f.updatePostedAd(adItem);
}
public void s(String str) {
PostingDraft postingDraft = this.f.getPostingDraft();
if (postingDraft != null) {
postingDraft.setAdId(str);
this.f.updatePostingDraft(postingDraft);
}
}
public void t(AdValidationResults adValidationResults) {
PostingDraft postingDraft = this.f.getPostingDraft();
if (postingDraft != null) {
postingDraft.setAdValidationResults(adValidationResults);
this.f.updatePostingDraft(postingDraft);
}
}
public void u(Status status) {
PostingDraft postingDraft = this.f.getPostingDraft();
if (postingDraft != null) {
postingDraft.setStatus(status);
this.f.updatePostingDraft(postingDraft);
}
}
public void v() {
a0.b(this, 1);
}
private void w() {
this.i.log("PostingIntentService : observePhotoUploadStatus");
this.e.observePhotoUploadStatus().subscribe(o());
}
private void x(final AdItem adItem) {
this.j.post(new Runnable() {
@Override
public final void run() {
PostingIntentService.this.r(adItem);
}
});
}
private AdItem y() {
PostingDraft postingDraft = this.f.getPostingDraft();
if (postingDraft == null) {
this.i.log("PostingIntentService - postAd : postingDraft " + postingDraft);
return null;
}
this.i.log("PostingIntentService - postAd : postingDraft " + postingDraft + " postingDraft.getAdId() " + postingDraft.getAdId());
return TextUtils.isEmpty(postingDraft.getAdId()) ? this.d.postAd(postingDraft) : this.d.editAd(postingDraft);
}
public void z() {
PostingDraft postingDraft = this.f.getPostingDraft();
try {
AdItem y = y();
this.i.log("PostingIntentService - postAdInternal postedAd " + y + " PostingDraft" + postingDraft);
if (postingDraft != null && y != null) {
E(Status.OK);
C(y.getId());
x(y);
this.i.log("PostingIntentService - postAdInternal send event to eventbus POSTED_SUCCESSFULLY");
this.h.postEvent(new PostingStatusUpdate(PostingStatusUpdate.Type.POSTED_SUCCESSFULLY, y, this.k));
}
F();
} catch (PostingException e) {
this.i.log("PostingIntentService - postAdInternal :: PostingException");
q(e);
}
}
@Override
protected void onHandleIntent(Intent intent) {
Notification b = com.olxgroup.panamera.app.common.utils.notifications.e.b(getApplicationContext(), 2032771379, "PostingService", "running");
a0.a(this, 2032771379, b, Build.VERSION.SDK_INT >= 30 ? 1 : 0);
startForeground(2032771379, b);
if (this.f.getPostingDraft() == null) {
F();
return;
}
E(Status.POSTING);
this.k = !TextUtils.isEmpty(r5.getAdId());
w();
}
}