Skip to content

Commit

Permalink
fix: fetchPathProperties for API 28 (#1161)
Browse files Browse the repository at this point in the history
Signed-off-by: Caijinglong <[email protected]>
  • Loading branch information
CaiJingLong authored Jul 16, 2024
1 parent 67f9ba9 commit ad17424
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ that can be found in the LICENSE file. -->

To know more about breaking changes, see the [Migration Guide][].

## Unreleased

### Fixes

- Fix `fetchPathProperties` exception on android of API 28.

## 3.2.2

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ object DBUtils : IDBUtils {
option: FilterOption
): AssetPathEntity? {
val args = ArrayList<String>()
val where = option.makeWhere(type, args)
val idSelection: String
if (pathId == "") {
idSelection = ""
} else {
idSelection = "AND ${MediaStore.MediaColumns.BUCKET_ID} = ?"
args.add(pathId)
}
val where = option.makeWhere(type, args)
val selection =
"${MediaStore.MediaColumns.BUCKET_ID} IS NOT NULL $where $idSelection) GROUP BY (${MediaStore.MediaColumns.BUCKET_ID}"
val cursor = context.contentResolver.logQuery(
Expand Down
69 changes: 69 additions & 0 deletions example/lib/page/developer/issues_page/issue_1152.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:oktoast/oktoast.dart';
import 'package:photo_manager/photo_manager.dart';

import 'issue_index_page.dart';

class Issus1152 extends StatefulWidget {
const Issus1152({super.key});

@override
State<Issus1152> createState() => _Issus1152State();
}

class _Issus1152State extends State<Issus1152> with IssueBase<Issus1152> {
@override
List<TargetPlatform>? get supportPlatforms => [
TargetPlatform.android,
];

List<RequestType> checkStatus = [];

@override
void initState() {
super.initState();
PhotoManager.setLog(true);
}

@override
Widget build(BuildContext context) {
return buildScaffold([
buildButton(
'Test API 28 get images',
reproduce,
),
buildLogWidget(),
]);
}

@override
int get issueNumber => 1152;

Future<void> reproduce() async {
final pathList = await PhotoManager.getAssetPathList();
final noAllPathList = pathList.where((element) => !element.isAll);
if (noAllPathList.isEmpty) {
showToast('No path found');
return;
}

final path = noAllPathList.first;

// final name = path.name;
// final count = await path.assetCountAsync;
// addLog('assetCount of "$name": $count');

// final list = await path.getAssetListPaged(page: 0, size: 50);
// addLog('list.length: ${list.length}');

await fetchNewProperties(path);
}

Future<void> fetchNewProperties(AssetPathEntity path) async {
try {
await path.obtainForNewProperties();
} catch (e) {
addLog('error: $e');
}
}
}
2 changes: 2 additions & 0 deletions example/lib/page/developer/issues_page/issue_index_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'issue_1025.dart';
import 'issue_1031.dart';
import 'issue_1051.dart';
import 'issue_1053.dart';
import 'issue_1152.dart';
import 'issue_734.dart';
import 'issue_918.dart';
import 'issue_962.dart';
Expand Down Expand Up @@ -73,6 +74,7 @@ class IssuePage extends StatelessWidget {
Issue979(),
Issus1051(),
Issus1053(),
Issus1152(),
],
),
),
Expand Down

0 comments on commit ad17424

Please sign in to comment.