Skip to content

Commit 385241f

Browse files
committed
change example
1 parent 7f5d06e commit 385241f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

app/src/main/java/com/mincor/flair/views/MVPMediator.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import android.content.Intent
66
import android.content.pm.PackageManager
77
import android.graphics.Color
88
import android.graphics.drawable.ColorDrawable
9+
import android.net.Uri
10+
import android.provider.ContactsContract
911
import android.support.v4.content.ContextCompat
1012
import android.view.View
1113
import android.widget.ListView
@@ -58,12 +60,12 @@ class MVPMediator : ToolbarMediator() {
5860
}
5961

6062
private fun pickContact() {
61-
//val pickContactIntent = Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"))
62-
//pickContactIntent.type = Phone.CONTENT_TYPE // Show user only contacts w/ phone numbers
63-
//startActivityForResult(pickContactIntent, 1001)
63+
val pickContactIntent = Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"))
64+
pickContactIntent.type = ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE // Show user only contacts w/ phone numbers
65+
startActivityForResult(pickContactIntent, 1001)
6466

6567
// Here, thisActivity is the current activity
66-
if (checkSelfPermission(Manifest.permission.READ_CONTACTS)
68+
/*if (checkSelfPermission(Manifest.permission.READ_CONTACTS)
6769
!= PackageManager.PERMISSION_GRANTED) {
6870
6971
// Permission is not granted
@@ -83,7 +85,7 @@ class MVPMediator : ToolbarMediator() {
8385
}
8486
} else {
8587
// Permission has already been granted
86-
}
88+
}*/
8789
}
8890

8991
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@@ -99,9 +101,11 @@ class MVPMediator : ToolbarMediator() {
99101
if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
100102
// permission was granted, yay! Do the
101103
// contacts-related task you need to do.
104+
activity.toast("PERMISSION GRANTED").show()
102105
} else {
103106
// permission denied, boo! Disable the
104107
// functionality that depends on this permission.
108+
activity.toast("PERMISSION DENIED").show()
105109
}
106110
return
107111
}

0 commit comments

Comments
 (0)