code refactor

This commit is contained in:
h4h13 2018-08-05 22:02:54 +05:30
parent 31467c9b5f
commit b046c85d78

View file

@ -12,21 +12,23 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView;
import com.afollestad.materialdialogs.color.ColorChooserDialog;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import code.name.monkey.appthemehelper.ThemeStore; import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.ColorUtil; import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager; import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager;
import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity; import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity;
import code.name.monkey.retromusic.ui.fragments.settings.MainSettingsFragment; import code.name.monkey.retromusic.ui.fragments.settings.MainSettingsFragment;
import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.PreferenceUtil;
import com.afollestad.materialdialogs.color.ColorChooserDialog;
public class SettingsActivity extends AbsBaseActivity implements ColorChooserDialog.ColorCallback { public class SettingsActivity extends AbsBaseActivity implements ColorChooserDialog.ColorCallback {
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@BindView(R.id.app_bar) @BindView(R.id.app_bar)
@ -34,7 +36,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
@BindView(R.id.detail_content_frame) @BindView(R.id.detail_content_frame)
@Nullable @Nullable
FrameLayout detailsFrame; FrameLayout detailsFrame;
private FragmentManager fragmentManager = getSupportFragmentManager(); private FragmentManager fragmentManager = getSupportFragmentManager();
@Override @Override
@ -77,17 +78,19 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
setupToolbar(); setupToolbar();
if (bundle == null) { if (bundle == null) {
fragmentManager.beginTransaction().replace(R.id.content_frame, new MainSettingsFragment()).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, new MainSettingsFragment())
.commit();
} else { } else {
restoreFragment(); restoreFragment();
} }
} }
private void setupToolbar() { private void setupToolbar() {
appBarLayout.setBackgroundColor(ThemeStore.primaryColor(this)); int primaryColor = ThemeStore.primaryColor(this);
toolbar.setBackgroundColor(ThemeStore.primaryColor(this)); appBarLayout.setBackgroundColor(primaryColor);
toolbar.setBackgroundColor(primaryColor);
toolbar.setNavigationOnClickListener(v -> onBackPressed()); toolbar.setNavigationOnClickListener(v -> onBackPressed());
setTitle(R.string.action_settings); setTitle(R.string.app_name);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
} }