-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timob 6101: Android: Contacts: Rhino/v8, get image from picker does not display an image #778
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cb8b11d
timob-6101: use current activity in showContacts()
pingwang2011 9495ff2
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 94dc551
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 08fad2a
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 4a480ea
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 8561223
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 f990ae0
timob 6101: null check for getRoot/CurrentActivity
pingwang2011 a596a68
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 e212b4f
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 3c142cb
add private function getActivity() and null check for activity
pingwang2011 c29023a
timob-6101: add getRootOrCurrentActivity() to TiApplication and add n…
pingwang2011 36a0934
Merge branch 'master' of git://github.com/appcelerator/titanium_mobil…
pingwang2011 2971b04
modify getRootOrCurrentActivity()
pingwang2011 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import org.appcelerator.titanium.TiApplication; | ||
import org.appcelerator.titanium.TiContext; | ||
|
||
import android.app.Activity; | ||
import android.content.ContentResolver; | ||
import android.content.ContentUris; | ||
import android.content.Intent; | ||
|
@@ -137,6 +138,18 @@ private PersonProxy[] getPeople(int limit, String additionalCondition, String[] | |
Log.d(LCAT , "Could not getPeople, context is GC'd"); | ||
return null; | ||
}*/ | ||
|
||
if (TiApplication.getInstance() == null) { | ||
Log.e(LCAT, "Could not getPeople, application is null"); | ||
return null; | ||
} | ||
|
||
Activity activity = TiApplication.getInstance().getRootOrCurrentActivity(); | ||
if (activity == null) { | ||
Log.e(LCAT, "Could not getPeople, activity is null"); | ||
return null; | ||
} | ||
|
||
LinkedHashMap<Long, CommonContactsApi.LightPerson> persons = new LinkedHashMap<Long, LightPerson>(); | ||
|
||
String condition = "mimetype IN " + INConditionForKinds + | ||
|
@@ -146,7 +159,7 @@ private PersonProxy[] getPeople(int limit, String additionalCondition, String[] | |
condition += " AND " + additionalCondition; | ||
} | ||
|
||
Cursor cursor = TiApplication.getInstance().getCurrentActivity().managedQuery( | ||
Cursor cursor = activity.managedQuery( | ||
DataUri, | ||
DATA_PROJECTION, | ||
condition, | ||
|
@@ -194,10 +207,21 @@ protected PersonProxy getPersonById(long id) | |
} | ||
*/ | ||
|
||
if (TiApplication.getInstance() == null) { | ||
Log.e(LCAT, "Could not getPersonById, application is null"); | ||
return null; | ||
} | ||
|
||
Activity activity = TiApplication.getInstance().getRootOrCurrentActivity(); | ||
if (activity == null) { | ||
Log.e(LCAT, "Could not getPersonById, activity is null"); | ||
return null; | ||
} | ||
|
||
CommonContactsApi.LightPerson person = null; | ||
|
||
// Basic person data. | ||
Cursor cursor = TiApplication.getInstance().getCurrentActivity().managedQuery( | ||
Cursor cursor = activity.managedQuery( | ||
ContentUris.withAppendedId(ContactsUri, id), | ||
PEOPLE_PROJECTION, null, null, null); | ||
|
||
|
@@ -216,7 +240,7 @@ protected PersonProxy getPersonById(long id) | |
String condition = "mimetype IN " + INConditionForKinds + | ||
" AND contact_id = ?"; | ||
|
||
cursor = TiApplication.getInstance().getCurrentActivity().managedQuery( | ||
cursor = activity.managedQuery( | ||
DataUri, | ||
DATA_PROJECTION, | ||
condition, | ||
|
@@ -247,8 +271,14 @@ protected Bitmap getInternalContactImage(long id) | |
return null; | ||
} | ||
*/ | ||
|
||
if (TiApplication.getInstance() == null) { | ||
Log.e(LCAT, "Could not getInternalContactImage, application is null"); | ||
return null; | ||
} | ||
|
||
Uri uri = ContentUris.withAppendedId(ContactsUri, id); | ||
ContentResolver cr = TiApplication.getInstance().getCurrentActivity().getContentResolver(); | ||
ContentResolver cr = TiApplication.getInstance().getContentResolver(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't need to be within the scope of this request, but we might consider adding geContentResolver() as a static method on TiApplication so we can wrap the getInstance() check in a single place much like was done with getRootOrCurrentActivity(). |
||
InputStream stream = null; | ||
try { | ||
stream = (InputStream) openContactPhotoInputStream.invoke(null, cr, uri); | ||
|
@@ -267,5 +297,4 @@ protected Bitmap getInternalContactImage(long id) | |
} | ||
return bm; | ||
} | ||
|
||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A space between this if block and the following statements below it.