@@ -194,7 +194,7 @@ static jobject NewError(JNIEnv* env, const Error& error)
194
194
return env->NewObject (cls, midInit, NewEnum (env, JavaErrorTypeName (error.type ()), " ErrorType" ), C2JString (env, error.msg ()));
195
195
}
196
196
197
- static jobject NewResult (JNIEnv* env, const Result& result, int time )
197
+ static jobject NewResult (JNIEnv* env, const Result& result)
198
198
{
199
199
jclass cls = env->FindClass (PACKAGE " Result" );
200
200
jmethodID midInit = env->GetMethodID (
@@ -213,7 +213,7 @@ static jobject NewResult(JNIEnv* env, const Result& result, int time)
213
213
" Z"
214
214
" I"
215
215
" L" PACKAGE " Error;"
216
- " I )V" );
216
+ " )V" );
217
217
bool valid = result.isValid ();
218
218
return env->NewObject (cls, midInit,
219
219
NewEnum (env, JavaBarcodeFormatName (result.format ()), " Format" ),
@@ -229,12 +229,11 @@ static jobject NewResult(JNIEnv* env, const Result& result, int time)
229
229
valid ? C2JString (env, result.sequenceId ()) : nullptr ,
230
230
result.readerInit (),
231
231
result.lineCount (),
232
- result.error () ? NewError (env, result.error ()) : nullptr ,
233
- time
232
+ result.error () ? NewError (env, result.error ()) : nullptr
234
233
);
235
234
}
236
235
237
- static jobject Read (JNIEnv *env, ImageView image, const DecodeHints& hints)
236
+ static jobject Read (JNIEnv *env, jobject thiz, ImageView image, const DecodeHints& hints)
238
237
{
239
238
try {
240
239
auto startTime = std::chrono::high_resolution_clock::now ();
@@ -243,12 +242,14 @@ static jobject Read(JNIEnv *env, ImageView image, const DecodeHints& hints)
243
242
// LOGD("time: %4d ms\n", (int)std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
244
243
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count ();
245
244
245
+ env->SetIntField (thiz, env->GetFieldID (env->GetObjectClass (thiz), " lastReadTime" , " I" ), time);
246
+
246
247
jclass clsList = env->FindClass (" java/util/ArrayList" );
247
248
jobject objList = env->NewObject (clsList, env->GetMethodID (clsList, " <init>" , " ()V" ));
248
249
if (!results.empty ()) {
249
250
jmethodID midAdd = env->GetMethodID (clsList, " add" , " (Ljava/lang/Object;)Z" );
250
251
for (const auto & result: results)
251
- env->CallBooleanMethod (objList, midAdd, NewResult (env, result, time ));
252
+ env->CallBooleanMethod (objList, midAdd, NewResult (env, result));
252
253
}
253
254
return objList;
254
255
} catch (const std::exception& e) {
@@ -329,7 +330,7 @@ Java_zxingcpp_BarcodeReader_readYBuffer(
329
330
ImageView{pixels + top * rowStride + left, width, height, ImageFormat::Lum, rowStride}
330
331
.rotated (rotation);
331
332
332
- return Read (env, image, CreateDecodeHints (env, options));
333
+ return Read (env, thiz, image, CreateDecodeHints (env, options));
333
334
}
334
335
335
336
struct LockedPixels
@@ -376,5 +377,5 @@ Java_zxingcpp_BarcodeReader_readBitmap(
376
377
.cropped (left, top, width, height)
377
378
.rotated (rotation);
378
379
379
- return Read (env, image, CreateDecodeHints (env, options));
380
+ return Read (env, thiz, image, CreateDecodeHints (env, options));
380
381
}
0 commit comments