package com.marverenic.music.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import com.marverenic.music.R;
import com.marverenic.music.fragments.PreferenceFragment;
public class SettingsActivity extends BaseActivity {
public static Intent newIntent(Context context) {
return new Intent(context, SettingsActivity.class);
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
if (getSupportActionBar() != null
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getSupportActionBar()
.setElevation(getResources().getDimension(R.dimen.header_elevation));
}
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.replace(R.id.pref_fragment_container, new PreferenceFragment())
.commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (!getSupportFragmentManager().popBackStackImmediate()) {
super.onOptionsItemSelected(item);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onBackPressed() {
if (!getSupportFragmentManager().popBackStackImmediate()) {
super.onBackPressed();
}
}
}