本文整理汇总了Java中com.squareup.seismic.ShakeDetector类的典型用法代码示例。如果您正苦于以下问题:Java ShakeDetector类的具体用法?Java ShakeDetector怎么用?Java ShakeDetector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShakeDetector类属于com.squareup.seismic包,在下文中一共展示了ShakeDetector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_match);
ButterKnife.bind(this);
MatchFragment matchFragment =MatchFragment.newInstance();
makeFullScreen();
ShakeDetector shakeDetector=new ShakeDetector(this);
SensorManager sensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
shakeDetector.start(sensorManager);
if(isFirstStart){
//to avoid overlapping of fragments' views
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, matchFragment).commit();
}else {
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, matchFragment).commit();
}
isFirstStart=true;
}
示例2: setUpSeekBars
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
public void setUpSeekBars() {
shakeNumber = Prefs.with(this).readInt(PreferencesUtils.PREFERENCES_SHAKE_NUMBER, 6);
sensorSensitivity = Prefs.with(this).readInt(PreferencesUtils.PREFERENCES_SENSOR_SENSITIVITY,
ShakeDetector.SENSITIVITY_LIGHT);
timeUntilRestart = Prefs.with(this).readInt(PreferencesUtils.PREFERENCES_TIME_TO_RESTART, 500);
seekbarShakeNumber.setKeyProgressIncrement(1);
seekbarSensitivity.setKeyProgressIncrement(1);
seekbarTimeUntilRestart.setKeyProgressIncrement(1);
seekbarShakeNumber.setProgress(shakeNumber - 3);
seekbarSensitivity.setProgress(sensorSensitivity - 7);
seekbarTimeUntilRestart.setProgress((timeUntilRestart - 250) / 250);
tvShakeNumber.setText(String.valueOf(shakeNumber));
tvSensitivity.setText(String.valueOf(sensorSensitivity));
tvTimeUntilRestart.setText(String.valueOf(timeUntilRestart));
}
示例3: onStartCommand
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null && (intent.hasExtra(SHAKE_COUNT_THRESHOLD_EXTRA) &&
intent.hasExtra(SHAKE_RESET_THRESHOLD_EXTRA) &&
intent.hasExtra(SENSOR_SENSITIVITY_EXTRA))) {
shakeCountThreshold = intent.getExtras().getInt(SHAKE_COUNT_THRESHOLD_EXTRA);
sensorSensitivity = intent.getExtras().getInt(SENSOR_SENSITIVITY_EXTRA);
shakeResetThreshold = intent.getExtras().getInt(SHAKE_RESET_THRESHOLD_EXTRA);
testing = true;
} else {
shakeCountThreshold = Prefs.with(this).readInt(PreferencesUtils.PREFERENCES_SHAKE_NUMBER, 6);
sensorSensitivity = Prefs.with(this).readInt(PreferencesUtils.PREFERENCES_SENSOR_SENSITIVITY,
ShakeDetector.SENSITIVITY_LIGHT);
shakeResetThreshold = Prefs.with(this).readInt(PreferencesUtils.PREFERENCES_TIME_TO_RESTART, 500);
}
listenForShakes();
return START_STICKY_COMPATIBILITY;
}
示例4: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
shakeDetectorListener = new ShakeDetectorListener(this, new ShakeDetectorListener.ShakeDetectorCallback() {
@Override
public void onStart() {
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onFinish() {
progressBar.setVisibility(View.GONE);
}
});
shakeDetector = new ShakeDetector(shakeDetectorListener);
initView();
}
示例5: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
SharedPreferences defualtPref = PreferenceManager.getDefaultSharedPreferences(this);
defualtPref.edit().putString("Test", "Done").apply();
SharedPreferences anotherPref = getSharedPreferences("Prasham", MODE_PRIVATE);
anotherPref.edit().putString("Test", "Love you life").apply();
anotherPref.edit().putInt("Test Int", 1138).apply();
anotherPref.edit().putFloat("Test Float", 11.38F).apply();
anotherPref.edit().putLong("Test Long", 113834).apply();
anotherPref.edit().putBoolean("Test Boolean", true).apply();
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
ShakeDetector sd = new ShakeDetector(this);
sd.start(sensorManager);
}
示例6: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("");
setContentView(R.layout.activity_home);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
metaball.setPaintMode(0);
FilterModel filter = new FilterModel(this);
commonAdapter = new FiltersAdapter(presenter(), filter.getFilters());
framesAdapter = new FramesAdapter(presenter(), getResources().getStringArray(R.array.colors));
recycler.setItemAnimator(new DefaultItemAnimator());
recycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
recycler.setHasFixedSize(true);
seek.setOnProgressChangeListener(presenter().onFilterAdjusted);
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
shakeDetector = new ShakeDetector(this);
zoomImage.setNestedScrollView(nestedScrollView);
}
示例7: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gson = new GsonBuilder().setPrettyPrinting().create();
t = (TextView) findViewById(R.id.tv);
/*fakeService.returnStringList().subscribe(new Action1<List<String>>() {
@Override
public void call(List<String> strings) {
setText(strings);
}
});*/
fakeService.returnMyModelObservable().subscribe(new Action1<MyModel>() {
@Override
public void call(MyModel myModel) {
setText(myModel);
}
});
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
ShakeDetector sd = new ShakeDetector(this);
sd.start(sensorManager);
}
示例8: NotifyDeveloperHandler
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
NotifyDeveloperHandler(Application context, Iterable<String> emailAddress, LogLevel minLevel, final ActivityStateListener stateListener) {
this.context = context;
this.emailAddress = Lists.newArrayList(emailAddress);
this.filter = new AtLeastFilter(minLevel);
this.activityState = new WeakReference<>(stateListener);
this.attachmentClassList = new ArrayList<>();
this.shakeDetector = new ShakeDetector(new ShakeDetector.Listener() {
@Override
public void hearShake() {
ActivityStateListener listener = activityState.get();
if (listener != null) {
if (listener.isAppInForeground()) {
beginPublishOnMainThread(new LogRecord(Level.INFO, "Report a problem with app"));
} else {
Log.i(TAG, "Ignore shake event - the app appears to be in background");
}
} else {
Log.i(TAG, "Ignore shake event - can't detect if app is in foreground (API < 14)");
}
}
});
this.emailSubject = context.getString(R.string.slf4android_email_subject) + context.getPackageName();
this.emailBody = context.getString(R.string.slf4android_email_extra_text);
}
示例9: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(BuildConfig.DEBUG) {
Log.i(this.getClass().getName(), "received intent on create");
}
cDb = new CreditDatabase(getApplicationContext());
setUpLocalBroadCastReceiver();
startNfcIntentService(getIntent());
setUpAddDataThingies();
setUpStatistics();
Helper.ratingCounter(this);
if(!Helper.isNfcEnabled(this)){
Helper.showEnableNfcDialog(this);
}
setUpNfcStuff();
setUpAdView();
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
ShakeDetector sd = new ShakeDetector(this);
sd.start(sensorManager);
}
示例10: listenForShakes
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
private void listenForShakes() {
final SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
shakeDetector = new ShakeDetector(this);
shakeDetector.setSensitivity(sensorSensitivity);
shakeDetector.start(sensorManager);
}
示例11: start
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
/**
* (Required) Start listening for device shaking. You MUST call <code>assemble</code> before calling this method.
*/
public void start() {
if (!assembled) {
throw new IllegalStateException("You MUST call assemble before calling start.");
}
if (startAttempted) {
logger.d("You have already attempted to start this BugShaker instance. Calling start "
+ "again is a no-op.");
return;
}
if (emailCapabilitiesProvider.canSendEmails()) {
application.registerActivityLifecycleCallbacks(simpleActivityLifecycleCallback);
final SensorManager sensorManager
= (SensorManager) application.getSystemService(SENSOR_SERVICE);
final ShakeDetector shakeDetector = new ShakeDetector(this);
final boolean didStart = shakeDetector.start(sensorManager);
if (didStart) {
logger.d("Shake detection successfully started!");
} else {
logger.e("Error starting shake detection: hardware does not support detection.");
}
} else {
logger.e("Error starting shake detection: device cannot send emails.");
}
startAttempted = true;
}
示例12: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image);
int type = getIntent().getIntExtra("type", NONE);
isRandomizable = (type & RANDOM) == RANDOM;
imageData = (ImageData)getIntent().getSerializableExtra("imageData");
filename = String.format("yandere_%s.%s", imageData.id, imageData.file_ext);
downloadManager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE);
handler = new Handler();
sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
shakeDetectorListener = new ShakeDetectorListener(this, new ShakeDetectorListener.ShakeDetectorCallback() {
@Override
public void onStart() {
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onFinish() {
progressBar.setVisibility(View.GONE);
finish();
}
});
shakeDetector = new ShakeDetector(shakeDetectorListener);
scheduleTaskExecutor = Executors.newScheduledThreadPool(5);
initView();
}
示例13: init
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
/**
* Starts listening shakes to open LynxActivity if a shake is detected and if the ShakeDetector is
* enabled.
*/
public void init(final LynxConfig lynxConfig) {
ShakeDetector shakeDetector = new ShakeDetector(new ShakeDetector.Listener() {
@Override public void hearShake() {
if (isEnabled) {
openLynxActivity(lynxConfig);
}
}
});
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
shakeDetector.start(sensorManager);
}
示例14: onCreate
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Timber.tag(getClass().getSimpleName());
Timber.d(getClass().getSimpleName() + " is creating");
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
ShakeDetector shakeDetector = new ShakeDetector(this);
shakeDetector.start(sensorManager);
listenShowEmergencyButton();
tombolPresenter = new TombolPresenter(this);
}
示例15: onViewReady
import com.squareup.seismic.ShakeDetector; //导入依赖的package包/类
@Override
protected void onViewReady(Bundle savedInstanceState) {
CacheManager.pluck().setShakeToNotify(false);
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
ShakeDetector shakeDetector = new ShakeDetector(this);
shakeDetector.start(sensorManager);
}