Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
LSR_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
GyuhoLee
2020-06-16 01:42:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0b04a81f1ee6e7d6f648b093a42e8f97133e568e
0b04a81f
1 parent
3b9d2a66
[Add] Report, DB Connect
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
230 additions
and
2 deletions
source/android/app/build.gradle
source/android/app/src/main/java/com/khuhacker/pocketgym/ChartXValueFormatter.java
source/android/app/src/main/java/com/khuhacker/pocketgym/ExerciseActivity.java
source/android/app/src/main/java/com/khuhacker/pocketgym/ReportActivity.java
source/android/app/src/main/res/drawable/caloriy_icon.png
source/android/app/src/main/res/drawable/clock_icon.png
source/android/app/src/main/res/drawable/sport_icon.png
source/android/app/src/main/res/layout/activity_report.xml
source/android/build.gradle
source/android/app/build.gradle
View file @
0b04a81
...
...
@@ -35,7 +35,10 @@ dependencies {
implementation
'org.tensorflow:tensorflow-lite:2.2.0'
implementation
'org.tensorflow:tensorflow-lite-gpu:2.2.0'
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation
'com.github.PhilJay:MPAndroidChart:v3.0.2'
}
repositories
{
mavenCentral
()
maven
{
url
"https://jitpack.io"
}
}
...
...
source/android/app/src/main/java/com/khuhacker/pocketgym/ChartXValueFormatter.java
0 → 100644
View file @
0b04a81
package
com
.
khuhacker
.
pocketgym
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.util.Log
;
import
com.github.mikephil.charting.components.AxisBase
;
import
com.github.mikephil.charting.formatter.IAxisValueFormatter
;
import
java.sql.Date
;
import
java.text.SimpleDateFormat
;
public
class
ChartXValueFormatter
implements
IAxisValueFormatter
{
private
String
[]
mValues
;
ChartXValueFormatter
(){
mValues
=
new
String
[
8
];
long
day
=
3600000
*
24
;
SQLiteDatabase
db
;
String
sql
;
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
long
now
=
System
.
currentTimeMillis
()
-
(
day
*
i
);
Date
date
=
new
Date
(
now
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
getTime
=
sdf
.
format
(
date
);
mValues
[
7
-
i
]
=
getTime
.
charAt
(
4
)
+
""
+
getTime
.
charAt
(
5
)
+
"/"
+
getTime
.
charAt
(
6
)
+
getTime
.
charAt
(
7
);
}
}
@Override
public
String
getFormattedValue
(
float
value
,
AxisBase
axis
){
return
mValues
[(
int
)
value
];
}
}
source/android/app/src/main/java/com/khuhacker/pocketgym/ExerciseActivity.java
View file @
0b04a81
...
...
@@ -311,6 +311,7 @@ public class ExerciseActivity extends AppCompatActivity implements SurfaceHolder
SQLiteDatabase
db
=
dbHelper
.
getReadableDatabase
();
String
sql
=
"SELECT pushup FROM reports WHERE date="
+
getTime
+
";"
;
Cursor
cs
=
db
.
rawQuery
(
sql
,
null
);
cs
.
moveToNext
();
int
before
=
cs
.
getInt
(
0
);
db
=
dbHelper
.
getWritableDatabase
();
...
...
source/android/app/src/main/java/com/khuhacker/pocketgym/ReportActivity.java
View file @
0b04a81
package
com
.
khuhacker
.
pocketgym
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.widget.TextView
;
import
androidx.appcompat.app.AppCompatActivity
;
import
com.github.mikephil.charting.animation.Easing
;
import
com.github.mikephil.charting.charts.LineChart
;
import
com.github.mikephil.charting.components.Description
;
import
com.github.mikephil.charting.components.XAxis
;
import
com.github.mikephil.charting.components.YAxis
;
import
com.github.mikephil.charting.data.Entry
;
import
com.github.mikephil.charting.data.LineData
;
import
com.github.mikephil.charting.data.LineDataSet
;
import
java.sql.Date
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ReportActivity
extends
AppCompatActivity
{
private
LineChart
lineChart
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_choice
);
setContentView
(
R
.
layout
.
activity_report
);
DBHelper
dbHelper
=
new
DBHelper
(
this
,
"reports.db"
,
null
,
1
);
long
now
=
System
.
currentTimeMillis
();
Date
date
=
new
Date
(
now
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
getTime
=
sdf
.
format
(
date
);
SQLiteDatabase
db
=
dbHelper
.
getReadableDatabase
();
String
sql
=
"SELECT * FROM reports WHERE date="
+
getTime
+
";"
;
Cursor
cs
=
db
.
rawQuery
(
sql
,
null
);
cs
.
moveToNext
();
int
pushupCnt
=
cs
.
getInt
(
0
);
int
squatCnt
=
cs
.
getInt
(
1
);
TextView
sport
=
(
TextView
)
findViewById
(
R
.
id
.
sport
);
sport
.
setText
(
String
.
valueOf
(
pushupCnt
+
squatCnt
)
+
" 회"
);
TextView
caloriy
=
(
TextView
)
findViewById
(
R
.
id
.
caloriy
);
caloriy
.
setText
(
String
.
valueOf
((
int
)(
0.25f
*
pushupCnt
+
0.41f
*
squatCnt
))
+
" kcal"
);
TextView
clock
=
(
TextView
)
findViewById
(
R
.
id
.
clock
);
clock
.
setText
(
String
.
valueOf
((
int
)(
0.05f
*
pushupCnt
+
0.1f
*
squatCnt
))
+
" 분"
);
lineChart
=
(
LineChart
)
findViewById
(
R
.
id
.
chart
);
List
<
Entry
>
entries
=
new
ArrayList
<>();
long
day
=
3600000
*
24
;
for
(
int
i
=
6
;
i
>=
0
;
i
--)
{
now
=
System
.
currentTimeMillis
()
-
(
day
*
i
);
date
=
new
Date
(
now
);
sdf
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
getTime
=
sdf
.
format
(
date
);
db
=
dbHelper
.
getReadableDatabase
();
sql
=
"SELECT * FROM reports WHERE date="
+
getTime
+
";"
;
cs
=
db
.
rawQuery
(
sql
,
null
);
cs
.
moveToNext
();
entries
.
add
(
new
Entry
(
7
-
i
,
cs
.
getFloat
(
0
)
+
cs
.
getFloat
(
1
)));
}
LineDataSet
lineDataSet
=
new
LineDataSet
(
entries
,
"횟수"
);
lineDataSet
.
setLineWidth
(
2
);
lineDataSet
.
setCircleRadius
(
5
);
lineDataSet
.
setCircleColor
(
R
.
color
.
pacific
);
lineDataSet
.
setColor
(
R
.
color
.
pacific
);
lineDataSet
.
setDrawCircles
(
true
);
lineDataSet
.
setDrawHorizontalHighlightIndicator
(
false
);
lineDataSet
.
setDrawHighlightIndicators
(
true
);
lineDataSet
.
setDrawValues
(
true
);
LineData
lineData
=
new
LineData
(
lineDataSet
);
lineChart
.
setData
(
lineData
);
XAxis
xAxis
=
lineChart
.
getXAxis
();
xAxis
.
setPosition
(
XAxis
.
XAxisPosition
.
BOTTOM
);
xAxis
.
setTextSize
(
11
f
);
xAxis
.
setTextColor
(
Color
.
BLACK
);
xAxis
.
setLabelCount
(
7
,
true
);
xAxis
.
setDrawGridLines
(
false
);
xAxis
.
setValueFormatter
(
new
ChartXValueFormatter
());
YAxis
yLAxis
=
lineChart
.
getAxisLeft
();
yLAxis
.
setTextColor
(
Color
.
BLACK
);
yLAxis
.
setAxisMinimum
(
0
f
);
yLAxis
.
setTextSize
(
15
f
);
YAxis
yRAxis
=
lineChart
.
getAxisRight
();
yRAxis
.
setDrawLabels
(
false
);
yRAxis
.
setDrawAxisLine
(
false
);
yRAxis
.
setDrawGridLines
(
false
);
Description
description
=
new
Description
();
description
.
setText
(
""
);
lineChart
.
setVisibleXRangeMinimum
(
7
);
lineChart
.
setDoubleTapToZoomEnabled
(
false
);
lineChart
.
setDrawGridBackground
(
false
);
lineChart
.
setDescription
(
description
);
lineChart
.
animateY
(
2000
,
Easing
.
EasingOption
.
EaseInCubic
);
lineChart
.
invalidate
();
}
}
...
...
source/android/app/src/main/res/drawable/caloriy_icon.png
0 → 100644
View file @
0b04a81
14.8 KB
source/android/app/src/main/res/drawable/clock_icon.png
0 → 100644
View file @
0b04a81
11 KB
source/android/app/src/main/res/drawable/sport_icon.png
0 → 100644
View file @
0b04a81
8.11 KB
source/android/app/src/main/res/layout/activity_report.xml
0 → 100644
View file @
0b04a81
<?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:background=
"#FFFFFF"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"오늘의 운동"
android:layout_gravity=
"center"
android:textSize=
"40dp"
android:layout_marginTop=
"30dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"130dp"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:layout_margin=
"10dp"
android:layout_marginBottom=
"50dp"
>
<LinearLayout
android:layout_width=
"130dp"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:background=
"@drawable/stroke_main"
android:orientation=
"vertical"
android:padding=
"15dp"
>
<ImageView
android:layout_width=
"70dp"
android:layout_height=
"70dp"
android:layout_gravity=
"center"
android:src=
"@drawable/sport_icon"
/>
<TextView
android:id=
"@+id/sport"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:text=
"1 회"
android:textColor=
"@color/pacific"
android:textSize=
"60px"
android:textStyle=
"bold"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"130dp"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:background=
"@drawable/stroke_main"
android:orientation=
"vertical"
android:padding=
"15dp"
>
<ImageView
android:layout_width=
"70dp"
android:layout_height=
"70dp"
android:layout_gravity=
"center"
android:src=
"@drawable/caloriy_icon"
/>
<TextView
android:id=
"@+id/caloriy"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:text=
"100 kcal"
android:textColor=
"@color/pacific"
android:textSize=
"60px"
android:textStyle=
"bold"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"130dp"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:background=
"@drawable/stroke_main"
android:orientation=
"vertical"
android:padding=
"15dp"
>
<ImageView
android:layout_width=
"60dp"
android:layout_height=
"70dp"
android:layout_gravity=
"center"
android:src=
"@drawable/clock_icon"
/>
<TextView
android:id=
"@+id/clock"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:text=
"30 분"
android:textColor=
"@color/pacific"
android:textSize=
"60px"
android:textStyle=
"bold"
/>
</LinearLayout>
</LinearLayout>
<com.github.mikephil.charting.charts.LineChart
android:id=
"@+id/chart"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</LinearLayout>
\ No newline at end of file
source/android/build.gradle
View file @
0b04a81
...
...
@@ -5,7 +5,6 @@ buildscript {
repositories
{
google
()
jcenter
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:3.6.3'
...
...
Please
register
or
login
to post a comment