Skip to content

Commit

Permalink
Merge pull request #39 from prolutionsGmbH/master
Browse files Browse the repository at this point in the history
Fix for issue #21
  • Loading branch information
clovisnicolas committed Oct 10, 2018
2 parents 988fcb5 + 3d9ba63 commit dd66026
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## [0.0.9] - October 10th, 2018
* Fix an issue when fetching contacts on Android

## [0.0.8] - August 16th, 2018
* Fix an issue with phones being added to emails on Android
* Update plugin for dart 2
Expand Down
Expand Up @@ -39,8 +39,6 @@ public class ContactsServicePlugin implements MethodCallHandler {

private final ContentResolver contentResolver;

private Result getContactResult;

public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "github.com/clovisnicolas/flutter_contacts");
channel.setMethodCallHandler(new ContactsServicePlugin(registrar.context().getContentResolver()));
Expand All @@ -50,8 +48,7 @@ public static void registerWith(Registrar registrar) {
public void onMethodCall(MethodCall call, Result result) {
switch(call.method){
case "getContacts":
getContactResult = result;
this.getContacts((String)call.arguments);
this.getContacts((String)call.arguments, result);
break;
case "addContact":
Contact c = Contact.fromMap((HashMap)call.arguments);
Expand Down Expand Up @@ -108,13 +105,19 @@ public void onMethodCall(MethodCall call, Result result) {


@TargetApi(Build.VERSION_CODES.ECLAIR)
private void getContacts(String query) {
new GetContactsTask().execute(new String[] {query});
private void getContacts(String query, Result result) {
new GetContactsTask(result).execute(new String[] {query});
}

@TargetApi(Build.VERSION_CODES.CUPCAKE)
private class GetContactsTask extends AsyncTask<String, Void, ArrayList<HashMap>> {

private Result getContactResult;

public GetContactsTask(Result result){
this.getContactResult = result;
}

@TargetApi(Build.VERSION_CODES.ECLAIR)
protected ArrayList<HashMap> doInBackground(String... query) {
ArrayList<Contact> contacts = getContactsFrom(getCursor(query[0]));
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,6 +1,6 @@
name: contacts_service
description: A Flutter plugin to retrieve and manage contacts on Android and iOS devices.
version: 0.0.8
version: 0.0.9
author: Clovis Nicolas <clovisnicolas0@gmail.com>
homepage: https://github.com/clovisnicolas/flutter_contacts

Expand Down

0 comments on commit dd66026

Please sign in to comment.