use of com.naman14.timber.fragments.SettingsFragment in project Timber by naman14.
the class LastFmLoginDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new MaterialDialog.Builder(getActivity()).positiveText("Login").negativeText("Cancel").title("Login to LastFM").customView(R.layout.dialog_lastfm_login, false).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String username = ((EditText) dialog.findViewById(R.id.lastfm_username)).getText().toString();
String password = ((EditText) dialog.findViewById(R.id.lastfm_password)).getText().toString();
if (username.length() == 0 || password.length() == 0)
return;
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Logging in..");
progressDialog.show();
LastFmClient.getInstance(getActivity()).getUserLoginInfo(new UserLoginQuery(username, password), new UserListener() {
@Override
public void userSuccess() {
progressDialog.dismiss();
if (getTargetFragment() instanceof SettingsFragment) {
((SettingsFragment) getTargetFragment()).updateLastFM();
}
}
@Override
public void userInfoFailed() {
progressDialog.dismiss();
Toast.makeText(getTargetFragment().getActivity(), "Failed to Login", Toast.LENGTH_SHORT).show();
}
});
}
}).build();
}
use of com.naman14.timber.fragments.SettingsFragment in project Timber by naman14.
the class SettingsActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
if (PreferencesUtility.getInstance(this).getTheme().equals("dark"))
setTheme(R.style.AppThemeNormalDark);
else if (PreferencesUtility.getInstance(this).getTheme().equals("black"))
setTheme(R.style.AppThemeNormalBlack);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
action = getIntent().getAction();
if (action.equals(Constants.SETTINGS_STYLE_SELECTOR)) {
getSupportActionBar().setTitle(R.string.now_playing);
String what = getIntent().getExtras().getString(Constants.SETTINGS_STYLE_SELECTOR_WHAT);
Fragment fragment = StyleSelectorFragment.newInstance(what);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().add(R.id.fragment_container, fragment).commit();
} else {
getSupportActionBar().setTitle(R.string.settings);
PreferenceFragment fragment = new SettingsFragment();
android.app.FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.fragment_container, fragment).commit();
}
}
Aggregations