Skip to content

Commit

Permalink
DCP UI Cleanup and calculations completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBogueRat committed Mar 18, 2017
1 parent 752f991 commit 4601068
Show file tree
Hide file tree
Showing 23 changed files with 759 additions and 318 deletions.
11 changes: 11 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ dependencies {
compile 'com.github.PhilJay:MPAndroidChart:v3.0.0'
compile 'io.realm:android-adapters:1.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.25'
compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
}
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.bogueratcreations.eaftoolkit.Main" />
</activity>
<activity
android:name=".DCP.ProjectsAdd"
android:label="@string/title_activity_projects"
android:parentActivityName=".DCP.Projects"
android:screenOrientation="portrait"
android:theme="@style/CustomActionBarTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.bogueratcreations.eaftoolkit.DCP.Projects" />
</activity>
<activity
android:name=".DCP.Points"
android:label="@string/title_activity_points"
Expand Down
56 changes: 48 additions & 8 deletions app/src/main/java/com/bogueratcreations/eaftoolkit/DCP/Points.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -43,7 +44,7 @@ public class Points extends AppCompatActivity {
Point selectedPoint;

boolean editMode = false; // Used to control the resulting FAB action
boolean newPoint = false; // Edit mode just means we are editing or adding a point this indicates a newPoint
boolean newPoint = false; // Edit mode just means we are editing or adding a point, this indicates editing a newPoint
static Boolean hasChanged = false;

private Realm realm;
Expand All @@ -55,6 +56,7 @@ public class Points extends AppCompatActivity {
EditText pointName;
static EditText pointDate;
TextView tvSoilType;
Button btnSaveEdit;

// TODO: Capture back button in edit mode and ask about saving....
@Override
Expand All @@ -66,6 +68,7 @@ protected void onCreate(Bundle savedInstanceState) {

// Get the project name (ID) for use in finding associated points and for use in creating new points.
passedProjectID = getIntent().getLongExtra("projId",-1);
Log.d("passedProjID in Pts: ", String.valueOf(passedProjectID));
// TODO: If receiving -1, I wasn't passed a valid project...
passedProject = realm.where(Project.class)
.equalTo("id",passedProjectID)
Expand All @@ -81,6 +84,17 @@ protected void onCreate(Bundle savedInstanceState) {
pointDate = (EditText) findViewById(R.id.etPointDate);
tvSoilType = (TextView) findViewById(R.id.tvPointSoilType);
tvProjName.setText(passedProject.getProjName());
switch(passedProjectSoilType) {
case 0:
tvSoilType.setText("Low Plasticity Clay");
break;
case 1:
tvSoilType.setText("High Plasticity Clay");
break;
case 2:
tvSoilType.setText("All Other Soils");
break;
}
pointDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -101,6 +115,7 @@ public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, lon
selectedPointID = adapter.getItem(i).getId(); // TODO: verifiy this is getting the Point id not just an arbitrary id from the list.
defaultView.setVisibility(View.GONE);
editView.setVisibility(View.VISIBLE);
btnSaveEdit.setText("Save");
editMode = true;
// TODO: Change FAB to save button

Expand All @@ -109,6 +124,7 @@ public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, lon
.equalTo("id", selectedPointID)
.findFirst();
pointName.setText(selectedPoint.getPointNum());

String dateTimeString = DateFormat.getDateInstance(DateFormat.SHORT).format(selectedPoint.getDate());
pointDate.setText(dateTimeString);
// TODO: The soil type is based on the project, displaying this to remind user.
Expand All @@ -131,19 +147,18 @@ public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, lon
@Override
public void onItemClick(AdapterView adapterView, View view, int position, long id) {
// Pass the selected Point and navigate to Reading.class
final long pointId = adapter.getItemId(position);
final long pointId = adapter.getItem(position).getId();
Intent intent = new Intent(view.getContext(), Readings.class);
intent.putExtra("pointId", pointId);
Log.d("Passing pointId: ", String.valueOf(pointId));
startActivity(intent);
startActivityForResult(intent, 1);
}
});

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
btnSaveEdit = (Button) findViewById(R.id.btnNew_Save);
btnSaveEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (editMode) {
Expand All @@ -158,22 +173,32 @@ public void onClick(View view) {
} else {
updatePoint();
}
btnSaveEdit.setText("New");
} else {
defaultView.setVisibility(View.GONE);
editView.setVisibility(View.VISIBLE);
editMode = true;
newPoint = true;
// Change FAB to save button
btnSaveEdit.setText("Save");
}

String dateTimeString = DateFormat.getDateInstance(DateFormat.SHORT).format(new Date());
pointDate.setText(dateTimeString);
}
});
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fabPoints);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//fab.setImageResource(R.drawable.icon_save);
// Intent intent = new Intent(view.getContext(), PointsAdd.class);
//// intent.putExtra("pointId", pointId);
// intent.putExtra("projectId", passedProjectID);
// startActivity(intent);
}
});
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Not using acctionBar back button any longer
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

private void savePoint() {
Expand Down Expand Up @@ -279,6 +304,21 @@ public void onDateSet(DatePicker view, int year, int month, int day) {
}
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
// passedProjectID = data.getLongExtra("passedProjectID", -1); // TODO: Don't think I need this here since I use the same key to receive this from Projects.class
}
}
}

@Override
public void onBackPressed() {
// Capture back pressed if in edit mode and save the data as requested.
}

@Override
protected void onDestroy() {
super.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bogueratcreations.eaftoolkit.DCP;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
Expand All @@ -9,6 +10,8 @@
import com.bogueratcreations.eaftoolkit.DCP.model.Point;
import com.bogueratcreations.eaftoolkit.R;

import java.util.Locale;

import io.realm.OrderedRealmCollection;
import io.realm.RealmBaseAdapter;

Expand Down Expand Up @@ -41,9 +44,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
viewHolder = (ViewHolder) convertView.getTag();
}
Point item = adapterData.get(position);
viewHolder.point.setText(item.getPointNum());
Double lowestCBR = item.getCbr(); // This should be the lowest recorded CBR which is set when saving the Readings
viewHolder.pointCbr.setText(lowestCBR.toString());
viewHolder.point.setText(item.getPointNum()); // This should be the lowest recorded CBR which is set when saving the Readings
String roundedCBR = String.format(Locale.US,"%.1f",item.getCbr());
viewHolder.pointCbr.setText(roundedCBR);
return convertView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public void onItemClick(AdapterView adapterView, View view, int position, long i
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), ProjectsAdd.class);
// intent.putExtra("projectId",-1);
intent.putExtra("projectId",-1);
startActivity(intent);
startActivity(new Intent(Projects.this, ProjectsAdd.class));
// startActivity(new Intent(Projects.this, ProjectsAdd.class));

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void onClick(View v) {
// Check for add/edit
passedProjectId = getIntent().getLongExtra("projectId", -1);
if (passedProjectId == -1) {
// Adding a new Project
String currentDateTimeString = DateFormat.getDateInstance(DateFormat.SHORT).format(new Date());
// textView is the TextView view that should display it
projectDate.setText(currentDateTimeString);
Expand Down Expand Up @@ -106,7 +107,7 @@ public void onClick(View v) {
}
}

public void clickHandler(View view) {
public void clickHandlerProjects(View view) {
if (view.getId()== R.id.btnSaveProject) {

// Retrieve appropriate date
Expand Down
Loading

0 comments on commit 4601068

Please sign in to comment.