Initial commit
This commit is contained in:
95
sources/com/facebook/ProgressOutputStream.java
Normal file
95
sources/com/facebook/ProgressOutputStream.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.facebook;
|
||||
|
||||
import android.os.Handler;
|
||||
import com.facebook.GraphRequestBatch;
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ProgressOutputStream extends FilterOutputStream implements RequestOutputStream {
|
||||
private final Map<GraphRequest, RequestProgress> a;
|
||||
private final GraphRequestBatch b;
|
||||
private final long c;
|
||||
private long d;
|
||||
private long e;
|
||||
private long f;
|
||||
private RequestProgress g;
|
||||
|
||||
ProgressOutputStream(OutputStream outputStream, GraphRequestBatch graphRequestBatch, Map<GraphRequest, RequestProgress> map, long j) {
|
||||
super(outputStream);
|
||||
this.b = graphRequestBatch;
|
||||
this.a = map;
|
||||
this.f = j;
|
||||
this.c = FacebookSdk.k();
|
||||
}
|
||||
|
||||
@Override // java.io.FilterOutputStream, java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
Iterator<RequestProgress> it = this.a.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().a();
|
||||
}
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // java.io.FilterOutputStream, java.io.OutputStream
|
||||
public void write(byte[] bArr) throws IOException {
|
||||
((FilterOutputStream) this).out.write(bArr);
|
||||
a(bArr.length);
|
||||
}
|
||||
|
||||
private void a(long j) {
|
||||
RequestProgress requestProgress = this.g;
|
||||
if (requestProgress != null) {
|
||||
requestProgress.a(j);
|
||||
}
|
||||
this.d += j;
|
||||
long j2 = this.d;
|
||||
if (j2 >= this.e + this.c || j2 >= this.f) {
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.io.FilterOutputStream, java.io.OutputStream
|
||||
public void write(byte[] bArr, int i, int i2) throws IOException {
|
||||
((FilterOutputStream) this).out.write(bArr, i, i2);
|
||||
a(i2);
|
||||
}
|
||||
|
||||
@Override // java.io.FilterOutputStream, java.io.OutputStream
|
||||
public void write(int i) throws IOException {
|
||||
((FilterOutputStream) this).out.write(i);
|
||||
a(1L);
|
||||
}
|
||||
|
||||
private void a() {
|
||||
if (this.d > this.e) {
|
||||
for (GraphRequestBatch.Callback callback : this.b.g()) {
|
||||
if (callback instanceof GraphRequestBatch.OnProgressCallback) {
|
||||
Handler f = this.b.f();
|
||||
final GraphRequestBatch.OnProgressCallback onProgressCallback = (GraphRequestBatch.OnProgressCallback) callback;
|
||||
if (f == null) {
|
||||
onProgressCallback.a(this.b, this.d, this.f);
|
||||
} else {
|
||||
f.post(new Runnable() { // from class: com.facebook.ProgressOutputStream.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
onProgressCallback.a(ProgressOutputStream.this.b, ProgressOutputStream.this.d, ProgressOutputStream.this.f);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.e = this.d;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.facebook.RequestOutputStream
|
||||
public void a(GraphRequest graphRequest) {
|
||||
this.g = graphRequest != null ? this.a.get(graphRequest) : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user