This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Tree{ | |
..... | |
} | |
Class Pine extends Tree { | |
..... | |
} |