Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor graph activities #103

Merged
merged 7 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;

Expand Down Expand Up @@ -55,6 +56,7 @@ protected void onStart(){

protected void initializeComponents(){
toolbar = findViewById(R.id.BarGraphToolbar);
toolbar.setTitleTextColor(Color.WHITE);
// Set up the toolbar
setSupportActionBar(toolbar);

Expand Down
286 changes: 0 additions & 286 deletions app/src/main/java/com/example/drinkingbuddy/Views/GraphActivity.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ protected void goToLineGraph() {
}

protected void goToPieChart() {
if(myDB.getAllResults().size() > 0)
if(myDB.ReturnDrinkTypes().size() > 0)
startActivity(new Intent(this, PieChartActivity.class));
else
Toast.makeText(getApplicationContext(), "Must have at least one measurement to see trends", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Must have at least one drink input to see trends", Toast.LENGTH_LONG).show();
}

protected void goToBarGraph() {
if(myDB.getAllResults().size() > 0)
if(myDB.ReturnDrinkTypes().size() > 0)
startActivity(new Intent(this, BarGraphActivity.class));
else
Toast.makeText(getApplicationContext(), "Must have at least one measurement to see trends", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Must have at least one drink input to see trends", Toast.LENGTH_LONG).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.drinkingbuddy.Controllers.DBHelper;
import com.example.drinkingbuddy.Models.Breathalyzer;
Expand All @@ -29,13 +31,14 @@
public class LineGraphActivity extends AppCompatActivity {

//Variables
LineChart lineChart;
protected LineChart lineChart;
protected Toolbar toolbar;
protected Menu menu;
private DBHelper database;
List<Breathalyzer> breathalyzerValues;
ArrayList<Entry> lineGraphValues = new ArrayList<>(); //holds points in line graph
String SpanOfData;
protected List<Breathalyzer> breathalyzerValues;
protected ArrayList<Entry> lineGraphValues = new ArrayList<>(); //holds points in line graph
protected String SpanOfData;
protected ListView sensorReadingsListview;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -54,10 +57,12 @@ protected void onStart(){

insertLineChartValues();
displayLineChart();
loadListView();
}

protected void initializeComponents(){
toolbar = findViewById(R.id.LineGraphToolbar);
toolbar.setTitleTextColor(Color.WHITE);
// Set up the toolbar
setSupportActionBar(toolbar);

Expand All @@ -67,6 +72,23 @@ protected void initializeComponents(){
}

lineChart = findViewById(R.id.lineGraph);

sensorReadingsListview = findViewById(R.id.sensorReadingsListview);
}

protected void loadListView(){
//List<Breathalyzer> readings = database.getAllResults();

ArrayList<String> readingsText = new ArrayList<>();

for(Breathalyzer result: breathalyzerValues){
String temp = "";
temp += result.getTimeStamp() + ": " + result.getResult();

readingsText.add(temp);
}
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.row, readingsText);
sensorReadingsListview.setAdapter(arrayAdapter);
}

//region Line Graph
Expand Down
Loading