Skip to content

Commit

Permalink
fixed backward compatibility (setBackground vs setBackgroundDrawable)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Zaycev committed May 28, 2015
1 parent 9d5741e commit ea76a11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.yalantis.contextmenu.lib;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -45,12 +44,10 @@ public void setTitle(String title) {
this.mTitle = title;
}

@TargetApi(16)
public Drawable getBgDrawable() {
return mBgDrawable;
}

@TargetApi(16)
public void setBgDrawable(Drawable mBgDrawable) {
this.mBgDrawable = mBgDrawable;
mBgColor = 0;
Expand Down
6 changes: 5 additions & 1 deletion lib/src/main/java/com/yalantis/contextmenu/lib/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ public static RelativeLayout getImageWrapper(Context context, MenuObject menuIte
if (menuItem.getBgColor() != 0) {
imageWrapper.setBackgroundColor(menuItem.getBgColor());
} else if (menuItem.getBgDrawable() != null) {
imageWrapper.setBackground(menuItem.getBgDrawable());
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
imageWrapper.setBackgroundDrawable(menuItem.getBgDrawable());
} else {
imageWrapper.setBackground(menuItem.getBgDrawable());
}
} else if (menuItem.getBgResource() != 0) {
imageWrapper.setBackgroundResource(menuItem.getBgResource());
} else {
Expand Down

0 comments on commit ea76a11

Please sign in to comment.