난 당신이 새 것으로 이미 존재하는 제스처를 교체하려면, 제대로 이해한다면?
그래서 사용자가 라이브러리에없는 제스처를 입력하면 앱에서 사용자가 바꿀 제스처를 선택하도록 사용자에게 요청합니다. 귀하의 질문에서 사용자가 소문자 a
을 그렸을 때 (그리고 a
이 라이브러리에없는 경우) 사용자가 현재 지원하는 사용 가능한 모든 제스처/문자의 목록이 표시된다고 가정합니다. 그런 다음 사용자가 자본을 A
으로 선택하면 대문자 인 A
을 소문자 a
으로 바꿔야합니다. 다음 코드에서 oldGesture는 A
에 해당하는 제스처입니다. 그리고 newGesture
은 방금 그린 제스처입니다.
그 과정은 다음과 같습니다. 이전 제스처를 삭제하고 이전 제스처의 이름을 사용하여 새 제스처를 추가하십시오. 제스처를 삭제하려면 GestureLibrary.removeGesture (문자열, 제스처)를 사용 : GestureLibrary.load를 사용
// Wrapper to hold a gesture
static class GestureHolder {
String name;
Gesture gesture;
}
로드 동작() :
public void onGesturePerformed(GestureOverlayView overlay, final Gesture gesture) {
ArrayList<Prediction> predictions = gesturelib.recognize(gesture);
if (predictions.size() > 1) {
for(Prediction prediction: predictions){
if (prediction.score > ...) {
} else {
if (user wants to replace) {
showListWithAllGestures(gesture);
}
}
}
}
}
public void showListWithAllGestures(Gesture newGesture) {
....
....
// User picks a gesture
Gesture oldGesture = userPickedItem.gesture;
String gestureName = userPickedItem.name;
// delete the gesture
gesturelib.removeGesture(gestureName, oldGesture);
gesturelib.save();
// add gesture
gesturelib.addGesture(gestureName, newGesture);
gesturelib.save();
}
가능한 모든 제스처의 목록을 얻으려면
if (gesturelib.load()) {
for (String name : gesturelib.getGestureEntries()) {
for (Gesture gesture : gesturelib.getGestures(name)) {
final GestureHolder gestureHolder = new GestureHolder();
gestureHolder.gesture = gesture;
gestureHolder.name = name;
// Add `gestureHolder` to a list
}
}
// Return the list that holds GestureHolder objects
}
편집 :
죄송하지만, 내가 제안한 내용을 확인하십시오 : if (wants to replace)
이 코드의 잘못된 위치에서 수행되고 있습니다.
if (predictions.size() > 1) {
// To check whether a match was found
boolean gotAMatch = false;
for(int i = 0; i < predictions.size() && !gotAMatch; i++){
if (prediction.score > ...) {
....
....
// Found a match, look no more
gotAMatch = true;
}
}
// If a match wasn't found, ask the user s/he wants to add it
if (!gotAMatch) {
if (user wants to replace) {
showListWithAllGestures(gesture);
}
}
}
감사를 줄 수 있습니다. – ridoy
(사용자가 교체하기를 원한다면) 조건을 설명 할 수 있습니까? 그 이유는 매 n-1 건마다 발생하기 때문입니다. 제가 6 개의 템플릿을 가지고 있고 단 하나의 템플릿을 그린다면 1 번째 예 (predict.score> 1.0) 해당 템플릿을 잡아 다음 다른 5 템플릿에 대한 조건이 발생합니다. 어떻게 관리 할 수 있습니까? – ridoy
현상금을 수여 할 수 있도록 답변을 삭제하십시오. – ridoy