当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseError类代码示例

本文整理汇总了Java中com.firebase.client.FirebaseError的典型用法代码示例。如果您正苦于以下问题:Java FirebaseError类的具体用法?Java FirebaseError怎么用?Java FirebaseError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FirebaseError类属于com.firebase.client包,在下文中一共展示了FirebaseError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderData

import com.firebase.client.FirebaseError; //导入依赖的package包/类
private void renderData() {
    Query queryRef = mRootRef.child("users").orderByChild(getOrderBy()).limitToLast(100);//we need to iterate them backwards
    queryRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {

            for (DataSnapshot userSnapshot : snapshot.getChildren()) {
                mUsersDataset.add(userSnapshot.getValue(User.class));
            }
            Collections.reverse(mUsersDataset);
            mAdapter = new UserListAdapter(mUsersDataset, getActivity(), getmTabType());
            mRecyclerView.setAdapter(mAdapter);
            mLoadingWrapper.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
开发者ID:silva96,项目名称:guessthehashtag,代码行数:23,代码来源:WeeklyFragment.java

示例2: generateAnonymousAccount

import com.firebase.client.FirebaseError; //导入依赖的package包/类
/**
 * 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
        }
    });
}
 
开发者ID:kyleparker,项目名称:io16experiment-master,代码行数:22,代码来源:MainActivity.java

示例3: authenticate

import com.firebase.client.FirebaseError; //导入依赖的package包/类
/**
 * @param appData {@link AppData} object which contains the token to authenticate with.
 * @param reAuth  True if this is a re-authentication attempt.
 * @return An {@link AuthData} object.
 */
public Task<AppData> authenticate(AppData appData, boolean reAuth) {
    Task<AppData>.TaskCompletionSource taskSource = Task.<AppData>create();

    firebaseRef.authWithCustomToken(appData.getFirebaseConfig().getToken(), new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            if (reAuth) {
                userManager.setLoggedIn(appData.getUser().getUsername());
            }

            taskSource.setResult(appData);
        }

        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            taskSource.setError(firebaseError.toException());
        }
    });

    return taskSource.getTask();
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:27,代码来源:FirebaseTasks.java

示例4: getPresenceImpl

import com.firebase.client.FirebaseError; //导入依赖的package包/类
private Task<PresenceType> getPresenceImpl(User user) {
    Task<PresenceType>.TaskCompletionSource taskSource = Task.<PresenceType>create();

    Firebase presenceRef = firebaseRef.child(user.getPresencePath());
    presenceRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            String status = dataSnapshot.getValue(String.class);
            taskSource.setResult(PresenceType.parse(status));
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            taskSource.setError(firebaseError.toException());
        }
    });

    return taskSource.getTask();
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:20,代码来源:FirebaseTasks.java

示例5: onCancelled

import com.firebase.client.FirebaseError; //导入依赖的package包/类
@Override
public void onCancelled(FirebaseError firebaseError) {
    if (firebaseError.getCode() != FirebaseError.PERMISSION_DENIED) {
        onError(firebaseError);
        return;
    }

    if (firebaseReAuthTask != null) {
        return;
    }

    firebaseReAuthTask = codementorTasks.extractAppData()
            .onSuccessTask(task -> firebaseTasks.authenticate(task.getResult(), true))
            .onSuccess(this::onReAuthSuccessful, UI)
            .continueWith(this::onReAuthCompleted, UI);
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:17,代码来源:QueryEventListener.java

示例6: checkThings

import com.firebase.client.FirebaseError; //导入依赖的package包/类
private void checkThings() {
    Calendar cal = Calendar.getInstance();
    boolean monday = cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY;
    mWeekResetRef = mRootRef.child("settings").child("week_reset");
    if (monday) {
        mWeekResetRef.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                boolean is_reseted = snapshot.getValue(boolean.class);
                if (!is_reseted) {
                    updateAllWeekScores();
                }
            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {

            }
        });
    } else {
        mWeekResetRef.setValue(false);
    }
}
 
开发者ID:silva96,项目名称:guessthehashtag,代码行数:24,代码来源:MainActivity.java

示例7: updateAllWeekScores

import com.firebase.client.FirebaseError; //导入依赖的package包/类
private void updateAllWeekScores() {
    mRootRef.child("users").addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            Map<String, Object> week_scores = new HashMap<String, Object>();
            for (DataSnapshot userSnapshot : snapshot.getChildren()) {
                week_scores.put(userSnapshot.child("username").getValue() + "/week_score", 0);
            }
            mRootRef.child("users").updateChildren(week_scores);
            mWeekResetRef.setValue(true);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
开发者ID:silva96,项目名称:guessthehashtag,代码行数:19,代码来源:MainActivity.java

示例8: DataPresenter

import com.firebase.client.FirebaseError; //导入依赖的package包/类
/**
 * Creates a data presenter.
 *
 * @param dataView The view which will display the data.
 * @param configUrl The firebase endpoint url.
 */
DataPresenter(@NonNull DataView<T> dataView, @NonNull String configUrl) {
    mFirebase = new Firebase(configUrl);
    mData = new ArrayList<>();
    mDataView = dataView;

    mValueEventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mData.clear();
            for (DataSnapshot data : dataSnapshot.getChildren()) {
                // Data parsing is being done within the extending classes.
                mData.add(parseData(data));
            }
            mDataView.showData(mData);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Log.d(TAG, "onCancelled: " + firebaseError.getMessage());
            // Deliberately swallow the firebase error here.
            mDataView.showError();
        }
    };
}
 
开发者ID:googlesamples,项目名称:android-OurStreets,代码行数:31,代码来源:DataPresenter.java

示例9: addToiletToFirebase

import com.firebase.client.FirebaseError; //导入依赖的package包/类
public void addToiletToFirebase(View v) {
    // Look up all the data: Assumes that no values are NULL
    Firebase rootRef = new Firebase(MainActivity.FIREBASE_URL);
    final Firebase array = rootRef.child("toilets");
    array.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Toilet t = new Toilet(mName, mLocation, mRating, mNotes, mFamilyFriendly, mGenderNeutral, mHandicapAccessible, "");
            array.push().setValue(t);
            // Actually ends the activity
            finish();
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
        }
    });
}
 
开发者ID:thorsteinson,项目名称:porcelain,代码行数:19,代码来源:AddToiletActivity.java

示例10: retrieveData

import com.firebase.client.FirebaseError; //导入依赖的package包/类
private void retrieveData(String key) {
    Firebase itemRef = new Firebase(Utils.getFirebaseUserReminderUrl(mUserUID))
            .child(key);
    itemRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mRemindItem = dataSnapshot.getValue(ReminderItem.class);
            setViews();
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Toast.makeText(getContext(), firebaseError.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:17,代码来源:ReminderItemFragment.java

示例11: onPause

import com.firebase.client.FirebaseError; //导入依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    firebase.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            updater = (long) dataSnapshot.getValue();
            updater--;
            firebase.setValue(updater);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
    Log.v(this.getClass().getSimpleName(), "onPause()");

    if (tts != null) {
        tts.stop();
        tts.shutdown();
    }
}
 
开发者ID:siddhantvinchurkar,项目名称:Marv,代码行数:24,代码来源:MainActivity.java

示例12: login

import com.firebase.client.FirebaseError; //导入依赖的package包/类
@Override
public void login(String username, String password) {

    final Firebase myFirebaseRef = RegLog.getFirebase();

    myFirebaseRef.authWithPassword(username, password, new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            System.out.println("Successfully authenticated with uid: " + authData.getUid());
            EventBus.getDefault().post(new LoginCallbackEvent(true, null));
        }

        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            EventBus.getDefault().post(new LoginCallbackEvent(false, firebaseError.getMessage()));
        }
    });
}
 
开发者ID:Antpachon,项目名称:RegLog,代码行数:19,代码来源:LoginServiceFirebaseImpl.java

示例13: onLoginClick

import com.firebase.client.FirebaseError; //导入依赖的package包/类
public void onLoginClick(View view)
{
    EditText passwordField = (EditText) findViewById(R.id.initial_password);
    EditText emailField = (EditText) findViewById(R.id.initial_email);

    rootReference.authWithPassword(emailField.getText().toString(), passwordField.getText().toString(), new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            Intent intent = new Intent(getApplicationContext(), MapsActivity.class);
            intent.putExtra("locLat",mLastLocation.getLatitude());
            intent.putExtra("locLong", mLastLocation.getLongitude());
            startActivity(intent);
        }
        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
           Toast.makeText(getApplicationContext(), "Error logging in", Toast.LENGTH_LONG);
        }
    });
}
 
开发者ID:StephenVanSon,项目名称:TutorMe,代码行数:20,代码来源:InitialActivity.java

示例14: Repository

import com.firebase.client.FirebaseError; //导入依赖的package包/类
public Repository(String firebaseUrl, final Class<T> modelClass) {
	firebase = new Firebase(firebaseUrl);

	firebase.addValueEventListener(new ValueEventListener() {
		@Override
		public void onDataChange(DataSnapshot snapshot) {
			List<T> items = new ArrayList<>();
			for (DataSnapshot postSnapshot : snapshot.getChildren()) {
				T restaurant = postSnapshot.getValue(modelClass);
				items.add(restaurant);
			}
			Repository.this.items = items;
			notifyDataChanged();
		}
		@Override
		public void onCancelled(FirebaseError firebaseError) {
			/* Do nothing */
		}
	});
}
 
开发者ID:alexmiragall,项目名称:Gourmet,代码行数:21,代码来源:Repository.java

示例15: getSchoolId

import com.firebase.client.FirebaseError; //导入依赖的package包/类
public void getSchoolId() {

        schoolRef = new Firebase(Constants.FIREBASE_URL+"schools");
        schoolRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                dataSnapshot.getKey();
            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {

            }
        });

    }
 
开发者ID:blessingoraz,项目名称:Akwukwo,代码行数:17,代码来源:ListOfMySchhols.java


注:本文中的com.firebase.client.FirebaseError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。