use of com.madonasyombua.growwithgoogleteamproject.ui.SharedPref in project Devsfolio by Madonahs.
the class MainActivity method onCreate.
/**
* Theme can only be changed before setContentView is called.
* Therefore, I am changing the theme on here.
* store data
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
sharedPref = new SharedPref(this);
if (sharedPref.loadNightModeState()) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.AppTheme);
}
prev_State = sharedPref.loadNightModeState();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
// This method will save the theme and initiates the preferenceChange listener
setCorrectTheme();
// Get all user information views from the drawer header view
View drawerHeaderView = navView.getHeaderView(0);
profilePicView = drawerHeaderView.findViewById(R.id.drawer_header_user_image);
userName = drawerHeaderView.findViewById(R.id.drawer_header_user_name);
userProfession = drawerHeaderView.findViewById(R.id.drawer_header_user_profession);
// Set action bar, navigation drawer, navigation drawer header
setSupportActionBar(toolbar);
setupNavDrawer();
setDrawerHeader();
fragment = getSupportFragmentManager().findFragmentByTag(TAG);
if (fragment == null) {
fragment = new FeedsFragment();
}
BottomNavigationView navigation = findViewById(R.id.navigation);
BottomNavigationViewHelper.disableShiftMode(navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.content, fragment, TAG);
transaction.commit();
/*TODO: Get user data from intent or load from DB if intent is null*/
Bundle data = getIntent().getBundleExtra(Constant.USER);
if (data != null)
user = User.build(data);
else
// TODO: load from DB
user = new User("this guy", "thisguy@devs.com", "000000");
}
use of com.madonasyombua.growwithgoogleteamproject.ui.SharedPref in project Devsfolio by Madonahs.
the class HelpActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
sharedPref = new SharedPref(this);
if (sharedPref.loadNightModeState()) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.AppTheme);
}
prev_State = sharedPref.loadNightModeState();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help_searchview);
ButterKnife.bind(this);
setCorrectTheme();
// Toolbar with Search Icon
Toolbar toolbar = (Toolbar) findViewById(R.id.tb_help);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle("Help");
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), MainActivity.class));
}
});
searchView = (MaterialSearchView) findViewById(R.id.search_view);
searchView.setVoiceSearch(true);
searchView.setCursorDrawable(R.drawable.color_cursor_white);
searchView.setSuggestions(getResources().getStringArray(R.array.search_suggestions));
searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Snackbar.make(findViewById(R.id.container), "Query: " + query, Snackbar.LENGTH_LONG).show();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
// Do something something
}
@Override
public void onSearchViewClosed() {
// Do something something
}
});
backToMain = findViewById(R.id.backToMain);
backToMain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HelpActivity.this, MainActivity.class);
startActivity(intent);
}
});
faq.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://www.madonahsyombua.com/faqs"));
startActivity(intent);
}
});
contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://www.madonahsyombua.com/contact"));
startActivity(intent);
}
});
terms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://www.madonahsyombua.com/privacy-policy"));
startActivity(intent);
}
});
}
Aggregations