forked from bumptech/glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
dependencies { | ||
compile project(':library') | ||
compile "com.android.support:support-v4:${SUPPORT_V4_VERSION}" | ||
compile "com.android.support:appcompat-v7:${SUPPORT_V7_VERSION}" | ||
} | ||
|
||
android { | ||
compileSdkVersion COMPILE_SDK_VERSION as int | ||
buildToolsVersion BUILD_TOOLS_VERSION as String | ||
|
||
defaultConfig { | ||
applicationId "com.bumptech.glide.samples.contacturi" | ||
minSdkVersion MIN_SDK_VERSION as int | ||
targetSdkVersion TARGET_SDK_VERSION as int | ||
|
||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.bumptech.glide.samples.contacturi" > | ||
|
||
<uses-permission android:name="android.permission.READ_CONTACTS" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@android:drawable/sym_def_app_icon" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AppCompat" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
62 changes: 62 additions & 0 deletions
62
samples/contacturi/src/main/java/com/bumptech/glide/samples/contacturi/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.bumptech.glide.samples.contacturi; | ||
|
||
import android.app.Activity; | ||
import android.content.ContentUris; | ||
import android.content.Intent; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.provider.ContactsContract; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import com.bumptech.glide.Glide; | ||
|
||
public class MainActivity extends Activity { | ||
private static final int REQUEST_CONTACT = 1; | ||
|
||
private ImageView imageViewHighRes; | ||
private ImageView imageViewThumbnail; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
imageViewHighRes = (ImageView) findViewById(R.id.image_highres); | ||
imageViewThumbnail = (ImageView) findViewById(R.id.image_thumbnail); | ||
|
||
findViewById(R.id.button_pick_contact).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); | ||
startActivityForResult(intent, REQUEST_CONTACT); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode == REQUEST_CONTACT && resultCode == RESULT_OK) { | ||
final Cursor cursor = | ||
getContentResolver().query(data.getData(), null, null, null, null); | ||
try { | ||
if (cursor != null && cursor.moveToFirst()) { | ||
// Get ID of the contact | ||
final long id = cursor.getLong(cursor.getColumnIndex(ContactsContract.Contacts._ID)); | ||
final Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id); | ||
final Uri thumbnailPhotoUri = Uri.withAppendedPath(contactUri, ContactsContract.Contacts.Photo | ||
.CONTENT_DIRECTORY); | ||
Glide.with(this).load(contactUri).into(imageViewHighRes); | ||
Glide.with(this).load(thumbnailPhotoUri).into(imageViewThumbnail); | ||
} | ||
} finally { | ||
if (cursor != null) { | ||
cursor.close(); | ||
} | ||
} | ||
return; | ||
} | ||
super.onActivityResult(requestCode, resultCode, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
android:padding="@dimen/activity_horizontal_margin" | ||
tools:context="com.bumptech.glide.samples.contacturi.MainActivity"> | ||
|
||
<Button | ||
android:id="@+id/button_pick_contact" | ||
android:layout_width="wrap_content" | ||
android:text="Pick Contact" | ||
android:layout_height="wrap_content"/> | ||
|
||
<ImageView | ||
android:id="@+id/image_highres" | ||
android:layout_width="160dp" | ||
android:layout_alignParentLeft="true" | ||
android:layout_centerVertical="true" | ||
android:layout_height="160dp"/> | ||
|
||
<ImageView | ||
android:id="@+id/image_thumbnail" | ||
android:layout_width="48dp" | ||
android:layout_alignParentRight="true" | ||
android:layout_centerVertical="true" | ||
android:layout_toRightOf="@+id/image_highres" | ||
android:scaleType="fitCenter" | ||
android:layout_height="48dp" /> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context="com.bumptech.glide.samples.contacturi.MainActivity" > | ||
<item android:id="@+id/action_settings" | ||
android:title="@string/action_settings" | ||
android:orderInCategory="100" | ||
app:showAsAction="never" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
<dimen name="fab_margin">16dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<resources> | ||
<string name="app_name">ContactUri Sample</string> | ||
<string name="action_settings">Settings</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters