Skip to content

Commit ccd5190

Browse files
RobAltenatreo
authored andcommitted
adds dataset selection menus.
Signed-off-by: Paul Dubs <[email protected]>
1 parent 91e1e76 commit ccd5190

File tree

8 files changed

+61
-16
lines changed

8 files changed

+61
-16
lines changed

android-examples/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
android:label="@string/app_name"
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
11-
android:theme="@style/AppTheme"
11+
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
1212
android:fullBackupContent="@xml/backup_descriptor">
1313
<activity android:name="com.example.androidDl4jClassifier.MainActivity">
1414
<intent-filter>

android-examples/app/src/main/java/com/example/androidDl4jClassifier/MainActivity.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import androidx.appcompat.app.AppCompatActivity;
44

55
import android.os.Bundle;
6+
import android.view.Menu;
7+
import android.view.MenuItem;
8+
69

710
public class MainActivity extends AppCompatActivity {
811

@@ -15,7 +18,38 @@ protected void onCreate(Bundle savedInstanceState) {
1518
setContentView(R.layout.activity_main);
1619
}
1720

21+
@Override
22+
public boolean onOptionsItemSelected(MenuItem item) {
23+
switch (item.getItemId()) {
24+
case R.id.action_linear:
25+
// User chose linear dataset.
26+
return true;
27+
28+
case R.id.action_moon:
29+
// User chose moon dataset.
30+
return true;
31+
32+
case R.id.action_saturn:
33+
// User chose moon dataset.
34+
return true;
35+
36+
default:
37+
// If we got here, the user's action was not recognized.
38+
// Invoke the superclass to handle it.
39+
return super.onOptionsItemSelected(item);
40+
41+
}
42+
}
43+
44+
@Override
45+
public boolean onCreateOptionsMenu(Menu menu) {
46+
// Inflate the menu; this adds items to the action bar if it is present.
47+
getMenuInflater().inflate(R.menu.menu_main, menu);
48+
return true;
49+
}
50+
1851
public static MainActivity getInstance(){
1952
return instance;
2053
}
54+
2155
}

android-examples/app/src/main/java/com/example/androidDl4jClassifier/ScatterView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ScatterView extends View {
4242

4343
private final int nPointsPerAxis = 100;
4444
private INDArray xyGrid; //x,y grid to calculate the output image. Needs to be calculated once, then re-used.
45-
INDArray modelOut = null;
45+
private INDArray modelOut = null;
4646

4747
public ScatterView(Context context, @Nullable AttributeSet attrs) {
4848
super(context, attrs);

android-examples/app/src/main/res/layout/activity_main.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
android:layout_height="match_parent"
77
tools:context=".MainActivity">
88

9+
910
<view
1011
class="com.example.androidDl4jClassifier.ScatterView"
1112
android:layout_width="fill_parent"
12-
android:layout_height="fill_parent"
13-
app:layout_constraintStart_toStartOf="parent"
14-
app:layout_constraintTop_toTopOf="parent" />
13+
android:layout_height="0dp"
14+
app:layout_constraintBottom_toBottomOf="parent"
15+
app:layout_constraintEnd_toEndOf="parent"
16+
app:layout_constraintStart_toStartOf="parent" />
1517
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto">
3+
<item
4+
android:id="@+id/action_linear"
5+
android:orderInCategory="100"
6+
android:title="@string/action_linear"
7+
app:showAsAction="never" />
8+
<item
9+
android:orderInCategory="101"
10+
android:id="@+id/action_moon"
11+
android:title="@string/action_moon" />
12+
<item
13+
android:orderInCategory="102"
14+
android:id="@+id/action_saturn"
15+
android:title="@string/action_saturn" />
16+
</menu>
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<resources>
3-
<color name="colorPrimary">#6200EE</color>
4-
<color name="colorPrimaryDark">#3700B3</color>
5-
<color name="colorAccent">#03DAC5</color>
6-
</resources>
2+
<resources />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<resources>
22
<string name="app_name">Android DL4j classifier</string>
3+
<string name="action_linear">Linear</string>
4+
<string name="action_moon">Moon</string>
5+
<string name="action_saturn">Saturn</string>
36
</resources>
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5-
<!-- Customize your theme here. -->
6-
<item name="colorPrimary">@color/colorPrimary</item>
7-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8-
<item name="colorAccent">@color/colorAccent</item>
9-
</style>
104

115
</resources>

0 commit comments

Comments
 (0)