Add prebuilt browseable samples as static files.

Change-Id: Ifb5382223343400882834d2dd9c182c3df602e34
This commit is contained in:
Dirk Dougherty
2013-10-29 20:56:17 -07:00
parent 7165109e6d
commit 4b737b695e
840 changed files with 35304 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.basicgesturedetect;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.GestureDetector;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import com.example.android.common.logger.Log;
import com.example.android.common.logger.LogFragment;
public class BasicGestureDetectFragment extends Fragment{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View gestureView = getActivity().findViewById(R.id.sample_output);
gestureView.setClickable(true);
gestureView.setFocusable(true);
// BEGIN_INCLUDE(init_detector)
// First create the GestureListener that will include all our callbacks.
// Then create the GestureDetector, which takes that listener as an argument.
GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener();
final GestureDetector gd = new GestureDetector(getActivity(), gestureListener);
/* For the view where gestures will occur, create an onTouchListener that sends
* all motion events to the gesture detector. When the gesture detector
* actually detects an event, it will use the callbacks you created in the
* SimpleOnGestureListener to alert your application.
*/
gestureView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
gd.onTouchEvent(motionEvent);
return false;
}
});
// END_INCLUDE(init_detector)
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.sample_action) {
clearLog();
}
return true;
}
public void clearLog() {
LogFragment logFragment = ((LogFragment) getActivity().getSupportFragmentManager()
.findFragmentById(R.id.log_fragment));
logFragment.getLogView().setText("");
}
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.basicgesturedetect;
import android.view.GestureDetector;
import android.view.MotionEvent;
import com.example.android.common.logger.Log;
public class GestureListener extends GestureDetector.SimpleOnGestureListener {
public static final String TAG = "GestureListener";
// BEGIN_INCLUDE(init_gestureListener)
@Override
public boolean onSingleTapUp(MotionEvent e) {
// Up motion completing a single tap occurred.
Log.i(TAG, "Single Tap Up");
return false;
}
@Override
public void onLongPress(MotionEvent e) {
// Touch has been long enough to indicate a long press.
// Does not indicate motion is complete yet (no up event necessarily)
Log.i(TAG, "Long Press");
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
// User attempted to scroll
Log.i(TAG, "Scroll");
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// Fling event occurred. Notification of this one happens after an "up" event.
Log.i(TAG, "Fling");
return false;
}
@Override
public void onShowPress(MotionEvent e) {
// User performed a down event, and hasn't moved yet.
Log.i(TAG, "Show Press");
}
@Override
public boolean onDown(MotionEvent e) {
// "Down" event - User touched the screen.
Log.i(TAG, "Down");
return false;
}
@Override
public boolean onDoubleTap(MotionEvent e) {
// User tapped the screen twice.
Log.i(TAG, "Double tap");
return false;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
// Since double-tap is actually several events which are considered one aggregate
// gesture, there's a separate callback for an individual event within the doubletap
// occurring. This occurs for down, up, and move.
Log.i(TAG, "Event within double tap");
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// A confirmed single-tap event has occurred. Only called when the detector has
// determined that the first tap stands alone, and is not part of a double tap.
Log.i(TAG, "Single tap confirmed");
return false;
}
// END_INCLUDE(init_gestureListener)
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.basicgesturedetect;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import com.example.android.common.activities.SampleActivityBase;
import com.example.android.common.logger.Log;
import com.example.android.common.logger.LogFragment;
import com.example.android.common.logger.LogWrapper;
import com.example.android.common.logger.MessageOnlyLogFilter;
/**
* A simple launcher activity containing a summary sample description
* and a few action bar buttons.
*/
public class MainActivity extends SampleActivityBase {
public static final String TAG = "MainActivity";
public static final String FRAGTAG = "BasicGestureDetectFragment";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (getSupportFragmentManager().findFragmentByTag(FRAGTAG) == null ) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
BasicGestureDetectFragment fragment = new BasicGestureDetectFragment();
transaction.add(fragment, FRAGTAG);
transaction.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
// Wraps Android's native log framework.
LogWrapper logWrapper = new LogWrapper();
// Using Log, front-end to the logging chain, emulates android.util.log method signatures.
Log.setLogNode(logWrapper);
// Filter strips out everything except the message text.
MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
logWrapper.setNext(msgFilter);
// On screen logging via a fragment with a TextView.
LogFragment logFragment = (LogFragment) getSupportFragmentManager()
.findFragmentById(R.id.log_fragment);
msgFilter.setNext(logFragment.getLogView());
Log.i(TAG, "Ready");
}
}