Android Open Source - wiigee_android_test Main Activity






From Project

Back to project page wiigee_android_test.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project wiigee_android_test listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package asus4.wiigeeandroid;
//from w ww  .jav a  2  s.  co  m
import java.io.IOException;

import org.wiigee.control.AndroidWiigee;
import org.wiigee.control.Wiigee;
import org.wiigee.event.GestureEvent;
import org.wiigee.event.GestureListener;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import asus4.wiigeeandroid.R.id;

public class MainActivity extends Activity {
  
  static final int _TRAIN_BUTTON = 0x01;
  static final int _SAVE_BUTTON = 0x02;
  static final int _RECOGNIZE_BUTTON = 0x03;
  
  AndroidWiigee wiigee;
  Logger logger;
  
  boolean isRecording;
  boolean isRecognizing;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    wiigee = new AndroidWiigee(this);
    logger = new Logger((TextView) findViewById(id.logText), 20);
    isRecording = false;
    isRecognizing = false;
    
    wiigee.setTrainButton(_TRAIN_BUTTON);
    wiigee.setCloseGestureButton(_SAVE_BUTTON);
    wiigee.setRecognitionButton(_RECOGNIZE_BUTTON);
    wiigee.addGestureListener(new GestureListener() {
      
      @Override
      public void gestureReceived(GestureEvent event) {
        logger.addLog("Recognized: "+event.getId()+" Probability: "+event.getProbability());
      }
    });
  }
  
  @Override
  protected void onResume() {
    super.onResume();
    try {
      wiigee.getDevice().setAccelerationEnabled(true);
    }
    catch(IOException e) {
      
    }
    
  }
  
  @Override
  protected void onPause() {
    super.onPause();
    try {
      wiigee.getDevice().setAccelerationEnabled(false);      
    }
    catch(IOException e) {
      
    }
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }
  
  // events from xml
  public void onRecordButtonClick(View view) {
    Button btn = (Button) view;
    if(isRecording) {
      btn.setText(R.string.button_train_start);
      isRecording = false;
      wiigee.getDevice().fireButtonReleasedEvent(_TRAIN_BUTTON);
    }
    else {
      btn.setText(R.string.button_train_stop);
      isRecording = true;
      wiigee.getDevice().fireButtonPressedEvent(_TRAIN_BUTTON);
    }
    logger.addLog("click:onRecord:"+isRecording);
  }
  
  public void onSaveButtonClick(View view) {
    logger.addLog("click:onSave");
    wiigee.getDevice().fireButtonPressedEvent(_SAVE_BUTTON);
    wiigee.getDevice().fireButtonReleasedEvent(_SAVE_BUTTON);
  }
  
  public void onRecognizeButtonClick(View view) {
    Button btn = (Button) view;
    if(isRecognizing) {
      btn.setText(R.string.button_recognize_start);
      isRecognizing = false;
      wiigee.getDevice().fireButtonReleasedEvent(_RECOGNIZE_BUTTON);
    }
    else {
      btn.setText(R.string.button_recognize_stop);
      isRecognizing = true;
      wiigee.getDevice().fireButtonPressedEvent(_RECOGNIZE_BUTTON);
    }
    logger.addLog("click:onRecognize");
  }

}




Java Source Code List

asus4.wiigeeandroid.Logger.java
asus4.wiigeeandroid.MainActivity.java
org.wiigee.control.AndroidWiigee.java
org.wiigee.control.Wiigee.java
org.wiigee.device.AndroidDevice.java
org.wiigee.device.Device.java
org.wiigee.event.AccelerationEvent.java
org.wiigee.event.AccelerationListener.java
org.wiigee.event.ActionStartEvent.java
org.wiigee.event.ActionStopEvent.java
org.wiigee.event.ButtonListener.java
org.wiigee.event.ButtonPressedEvent.java
org.wiigee.event.ButtonReleasedEvent.java
org.wiigee.event.GestureEvent.java
org.wiigee.event.GestureListener.java
org.wiigee.event.MotionStartEvent.java
org.wiigee.event.MotionStopEvent.java
org.wiigee.filter.DirectionalEquivalenceFilter.java
org.wiigee.filter.Filter.java
org.wiigee.filter.HighPassFilter.java
org.wiigee.filter.IdleStateFilter.java
org.wiigee.filter.LowPassFilter.java
org.wiigee.filter.MotionDetectFilter.java
org.wiigee.logic.Classifier.java
org.wiigee.logic.GestureModel.java
org.wiigee.logic.Gesture.java
org.wiigee.logic.HMM.java
org.wiigee.logic.PreciseHMM.java
org.wiigee.logic.ProcessingUnit.java
org.wiigee.logic.Quantizer.java
org.wiigee.logic.TriggeredProcessingUnit.java
org.wiigee.util.FileIO.java
org.wiigee.util.Log.java