mini-cards/app/src/main/java/com/codigoparallevar/minicards/MainActivity.java

52 lines
1.5 KiB
Java

package com.codigoparallevar.minicards;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
public class MainActivity extends AppCompatActivity {
CanvasView canvasView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide action bar
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
// Use controled canvas
setContentView(R.layout.activity_main);
canvasView = (CanvasView) findViewById(R.id.canvasView);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (canvasView != null){
return canvasView.onTouchEvent(event);
}
Log.e("MainActivity", "CanvasView is null");
return super.onTouchEvent(event);
}
}