OSDN Git Service

暫定で記録。
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / camera / nikon / wrapper / liveview / NikonLiveViewStatusReceiver.kt
1 package net.osdn.gokigen.a01d.camera.nikon.wrapper.liveview
2
3 import android.util.Log
4 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback
5 import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper
6
7 class NikonLiveViewStatusReceiver(private val isDumpLog: Boolean = false) : IPtpIpCommandCallback
8 {
9     override fun receivedMessage(id: Int, rx_body: ByteArray?)
10     {
11         if (rx_body == null)
12         {
13             Log.v(TAG, " receivedMessage $id  is NULL.")
14             return
15         }
16
17         if (isDumpLog)
18         {
19             Log.v(TAG, " receivedMessage() [$id] : ${rx_body.size} bytes. ");
20             val logDumpSize = if (rx_body.size > 64) 64 else rx_body.size
21             SimpleLogDumper.dump_bytes(" [rcv]", rx_body.copyOfRange(0, logDumpSize))
22         }
23     }
24
25     override fun onReceiveProgress(currentBytes: Int, totalBytes: Int, rx_body: ByteArray?)
26     {
27         if (rx_body == null)
28         {
29             Log.v(TAG, " onReceiveProgress() : $currentBytes/$totalBytes is NULL")
30             return
31         }
32         if (isDumpLog)
33         {
34             Log.v(TAG, " receivedMessage() [$currentBytes/$totalBytes] : ${rx_body.size} bytes. ");
35             val logDumpSize = if (rx_body.size > 64) 64 else rx_body.size
36             SimpleLogDumper.dump_bytes(" [rcv-m]", rx_body.copyOfRange(0, logDumpSize))
37         }
38     }
39
40     override fun isReceiveMulti(): Boolean
41     {
42         Log.v(TAG, " isReceiveMulti() : false")
43         return (false)
44     }
45
46     companion object
47     {
48         private val TAG = "NikonLiveViewImageReceiver"
49     }
50 }