Feature #2893 Create Java sample without layout.xml implemented.
This commit is contained in:
parent
aef8e6ba59
commit
82c61eba49
@ -1,11 +0,0 @@
|
||||
<LinearLayout 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" >
|
||||
|
||||
<org.opencv.android.JavaCameraView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/puzzle_activity_surface_view" />
|
||||
|
||||
</LinearLayout>
|
@ -1,6 +0,0 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_start_new_game"
|
||||
android:title="@string/menu_start_new_game"
|
||||
android:orderInCategory="100" />
|
||||
<item android:id="@+id/menu_toggle_tile_numbers" android:title="@string/menu_toggle_tile_numbers"></item>
|
||||
</menu>
|
@ -6,6 +6,7 @@ import org.opencv.android.OpenCVLoader;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.android.CameraBridgeViewBase;
|
||||
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
|
||||
import org.opencv.android.JavaCameraView;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
@ -22,6 +23,9 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
|
||||
|
||||
private CameraBridgeViewBase mOpenCvCameraView;
|
||||
private Puzzle15Processor mPuzzle15;
|
||||
private MenuItem mItemHideNumbers;
|
||||
private MenuItem mItemStartNewGame;
|
||||
|
||||
|
||||
private int mGameWidth;
|
||||
private int mGameHeight;
|
||||
@ -52,9 +56,9 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
setContentView(R.layout.activity_puzzle15);
|
||||
|
||||
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.puzzle_activity_surface_view);
|
||||
Log.d(TAG, "Creating and seting view");
|
||||
mOpenCvCameraView = (CameraBridgeViewBase) new JavaCameraView(this, -1);
|
||||
setContentView(mOpenCvCameraView);
|
||||
mOpenCvCameraView.setCvCameraViewListener(this);
|
||||
mPuzzle15 = new Puzzle15Processor();
|
||||
mPuzzle15.prepareNewGame();
|
||||
@ -83,17 +87,19 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_puzzle15, menu);
|
||||
Log.i(TAG, "called onCreateOptionsMenu");
|
||||
mItemHideNumbers = menu.add("Show/hide tile numbers");
|
||||
mItemStartNewGame = menu.add("Start new game");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
Log.i(TAG, "Menu Item selected " + item);
|
||||
if (item.getItemId() == R.id.menu_start_new_game) {
|
||||
if (item == mItemStartNewGame) {
|
||||
/* We need to start new game */
|
||||
mPuzzle15.prepareNewGame();
|
||||
} else if (item.getItemId() == R.id.menu_toggle_tile_numbers) {
|
||||
} else if (item == mItemHideNumbers) {
|
||||
/* We need to enable or disable drawing of the tile numbers */
|
||||
mPuzzle15.toggleTileNumbers();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user