@android.annotation.TargetApi(android.os.Build.VERSION_CODES.JELLY_BEAN)

Here are the examples of the java api @android.annotation.TargetApi(android.os.Build.VERSION_CODES.JELLY_BEAN) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

16 Source : Custom.java
with MIT License
from mehrdadsafari

@TargetApi(android.os.Build.VERSION_CODES.JELLY_BEAN)
public clreplaced Custom extends Builder implements OnImageLoadingCompleted {

    private static final String TAG = Custom.clreplaced.getSimpleName();

    private RemoteViews mRemoteView;

    private String mreplacedle;

    private String mMessage;

    private Spanned mMessageSpanned;

    private String mUri;

    private int mSmallIcon;

    private int mBackgroundResId;

    private int mPlaceHolderResourceId;

    private ImageLoader mImageLoader;

    public Custom(NotificationCompat.Builder builder, int identifier, String replacedle, String message, Spanned messageSpanned, int smallIcon, String tag) {
        super(builder, identifier, tag);
        this.mRemoteView = new RemoteViews(ZadakNotification.mSingleton.mContext.getPackageName(), R.layout.notification_custom);
        this.mreplacedle = replacedle;
        this.mMessage = message;
        this.mMessageSpanned = messageSpanned;
        this.mSmallIcon = smallIcon;
        this.mPlaceHolderResourceId = R.drawable.ic_launcher;
        this.init();
    }

    private void init() {
        this.setreplacedle();
        this.setMessage();
        this.setSmallIcon();
    }

    private void setreplacedle() {
        mRemoteView.setTextViewText(R.id.notification_text_replacedle, mreplacedle);
    }

    private void setMessage() {
        if (mMessageSpanned != null) {
            mRemoteView.setTextViewText(R.id.notification_text_message, mMessageSpanned);
        } else {
            mRemoteView.setTextViewText(R.id.notification_text_message, mMessage);
        }
    }

    private void setSmallIcon() {
        if (mSmallIcon <= 0) {
            mRemoteView.setImageViewResource(R.id.notification_img_icon, R.drawable.ic_launcher);
        }
        mRemoteView.setImageViewResource(R.id.notification_img_icon, mSmallIcon);
    }

    @SuppressLint("ResourceType")
    public Custom background(@DrawableRes int resource) {
        if (resource <= 0) {
            throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!");
        }
        if (mUri != null) {
            throw new IllegalStateException("Background Already Set!");
        }
        this.mBackgroundResId = resource;
        return this;
    }

    @SuppressLint("ResourceType")
    public Custom setPlaceholder(@DrawableRes int resource) {
        if (resource <= 0) {
            throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!");
        }
        this.mPlaceHolderResourceId = resource;
        return this;
    }

    public Custom setImageLoader(ImageLoader imageLoader) {
        this.mImageLoader = imageLoader;
        return this;
    }

    public Custom background(String uri) {
        if (mBackgroundResId > 0) {
            throw new IllegalStateException("Background Already Set!");
        }
        if (mUri != null) {
            throw new IllegalStateException("Background Already Set!");
        }
        if (uri == null) {
            throw new IllegalArgumentException("Path Must Not Be Null!");
        }
        if (uri.trim().length() == 0) {
            throw new IllegalArgumentException("Path Must Not Be Empty!");
        }
        if (mImageLoader == null) {
            throw new IllegalStateException("You have to set an ImageLoader!");
        }
        this.mUri = uri;
        return this;
    }

    @Override
    public void build() {
        if (!(Looper.getMainLooper().getThread() == Thread.currentThread())) {
            throw new IllegalStateException("Method call should happen from the main thread.");
        }
        super.build();
        setBigContentView(mRemoteView);
        loadImageBackground();
        super.notificationNotify();
    }

    private void loadImageBackground() {
        mRemoteView.setImageViewResource(R.id.notification_img_background, mPlaceHolderResourceId);
        if (mUri != null) {
            mImageLoader.load(mUri, this);
        } else {
            mImageLoader.load(mBackgroundResId, this);
        }
    }

    @Override
    public void imageLoadingCompleted(Bitmap bitmap) {
        if (bitmap == null) {
            throw new IllegalArgumentException("bitmap cannot be null");
        }
        mRemoteView.setImageViewBitmap(R.id.notification_img_background, bitmap);
        super.notificationNotify();
    }
}