Skip to content

Instantly share code, notes, and snippets.

View RBonaventure's full-sized avatar

Raphaël Bonaventure RBonaventure

View GitHub Profile
language: android
jdk: oraclejdk8
sudo: false
android:
components:
- platform-tools
- tools
- build-tools-26.0.2
- android-27
@RBonaventure
RBonaventure / firestore-like.java
Last active December 21, 2017 11:45
firestore-like
/* @method Permet l'ajout d'un document à la collection 'like'
* Reference path : /resources/{resourceId}/likes/{uniqueLikeId}
*/
public void like() {
Map<String, Date> like = new HashMap<>();
like.put("date", new Date());
// mRef est la référence d'un collaborateur que l'on récupère via https://gist.github.com/RBonaventure/12283d6115d9960421470dde949acc41#file-firestore-fetch-data-java-L8
mRef.collection(FirestoreCollections.LIKES).document(App.getGUID())
.set(like).addOnCompleteListener(new OnCompleteListener<Void>() {
@RBonaventure
RBonaventure / firestore-fetch-data.java
Last active December 22, 2017 08:50
firestore-fetch-data
// @see Firebase Performance
Traces.start(Traces.COLLABORATORS_TIME);
// Fetch collaborators list from Firestore
Collaborator.getAll(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()) {
mCollaborators = task.getResult();
CollaboratorsAdapter.this.notifyDataSetChanged();
service cloud.firestore {
match /databases/{database}/documents {
match /resources/{document=**} {
allow read;
}
match /locations/{document=**} {
allow read;
}
match /resources/{id}/likes/{document=**} {
allow read, write;
/*
* Les deux traces et les URLs associées :
* A : ReactJS
* B : Plain HTML
*/
private enum RenderingType {
REACT_JS(Traces.REACT_JS_TIME, "https://pot-pourri-android.firebaseapp.com/reactjs"),
PLAIN_HTML(Traces.PLAIN_HTML_TIME, "https://pot-pourri-android.firebaseapp.com/html");
private String mTraceName;
// Dans votre Activity#onCreate par exemple
mWebView.setWebViewClient(new WebViewClient() {
/*
* Le timer est démarré dès le chargement du contenu Web
*/
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);