Search in sources :

Example 1 with SharedPref

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");
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) User(com.madonasyombua.growwithgoogleteamproject.models.User) BottomNavigationView(android.support.design.widget.BottomNavigationView) Bundle(android.os.Bundle) FeedsFragment(com.madonasyombua.growwithgoogleteamproject.ui.fragment.FeedsFragment) SharedPref(com.madonasyombua.growwithgoogleteamproject.ui.SharedPref) NavigationView(android.support.design.widget.NavigationView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) BottomNavigationView(android.support.design.widget.BottomNavigationView) TextView(android.widget.TextView)

Example 2 with SharedPref

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);
        }
    });
}
Also used : MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) SharedPref(com.madonasyombua.growwithgoogleteamproject.ui.SharedPref) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

View (android.view.View)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 SharedPref (com.madonasyombua.growwithgoogleteamproject.ui.SharedPref)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 RecognizerIntent (android.speech.RecognizerIntent)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 NavigationView (android.support.design.widget.NavigationView)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 Toolbar (android.support.v7.widget.Toolbar)1 AdapterView (android.widget.AdapterView)1 User (com.madonasyombua.growwithgoogleteamproject.models.User)1 FeedsFragment (com.madonasyombua.growwithgoogleteamproject.ui.fragment.FeedsFragment)1 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1