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

Side by Side Diff: mobile/android/thirdparty/org/adblockplus/browser/UrlInputOpenerPreference.java

Issue 29322610: Issue 2720 - [Adblocking settings] Add the other filter lists category (Closed)
Patch Set: Changed screen title Created July 20, 2015, 5 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
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 package org.adblockplus.browser;
19
20 import java.lang.ref.WeakReference;
21
22 import android.content.Context;
23 import android.preference.Preference;
24 import android.util.AttributeSet;
25
26 public class UrlInputOpenerPreference extends Preference implements UrlInputDial og.UrlReadyCallback
27 {
28 private static WeakReference<UrlInputDialog.UrlReadyCallback> redirectUrlReady Callback = null;
29
30 public UrlInputOpenerPreference(Context context)
31 {
32 super(context);
33 }
34
35 public UrlInputOpenerPreference(Context context, AttributeSet attrs)
36 {
37 super(context, attrs);
38 }
39
40 public UrlInputOpenerPreference(Context context, AttributeSet attrs, int defSt yleAttr)
41 {
42 super(context, attrs, defStyleAttr);
43 }
44
45 protected static synchronized void setRedirectUrlReadyCallback(
46 final UrlInputDialog.UrlReadyCallback callback)
47 {
48 redirectUrlReadyCallback = new WeakReference<UrlInputDialog.UrlReadyCallback >(callback);
49 }
50
51 @Override
52 protected void onAttachedToActivity()
53 {
54 this.setPersistent(false);
55 }
56
57 @Override
58 protected void onClick()
59 {
60 new UrlInputDialog(this.getContext(), UrlInputDialog.Type.ADD_BLOCKING_LIST, this).show();
61 }
62
63 @Override
64 public void callback(String url)
65 {
66 try
67 {
68 if (redirectUrlReadyCallback != null)
69 {
70 final UrlInputDialog.UrlReadyCallback callback = redirectUrlReadyCallbac k.get();
71 if (callback != null)
72 {
73 callback.callback(url);
74 }
75 }
76 }
77 catch (Throwable t)
78 {
79 // we do not care
80 }
81 }
82 }
OLDNEW

Powered by Google App Engine
This is Rietveld