Remove intermediate activity classes

This commit is contained in:
serso 2016-02-21 19:27:11 +01:00
parent c5a637de78
commit 65fb876c5e
10 changed files with 9 additions and 80 deletions

View File

@ -50,7 +50,7 @@ import javax.annotation.Nullable;
public class ActivityUi extends BaseUi { public class ActivityUi extends BaseUi {
private int layoutId; private final int layoutId;
@Nonnull @Nonnull
private Preferences.Gui.Theme theme = Preferences.Gui.Theme.material_theme; 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 @Nonnull
public Language getLanguage() { public Language getLanguage() {
return language; return language;

View File

@ -18,16 +18,12 @@ public class BaseActivity extends AppCompatActivity {
@Nonnull @Nonnull
protected final ActivityUi ui; protected final ActivityUi ui;
public BaseActivity(@Nonnull ActivityUi ui) { public BaseActivity() {
this.ui = ui; this(R.layout.main_empty);
} }
public BaseActivity(@LayoutRes int layout) { public BaseActivity(@LayoutRes int layout) {
this(layout, "Activity"); this.ui = new ActivityUi(layout, getClass().getSimpleName());
}
public BaseActivity(@LayoutRes int layout, @Nonnull String logTag) {
this.ui = new ActivityUi(layout, logTag);
} }
@Nonnull @Nonnull

View File

@ -62,8 +62,6 @@ import static org.solovyev.android.wizard.WizardUi.*;
public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener, Toolbar.OnMenuItemClickListener { public class CalculatorActivity extends BaseActivity implements SharedPreferences.OnSharedPreferenceChangeListener, Toolbar.OnMenuItemClickListener {
@Nonnull
public static final String TAG = CalculatorActivity.class.getSimpleName();
@Inject @Inject
PreferredPreferences preferredPreferences; PreferredPreferences preferredPreferences;
@Inject @Inject
@ -89,7 +87,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
private boolean useBackAsPrev; private boolean useBackAsPrev;
public CalculatorActivity() { public CalculatorActivity() {
super(0, TAG); super(R.layout.activity_main);
} }
private static void firstTimeInit(@Nonnull SharedPreferences preferences, @Nonnull Context context) { private static void firstTimeInit(@Nonnull SharedPreferences preferences, @Nonnull Context context) {
@ -163,8 +161,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
ui.setLayoutId(R.layout.activity_main);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ButterKnife.bind(this); ButterKnife.bind(this);

View File

@ -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);
}
}

View File

@ -23,14 +23,13 @@
package org.solovyev.android.calculator.about; package org.solovyev.android.calculator.about;
import android.os.Bundle; import android.os.Bundle;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.EmptyActivity;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class AboutActivity extends EmptyActivity { public class AboutActivity extends BaseActivity {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {

View File

@ -34,10 +34,6 @@ public class FunctionsActivity extends BaseActivity {
public static final String EXTRA_FUNCTION = "function"; public static final String EXTRA_FUNCTION = "function";
public FunctionsActivity() {
super(R.layout.main_empty, FunctionsActivity.class.getSimpleName());
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@ -34,10 +34,6 @@ import static org.solovyev.android.calculator.FragmentTab.saved_history;
public class HistoryActivity extends BaseActivity { public class HistoryActivity extends BaseActivity {
public HistoryActivity() {
super(R.layout.main_empty, HistoryActivity.class.getSimpleName());
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@ -23,19 +23,13 @@
package org.solovyev.android.calculator.matrix; package org.solovyev.android.calculator.matrix;
import android.os.Bundle; import android.os.Bundle;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.EmptyActivity;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import static android.support.v7.app.ActionBar.NAVIGATION_MODE_STANDARD; import static android.support.v7.app.ActionBar.NAVIGATION_MODE_STANDARD;
/** public class CalculatorMatrixActivity extends BaseActivity {
* User: Solovyev_S
* Date: 12.10.12
* Time: 10:56
*/
public class CalculatorMatrixActivity extends EmptyActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {

View File

@ -25,16 +25,11 @@ package org.solovyev.android.calculator.operators;
import android.os.Bundle; import android.os.Bundle;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.R;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class OperatorsActivity extends BaseActivity { public class OperatorsActivity extends BaseActivity {
public OperatorsActivity() {
super(R.layout.main_empty, OperatorsActivity.class.getSimpleName());
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@ -25,7 +25,6 @@ package org.solovyev.android.calculator.variables;
import android.os.Bundle; import android.os.Bundle;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.FragmentTab; import org.solovyev.android.calculator.FragmentTab;
import org.solovyev.android.calculator.R;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -33,10 +32,6 @@ public class VariablesActivity extends BaseActivity {
public static final String EXTRA_VARIABLE = "variable"; public static final String EXTRA_VARIABLE = "variable";
public VariablesActivity() {
super(R.layout.main_empty, VariablesActivity.class.getSimpleName());
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);