本文整理汇总了Java中com.google.firebase.firestore.FirebaseFirestore类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseFirestore类的具体用法?Java FirebaseFirestore怎么用?Java FirebaseFirestore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseFirestore类属于com.google.firebase.firestore包,在下文中一共展示了FirebaseFirestore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onEvent
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
for (DocumentChange change : documentSnapshots.getDocumentChanges()) {
switch (change.getType()) {
case ADDED: {
String groupId = change.getDocument().getId();
FirebaseFirestore.getInstance()
.collection("groups")
.document(groupId)
.collection("items")
.addSnapshotListener(new GroupItemsChangeListener(groupId));
}
break;
}
}
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:17,代码来源:DashboardAdapter.java
示例2: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
// View model
mViewModel = ViewModelProviders.of(this).get(MainActivityViewModel.class);
// Enable Firestore logging
FirebaseFirestore.setLoggingEnabled(true);
// Initialize Firestore and the main RecyclerView
initFirestore();
initRecyclerView();
// Filter Dialog
mFilterDialog = new FilterDialogFragment();
}
开发者ID:chauhan-abhi,项目名称:CloudFirestore,代码行数:21,代码来源:MainActivity.java
示例3: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_product);
// Firebase Setting
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
firestore = FirebaseFirestore.getInstance();
postColRef = firestore.collection("post");
userId = user.getUid();
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
coverLL = (LinearLayout) findViewById(R.id.myProductLL);
setImageView();
}
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:20,代码来源:MyProductActivity.java
示例4: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sales_history);
// Firebase Setting
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
firestore = FirebaseFirestore.getInstance();
userId = user.getUid();
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
coverLL = (LinearLayout) findViewById(R.id.myProductLL);
setImageView();
}
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:19,代码来源:SalesHistoryActivity.java
示例5: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_purchase_history);
// Firebase Setting
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
firestore = FirebaseFirestore.getInstance();
userId = user.getUid();
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
coverLL = (LinearLayout) findViewById(R.id.myProductLL);
setImageView();
}
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:19,代码来源:PurchaseHistoryActivity.java
示例6: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_purchase_history);
// Firebase Setting
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
firestore = FirebaseFirestore.getInstance();
userId = user.getUid();
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
coverLL = (LinearLayout) findViewById(R.id.myProductLL);
setImageView();
}
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:21,代码来源:DibsListActivity.java
示例7: offlineListen
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
private void offlineListen(FirebaseFirestore db) {
// [START offline_listen]
db.collection("cities").whereEqualTo("state", "CA")
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot querySnapshot,
@Nullable FirebaseFirestoreException e) {
if (e != null) {
Log.w(TAG, "Listen error", e);
return;
}
for (DocumentChange change : querySnapshot.getDocumentChanges()) {
if (change.getType() == Type.ADDED) {
Log.d(TAG, "New city:" + change.getDocument().getData());
}
String source = querySnapshot.getMetadata().isFromCache() ?
"local cache" : "server";
Log.d(TAG, "Data fetched from " + source);
}
}
});
// [END offline_listen]
}
开发者ID:firebase,项目名称:snippets-android,代码行数:27,代码来源:DocSnippets.java
示例8: onEvent
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
for (DocumentChange change : documentSnapshots.getDocumentChanges()) {
switch (change.getType()) {
case ADDED: {
Group group = new Group();
group.setId(change.getDocument().getId());
userGroups.add(group);
adapter.setUserGroups(userGroups);
FirebaseFirestore.getInstance()
.collection("groups")
.whereEqualTo("parentGroup", change.getDocument().getId())
.addSnapshotListener(CoursesFragment.this);
}
break;
case REMOVED: {
for (int i = 0; i < userGroups.size(); i++)
if (userGroups.get(i).getId().equals(change.getDocument().getId())) {
userGroups.remove(i);
adapter.notifyDataSetChanged();
return;
}
}
break;
}
}
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:29,代码来源:CoursesFragment.java
示例9: getItemsReference
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
public static CollectionReference getItemsReference(String groupId) {
CollectionReference items;
if (FirebaseAuth.getInstance().getCurrentUser().getUid().equals(groupId))
items = FirebaseFirestore.getInstance()
.collection("users");
else
items = FirebaseFirestore.getInstance()
.collection("groups");
return items.document(groupId).collection("items");
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:11,代码来源:BackendHelper.java
示例10: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
LocalBroadcastManager.getInstance(this);
FirebaseApp.initializeApp(this);
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(true)
.build();
FirebaseFirestore.getInstance().setFirestoreSettings(settings);
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:11,代码来源:Application.java
示例11: DashboardAdapter
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
public DashboardAdapter(Context context) {
Calendar calendar = Calendar.getInstance();
int today = calendar.get(Calendar.DAY_OF_WEEK);
// Today is default
rowItems.add(new Section(context.getString(R.string.section_title_today), getSectionDate(calendar)));
calendar.add(Calendar.DAY_OF_YEAR, 1);
if (today >= Calendar.MONDAY && today <= Calendar.WEDNESDAY) {
rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
calendar.add(Calendar.DAY_OF_YEAR, 1);
rowItems.add(new Section(context.getString(R.string.section_title_this_week), getSectionDate(calendar)));
} else if (today == Calendar.THURSDAY) {
rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
calendar.add(Calendar.DAY_OF_YEAR, 1);
rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
} else if (today == Calendar.FRIDAY)
rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
else if (today == Calendar.SATURDAY)
rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
if (calendar.getFirstDayOfWeek() != Calendar.SUNDAY || today != Calendar.SUNDAY)
calendar.add(Calendar.WEEK_OF_YEAR, 1);
rowItems.add(new Section(context.getString(R.string.section_title_next_week), getSectionDate(calendar)));
// TODO: Holiday and interval sections (between two holidays, to give a clearer overview over whats happening in the long run)
calendar.add(Calendar.WEEK_OF_YEAR, 1);
rowItems.add(new Section("Until the end of the universe", getSectionDate(calendar)));
// TODO: Listen on login
UserInfo userInfo = FirebaseAuth.getInstance().getCurrentUser();
if (userInfo != null) {
DocumentReference userReference = FirebaseFirestore.getInstance()
.collection("users")
.document(userInfo.getUid());
userReference.collection("groups")
.addSnapshotListener(this);
userReference.collection("items")
.addSnapshotListener(new GroupItemsChangeListener(FirebaseAuth.getInstance().getCurrentUser().getUid()));
}
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:47,代码来源:DashboardAdapter.java
示例12: done
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
private void done() {
layout.setErrorEnabled(false);
String name = editText.getText().toString();
if ("".equals(name)) {
layout.setError(getString(R.string.error_field_required));
return;
}
Map<String, Object> group = new HashMap<>();
group.put("name", name);
group.put("type", Group.TYPE_SCHOOL);
FirebaseFirestore.getInstance()
.collection("groups")
.add(group)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
Map<String, Object> userGroup = new HashMap<>();
userGroup.put("access_level", Group.ACCESS_LEVEL_MEMBER);
BackendHelper.getUserReference()
.collection("groups")
.document(documentReference.getId())
.set(userGroup);
Map<String, Object> school = new HashMap<>();
school.put("school", documentReference.getId());
BackendHelper.getUserReference()
.set(school);
finish();
}
});
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:37,代码来源:SchoolCreateActivity.java
示例13: init
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
public void init (FirebaseApp firebaseApp) {
mFirebaseApp = firebaseApp;
// Enable Firestore logging
FirebaseFirestore.setLoggingEnabled(true);
db = FirebaseFirestore.getInstance();
Utils.d("Firestore::Initialized");
}
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:10,代码来源:Firestore.java
示例14: providesRestaurants
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Singleton
@Provides
@Named("restaurants")
CollectionReference providesRestaurants() {
FirebaseFirestore.setLoggingEnabled(true);
return FirebaseFirestore.getInstance().collection("restaurants");
}
开发者ID:amrro,项目名称:firestore-android-arch-components,代码行数:8,代码来源:FirebaseModule.java
示例15: initFirestore
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
private void initFirestore() {
mFirestore = FirebaseFirestore.getInstance();
// Get the 50 highest rated restaurants
mQuery = mFirestore.collection("restaurants")
.orderBy("avgRating", Query.Direction.DESCENDING)
.limit(LIMIT);
/**
* Now we want to listen to the query,
* so that we get all matching documents and are notified of future updates in real time.
* Because our eventual goal is to bind this data to a RecyclerView,
* we need to create a RecyclerView.Adapter class to listen to the data.
*/
}
开发者ID:chauhan-abhi,项目名称:CloudFirestore,代码行数:16,代码来源:MainActivity.java
示例16: onCreate
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_main);
findViewById(R.id.button_write).setOnClickListener(this);
findViewById(R.id.button_smoketest).setOnClickListener(this);
findViewById(R.id.button_delete_all).setOnClickListener(this);
mFirestore = FirebaseFirestore.getInstance();
new SolutionRateLimiting().startUpdates();
}
开发者ID:firebase,项目名称:snippets-android,代码行数:14,代码来源:MainActivity.java
示例17: setup
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
private void setup() {
// [START get_firestore_instance]
FirebaseFirestore db = FirebaseFirestore.getInstance();
// [END get_firestore_instance]
// [START set_firestore_settings]
FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
.setPersistenceEnabled(true)
.build();
db.setFirestoreSettings(settings);
// [END set_firestore_settings]
}
开发者ID:firebase,项目名称:snippets-android,代码行数:13,代码来源:DocSnippets.java
示例18: getUserReference
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
public static DocumentReference getUserReference() {
return FirebaseFirestore.getInstance()
.collection("users")
.document(FirebaseAuth.getInstance().getCurrentUser().getUid());
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:6,代码来源:BackendHelper.java
示例19: onOptionsItemSelected
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Cannot use switch here due to library resource id's
if (item.getItemId() == android.R.id.home)
onBackPressed();
else if (item.getItemId() == R.id.action_done) {
BackendHelper.getUserReference().get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (!documentSnapshot.exists())
return;
if (documentSnapshot.get("school") == null)
new TextPopup(R.string.error_title, R.string.message_no_school).show();
else {
TextView textView = findViewById(R.id.activity_config_course_name);
String name = textView.getText().toString();
Group group = new Group();
group.name = name;
group.type = Group.TYPE_COURSE;
group.parentGroup = documentSnapshot.getString("school");
FirebaseFirestore.getInstance()
.collection("groups")
.add(group)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
Map<String, Object> map = new HashMap<>();
map.put("access_level", Group.ACCESS_LEVEL_CREATOR);
BackendHelper.getUserReference().collection("groups")
.document(documentReference.getId())
.set(map)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
finish();
}
});
}
});
}
}
});
} else
return super.onOptionsItemSelected(item);
return true;
}
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:52,代码来源:ConfigCourseActivity.java
示例20: MainRepository
import com.google.firebase.firestore.FirebaseFirestore; //导入依赖的package包/类
@Inject
public MainRepository(FirebaseFirestore store) {
this.firestore = store;
}
开发者ID:amrro,项目名称:firestore-android-arch-components,代码行数:5,代码来源:MainRepository.java
注:本文中的com.google.firebase.firestore.FirebaseFirestore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论