Skip to content

Commit

Permalink
Use view binding in SettingsActivity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Dec 18, 2020
1 parent b4d77df commit d6121c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.SettingsLayoutBinding;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.views.FocusOverlayView;
Expand Down Expand Up @@ -51,10 +51,12 @@ protected void onCreate(final Bundle savedInstanceBundle) {
setTheme(ThemeHelper.getSettingsThemeStyle(this));
assureCorrectAppLanguage(this);
super.onCreate(savedInstanceBundle);
setContentView(R.layout.settings_layout);

final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final SettingsLayoutBinding settingsLayoutBinding =
SettingsLayoutBinding.inflate(getLayoutInflater());
setContentView(settingsLayoutBinding.getRoot());

setSupportActionBar(settingsLayoutBinding.toolbarLayout.toolbar);

if (savedInstanceBundle == null) {
getSupportFragmentManager().beginTransaction()
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/settings_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize" />

<include layout="@layout/toolbar_layout" />
<include
layout="@layout/toolbar_layout"
android:id="@+id/toolbar_layout"/>

</RelativeLayout>

0 comments on commit d6121c8

Please sign in to comment.