debug: improved display for mediastore timestamps
This commit is contained in:
parent
25e394dbba
commit
9c98920639
2 changed files with 36 additions and 18 deletions
|
@ -352,23 +352,27 @@ public class MetadataHandler implements MethodChannel.MethodCallHandler {
|
|||
String[] columnNames = cursor.getColumnNames();
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
String key = columnNames[i];
|
||||
switch (cursor.getType(i)) {
|
||||
case Cursor.FIELD_TYPE_NULL:
|
||||
default:
|
||||
metadataMap.put(key, null);
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_INTEGER:
|
||||
metadataMap.put(key, cursor.getInt(i));
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_FLOAT:
|
||||
metadataMap.put(key, cursor.getFloat(i));
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_STRING:
|
||||
metadataMap.put(key, cursor.getString(i));
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_BLOB:
|
||||
metadataMap.put(key, cursor.getBlob(i));
|
||||
break;
|
||||
try {
|
||||
switch (cursor.getType(i)) {
|
||||
case Cursor.FIELD_TYPE_NULL:
|
||||
default:
|
||||
metadataMap.put(key, null);
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_INTEGER:
|
||||
metadataMap.put(key, cursor.getLong(i));
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_FLOAT:
|
||||
metadataMap.put(key, cursor.getFloat(i));
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_STRING:
|
||||
metadataMap.put(key, cursor.getString(i));
|
||||
break;
|
||||
case Cursor.FIELD_TYPE_BLOB:
|
||||
metadataMap.put(key, cursor.getBlob(i));
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(LOG_TAG, "failed to get value for key=" + key, e);
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
|
|
|
@ -144,6 +144,10 @@ class _FullscreenDebugPageState extends State<FullscreenDebugPage> {
|
|||
);
|
||||
}
|
||||
|
||||
// MediaStore timestamp keys
|
||||
static const secondTimestampKeys = ['date_added', 'date_modified', 'date_expires', 'isPlayed'];
|
||||
static const millisecondTimestampKeys = ['datetaken', 'datetime'];
|
||||
|
||||
Widget _buildContentResolverTabView() {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
|
@ -153,7 +157,17 @@ class _FullscreenDebugPageState extends State<FullscreenDebugPage> {
|
|||
builder: (context, AsyncSnapshot<Map> snapshot) {
|
||||
if (snapshot.hasError) return Text(snapshot.error.toString());
|
||||
if (snapshot.connectionState != ConnectionState.done) return const SizedBox.shrink();
|
||||
final data = SplayTreeMap.of(snapshot.data.map((k, v) => MapEntry(k.toString(), v?.toString() ?? 'null')));
|
||||
final data = SplayTreeMap.of(snapshot.data.map((k, v) {
|
||||
final key = k.toString();
|
||||
var value = v?.toString() ?? 'null';
|
||||
if ([...secondTimestampKeys, ...millisecondTimestampKeys].contains(key) && v is num && v != 0) {
|
||||
if (secondTimestampKeys.contains(key)) {
|
||||
v *= 1000;
|
||||
}
|
||||
value += ' (${DateTime.fromMillisecondsSinceEpoch(v)})';
|
||||
}
|
||||
return MapEntry(key, value);
|
||||
}));
|
||||
return InfoRowGroup(data);
|
||||
},
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue