Java Code Examples for android.support.v7.app.AppCompatDelegate.setCompatVectorFromResourcesEnabled()

The following are Jave code examples for showing how to use setCompatVectorFromResourcesEnabled() of the android.support.v7.app.AppCompatDelegate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: MTweaks-KernelAdiutorMOD   File: BaseActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    Utils.DARK_THEME = Prefs.getBoolean("darktheme", false, this);
    int theme;
    String accent = Prefs.getString("accent_color", "pink_accent", this);
    if (Utils.DARK_THEME) {
        theme = sAccentDarkColors.get(accent);
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    } else {
        theme = sAccentColors.get(accent);
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
    }
    setTheme(theme);
    super.onCreate(savedInstanceState);
    if (Prefs.getBoolean("forceenglish", false, this)) {
        Utils.setLocale("en_US", this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(statusBarColor());
    }
}
 
Example 2
Project: Programmers   File: SettingsActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.v(TAG, "onCreate: ");

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    FragmentManager fragmentManager = getFragmentManager();
    settingsFragment = (SettingsFragment) fragmentManager.findFragmentByTag(TAG);

    if (settingsFragment == null) {
        settingsFragment = SettingsFragment.newInstance(R.xml.settings_main);

        replaceFragment(settingsFragment);
    } else {
        showFragment(settingsFragment);
    }
}
 
Example 3
Project: ConnectU   File: TutoriasActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_tutorias);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
    app = (App) this.getApplication();
    //SetView
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    tabLayout = (TabLayout) findViewById(R.id.tabs);
    progress = (AVLoadingIndicatorView) findViewById(R.id.material_progress);
    title = (TextView) findViewById(R.id.toolbar_title);
    fabTut = (FloatingActionButton) findViewById(R.id.fabTut);
    setYearAdapters();
    request = new TutoriasRequest(this);
    updateYear(true, app.getPublicPreferenceI(Common.GLOBAL_FILTER_YEAR));
    doRequest();
}
 
Example 4
Project: ConnectU   File: HorarioActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_horario);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
    app = (App) getApplication();
    if (app.account == null && !app.loadUser()) //If account is null and cannot create user
        super.onDestroy();
    mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView = (RecyclerView) findViewById(R.id.horarioRecycler);
    emptyView = (LinearLayout) findViewById(R.id.horario_blank);
    recyclerView.setLayoutManager(mLayoutManager);

    initializePicker();
    getDateData(new Date());
}
 
Example 5
Project: Kids-Portal-Android   File: Activity_settings_start.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings_start.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.pref_3);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();

    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
}
 
Example 6
Project: Android-Development   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
        setContentView(R.layout.activity_main);
        //load last known location from SharedPreferences
        lastKnownLocation = new StorageUtil(this).getLastKnownLocation();

        if (lastKnownLocation == null) {
            registerReceiver(locationEnabledReceiver, new IntentFilter("LOCATION_ENABLED"));
        }

        //request permissions
        requestWriteExternalStoragePermission();

        getStatusBatColor();
        updateStatusBarColor();
        viewSetup();

        setupOsmConnection();

//        AppLog.log("OAUTH");
//        AppLog.log(osm.getUserAgent());
//        AppLog.log(osm.getApiUrl());
//        AppLog.log(osm.getOAuth().getConsumerKey());
//        AppLog.log(osm.getOAuth().getConsumerSecret());
//        AppLog.log(osm.getOAuth().getRequestParameters());
//        logUserInfo();
    }
 
Example 7
Project: Kids-Portal-Android   File: Activity_settings_app.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings_app.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.pref_2);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();

    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
}
 
Example 8
Project: haven   File: HavenApp.java   Source Code and License Vote up 5 votes
@Override
public void onCreate() {
    super.onCreate();

    mPrefs = new PreferenceManager(this);

    Fresco.initialize(this);
    SugarContext.init(this);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    if (mPrefs.getRemoteAccessActive())
        startServer();

}
 
Example 9
Project: RxRedux   File: BaseActivity.java   Source Code and License Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLifecycleRegistry = new LifecycleRegistry(this);
    mLifecycleRegistry.markState(Lifecycle.State.CREATED);
    navigator = NavigatorFactory.getInstance();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    restoreViewStateFromBundle(savedInstanceState);
    initialize();
    setupUI(savedInstanceState == null);
}
 
Example 10
Project: Kids-Portal-Android   File: Activity_settings_close.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings_close.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.pref_5);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();

    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
}
 
Example 11
Project: DuckDuckDefine-Android   File: DuckDuckDefineApplication.java   Source Code and License Vote up 5 votes
@Override
public void onCreate() {
    super.onCreate();

    initialiseDependencyInjection();

    if (BuildConfig.DEBUG) {
        initTimberDebugPlant();
    }

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
 
Example 12
Project: javaide   File: JavaApplication.java   Source Code and License Vote up 5 votes
@Override
public void onCreate() {
    super.onCreate();
    systemOut = new InterceptorOutputStream(System.out, out);
    systemErr = new InterceptorOutputStream(System.err, err);
    System.setOut(systemOut);
    System.setErr(systemErr);

    //for log cat
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
 
Example 13
Project: RxRedux   File: BaseFragmentActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    navigator = NavigatorFactory.getInstance();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    restoreViewStateFromBundle(savedInstanceState);
    initialize();
    setupUI(savedInstanceState == null);
}
 
Example 14
Project: NoInternetDialog   File: NoInternetDialog.java   Source Code and License Vote up 4 votes
private NoInternetDialog(@NonNull Context context, int bgGradientStart, int bgGradientCenter, int bgGradientEnd,
                         int bgGradientOrientation, int bgGradientType, float dialogRadius,
                         @Nullable Typeface titleTypeface, @Nullable Typeface messageTypeface,
                         int buttonColor, int buttonTextColor, int buttonIconsColor, int wifiLoaderColor,
                         boolean cancelable) {
    super(context);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    isHalloween = NoInternetUtils.getCurrentDate().equals("10-31");

    this.bgGradientStart = bgGradientStart == 0
            ? (isHalloween
            ? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradStartH)
            : ContextCompat.getColor(getContext(), R.color.colorNoInternetGradStart))
            : bgGradientStart;
    this.bgGradientCenter = bgGradientCenter == 0
            ? (isHalloween
            ? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH)
            : ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenter))
            : bgGradientCenter;
    this.bgGradientEnd = bgGradientEnd == 0
            ? (isHalloween
            ? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradEndH)
            : ContextCompat.getColor(getContext(), R.color.colorNoInternetGradEnd))
            : bgGradientEnd;
    this.bgGradientOrientation = bgGradientOrientation < 10 || bgGradientOrientation > 17 ? ORIENTATION_TOP_BOTTOM : bgGradientOrientation;
    this.bgGradientType = bgGradientType <= 0 || bgGradientType > 2 ? GRADIENT_LINEAR : bgGradientType;
    this.dialogRadius = dialogRadius == 0 ? RADIUS : dialogRadius;
    if (dialogRadius == NO_RADIUS) {
        this.dialogRadius = 0f;
    }
    this.titleTypeface = titleTypeface;
    this.messageTypeface = messageTypeface;

    this.buttonColor = buttonColor == 0
            ? (isHalloween
            ? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH)
            : ContextCompat.getColor(getContext(), R.color.colorAccent))
            : buttonColor;
    this.buttonTextColor = buttonTextColor == 0
            ? ContextCompat.getColor(getContext(), R.color.colorWhite)
            : buttonTextColor;
    this.buttonIconsColor = buttonIconsColor == 0
            ? ContextCompat.getColor(getContext(), R.color.colorWhite)
            : buttonIconsColor;
    this.wifiLoaderColor = wifiLoaderColor == 0
            ? ContextCompat.getColor(getContext(), R.color.colorWhite)
            : wifiLoaderColor;

    this.cancelable = cancelable;

    initReceivers(context);
}
 
Example 15
Project: ConnectU   File: WebmailActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_web);
    name = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_NAME);
    url = getIntent().getExtras().getString(Common.WEBVIEW_EXTRA_URL);
    color = getIntent().getExtras().getInt(Common.WEBVIEW_EXTRA_COLOR);
    needsLogin = getIntent().getExtras().getBoolean(Common.WEBVIEW_EXTRA_NLOGIN);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(color);
        getWindow().setStatusBarColor(color);
    }
    app = (App) getApplication();
    if (app.account == null && !app.loadUser()) //If account is null and cannot create user
        super.onDestroy();

    TextView title = (TextView) findViewById(R.id.toolbar_title);
    title.setText(name);

    progress = (ProgressBar) findViewById(R.id.web_progressBar);
    webView = (WebView) findViewById(R.id.webView);

    if (savedInstanceState != null) {
        progress.setVisibility(View.INVISIBLE);
        webView.setVisibility(View.VISIBLE);
        webView.restoreState(savedInstanceState);
    }
    else {
        progress.setVisibility(View.VISIBLE);
        webView.setWebViewClient(new WebViewClient());
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setUserAgentString("IEMobile");
        startControllers();
    }
}
 
Example 16
Project: whatanime-android   File: App.java   Source Code and License Vote up 4 votes
@Override
public void onCreate() {
    super.onCreate();
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    Logger2.get().setEnabled(BuildConfig.IS_LOGGER_ENABLED);
}
 
Example 17
Project: foco   File: EditDocActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {

    // get document metadata
    mDocumentMetadata = getIntent().getParcelableExtra(EXTRA_DOC);
    if (mDocumentMetadata == null) {
        finish();
        return;
    }

    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_edit_doc);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    mToolbarTitle.setText(mDocumentMetadata.getName());
    mToolbarTitle.setContentDescription(mDocumentMetadata.getName());

    FontChangeCrawler fontChanger = new FontChangeCrawler(getAssets(),
            getString(R.string.font_libre_baskerville_regular));
    fontChanger.replaceFonts(mEditTextContent);

    // set up selection tool bar
    SelectionToolbarUtils.setDescriptionToToast(this,
            R.id.edit_toolbar_title,
            R.id.edit_toolbar_back,
            R.id.edit_selection_bar_format_bold,
            R.id.edit_selection_bar_format_italic,
            R.id.edit_selection_bar_format_strikethrough,
            R.id.edit_selection_bar_format_quote,
            R.id.edit_selection_bar_format_list_bulleted,
            R.id.edit_selection_bar_format_list_numbered,
            R.id.edit_selection_bar_format_link,
            R.id.edit_selection_bar_format_image,
            R.id.edit_selection_bar_format_video,
            R.id.edit_selection_bar_format_header,
            R.id.edit_selection_bar_format_header_2,
            R.id.edit_selection_bar_format_header_3);

    // set up markdown
    mPreview.addStyleSheet(new ExternalStyleSheet("https://fonts.googleapis.com/css?family=Libre+Baskerville"));
    InternalStyleSheet css = new Github();
    css.addRule("*", "color: black", "font-family: 'Libre Baskerville', serif");
    mPreview.addStyleSheet(css);

    if (savedInstanceState == null || !savedInstanceState.getBoolean(TEXT_LOADED_KEY, false)) {
        loadTextAsync();
    } else {
        mAppBar.setExpanded(true, true);
        mStartTime = savedInstanceState.getLong(START_TIME_KEY, -1);
        mTextEdited = savedInstanceState.getBoolean(TEXT_EDITED_KEY, false);
        mPreviewMode = savedInstanceState.getBoolean(PREVIEW_MODE_KEY, false);
        mTextLoaded = true;
        showLoading();
        // post runnable to be executed after edit text restore its content
        mEditTextContent.post(new Runnable() {
            @Override
            public void run() {
                subscribeObserver();
                showContent();
                if (mPreviewMode) {
                    showPreviewMode();
                }
            }
        });
    }
}
 
Example 18
Project: foco   File: MainActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle(null);

    // set up selection tool bar
    SelectionToolbarUtils.setDescriptionToToast(this,
            R.id.main_selection_bar_exit,
            R.id.main_selection_bar_delete,
            R.id.main_selection_bar_export,
            R.id.main_selection_bar_favorite,
            R.id.main_selection_bar_edit_cover,
            R.id.main_selection_bar_edit_title);

    // disable export feature if SDK version is not valid
    mExportEnabled = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
    if (!mExportEnabled) mExportSelectionBar.setVisibility(View.GONE);

    // set up recycler view
    int spanCount = getResources().getInteger(R.integer.grid_doc_columns);
    int orientation = OrientationHelper.VERTICAL;
    boolean reverseLayout = false;
    mLayoutManager = new GridLayoutManager(this, spanCount, orientation, reverseLayout);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new DocsAdapter(this, mSelectedDocuments, this);
    mRecyclerView.setAdapter(mAdapter);
    updateAdapterComparator();

    mAppBar.addOnOffsetChangedListener(this);
    startAlphaAnimation(mToolbarLogo, 0, View.INVISIBLE);

    showLoading();
    // subscribe to view model
    DocListViewModel viewModel = ViewModelProviders.of(this).get(DocListViewModel.class);
    subscribeUi(viewModel);
}
 
Example 19
Project: Open-Quran-Radio   File: MainActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    // get collection folder
    StorageHelper storageHelper = new StorageHelper(this);
    mCollectionFolder = storageHelper.getCollectionDirectory();
    if (mCollectionFolder == null) {
        Toast.makeText(this, getString(R.string.toastalert_no_external_storage), Toast.LENGTH_LONG).show();
        finish();
    }

    // set layout
    setContentView(R.layout.activity_main);

    // initialize broadcast receivers
    initializeBroadcastReceivers();

    //Mal:toolbar and Drawer
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    //Mal:END toolbar and Drawer

    //authentication (login using Firebase components)
    Button btnLogin = (Button) navigationView.getHeaderView(0).findViewById(R.id.btnLogin);
    layoutLogin = (LinearLayout) navigationView.getHeaderView(0).findViewById(R.id.layoutLogin);
    layoutLoggedIn = (LinearLayout) navigationView.getHeaderView(0).findViewById(R.id.layoutLoggedIn);

    //coordinatorLayout
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);

    mAuth = FirebaseAuth.getInstance();
    //layout
    if (mAuth.getCurrentUser() != null) {
        // already signed in
        fillUserProfileData();
        layoutLoggedIn.setVisibility(View.VISIBLE);
        layoutLogin.setVisibility(View.GONE);
    } else {
        // not signed in
        layoutLoggedIn.setVisibility(View.GONE);
        layoutLogin.setVisibility(View.VISIBLE);
    }
    btnLogin.setOnClickListener(new View.OnClickListener() {
        // Choose an arbitrary request code value
        @Override
        public void onClick(View v) {
            if (mAuth.getCurrentUser() == null) {
                // not signed in
                startActivityForResult(
                        AuthUI.getInstance()
                                .createSignInIntentBuilder()
                                .setTheme(R.style.TransistorAppTheme_NoActionBar)
                                .setProviders(Arrays.asList(
                                        new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()))
                                .build(),
                        RC_SIGN_IN);
            }
        }
    });

    //for search
    handleIntent(getIntent());
}
 
Example 20
Project: ModesoActionOverlay-Android   File: AnimatedMenuItem.java   Source Code and License Vote up 2 votes
private void init(){
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setBackground(ContextCompat.getDrawable(getContext(),R.drawable.item_bg_selector));


}