当前位置: 首页>>代码示例>>Java>>正文


Java Gesture类代码示例

本文整理汇总了Java中com.google.android.glass.touchpad.Gesture的典型用法代码示例。如果您正苦于以下问题:Java Gesture类的具体用法?Java Gesture怎么用?Java Gesture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Gesture类属于com.google.android.glass.touchpad包,在下文中一共展示了Gesture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createGestureDetector

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
private GestureDetector createGestureDetector(final Context context) {
    GestureDetector gestureDetector = new GestureDetector(context);
    //Create a base listener for generic gestures
    gestureDetector.setBaseListener(new GestureDetector.BaseListener() {
        @Override
        public boolean onGesture(Gesture gesture) {
            if (gesture == Gesture.TAP) {
                AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                audio.playSoundEffect(Sounds.DISALLOWED);
            }
            return false;
        }
    });

    return gestureDetector;
}
 
开发者ID:chenkel,项目名称:Lokalisierung-mit-Wearables,代码行数:17,代码来源:BaseGlassActivity.java

示例2: createGestureDetector

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
private GestureDetector createGestureDetector(Context context) {
    GestureDetector gestureDetector = new GestureDetector(context);
    gestureDetector.setBaseListener(new GestureDetector.BaseListener() {
        @Override
        public boolean onGesture(Gesture gesture) {
            if(cameraView != null) {
                if(gesture == Gesture.TAP){
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    if(intent != null) {
                        startActivityForResult(intent, TAKE_PICTURE_REQUEST);
                    }
                    return true;
                }
            }
            return false;
        }
    });
    return gestureDetector;
}
 
开发者ID:akashlevy,项目名称:WhoDatFace,代码行数:20,代码来源:whodatcamera.java

示例3: onGesture

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture gesture) {
  Log.d("GestureInputActivity", "BaseListener called");
  Log.d("GestureInputActivity", getResources().getString(_gestureMap.get(gesture)));

  // Show the gesture in the Glass interface
  _titleTextView.setText(_gestureMap.get(gesture));
  _instructionsTextView.setText(R.string.empty_string);

  if (Gesture.SWIPE_DOWN == gesture) {
    _instructionsTextView.setText(R.string.swipe_to_go_back);
    _swipeDownCount++;

    return (_swipeDownCount < 2);
  }
  else {
    _swipeDownCount = 0;
  }

  return true;
}
 
开发者ID:Mobilevangelist,项目名称:google-glass-kitchen-sink,代码行数:22,代码来源:GestureInputActivity.java

示例4: createGestureDetector

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
private GestureDetector createGestureDetector(Context context){
    GestureDetector gestureDetector = new GestureDetector(context);
    //Create a base listener for generic gestures
    gestureDetector.setBaseListener( new GestureDetector.BaseListener() {
        @Override
        public boolean onGesture(Gesture gesture) {
            Log.d(TAG,"gesture = " + gesture);
            switch (gesture) {
                case TAP:
                    Log.d(TAG,"TAP called.");
                    if(id != 0){
                    	timerHandler.removeCallbacks(timerRunnable);
                    	createCards("��leminiz yap�l�yor...","L�tfen Bekleyin...",R.drawable.refresh);
                        String addToChartUrl = "http://54.72.214.188:3101/glass/order/"+id+"?token=" + token;
                        id = 0;
                        remainingTime = 10;
            			new HttpAsyncTask().execute(addToChartUrl);
                    }
                    return true;
            }

            return false;
        }
    });
    return gestureDetector;
}
 
开发者ID:CagataySonmez,项目名称:MobilHackathon2014,代码行数:27,代码来源:ResultsActivity.java

示例5: createGestureDetector

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
private GestureDetector createGestureDetector(Context context) {
	GestureDetector gestureDetector = new GestureDetector(context);
	//Create a base listener for generic gestures
	gestureDetector.setBaseListener( new GestureDetector.BaseListener() {
		@Override
		public boolean onGesture(Gesture gesture) {
			if (gesture == Gesture.TAP) {
				//On tap, play tap sound and open menu
				AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
				audio.playSoundEffect(Sounds.TAP);
				openOptionsMenu();
				return true;
			}
			return false;
		}
	});
	return gestureDetector;
}
 
开发者ID:RIVeR-Lab,项目名称:google_glass_driver,代码行数:19,代码来源:MainActivity.java

示例6: handleGameGesture

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
/**
 * Overridden to only allow the tap gesture on the "Tap to score" screen and to only allow the
 * swipe gesture on the "Swipe to pass" screen. The game is also automatically ended when the
 * final card is either tapped or swiped.
 */
@Override
protected void handleGameGesture(Gesture gesture) {
    int phraseIndex = getCharadesModel().getCurrentPhraseIndex();
    switch (gesture) {
        case TAP:
            if (phraseIndex != SWIPE_TO_PASS_CARD) {
                score();
            }
            break;
        case SWIPE_RIGHT:
            if (phraseIndex == SWIPE_TO_PASS_CARD) {
                pass();
            }
            break;
    }

    // Finish the tutorial if we transitioned away from the final card.
    if (phraseIndex == getCharadesModel().getPhraseCount() - 1) {
        finish();
    }
}
 
开发者ID:locateflow,项目名称:gdk-charades-sample-master,代码行数:27,代码来源:TutorialActivity.java

示例7: onGesture

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture gesture) {
    if (areGesturesEnabled()) {
        switch (gesture) {
            case SWIPE_LEFT:
                // Swipe left (backward) is always handled here to provide a brief
                // "disallowed" tug animation.
                tugPhrase();
                return true;
            case TAP:
            case SWIPE_RIGHT:
                // Delegate tap and swipe right (forward) to the subclass so that the
                // tutorial and actual game can handle them differently.
                handleGameGesture(gesture);
                return true;
            default:
                return false;
        }
    }
    return false;
}
 
开发者ID:locateflow,项目名称:gdk-charades-sample-master,代码行数:22,代码来源:BaseGameActivity.java

示例8: createGestureDetector

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
private GestureDetector createGestureDetector(Context context) {
    GestureDetector gestureDetector = new GestureDetector(context);

    gestureDetector.setBaseListener(new GestureDetector.BaseListener() {
        @Override
        public boolean onGesture(Gesture gesture) {
            if (gesture == Gesture.TAP || gesture == Gesture.LONG_PRESS) {
                return onTap();
            } else if (gesture == Gesture.TWO_TAP) {
                return onTwoTap();
            } else if (gesture == Gesture.SWIPE_RIGHT) {
                return onSwipeRight();
            } else if (gesture == Gesture.SWIPE_LEFT) {
                return onSwipeLeft();
            } else if (gesture == Gesture.SWIPE_DOWN) {
                return onSwipeDown();
            }
            return false;
        }
    });
    return gestureDetector;
}
 
开发者ID:pt2121,项目名称:NYC-Glass-Challenge-Oct2014,代码行数:23,代码来源:BaseGlassActivity.java

示例9: onGesture

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
/**
 * This method includes special behavior to handle SWIPE_DOWN gestures. The first time the user
 * swipes down, we return true so that the user can still see the feedback in the gesture
 * label, and we fade in an instructional tip label. The second time the user swipes down, we
 * return false so that the activity can handle the event and return to the previous activity.
 */
@Override
public boolean onGesture(Gesture gesture) {
    mLastGesture.setText(gesture.name());

    if (gesture == Gesture.SWIPE_DOWN) {
        if (!mSwipedDownOnce) {
            mSwipeAgainTip.animate().alpha(1.0f);
            mSwipedDownOnce = true;
            return true;
        } else {
            return false;
        }
    } else {
        return true;
    }
}
 
开发者ID:googleglass,项目名称:gdk-apidemo-sample,代码行数:23,代码来源:DiscreteGesturesActivity.java

示例10: onGesture

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture gesture) {
    switch (gesture) {
        case TAP:
            Intent resultIntent = new Intent();
            resultIntent.putExtra(EXTRA_SELECTED_VALUE, getView().getSelectedItemPosition());
            setResultInternal(RESULT_OK, resultIntent);
            playSoundEffect(Sounds.TAP);
            finish();
            return true;
        case SWIPE_DOWN:
            setResultInternal(RESULT_CANCELED, null);
            playSoundEffect(Sounds.DISMISSED);
            finish();
            return true;
        default:
            return false;
    }
}
 
开发者ID:longzheng,项目名称:PTVGlass,代码行数:20,代码来源:SelectValueActivity.java

示例11: testOnGestureTapSupported

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@UiThreadTest
public void testOnGestureTapSupported() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);

    activity.onResume();
    activity.getView().setSelection(0);

    assertTrue(activity.onGesture(Gesture.TAP));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue());

    Intent startedIntent = getStartedActivityIntent();

    assertNotNull(startedIntent);
    assertEquals(
            SelectValueActivity.class.getName(), startedIntent.getComponent().getClassName());
    assertEquals(
            SetTimerScrollAdapter.TimeComponents.HOURS.getMaxValue(),
            startedIntent.getIntExtra(SelectValueActivity.EXTRA_COUNT, 0));
    assertEquals(
            0, startedIntent.getIntExtra(SelectValueActivity.EXTRA_INITIAL_VALUE, 0));
    assertEquals(SetTimerActivity.SELECT_VALUE, getStartedActivityRequest());
    assertFalse(isFinishCalled());
}
 
开发者ID:longzheng,项目名称:PTVGlass,代码行数:25,代码来源:SetTimerActivityTest.java

示例12: testOnGestureTapSupportedSelectValueForMinutes

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@UiThreadTest
public void testOnGestureTapSupportedSelectValueForMinutes() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);

    activity.onResume();
    activity.getView().setSelection(1);

    assertTrue(activity.onGesture(Gesture.TAP));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue());

    Intent startedIntent = getStartedActivityIntent();

    assertNotNull(startedIntent);
    assertEquals(
            SelectValueActivity.class.getName(), startedIntent.getComponent().getClassName());
    assertEquals(
            SetTimerScrollAdapter.TimeComponents.MINUTES.getMaxValue(),
            startedIntent.getIntExtra(SelectValueActivity.EXTRA_COUNT, 0));
    assertEquals(
            5, startedIntent.getIntExtra(SelectValueActivity.EXTRA_INITIAL_VALUE, 0));
    assertEquals(SetTimerActivity.SELECT_VALUE, getStartedActivityRequest());
    assertFalse(isFinishCalled());
}
 
开发者ID:longzheng,项目名称:PTVGlass,代码行数:25,代码来源:SetTimerActivityTest.java

示例13: testOnGestureSwipeDownSupported

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@UiThreadTest
public void testOnGestureSwipeDownSupported() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);
    SetTimerScrollAdapter adapter = (SetTimerScrollAdapter) activity.getView().getAdapter();
    long expectedDuration = TimeUnit.SECONDS.toMillis(45);

    adapter.setDurationMillis(expectedDuration);
    assertTrue(activity.onGesture(Gesture.SWIPE_DOWN));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.DISMISSED, activity.mPlayedSoundEffects.get(0).intValue());

    assertTrue(isFinishCalled());
    assertEquals(Activity.RESULT_OK, activity.mResultCode);
    assertNotNull(activity.mResultIntent);
    assertEquals(
            expectedDuration,
            activity.mResultIntent.getLongExtra(SetTimerActivity.EXTRA_DURATION_MILLIS, 0));
}
 
开发者ID:longzheng,项目名称:PTVGlass,代码行数:19,代码来源:SetTimerActivityTest.java

示例14: testOnGestureTapSupported

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@UiThreadTest
public void testOnGestureTapSupported() {
    MockSelectValueActivity activity = startActivity(mActivityIntent, null, null);
    int expectedSelectedValue = 35;

    activity.onResume();
    activity.getView().setSelection(expectedSelectedValue);

    assertTrue(activity.onGesture(Gesture.TAP));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue());

    assertTrue(isFinishCalled());
    assertEquals(Activity.RESULT_OK, activity.mResultCode);
    assertNotNull(activity.mResultIntent);
    assertEquals(
            expectedSelectedValue,
            activity.mResultIntent.getIntExtra(SelectValueActivity.EXTRA_SELECTED_VALUE, 0));
}
 
开发者ID:longzheng,项目名称:PTVGlass,代码行数:20,代码来源:SelectValueActivityTest.java

示例15: onGesture

import com.google.android.glass.touchpad.Gesture; //导入依赖的package包/类
@Override
public boolean onGesture(Gesture gesture) {
    if (gesture == Gesture.TAP) {
        int position = mView.getSelectedItemPosition();
        SetTimerScrollAdapter.TimeComponents component =
                (SetTimerScrollAdapter.TimeComponents) mAdapter.getItem(position);
        Intent selectValueIntent = new Intent(this, SelectValueActivity.class);

        selectValueIntent.putExtra(SelectValueActivity.EXTRA_COUNT, component.getMaxValue());
        selectValueIntent.putExtra(
                SelectValueActivity.EXTRA_INITIAL_VALUE,
                (int) mAdapter.getTimeComponent(component));
        startActivityForResult(selectValueIntent, SELECT_VALUE);
        mAudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
        return true;
    }
    return false;
}
 
开发者ID:longzheng,项目名称:PTVGlass,代码行数:19,代码来源:SetTimerActivity.java


注:本文中的com.google.android.glass.touchpad.Gesture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。