|
@@ -1,281 +0,0 @@
|
|
|
-package app.ara.activities;
|
|
|
-
|
|
|
-import android.content.Intent;
|
|
|
-import android.graphics.Bitmap;
|
|
|
-import android.support.v4.view.MotionEventCompat;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.MotionEvent;
|
|
|
-import android.view.View;
|
|
|
-import android.view.WindowManager;
|
|
|
-import android.widget.Button;
|
|
|
-import android.widget.FrameLayout;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.RelativeLayout;
|
|
|
-import android.widget.TextView;
|
|
|
-import android.widget.VideoView;
|
|
|
-
|
|
|
-import app.ara.ui.MediaView;
|
|
|
-import app.ara.utils.FontChangeCrawler;
|
|
|
-import app.ara.utils.app.brest.game.Resource;
|
|
|
-import app.ara.utils.files.FileManager;
|
|
|
-import app.ara.utils.geometry.Point;
|
|
|
-import min3d.core.Object3d;
|
|
|
-import min3d.core.RendererActivity;
|
|
|
-import min3d.vos.CameraVo;
|
|
|
-import min3d.vos.Light;
|
|
|
-import uk.co.senab.photoview.PhotoViewAttacher;
|
|
|
-
|
|
|
-/**
|
|
|
- * An example full-screen activity that shows and hides the system UI (i.e.
|
|
|
- * status bar and navigation/system bar) with user interaction.
|
|
|
- */
|
|
|
-public class ViewerActivity extends RendererActivity implements View.OnTouchListener {
|
|
|
-
|
|
|
-
|
|
|
- private Resource mResource;
|
|
|
- private FrameLayout mFrameLayout;
|
|
|
- private ImageView mImageView;
|
|
|
- private Button mButton;
|
|
|
- private TextView mText;
|
|
|
- private PhotoViewAttacher mAttacher;
|
|
|
-
|
|
|
- protected float mPreviousX;
|
|
|
- protected float mPreviousY;
|
|
|
- protected float mPreviousDist=0;
|
|
|
- protected CameraVo mCamera = new CameraVo();
|
|
|
- protected boolean mIsZooming = false;
|
|
|
- protected boolean mIsMoving = false;
|
|
|
-
|
|
|
- public static final int CONTENT_NULL=0;
|
|
|
- public static final int CONTENT_MAP=1;
|
|
|
- public static final int CONTENT_INFO=2;
|
|
|
- public static final int CONTENT_IMAGE=3;
|
|
|
- public static final int CONTENT_3D=4;
|
|
|
- protected int mContent=CONTENT_NULL;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setContentView(R.layout.activity_viewer);
|
|
|
- FontChangeCrawler.setFont(this);
|
|
|
-
|
|
|
- mFrameLayout = (FrameLayout) findViewById(R.id.frame_viewer);
|
|
|
- mImageView = (ImageView) findViewById(R.id.imageView);
|
|
|
- mButton = (Button) findViewById(R.id.button_info);
|
|
|
- mText = (TextView) findViewById(R.id.tv_comment);
|
|
|
- if(getIntent().hasExtra("resource"))
|
|
|
- {
|
|
|
- mResource = (Resource) getIntent().getSerializableExtra("resource");
|
|
|
- if(mResource!=null) setTitle(mResource.getTitle());
|
|
|
- }
|
|
|
-
|
|
|
- final TextView title = (TextView) findViewById(R.id.b_title);
|
|
|
- title.setVisibility(View.VISIBLE);
|
|
|
- mText.setVisibility(View.INVISIBLE);
|
|
|
-
|
|
|
- if(mResource != null && !getIntent().hasExtra("information") && !getIntent().hasExtra("map"))
|
|
|
- {
|
|
|
- title.setText(mResource.getTitle());
|
|
|
- if(mResource.isImage())
|
|
|
- {
|
|
|
- mContent=CONTENT_IMAGE;
|
|
|
- Bitmap bmp=null;
|
|
|
- try {
|
|
|
- bmp = FileManager.openImage(mResource.getName());
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- mImageView.setImageBitmap(bmp);
|
|
|
- mAttacher = new PhotoViewAttacher(mImageView);
|
|
|
- mAttacher.setMaximumScale(20);
|
|
|
-
|
|
|
- }
|
|
|
- else if(mResource.is3D()) {
|
|
|
- mContent=CONTENT_3D;
|
|
|
- mFrameLayout.addView(_glSurfaceView);
|
|
|
- mImageView.setVisibility(View.INVISIBLE);
|
|
|
- }
|
|
|
-
|
|
|
- } else if(getIntent().hasExtra("map") )
|
|
|
- {
|
|
|
- mContent=CONTENT_MAP;
|
|
|
- Bitmap bmp=null;
|
|
|
- try {
|
|
|
- bmp = FileManager.openImage("map");
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- title.setVisibility(View.GONE);
|
|
|
- mImageView.setImageBitmap(bmp);
|
|
|
- mAttacher = new PhotoViewAttacher(mImageView);
|
|
|
- mAttacher.setMaximumScale(20);
|
|
|
- mButton.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- else if(mResource != null && getIntent().hasExtra("information"))
|
|
|
- {
|
|
|
- mContent=CONTENT_INFO;
|
|
|
- title.setText(mResource.getTitle());
|
|
|
- mButton.setVisibility(View.GONE);
|
|
|
- mText.setVisibility(View.VISIBLE);
|
|
|
- mText.setText(mResource.getComment());
|
|
|
- //mFrameLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void onClickInfo(View v)
|
|
|
- {
|
|
|
- Intent intent = new Intent(this, ViewerActivity.class);
|
|
|
- intent.putExtra("resource", mResource);
|
|
|
- intent.putExtra("information", true);
|
|
|
- startActivity(intent);
|
|
|
- }
|
|
|
-
|
|
|
- protected void onPause()
|
|
|
- {
|
|
|
- super.onPause();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public void finish()
|
|
|
- {
|
|
|
- super.finish();
|
|
|
- }
|
|
|
-
|
|
|
- public void onDestroy()
|
|
|
- {
|
|
|
- super.onDestroy();
|
|
|
- }
|
|
|
-
|
|
|
- public void initScene()
|
|
|
- {
|
|
|
-
|
|
|
- scene.backgroundColor().setAll(0x00000000);
|
|
|
-
|
|
|
- Light myLight = new Light();
|
|
|
- myLight.position.setZ(0);
|
|
|
- myLight.position.setY(0);
|
|
|
- scene.lights().add(myLight);
|
|
|
- Object3d oo = mResource.get3DModel(this);
|
|
|
- oo.position().z=mResource.getPosition().z;
|
|
|
- oo.position().y=mResource.getPosition().y;
|
|
|
- oo.position().x=mResource.getPosition().x;
|
|
|
- oo.position().z-=20;
|
|
|
- mCamera.frustum.zFar(0.1f);
|
|
|
- mCamera.frustum.zFar(1000);
|
|
|
- scene.addChild(mResource.get3DModel(this));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateScene() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static String actionToString(int action) {
|
|
|
- switch (action) {
|
|
|
-
|
|
|
- case MotionEvent.ACTION_DOWN: return "Down";
|
|
|
- case MotionEvent.ACTION_MOVE: return "Move";
|
|
|
- case MotionEvent.ACTION_POINTER_DOWN: return "Pointer Down";
|
|
|
- case MotionEvent.ACTION_UP: return "Up";
|
|
|
- case MotionEvent.ACTION_POINTER_UP: return "Pointer Up";
|
|
|
- case MotionEvent.ACTION_OUTSIDE: return "Outside";
|
|
|
- case MotionEvent.ACTION_CANCEL: return "Cancel";
|
|
|
- }
|
|
|
- return "";
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
- float x = motionEvent.getX();
|
|
|
- float y = motionEvent.getY();
|
|
|
- final int action = motionEvent.getAction()%256;
|
|
|
- int index = MotionEventCompat.getActionIndex(motionEvent);
|
|
|
- if (motionEvent.getPointerCount() > 1) {
|
|
|
- switch (action) {
|
|
|
- case MotionEvent.ACTION_MOVE:
|
|
|
- {
|
|
|
- if(!mIsZooming) break;
|
|
|
- Point a = new Point(motionEvent.getX(0), motionEvent.getY(0));
|
|
|
- Point b = new Point(motionEvent.getX(1), motionEvent.getY(1));
|
|
|
- double d = a.getDistanceWith(b);
|
|
|
- double delta = d - mPreviousDist;
|
|
|
- mCamera.position.z+=delta/2;
|
|
|
- mPreviousDist = (float)a.getDistanceWith(b);
|
|
|
- scene.camera(mCamera);
|
|
|
- break;
|
|
|
- }
|
|
|
- case MotionEvent.ACTION_POINTER_DOWN:
|
|
|
- case MotionEvent.ACTION_DOWN: {
|
|
|
- Point a = new Point(motionEvent.getX(0), motionEvent.getY(0));
|
|
|
- Point b = new Point(motionEvent.getX(1), motionEvent.getY(1));
|
|
|
- mPreviousDist = (float)a.getDistanceWith(b);
|
|
|
- mIsZooming=true;
|
|
|
- break;
|
|
|
- }
|
|
|
- case MotionEvent.ACTION_UP:
|
|
|
- case MotionEvent.ACTION_POINTER_UP:
|
|
|
- case MotionEvent.ACTION_CANCEL:
|
|
|
- mIsZooming=false;
|
|
|
- mIsMoving=false;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- mIsZooming=false;
|
|
|
- switch (motionEvent.getAction()) {
|
|
|
- case MotionEvent.ACTION_MOVE:
|
|
|
- {
|
|
|
- if(!mIsMoving) break;
|
|
|
- float dx = x - mPreviousX;
|
|
|
- float dy = y - mPreviousY;
|
|
|
- Object3d oo = mResource.get3DModel(this);
|
|
|
-
|
|
|
- oo.rotation().y += dx / 3;
|
|
|
- oo.rotation().x += dy / 3;
|
|
|
- _glSurfaceView.requestRender();
|
|
|
-
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- case MotionEvent.ACTION_DOWN:
|
|
|
- mIsMoving=true;
|
|
|
- break;
|
|
|
- case MotionEvent.ACTION_UP:
|
|
|
- case MotionEvent.ACTION_CANCEL:
|
|
|
- mIsMoving=false;
|
|
|
- mIsZooming=false;
|
|
|
- break;
|
|
|
- }
|
|
|
- mPreviousX = x;
|
|
|
- mPreviousY = y;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return true;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public void onClick(View v)
|
|
|
- {
|
|
|
- if(mContent==CONTENT_IMAGE) {
|
|
|
- Log.e("______________", "OnClick");
|
|
|
-
|
|
|
- final TextView title = (TextView) findViewById(R.id.b_title);
|
|
|
- if (title.getVisibility() == View.VISIBLE) {
|
|
|
- Log.e("______________", "Visible -> Gone");
|
|
|
- title.setVisibility(View.GONE);
|
|
|
- mButton.setVisibility(View.GONE);
|
|
|
- } else {
|
|
|
- Log.e("______________", "Gone -> Visible");
|
|
|
-
|
|
|
- title.setVisibility(View.VISIBLE);
|
|
|
- mButton.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|