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

Unified Diff: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/BaseSettingsFragment.java

Issue 29678581: Issue 6000 - Rename "libadblockplus-android" (Closed)
Patch Set: addressed comments Created Jan. 29, 2018, 11:04 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/BaseSettingsFragment.java
diff --git a/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/BaseSettingsFragment.java b/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/BaseSettingsFragment.java
deleted file mode 100644
index f9de9c2cea01898290473ff25a0688c9f3de7d64..0000000000000000000000000000000000000000
--- a/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/BaseSettingsFragment.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file is part of Adblock Plus <https://adblockplus.org/>,
- * Copyright (C) 2006-present eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.adblockplus.libadblockplus.android.settings;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.preference.PreferenceFragment;
-import android.util.Log;
-
-import org.adblockplus.libadblockplus.android.AdblockEngine;
-import org.adblockplus.libadblockplus.android.Utils;
-
-public abstract class BaseSettingsFragment
- <ListenerClass extends BaseSettingsFragment.Listener>
- extends PreferenceFragment
-{
- protected final String TAG = Utils.getTag(this.getClass());
- protected AdblockSettings settings;
- protected Provider provider;
- protected ListenerClass listener;
-
- /**
- * Provides AdblockEngine and SharedPreferences to store settings
- * (activity holding BaseSettingsFragment fragment should implement this interface)
- */
- public interface Provider
- {
- AdblockEngine getAdblockEngine();
- AdblockSettingsStorage getAdblockSettingsStorage();
- }
-
- /**
- * Listens for Adblock settings events
- */
- public interface Listener
- {
- /**
- * `Settings were changed` callback
- * Note: settings are available using BaseSettingsFragment.getSettings()
- *
- * @param fragment fragment
- */
- void onAdblockSettingsChanged(BaseSettingsFragment fragment);
- }
-
- protected <T> T castOrThrow(Activity activity, Class<T> clazz)
- {
- if (!(activity instanceof Provider))
- {
- String message = activity.getClass().getSimpleName()
- + " should implement "
- + clazz.getSimpleName()
- + " interface";
-
- Log.e(TAG, message);
- throw new RuntimeException(message);
- }
-
- return (T) activity;
- }
-
- public void loadSettings()
- {
- settings = provider.getAdblockSettingsStorage().load();
- if (settings == null)
- {
- Log.w(TAG, "No adblock settings, yet. Using defdault ones from adblock engine");
-
- // null because it was not saved yet
- settings = AdblockSettingsStorage.getDefaultSettings(provider.getAdblockEngine());
- }
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- loadSettings();
- }
-
- @Override
- public void onAttach(Activity activity)
- {
- super.onAttach(activity);
- provider = castOrThrow(activity, Provider.class);
- }
-
- @Override
- public void onResume()
- {
- super.onResume();
- loadSettings();
- }
-
- public AdblockSettings getSettings()
- {
- return settings;
- }
-
- @Override
- public void onDetach()
- {
- super.onDetach();
- provider = null;
- listener = null;
- }
-}

Powered by Google App Engine
This is Rietveld