[go: nahoru, domu]

Skip to content

Commit

Permalink
Squashed 'libs/editor/' changes from 4125f05..6c35434
Browse files Browse the repository at this point in the history
6c35434 Merge pull request #168 from wordpress-mobile/issue/156-npe-imagespan-init
c887b61 Merge branch 'develop' into issue/156-npe-imagespan-init
160c283 Can't add spans if the Activity is null.
14acea5 Avoiding NPE when initializing WPEditImageSpan.

git-subtree-dir: libs/editor
git-subtree-split: 6c35434f798d4c5ce6a824b7faa00b24b51f179d
  • Loading branch information
aforcier committed Jun 19, 2015
1 parent df5f634 commit 56693c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ public void onResponse(ImageLoader.ImageContainer container, boolean arg1) {
return;
}
WPImageSpan[] spans = s.getSpans(0, s.length(), WPImageSpan.class);
if (spans.length != 0) {
if (spans.length != 0 && getActivity() != null) {
for (WPImageSpan is : spans) {
MediaFile mediaFile = is.getMediaFile();
if (mediaFile == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ public WPEditImageSpan(Context context, int resId, Uri src) {
}

private void init(Context context) {
mEditIconBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.ab_icon_edit);
if (context != null) {
mEditIconBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.ab_icon_edit);
}
}

@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom,
Paint paint) {
super.draw(canvas, text, start, end, x, top, y, bottom, paint);

if (!mMediaFile.isVideo()) {
if (mEditIconBitmap != null && !mMediaFile.isVideo()) {
// Add 'edit' icon at bottom right of image
int width = getSize(paint, text, start, end, paint.getFontMetricsInt());
float editIconXPosition = (x + width) - mEditIconBitmap.getWidth();
Expand Down

0 comments on commit 56693c5

Please sign in to comment.