import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
import net.osdn.gokigen.pkremote.camera.vendor.fujix.wrapper.command.IFujiXCommandCallback;
+
+import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Locale;
public class FujiXImageContentInfo implements ICameraContent, IFujiXCommandCallback
{
private final int indexNumber;
private boolean isReceived = false;
private Date date = null;
+ private String realFileName = null;
private byte[] rx_body;
FujiXImageContentInfo(int indexNumber, byte[] rx_body)
{
this.rx_body = rx_body;
if (this.rx_body != null)
{
- isReceived = true;
+ updateInformation(rx_body);
+ }
+ else
+ {
+ date = new Date();
}
}
@Override
public String getContentName()
{
- if (isReceived)
+ try
+ {
+ if ((realFileName != null)&&(realFileName.contains(".MOV")))
+ {
+ return ("" + indexNumber + ".MOV");
+ }
+ }
+ catch (Exception e)
{
- return ("" + indexNumber + ".JPG");
+ e.printStackTrace();
}
return ("" + indexNumber + ".JPG");
}
@Override
public Date getCapturedDate()
{
- if (isReceived)
- {
- return (new Date());
- }
- return (new Date());
+ return (date);
}
@Override
{
Log.v(TAG, "RX : " + indexNumber + "(" + id + ") " + rx_body.length + " bytes.");
this.rx_body = rx_body;
- isReceived = true;
- updateCapturedDate(rx_body);
+ updateInformation(rx_body);
}
- private void updateCapturedDate(byte[] rx_body)
+ public int getId()
+ {
+ return (indexNumber);
+ }
+
+ public boolean isReceived()
+ {
+ return (isReceived);
+ }
+
+ private void updateInformation(byte[] rx_body)
{
try
{
if (rx_body.length >= 166)
{
// データの切り出し
- String fileNameString = new String(pickupString(rx_body, 65, 12));
+ realFileName = new String(pickupString(rx_body, 65, 12));
String dateString = new String(pickupString(rx_body, 92, 15));
//char orientation = Character.(rx_body[151]);
- Log.v(TAG, "[" + indexNumber + "] FILE NAME : " + fileNameString + " DATE : '" + dateString + "'");
+ Log.v(TAG, "[" + indexNumber + "] FILE NAME : " + realFileName + " DATE : '" + dateString + "'");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH);
+ date = dateFormat.parse(dateString);
+ isReceived = true;
}
}
catch (Exception e)
}
return (result);
}
-
}
import android.app.Activity;
import android.util.Log;
+import android.util.SparseArray;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
private final String TAG = toString();
private final Activity activity;
private final FujiXInterfaceProvider provider;
- private List<ICameraContent> imageInfo;
+ //private List<ICameraContent> imageInfo;
+ private SparseArray<FujiXImageContentInfo> imageContentInfo;
private int indexNumber = 0;
private ICameraContentListCallback finishedCallback = null;
{
this.activity = activity;
this.provider = provider;
- this.imageInfo = new ArrayList<>();
+ this.imageContentInfo = new SparseArray<>();
}
-
@Override
public String getRawFileSuffix() {
return (null);
@Override
public void downloadContentList(IDownloadContentListCallback callback)
{
-
+ // なにもしない。(未使用)
}
@Override
@Override
public void updateCameraFileInfo(ICameraFileInfo info)
{
-
+ // なにもしない
}
@Override
String indexStr = path.substring(start, path.indexOf("."));
Log.v(TAG, "downloadContentThumbnail() : " + path + " " + indexStr);
int index = Integer.parseInt(indexStr);
- if ((index > 0)&&(index <= imageInfo.size()))
+ if ((index > 0)&&(index <= imageContentInfo.size()))
{
IFujiXCommandPublisher publisher = provider.getCommandPublisher();
- ICameraContent contentInfo = imageInfo.get(index - 1);
- publisher.enqueueCommand(new GetImageInfo(indexNumber, indexNumber, (FujiXImageContentInfo) contentInfo));
+ FujiXImageContentInfo contentInfo = imageContentInfo.get(index);
+ if (!contentInfo.isReceived())
+ {
+ publisher.enqueueCommand(new GetImageInfo(index, index, contentInfo));
+ }
publisher.enqueueCommand(new GetThumbNail(index, new FujiXThumbnailImageReceiver(activity, callback)));
}
}
String indexStr = path.substring(start, path.indexOf("."));
Log.v(TAG, "FujiX::downloadContent() : " + path + " " + indexStr);
int index = Integer.parseInt(indexStr);
- if ((index > 0)&&(index <= imageInfo.size()))
+ //FujiXImageContentInfo contentInfo = imageContentInfo.get(index); // 特にデータを更新しないから大丈夫か?
+ if ((index > 0)&&(index <= imageContentInfo.size()))
{
IFujiXCommandPublisher publisher = provider.getCommandPublisher();
publisher.enqueueCommand(new GetFullImage(index, new FujiXFullImageReceiver(callback)));
}
else
{
+ // 件数が不明だったら、1件づつインデックスの情報を取得する
checkImageFileAll();
}
}
{
try
{
- imageInfo.clear();
+ imageContentInfo.clear();
//IFujiXCommandPublisher publisher = provider.getCommandPublisher();
+ //for (int index = nofFiles; index > 0; index--)
for (int index = 1; index <= nofFiles; index++)
{
- FujiXImageContentInfo info = new FujiXImageContentInfo(index, null);
- //ファイル名などを取得する
+ // ファイル数分、仮のデータを生成する
+ imageContentInfo.append(index, new FujiXImageContentInfo(index, null));
+
+ //ファイル名などを取得する (メッセージを積んでおく...でも遅くなるので、ここではやらない方がよいかな。)
//publisher.enqueueCommand(new GetImageInfo(index, index, info));
- imageInfo.add(info);
}
// インデックスデータがなくなったことを検出...データがそろったとして応答する。
- Log.v(TAG, "IMAGE LIST : " + imageInfo.size() + " (" + nofFiles + ")");
- finishedCallback.onCompleted(imageInfo);
+ Log.v(TAG, "IMAGE LIST : " + imageContentInfo.size() + " (" + nofFiles + ")");
+ finishedCallback.onCompleted(getCameraContentList());
finishedCallback = null;
}
catch (Exception e)
{
try
{
- imageInfo.clear();
+ imageContentInfo.clear();
indexNumber = 1;
IFujiXCommandPublisher publisher = provider.getCommandPublisher();
publisher.enqueueCommand(new GetImageInfo(indexNumber, indexNumber, this));
if (rx_body.length < 16)
{
// インデックスデータがなくなったことを検出...データがそろったとして応答する。
- Log.v(TAG, "IMAGE LIST : " + imageInfo.size());
- finishedCallback.onCompleted(imageInfo);
+ Log.v(TAG, "IMAGE LIST : " + imageContentInfo.size());
+ finishedCallback.onCompleted(getCameraContentList());
finishedCallback = null;
return;
}
Log.v(TAG, "RECEIVED IMAGE INFO : " + indexNumber);
// 受信データを保管しておく
- imageInfo.add(new FujiXImageContentInfo(indexNumber, rx_body));
+ imageContentInfo.append(indexNumber, new FujiXImageContentInfo(indexNumber, rx_body));
// 次のインデックスの情報を要求する
indexNumber++;
{
// エラーになったら、そこで終了にする
e.printStackTrace();
- finishedCallback.onCompleted(imageInfo);
+ finishedCallback.onCompleted(getCameraContentList());
finishedCallback = null;
}
}
+
+ private List<ICameraContent> getCameraContentList()
+ {
+ /// ダサいけど...コンテナクラスを詰め替えて応答する
+ List<ICameraContent> contentList = new ArrayList<>();
+ int listSize = imageContentInfo.size();
+ for(int index = 0; index < listSize; index++)
+ {
+ contentList.add(imageContentInfo.valueAt(index));
+ }
+ return (contentList);
+ }
+
}