updated gradle und stuff...
fixed threading bug in tapping on the huawei watch
This commit is contained in:
@@ -13,6 +13,9 @@ import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import de.tonifetzer.conductorswatch.network.SensorDataFileSender;
|
||||
import de.tonifetzer.conductorswatch.utilities.Utils;
|
||||
|
||||
@@ -21,7 +24,6 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
// member
|
||||
private TextView mTextView;
|
||||
private Croller mCroller;
|
||||
private GestureDetector mDetector;
|
||||
private boolean mModeRecord = false;
|
||||
|
||||
// connection to phone stuff
|
||||
@@ -40,16 +42,18 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
private int mMetronomBpm = 80;
|
||||
private int mLastSendBPM = 80;
|
||||
|
||||
//threading
|
||||
final ExecutorService mExecutorService = Executors.newCachedThreadPool();
|
||||
|
||||
// tapping
|
||||
private Thread mTapBpmThread;
|
||||
private TapBpm mTapBpm;
|
||||
private boolean mTapRecognized = false;
|
||||
private boolean mTapRecognized = true;
|
||||
private int mTapBpmEstimation;
|
||||
private Vibrator mVibrator;
|
||||
|
||||
//parameter for long press to start the worker
|
||||
private Point mPreviousMovePoint;
|
||||
private int mDistanceJitteringLongPress = 50; // in pixel
|
||||
//private Point mPreviousMovePoint;
|
||||
//private int mDistanceJitteringLongPress = 50; // in pixel
|
||||
private int mLongPressDelay = 1200; // in Milliseconds
|
||||
private boolean mLongPressHandlerActivated = false;
|
||||
private final Handler mHandler = new Handler();
|
||||
@@ -135,7 +139,7 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
mHandler.removeCallbacks(mLongPressed);
|
||||
if (mLongPressHandlerActivated) {
|
||||
mLongPressHandlerActivated = false;
|
||||
mPreviousMovePoint = null;
|
||||
//mPreviousMovePoint = null;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -195,17 +199,21 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
|
||||
if (!mTapRecognized) {
|
||||
//if (!mTapRecognized) {
|
||||
|
||||
mTapBpm.addTimestamp(System.currentTimeMillis());
|
||||
mTapRecognized = true;
|
||||
}
|
||||
//mTapRecognized = true;
|
||||
//}
|
||||
}
|
||||
|
||||
if (ev.getAction() == MotionEvent.ACTION_UP) {
|
||||
|
||||
if (!mTapBpmThread.isAlive() && mTapRecognized) {
|
||||
mTapBpmThread.start();
|
||||
if (mTapRecognized) {
|
||||
|
||||
mExecutorService.submit(mTapBpm);
|
||||
|
||||
//mTapBpmThread = new Thread(mTapBpm);
|
||||
//mTapBpmThread.start();
|
||||
mCroller.setLabel("Tippe weiter");
|
||||
}
|
||||
mTapRecognized = false;
|
||||
@@ -225,11 +233,11 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
mDisplayHeight = this.getResources().getDisplayMetrics().heightPixels;
|
||||
mDisplayCenter = new Point((mDisplayWidth / 2), (mDisplayHeight / 2));
|
||||
|
||||
//add tap listener
|
||||
mTapBpm = new TapBpm();
|
||||
mTapBpm.add(this);
|
||||
mTapBpmThread = new Thread(mTapBpm, "tapThread");
|
||||
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
||||
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
mTextView = (TextView) findViewById(R.id.bpmText);
|
||||
|
||||
mSender = new SensorDataFileSender(this);
|
||||
@@ -263,17 +271,6 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
}
|
||||
});
|
||||
|
||||
// detector for double clicks
|
||||
mDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
|
||||
|
||||
public boolean onDoubleTap(MotionEvent ev) {
|
||||
Log.d("Gesture", "onDoubleTap: " + ev.toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Enables Always-on
|
||||
setAmbientEnabled();
|
||||
}
|
||||
@@ -343,7 +340,7 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
if (mTapBpmEstimation > 0) {
|
||||
mCroller.setProgress(mTapBpmEstimation);
|
||||
mCroller.setLabel("Fertig");
|
||||
mVibrator.vibrate(10);
|
||||
mVibrator.vibrate(20);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -361,7 +358,7 @@ public class MainActivity extends WearableActivity implements WorkerFragment.OnF
|
||||
});
|
||||
|
||||
mTapBpm.clearTimestamps();
|
||||
mTapRecognized = false;
|
||||
mTapRecognized = true;
|
||||
/*
|
||||
mTapBpmThread.interrupt();
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package de.tonifetzer.conductorswatch;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -28,7 +26,7 @@ public class TapBpm implements Runnable {
|
||||
|
||||
if (mReceivedTabs.size() > calcNewBpmCounter) {
|
||||
|
||||
Long sumDifferenceMs = 0l;
|
||||
long sumDifferenceMs = 0L;
|
||||
for (int i = 0; i < mReceivedTabs.size() -1; ++i) {
|
||||
sumDifferenceMs += mReceivedTabs.get(i + 1)- mReceivedTabs.get(i);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ public class WorkerFragment extends Fragment implements Metronome.OnMetronomeLis
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// init bpm estimator and listener
|
||||
//TODO: hier ein Thread draus machen?
|
||||
mEstimator = new Estimator(getContext());
|
||||
mEstimator.add(this);
|
||||
mBpmList = new Vector<Double>();
|
||||
|
||||
@@ -10,7 +10,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.3'
|
||||
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Fri Apr 27 14:10:48 CEST 2018
|
||||
#Sun Jan 27 12:15:23 CET 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||
|
||||
Reference in New Issue
Block a user