added example plot

This commit is contained in:
paul-loedige 2021-01-07 18:30:42 +01:00
parent d2770ca624
commit 9543f72ce5
9 changed files with 96 additions and 3 deletions

4
APED/.idea/gradle.xml generated
View File

@ -10,8 +10,8 @@
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$USER_HOME$/Storage/Programs/TH/MO_Mobile_Systeme/aped_app/APED" />
<option value="$USER_HOME$/Storage/Programs/TH/MO_Mobile_Systeme/aped_app/APED/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />

View File

@ -38,6 +38,8 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.github.lecho:hellocharts-library:1.5.8'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

View File

@ -73,7 +73,7 @@ public class MainActivity extends AppCompatActivity {
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_all_IOs, R.id.nav_your_IOs)
R.id.nav_all_IOs, R.id.nav_your_IOs,R.id.nav_plots)
.setDrawerLayout(drawer)
.build();
NavController navController = Navigation.findNavController(this,

View File

@ -0,0 +1,62 @@
package com.example.aped.ui.plots;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.aped.MainActivity;
import com.example.aped.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lecho.lib.hellocharts.model.AxisValue;
import lecho.lib.hellocharts.model.Line;
import lecho.lib.hellocharts.model.LineChartData;
import lecho.lib.hellocharts.model.PointValue;
import lecho.lib.hellocharts.view.LineChartView;
public class PlotFragment extends Fragment {
private MainActivity mainActivity;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_plot, container, false);
LineChartView lineChartView = view.findViewById(R.id.test_plot);
String[] xAxisData = {"15:30","15:31","15:32"};
int[] yAxisData = {1,3,2};
List yAxisValues = new ArrayList();
List xAxisValues = new ArrayList();
Line line = new Line(yAxisValues);
for(int i = 0; i < xAxisData.length; i++){
xAxisValues.add(i, new AxisValue(i).setLabel(xAxisData[i]));
}
for (int i = 0; i < yAxisData.length; i++){
yAxisValues.add(new PointValue(i, yAxisData[i]));
}
List lines = new ArrayList();
lines.add(line);
LineChartData lineChartData = new LineChartData();
lineChartData.setLines(lines);
lineChartView.setLineChartData(lineChartData);
return view;
}
}

View File

@ -0,0 +1,4 @@
/**
* Package for the plot fragment.
* */
package com.example.aped.ui.plots;

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.plots.PlotFragment">
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/test_plot"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>

View File

@ -12,5 +12,9 @@
android:id="@+id/nav_your_IOs"
android:icon="@android:drawable/btn_star_big_on"
android:title="@string/menu_favorite_IOs" />
<item
android:id="@+id/nav_plots"
android:icon="@android:drawable/ic_menu_gallery"
android:title="@string/menu_plots" />
</group>
</menu>

View File

@ -17,4 +17,10 @@
android:label="@string/menu_favorite_IOs"
tools:layout="@layout/fragment_your_ios" />
<fragment
android:id="@+id/nav_plots"
android:name="com.example.aped.ui.plots.PlotFragment"
android:label="@string/menu_plots"
tools:layout="@layout/fragment_plot" />
</navigation>

View File

@ -12,4 +12,7 @@
<string name="menu_all_IOs">all IOs</string>
<string name="menu_favorite_IOs">favorite IOs</string>
<string name="menu_plots">plots</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>