Skip to content

Commit

Permalink
Merge pull request #16 from EPICSGroup/Samuel2
Browse files Browse the repository at this point in the history
added WaterWayReport and layout of the report page
  • Loading branch information
seford authored Apr 1, 2021
2 parents 2c89344 + 9b8288e commit 544a2f0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 17 deletions.
11 changes: 8 additions & 3 deletions app/src/main/java/com/sf/stormwaterutilityandroid/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void onClick(View v) {
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

System.out.println("Execute:85");
String email = inputEmail.getText().toString();
final String password = inputPassword.getText().toString();

Expand All @@ -99,10 +99,13 @@ public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);

//authenticate user
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(Login.this, new OnCompleteListener<AuthResult>() {
System.out.println("Execute:102");
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {


@Override
public void onComplete(@NonNull Task<AuthResult> task) {
System.out.println("Execute:106");
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
Expand All @@ -116,6 +119,7 @@ public void onComplete(@NonNull Task<AuthResult> task) {
}
} else {
if (auth.getCurrentUser().isEmailVerified()) {
System.out.println("Execute:122");
FirebaseFirestore.getInstance().collection("Users").document(auth.getUid()).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
Expand All @@ -132,6 +136,7 @@ public void onComplete(@NonNull Task<DocumentSnapshot> task) {
progressBar.setVisibility(View.INVISIBLE);
finish();
} else {
System.out.println("Execute:139");
progressBar.setVisibility(View.INVISIBLE);
AlertDialog.Builder builder;
builder = new AlertDialog.Builder(Login.this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public void onClick(View v) {
cvSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(MainMenu.this, Settings.class);
startActivity(intent);

}
});
// launchWWF = findViewById(R.id.wwf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

import androidx.recyclerview.widget.RecyclerView;

public class ReportAdapter extends RecyclerView.Adapter<ReportAdapter.MyHolder>{
import com.sf.stormwaterutilityandroid.WaterWay.WaterWayReport;

// List<Report> listdata;
import java.util.List;

// public ReportAdapter(List<Report> listdata) {
// this.listdata = listdata;
// }
public class ReportAdapter extends RecyclerView.Adapter<ReportAdapter.MyHolder>{

List<WaterWayReport> listdata;
public ReportAdapter(List<WaterWayReport> listdata) {
this.listdata = listdata;
}

@Override
public ReportAdapter.MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
active = fragment1;
fm.popBackStack();
return true;
case R.id.navigation_dashboard:
case R.id.waterWayReports:
// mTextMessage.setText(R.string.title_dashboard);
fm.beginTransaction().hide(active).show(fragment2).commit();
active = fragment2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.sf.stormwaterutilityandroid.WaterWay;

import com.google.firebase.Timestamp;
import com.google.firebase.firestore.GeoPoint;

import java.util.HashMap;
import java.util.Map;

public class WaterWayReport {
String H_date;
String H_inspector_name;
String H_site_name;
Timestamp SortTimeStamp;
GeoPoint location;
Map<String,Boolean> boolFields = new HashMap<>();
Map<String, Double> doubleFields = new HashMap<>();
Map<String,String> stringFields = new HashMap<>();

public WaterWayReport(String h_date, String h_inspector_name, String h_site_name, Timestamp sortTimeStamp, GeoPoint location, Map<String, Boolean> boolFields, Map<String, Double> doubleFields, Map<String, String> stringFields) {
H_date = h_date;
H_inspector_name = h_inspector_name;
H_site_name = h_site_name;
SortTimeStamp = sortTimeStamp;
this.location = location;
this.boolFields = boolFields;
this.doubleFields = doubleFields;
this.stringFields = stringFields;
}

public Timestamp getSortTimeStamp() {
return SortTimeStamp;
}

public String getH_date() {
return H_date;
}

public String getH_inspector_name() {
return H_inspector_name;
}

public String getH_site_name() {
return H_site_name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public void onClick(View v) {

}
public void fetchData() {
/* final ReportAdapter reporter = new ReportAdapter(reportList);
List<WaterWayReport> reportList = new ArrayList<>();
final ReportAdapter reportAdapter = new ReportAdapter(reportList);
FirebaseFirestore.getInstance().collection("AquaSourceForms").orderBy("SortTimeStamp", Query.Direction.DESCENDING).addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@javax.annotation.Nullable QuerySnapshot queryDocumentSnapshots, @javax.annotation.Nullable FirebaseFirestoreException e) {
Expand All @@ -106,16 +107,16 @@ public void onEvent(@javax.annotation.Nullable QuerySnapshot queryDocumentSnapsh

for (DocumentSnapshot d:queryDocumentSnapshots){
//needs to be changed to waterway data type
reportList.add( d.toObject(Report.class));
reportList.add( d.toObject(WaterWayReport.class));
}

reporter.notifyDataSetChanged();
reportAdapter.notifyDataSetChanged();
}
});
RecyclerView.LayoutManager layoutmanager = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(layoutmanager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(reporter);*/
recyclerView.setAdapter(reportAdapter);
}

}
Expand Down
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ buildscript {
}
dependencies {

classpath "com.android.tools.build:gradle:4.1.2"
classpath 'com.google.gms:google-services:4.3.4'




classpath 'com.google.gms:google-services:4.3.5'

classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:4.1.3'



Expand Down

0 comments on commit 544a2f0

Please sign in to comment.