Skip to content

Instantly share code, notes, and snippets.

View griajobag's full-sized avatar
🏠
Working from home

Putu Guna griajobag

🏠
Working from home
View GitHub Profile
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
private void deleteData(){
progressDialog.setMessage("Deleting Data...");
progressDialog.show();
CollectionReference collectionReference = firebaseFirestore.collection("data");
DocumentReference documentReference = collectionReference.document(modelWebsite.get(0).getIdDocument());
documentReference.delete()
.addOnCompleteListener(task -> {
progressDialog.dismiss();
Toast.makeText(MainActivity.this, "Deleting successfulyy", Toast.LENGTH_SHORT).show();
}).addOnFailureListener(new OnFailureListener() {
private void updateTheData() {
progressDialog.setMessage("Updating Data...");
progressDialog.show();
WebsiteModel model = new WebsiteModel("Droid Newbie (updated)", "androidbie.com (updated)", "About Programming (updated)", modelWebsite.get(0).getIdDocument());
CollectionReference collectionReference = firebaseFirestore.collection("data");
DocumentReference documentReference = collectionReference.document(modelWebsite.get(0).getIdDocument());
documentReference.set(model)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
@griajobag
griajobag / ReadData.java
Last active May 16, 2018 15:23
firestores
private void readData(){
CollectionReference collectionReference = firebaseFirestore.collection("data");
collectionReference.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
progressDialog.dismiss();
if(task.getResult().isEmpty()){
Toast.makeText(MainActivity.this, "Data is empty", Toast.LENGTH_SHORT).show();
}else if(task.isSuccessful()){
package com.putuguna.insertcolldoc;
public class WebsiteModel {
private String name;
private String website;
private String webTopic;
private String idDocument;
public WebsiteModel(String name, String website, String webTopic) {
this.name = name;
@griajobag
griajobag / InsertData.java
Last active May 16, 2018 14:43
firestores
private void startInsertDataDocumentGeneratedSendiri() {
progressDialog.show();
WebsiteModel model = new WebsiteModel("Droid Newbie","androidbie.com","About Programming");
CollectionReference collectionReference = firebaseFirestore.collection("data");
collectionReference.add(model)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
@griajobag
griajobag / Main.java
Created May 12, 2018 02:29
Inheritance
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hs;
/**
*
* @author androidbie.com
@griajobag
griajobag / Employee.java
Created May 12, 2018 02:22
inheritance
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hs;
/**
*
* @author androidbie.com
@griajobag
griajobag / Hospital.java
Created May 12, 2018 02:09
inheritance
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hs;
/**
*
* @author androidbie.com
Class Tree{
.....
}
Class Pine extends Tree {
.....
}