<commit_before>package cn.qqtheme.NotifyHelperDemo;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.text.Spanned;

import java.util.HashMap;
import java.util.Random;

/**
 * 参见：https://github.com/halysongoncalves/pugnotification
 * <p/>
 * 示例:
 * NotifyHelper.with(context)
 * .autoCancel(true)
 * .when(System.currentTimeMillis())
 * .defaults(NotificationCompat.DEFAULT_LIGHTS)
 * .title("标题")
 * .message("内容内容内容内容")
 * .ticker("有新消息")
 * .smallIcon(R.drawable.ic_launcher)
 * .largeIcon(R.drawable.ic_launcher)
 * .click(MyActivity.class)
 * .show();
 *
 * @author 李玉江[QQ:1032694760]
 * @since 2015-08-10 17:79
 */
public class NotifyHelper {
    public static final String ACTION_NOTIFICATION_CLICK_INTENT = "liyujiang.notify.intent.action.CLICK";
    public static final String ACTION_NOTIFICATION_DISMISS_INTENT = "liyujiang.notify.intent.action.DISMISS";
    private static NotifyHelper singleton = null;
    private Context context;
    private NotificationCompat.Builder builder;
    private int notificationId;
    private HashMap<Integer, Integer> flagMap = new HashMap<Integer, Integer>();

    private NotifyHelper(Context context) {
        this.context = context;
        notificationId = (new Random()).nextInt(9999);
        builder = new NotificationCompat.Builder(context);
        builder.setContentTitle("标题");
        builder.setContentText("内容");
        builder.setSmallIcon(context.getApplicationContext().getApplicationInfo().icon);
        builder.setDefaults(Notification.DEFAULT_ALL);
        builder.setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT));
    }

    public static NotifyHelper with(Context context) {
        if (singleton == null) {
            synchronized (NotifyHelper.class) {
                singleton = new NotifyHelper(context);
            }
        }
        return singleton;
    }

    public NotifyHelper identifier(int id) {
        if (id <= 0) {
            throw new IllegalStateException("Notification ID Should Not Be Less Than Or Equal To Zero!");
        }
        Integer value = flagMap.get(this.notificationId);
        if (value == null) {
            value = Notification.DEFAULT_LIGHTS;
        }
        flagMap.put(id, value);
        this.notificationId = id;
        return this;<commit_msg>modify default large icon<commit_after>package cn.qqtheme.NotifyHelperDemo;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.text.Spanned;

import java.util.HashMap;
import java.util.Random;

/**
 * 参见：https://github.com/halysongoncalves/pugnotification
 * <p/>
 * 示例:
 * NotifyHelper.with(context)
 * .autoCancel(true)
 * .when(System.currentTimeMillis())
 * .defaults(NotificationCompat.DEFAULT_LIGHTS)
 * .title("标题")
 * .message("内容内容内容内容")
 * .ticker("有新消息")
 * .smallIcon(R.drawable.ic_launcher)
 * .largeIcon(R.drawable.ic_launcher)
 * .click(MyActivity.class)
 * .show();
 *
 * @author 李玉江[QQ:1032694760]
 * @since 2015-08-10 17:79
 */
public class NotifyHelper {
    public static final String ACTION_NOTIFICATION_CLICK_INTENT = "liyujiang.notify.intent.action.CLICK";
    public static final String ACTION_NOTIFICATION_DISMISS_INTENT = "liyujiang.notify.intent.action.DISMISS";
    private static NotifyHelper singleton = null;
    private Context context;
    private NotificationCompat.Builder builder;
    private int notificationId;
    private HashMap<Integer, Integer> flagMap = new HashMap<Integer, Integer>();

    private NotifyHelper(Context context) {
        this.context = context;
        notificationId = (new Random()).nextInt(9999);
        builder = new NotificationCompat.Builder(context);
        builder.setContentTitle("标题");
        builder.setContentText("内容");
        int icon = context.getApplicationContext().getApplicationInfo().icon;
        builder.setSmallIcon(icon);
        builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), icon));
        builder.setDefaults(Notification.DEFAULT_ALL);
        builder.setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT));
    }

    public static NotifyHelper with(Context context) {
        if (singleton == null) {
            synchronized (NotifyHelper.class) {
                singleton = new NotifyHelper(context);
            }
        }
        return singleton;
    }

    public NotifyHelper identifier(int id) {
        if (id <= 0) {
            throw new IllegalStateException("Notification ID Should Not Be Less Than Or Equal To Zero!");
        }
        Integer value = flagMap.get(this.notificationId);
        if (value == null) {
            value = Notification.DEFAULT_LIGHTS;
        }
        flagMap.put(id, value);
        this.notificationId = id;
        return this;
{'fraction_non_alphanumeric': 0.10947109471094711, 'fraction_numerical': 0.010542962572482868, 'mean_word_length': 3.708023159636063, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5830758', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1637, 'n_words': 323}