1 package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.playback;
3 import android.util.Log;
5 import androidx.annotation.NonNull;
7 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
8 import net.osdn.gokigen.gr2control.camera.playback.IDownloadContentCallback;
9 import net.osdn.gokigen.gr2control.camera.playback.ProgressEvent;
11 public class FujiXFullImageReceiver implements IFujiXCommandCallback
13 private final String TAG = toString();
14 private final IDownloadContentCallback callback;
15 private int receivedLength;
17 FujiXFullImageReceiver( @NonNull IDownloadContentCallback callback)
19 this.callback = callback;
20 this.receivedLength = 0;
24 public void receivedMessage(int id, byte[] rx_body)
28 Log.v(TAG, " receivedMessage() : onCompleted. " + id + " (" + receivedLength + " bytes.)");
29 callback.onCompleted();
35 callback.onErrorOccurred(e);
41 public void onReceiveProgress(final int currentBytes, final int totalBytes, byte[] body)
45 receivedLength = receivedLength + currentBytes;
46 float percent = (totalBytes == 0) ? 0.0f : ((float) receivedLength / (float) totalBytes);
47 //Log.v(TAG, " onReceiveProgress() " + receivedLength + "/" + totalBytes + " " + percent);
48 ProgressEvent event = new ProgressEvent(percent, null);
49 callback.onProgress(body, currentBytes, event);
54 callback.onErrorOccurred(e);
59 public boolean isReceiveMulti()