Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Field Science
Field Day
Commits
f2bf60f3
Commit
f2bf60f3
authored
Jun 09, 2016
by
Kristin Muterspaw
Browse files
Initial activity for the bench sampling.
parent
8df68108
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/fieldscience/cs/earlham/edu/fieldday/BenchSampleActivity.java
0 → 100644
View file @
f2bf60f3
package
fieldscience.cs.earlham.edu.fieldday
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.ArrayAdapter
;
import
android.widget.EditText
;
import
android.widget.Spinner
;
import
java.util.List
;
import
java.util.ArrayList
;
public
class
BenchSampleActivity
extends
Activity
{
Spinner
siteSpinner
,
sectorSpinner
,
spotSpinner
,
platformSpinner
,
sensorSpinner
;
EditText
sensorValue
,
sensorQuality
,
readingNotes
;
ReadingsDatabase
db
;
String
site
,
sector
,
spot
,
platform
,
sensor
;
boolean
remote_db
;
List
<
String
>
siteList
,
sectorList
,
spotList
,
platformList
,
sensorList
;
public
static
final
String
REMOTE_DB
=
"Remote DB Connected"
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
){
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_benchsample
);
db
=
ReadingsDatabase
.
getInstance
(
this
);
siteList
=
new
ArrayList
<>();
sectorList
=
new
ArrayList
<>();
spotList
=
new
ArrayList
<>();
platformList
=
new
ArrayList
<>();
sensorList
=
new
ArrayList
<>();
remote_db
=
getIntent
().
getBooleanExtra
(
REMOTE_DB
,
false
);
if
(
remote_db
){
siteList
=
db
.
getSites
(
null
);
}
siteList
.
add
(
0
,
"Site"
);
siteSpinner
=
(
Spinner
)
findViewById
(
R
.
id
.
selectSite
);
final
ArrayAdapter
<
String
>
siteAdapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
siteList
);
siteAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
siteSpinner
.
setAdapter
(
siteAdapter
);
sectorSpinner
=
(
Spinner
)
findViewById
(
R
.
id
.
selectSector
);
sectorList
.
add
(
0
,
"Sector"
);
final
ArrayAdapter
<
String
>
sectorAdapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
sectorList
);
sectorAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
sectorSpinner
.
setAdapter
(
sectorAdapter
);
spotSpinner
=
(
Spinner
)
findViewById
(
R
.
id
.
selectSpot
);
spotList
.
add
(
0
,
"Spot"
);
final
ArrayAdapter
<
String
>
spotAdapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
spotList
);
spotAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
spotSpinner
.
setAdapter
(
spotAdapter
);
platformSpinner
=
(
Spinner
)
findViewById
(
R
.
id
.
selectPlatform
);
platformList
.
add
(
0
,
"Platform"
);
if
(
remote_db
){
platformList
.
addAll
(
db
.
getPlatforms
());
}
ArrayAdapter
<
String
>
platformAdapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
platformList
);
platformAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
platformSpinner
.
setAdapter
(
platformAdapter
);
sensorSpinner
=
(
Spinner
)
findViewById
(
R
.
id
.
selectSensor
);
sensorList
.
add
(
0
,
"Sensor"
);
final
ArrayAdapter
<
String
>
sensorAdapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_item
,
sensorList
);
sensorAdapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
sensorSpinner
.
setAdapter
(
sensorAdapter
);
siteSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
if
(
position
!=
0
)
{
site
=
parent
.
getItemAtPosition
(
position
).
toString
();
sectorList
.
addAll
(
db
.
getSectors
(
site
));
if
(
siteList
.
get
(
0
).
equals
(
"Site"
))
{
siteList
.
remove
(
0
);
}
siteList
.
remove
(
0
);
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
sectorSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
if
(
position
!=
0
)
{
sector
=
parent
.
getItemAtPosition
(
position
).
toString
();
spotList
.
addAll
(
db
.
getSpots
(
site
,
sector
));
if
(
sectorList
.
get
(
0
).
equals
(
"Sector"
))
{
sectorList
.
remove
(
0
);
}
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
spotSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
if
(
position
!=
0
)
{
spot
=
parent
.
getItemAtPosition
(
position
).
toString
();
if
(
spotList
.
get
(
0
).
equals
(
"Spot"
))
{
spotList
.
remove
(
0
);
}
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
platformSpinner
.
setOnItemSelectedListener
(
new
AdapterView
.
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
if
(
position
!=
0
)
{
platform
=
parent
.
getItemAtPosition
(
position
).
toString
();
sensorList
=
db
.
getSensors
(
platform
);
if
(
platformList
.
get
(
0
).
equals
(
"Platform"
))
{
platformList
.
remove
(
0
);
}
}
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
parent
)
{
}
});
sensorValue
=
(
EditText
)
findViewById
(
R
.
id
.
sensorValue
);
sensorValue
.
requestFocus
();
sensorQuality
=
(
EditText
)
findViewById
(
R
.
id
.
sensorQuality
);
sensorQuality
.
requestFocus
();
readingNotes
=
(
EditText
)
findViewById
(
R
.
id
.
readingNotes
);
readingNotes
.
requestFocus
();
}
}
app/src/main/res/layout/activity_benchsample.xml
0 → 100644
View file @
f2bf60f3
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/siteSectorSpot"
android:layout_marginTop=
"10dp"
android:orientation=
"horizontal"
>
<Spinner
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"6"
android:id=
"@+id/selectSite"
/>
<Spinner
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"6"
android:id=
"@+id/selectSector"
/>
<Spinner
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"6"
android:id=
"@+id/selectSpot"
/>
</LinearLayout>
<View
android:layout_width=
"wrap_content"
android:layout_height=
"3dp"
android:id=
"@+id/rule"
android:background=
"@color/dark_gray_blue"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/platformSensor"
android:layout_marginTop=
"10dp"
android:orientation=
"horizontal"
>
<Spinner
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:id=
"@+id/selectPlatform"
/>
<Spinner
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:id=
"@+id/selectSensor"
/>
</LinearLayout>
<View
android:layout_width=
"wrap_content"
android:layout_height=
"3dp"
android:id=
"@+id/rule2"
android:background=
"@color/dark_gray_blue"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/sensorData"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"10dp"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"10dp"
android:textSize=
"18sp"
android:text=
"@string/sensorValue"
/>
<EditText
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"2"
android:id=
"@+id/sensorValue"
android:textColorHint=
"@color/dark_gray_blue"
android:textColor=
"@color/dark_gray_blue"
android:textCursorDrawable=
"@null"
android:inputType=
"number"
android:singleLine=
"true"
android:layout_marginEnd=
"10dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:textSize=
"18sp"
android:layout_height=
"wrap_content"
android:text=
"@string/sensorQuality"
/>
<EditText
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:id=
"@+id/sensorQuality"
android:textColorHint=
"@color/dark_gray_blue"
android:textColor=
"@color/dark_gray_blue"
android:textCursorDrawable=
"@null"
android:layout_weight=
"2"
android:singleLine=
"true"
android:inputType=
"number"
/>
</LinearLayout>
<View
android:layout_width=
"wrap_content"
android:layout_height=
"3dp"
android:id=
"@+id/rule3"
android:background=
"@color/dark_gray_blue"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<EditText
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:id=
"@+id/readingNotes"
android:layout_weight=
"5"
android:gravity=
"top"
android:background=
"@android:color/transparent"
android:hint=
"@string/readingNotes"
android:layout_marginStart=
"10dp"
android:layout_marginTop=
"10dp"
/>
<Button
android:layout_width=
"wrap_content"
android:layout_height=
"0dp"
android:layout_gravity=
"end"
android:text=
"@string/recordButton"
android:layout_weight=
"1"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment