Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/libadblockplus/Notification.java

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Patch Set: Only one Notification displayed now Created Feb. 18, 2015, 3:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/org/adblockplus/libadblockplus/FilterEngine.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.libadblockplus; 18 package org.adblockplus.libadblockplus;
19 19
20 import java.util.List; 20 public class Notification extends JsValue
21
22 public abstract class EventCallback implements Disposable
23 { 21 {
24 private final Disposer disposer;
25 protected final long ptr;
26
27 static 22 static
28 { 23 {
29 System.loadLibrary("adblockplus-jni"); 24 System.loadLibrary("adblockplus-jni");
30 registerNatives(); 25 registerNatives();
31 } 26 }
32 27
33 public EventCallback() 28 private Notification(final long ptr)
34 { 29 {
35 this.ptr = ctor(this); 30 super(ptr);
36 this.disposer = new Disposer(this, new DisposeWrapper(this.ptr));
37 } 31 }
38 32
39 public abstract void eventCallback(List<JsValue> params); 33 public static enum Type
34 {
35 INFORMATION,
36 QUESTION,
37 CRITICAL,
38 INVALID
39 }
40
41 public String getMessageString()
42 {
43 return getMessageString(this.ptr);
44 }
45
46 public String getTitle()
47 {
48 return getTitle(this.ptr);
49 }
50
51 public Type getType()
52 {
53 return getType(this.ptr);
54 }
55
56 public void markAsShown()
57 {
58 markAsShown(this.ptr);
59 }
40 60
41 @Override 61 @Override
42 public void dispose() 62 public String toString()
43 { 63 {
44 this.disposer.dispose(); 64 return this.getTitle() + " - " + this.getMessageString();
45 }
46
47 private final static class DisposeWrapper implements Disposable
48 {
49 private final long ptr;
50
51 public DisposeWrapper(final long ptr)
52 {
53 this.ptr = ptr;
54 }
55
56 @Override
57 public void dispose()
58 {
59 dtor(this.ptr);
60 }
61 } 65 }
62 66
63 private final static native void registerNatives(); 67 private final static native void registerNatives();
64 68
65 private final static native long ctor(Object obj); 69 private final static native String getMessageString(long ptr);
66 70
67 private final static native void dtor(long ptr); 71 private final static native String getTitle(long ptr);
72
73 private final static native Type getType(long ptr);
74
75 private final static native void markAsShown(long ptr);
68 } 76 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/libadblockplus/FilterEngine.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld