com.firebase.client.AuthData Java Examples
The following examples show how to use
com.firebase.client.AuthData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From io16experiment-master with Apache License 2.0 | 6 votes |
/** * Generate an anonymous account to identify this user. The UID will be transmitted as part of the payload for all * connected devices. */ private void generateAnonymousAccount() { LogUtils.LOGE("***> generate anon account", "here"); Firebase ref = new Firebase(Constants.FIREBASE_URL); ref.authAnonymously(new Firebase.AuthResultHandler() { @Override public void onAuthenticated(AuthData authData) { // we've authenticated this session with your Firebase app LogUtils.LOGE("***> onAuthenticated", authData.getUid()); PreferencesUtils.setString(mActivity, R.string.key_firebase_uid, authData.getUid()); createUserInFirebaseHelper(authData.getUid()); } @Override public void onAuthenticationError(FirebaseError firebaseError) { // there was an error } }); }
Example #2
Source File: ClimbSessionListFragment.java From climb-tracker with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url)); mFirebaseRef.addAuthStateListener(new Firebase.AuthStateListener() { @Override public void onAuthStateChanged(AuthData authData) { if (authData != null) { Firebase ref = mFirebaseRef.child("users").child(authData.getUid()); ref.keepSynced(true); mListAdapter = new ClimbSessionListAdapter(ref.child("climbs").limitToLast(CLIMB_LIMIT).orderByChild("date"), R.layout.climbsession_item, getActivity()); setListAdapter(mListAdapter); } } }); }
Example #3
Source File: ClimbSessionDetailFragment.java From climb-tracker with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Analytics. ClimbTrackerApplication application = (ClimbTrackerApplication) getActivity().getApplication(); mTracker = application.getDefaultTracker(); // track pageview mTracker.setScreenName(LOG_TAG); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url)); AuthData authData = mFirebaseRef.getAuth(); mFirebaseRef = mFirebaseRef.child("users") .child(authData.getUid()) .child("climbs"); long time = getArguments().getLong(ARG_FIRST_CLIMB_TIME); mSession = new ClimbSession( new Date(time) ); long lastTime = getArguments().getLong(ARG_LAST_CLIMB_TIME); mListAdapter = new ClimbListAdapter(mFirebaseRef.limitToFirst(50).orderByChild("date").startAt(time).endAt(lastTime), R.layout.climb_item, getActivity()); }
Example #4
Source File: MainActivity.java From firebase-login-demo-android with MIT License | 5 votes |
/** * Once a user is logged in, take the mAuthData provided from Firebase and "use" it. */ private void setAuthenticatedUser(AuthData authData) { if (authData != null) { /* Hide all the login buttons */ mFacebookLoginButton.setVisibility(View.GONE); mGoogleLoginButton.setVisibility(View.GONE); mTwitterLoginButton.setVisibility(View.GONE); mPasswordLoginButton.setVisibility(View.GONE); mAnonymousLoginButton.setVisibility(View.GONE); mLoggedInStatusTextView.setVisibility(View.VISIBLE); /* show a provider specific status text */ String name = null; if (authData.getProvider().equals("facebook") || authData.getProvider().equals("google") || authData.getProvider().equals("twitter")) { name = (String) authData.getProviderData().get("displayName"); } else if (authData.getProvider().equals("anonymous") || authData.getProvider().equals("password")) { name = authData.getUid(); } else { Log.e(TAG, "Invalid provider: " + authData.getProvider()); } if (name != null) { mLoggedInStatusTextView.setText("Logged in as " + name + " (" + authData.getProvider() + ")"); } } else { /* No authenticated user show all the login buttons */ mFacebookLoginButton.setVisibility(View.VISIBLE); mGoogleLoginButton.setVisibility(View.VISIBLE); mTwitterLoginButton.setVisibility(View.VISIBLE); mPasswordLoginButton.setVisibility(View.VISIBLE); mAnonymousLoginButton.setVisibility(View.VISIBLE); mLoggedInStatusTextView.setVisibility(View.GONE); } this.mAuthData = authData; /* invalidate options menu to hide/show the logout button */ supportInvalidateOptionsMenu(); }
Example #5
Source File: CloudManager.java From thunderboard-android with Apache License 2.0 | 4 votes |
@Override public void onAuthenticated(AuthData authData) { Timber.d("Firebase authentication success"); }
Example #6
Source File: MobileDataLayerListenerService.java From climb-tracker with Apache License 2.0 | 4 votes |
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG, "onDataChanged: " + dataEvents); final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents); dataEvents.close(); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String gradeSystemType = sharedPref.getString(Path.PREF_GRAD_SYSTEM_TYPE, GradeList.SYSTEM_DEFAULT); Location lastLocation = null; if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { lastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); } for (DataEvent event : events) { Log.d(TAG, "Event: " + event.getDataItem().toString()); Uri uri = event.getDataItem().getUri(); String path = uri.getPath(); if (path.startsWith(Path.CLIMB)) { DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem()); String routeGradeLabel = dataMapItem.getDataMap().getString(Path.ROUTE_GRADE_LABEL_KEY); Date climbDate = new Date(dataMapItem.getDataMap().getLong(Path.CLIMB_DATE_KEY)); // check that climb date and location date are not too far, do not save location if so. double latitude = 0; double longitude = 0; if(lastLocation != null && Math.abs(lastLocation.getTime() - climbDate.getTime()) < MAX_TIME_FOR_LOCATION) { latitude = lastLocation.getLatitude(); longitude = lastLocation.getLongitude(); } if (routeGradeLabel != null) { Log.d(TAG, "New Climb, grade : " + routeGradeLabel + " " + climbDate.toString()); AuthData authData = mFirebaseRef.getAuth(); if (authData != null) { Climb newClimb = new Climb(climbDate, routeGradeLabel, gradeSystemType, latitude, longitude); mFirebaseRef.child("users") .child(authData.getUid()) .child("climbs") .push().setValue(newClimb); } } } } }
Example #7
Source File: ClimbTrackerActivity.java From climb-tracker with Apache License 2.0 | 4 votes |
/** * Once a user is logged in, take the mAuthData provided from Firebase and "use" it. */ private void setAuthenticatedUser(AuthData authData) { this.mAuthData = authData; }
Example #8
Source File: MainActivity.java From firebase-login-demo-android with MIT License | 4 votes |
@Override public void onAuthenticated(AuthData authData) { mAuthProgressDialog.hide(); Log.i(TAG, provider + " auth successful"); setAuthenticatedUser(authData); }