From 65fb876c5e259ae1e4020a1bffd075e178d92bf2 Mon Sep 17 00:00:00 2001 From: serso Date: Sun, 21 Feb 2016 19:27:11 +0100 Subject: [PATCH] Remove intermediate activity classes --- .../android/calculator/ActivityUi.java | 6 +--- .../android/calculator/BaseActivity.java | 10 ++---- .../calculator/CalculatorActivity.java | 6 +--- .../android/calculator/EmptyActivity.java | 34 ------------------- .../calculator/about/AboutActivity.java | 5 ++- .../functions/FunctionsActivity.java | 4 --- .../calculator/history/HistoryActivity.java | 4 --- .../matrix/CalculatorMatrixActivity.java | 10 ++---- .../operators/OperatorsActivity.java | 5 --- .../variables/VariablesActivity.java | 5 --- 10 files changed, 9 insertions(+), 80 deletions(-) delete mode 100644 app/src/main/java/org/solovyev/android/calculator/EmptyActivity.java diff --git a/app/src/main/java/org/solovyev/android/calculator/ActivityUi.java b/app/src/main/java/org/solovyev/android/calculator/ActivityUi.java index 12bc2951..240b4b8f 100644 --- a/app/src/main/java/org/solovyev/android/calculator/ActivityUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/ActivityUi.java @@ -50,7 +50,7 @@ import javax.annotation.Nullable; public class ActivityUi extends BaseUi { - private int layoutId; + private final int layoutId; @Nonnull private Preferences.Gui.Theme theme = Preferences.Gui.Theme.material_theme; @@ -267,10 +267,6 @@ public class ActivityUi extends BaseUi { } } - public void setLayoutId(int layoutId) { - this.layoutId = layoutId; - } - @Nonnull public Language getLanguage() { return language; diff --git a/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java b/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java index 82a7696c..6bf4fe2a 100644 --- a/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java @@ -18,16 +18,12 @@ public class BaseActivity extends AppCompatActivity { @Nonnull protected final ActivityUi ui; - public BaseActivity(@Nonnull ActivityUi ui) { - this.ui = ui; + public BaseActivity() { + this(R.layout.main_empty); } public BaseActivity(@LayoutRes int layout) { - this(layout, "Activity"); - } - - public BaseActivity(@LayoutRes int layout, @Nonnull String logTag) { - this.ui = new ActivityUi(layout, logTag); + this.ui = new ActivityUi(layout, getClass().getSimpleName()); } @Nonnull diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 7bfc528b..ccd6ca26 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -62,8 +62,6 @@ import static org.solovyev.android.wizard.WizardUi.*; public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener, Toolbar.OnMenuItemClickListener { - @Nonnull - public static final String TAG = CalculatorActivity.class.getSimpleName(); @Inject PreferredPreferences preferredPreferences; @Inject @@ -89,7 +87,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference private boolean useBackAsPrev; public CalculatorActivity() { - super(0, TAG); + super(R.layout.activity_main); } private static void firstTimeInit(@Nonnull SharedPreferences preferences, @Nonnull Context context) { @@ -163,8 +161,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference @Override public void onCreate(@Nullable Bundle savedInstanceState) { - ui.setLayoutId(R.layout.activity_main); - super.onCreate(savedInstanceState); ButterKnife.bind(this); diff --git a/app/src/main/java/org/solovyev/android/calculator/EmptyActivity.java b/app/src/main/java/org/solovyev/android/calculator/EmptyActivity.java deleted file mode 100644 index e027d2b0..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/EmptyActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator; - -public abstract class EmptyActivity extends BaseActivity { - - protected EmptyActivity() { - this(R.layout.main_empty); - } - - protected EmptyActivity(int layoutResId) { - super(layoutResId); - } -} diff --git a/app/src/main/java/org/solovyev/android/calculator/about/AboutActivity.java b/app/src/main/java/org/solovyev/android/calculator/about/AboutActivity.java index cd1b1c3b..c1c542fe 100644 --- a/app/src/main/java/org/solovyev/android/calculator/about/AboutActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/about/AboutActivity.java @@ -23,14 +23,13 @@ package org.solovyev.android.calculator.about; import android.os.Bundle; - +import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.FragmentTab; -import org.solovyev.android.calculator.EmptyActivity; import org.solovyev.android.calculator.R; import javax.annotation.Nullable; -public class AboutActivity extends EmptyActivity { +public class AboutActivity extends BaseActivity { @Override public void onCreate(@Nullable Bundle savedInstanceState) { diff --git a/app/src/main/java/org/solovyev/android/calculator/functions/FunctionsActivity.java b/app/src/main/java/org/solovyev/android/calculator/functions/FunctionsActivity.java index 5b6e2c55..2c9be49f 100644 --- a/app/src/main/java/org/solovyev/android/calculator/functions/FunctionsActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/functions/FunctionsActivity.java @@ -34,10 +34,6 @@ public class FunctionsActivity extends BaseActivity { public static final String EXTRA_FUNCTION = "function"; - public FunctionsActivity() { - super(R.layout.main_empty, FunctionsActivity.class.getSimpleName()); - } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/org/solovyev/android/calculator/history/HistoryActivity.java b/app/src/main/java/org/solovyev/android/calculator/history/HistoryActivity.java index 0c25a186..cc90e591 100644 --- a/app/src/main/java/org/solovyev/android/calculator/history/HistoryActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/history/HistoryActivity.java @@ -34,10 +34,6 @@ import static org.solovyev.android.calculator.FragmentTab.saved_history; public class HistoryActivity extends BaseActivity { - public HistoryActivity() { - super(R.layout.main_empty, HistoryActivity.class.getSimpleName()); - } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java b/app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java index 1577f29f..eb5afa0a 100644 --- a/app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java @@ -23,19 +23,13 @@ package org.solovyev.android.calculator.matrix; import android.os.Bundle; - +import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.FragmentTab; -import org.solovyev.android.calculator.EmptyActivity; import org.solovyev.android.calculator.R; import static android.support.v7.app.ActionBar.NAVIGATION_MODE_STANDARD; -/** - * User: Solovyev_S - * Date: 12.10.12 - * Time: 10:56 - */ -public class CalculatorMatrixActivity extends EmptyActivity { +public class CalculatorMatrixActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/org/solovyev/android/calculator/operators/OperatorsActivity.java b/app/src/main/java/org/solovyev/android/calculator/operators/OperatorsActivity.java index 6e6a4f55..0dfbc39c 100644 --- a/app/src/main/java/org/solovyev/android/calculator/operators/OperatorsActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/operators/OperatorsActivity.java @@ -25,16 +25,11 @@ package org.solovyev.android.calculator.operators; import android.os.Bundle; import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.FragmentTab; -import org.solovyev.android.calculator.R; import javax.annotation.Nullable; public class OperatorsActivity extends BaseActivity { - public OperatorsActivity() { - super(R.layout.main_empty, OperatorsActivity.class.getSimpleName()); - } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/org/solovyev/android/calculator/variables/VariablesActivity.java b/app/src/main/java/org/solovyev/android/calculator/variables/VariablesActivity.java index 01c7ccee..c79c2bff 100644 --- a/app/src/main/java/org/solovyev/android/calculator/variables/VariablesActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/variables/VariablesActivity.java @@ -25,7 +25,6 @@ package org.solovyev.android.calculator.variables; import android.os.Bundle; import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.FragmentTab; -import org.solovyev.android.calculator.R; import javax.annotation.Nullable; @@ -33,10 +32,6 @@ public class VariablesActivity extends BaseActivity { public static final String EXTRA_VARIABLE = "variable"; - public VariablesActivity() { - super(R.layout.main_empty, VariablesActivity.class.getSimpleName()); - } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState);