You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
run whitespace_format.py --add-new-line-marker-at-end-of-file --remove-trailing-whitespace --remove-trailing-empty-lines --new-line-marker=linux --normalize-non-standard-whitespace=remove on src/
This commit is contained in:
@@ -30,7 +30,7 @@ import android.view.ViewGroup;
|
||||
/**
|
||||
* An abstract base class for spinner widgets. SDK users will probably not
|
||||
* need to use this class.
|
||||
*
|
||||
*
|
||||
* @attr ref android.R.styleable#AbsSpinner_entries
|
||||
*/
|
||||
public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
@@ -102,12 +102,12 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
mAdapter.unregisterDataSetObserver(mDataSetObserver);
|
||||
resetList();
|
||||
}
|
||||
|
||||
|
||||
mAdapter = adapter;
|
||||
|
||||
|
||||
mOldSelectedPosition = INVALID_POSITION;
|
||||
mOldSelectedRowId = INVALID_ROW_ID;
|
||||
|
||||
|
||||
if (mAdapter != null) {
|
||||
mOldItemCount = mItemCount;
|
||||
mItemCount = mAdapter.getCount();
|
||||
@@ -120,14 +120,14 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
|
||||
setSelectedPositionInt(position);
|
||||
setNextSelectedPositionInt(position);
|
||||
|
||||
|
||||
if (mItemCount == 0) {
|
||||
// Nothing selected
|
||||
checkSelectionChanged();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
checkFocus();
|
||||
checkFocus();
|
||||
resetList();
|
||||
// Nothing selected
|
||||
checkSelectionChanged();
|
||||
@@ -142,26 +142,26 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
void resetList() {
|
||||
mDataChanged = false;
|
||||
mNeedSync = false;
|
||||
|
||||
|
||||
// removeAllViewsInLayout();
|
||||
for (int i = getChildCount() - 1; i >= 0; i--) {
|
||||
removeViewInLayout(getChildAt(i));
|
||||
}
|
||||
mOldSelectedPosition = INVALID_POSITION;
|
||||
mOldSelectedRowId = INVALID_ROW_ID;
|
||||
|
||||
|
||||
setSelectedPositionInt(INVALID_POSITION);
|
||||
setNextSelectedPositionInt(INVALID_POSITION);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @see android.view.View#measure(int, int)
|
||||
*
|
||||
*
|
||||
* Figure out the dimensions of this Spinner. The width comes from
|
||||
* the widthMeasureSpec as Spinnners can't have their width set to
|
||||
* UNSPECIFIED. The height is based on the height of the selected item
|
||||
* plus padding.
|
||||
* plus padding.
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
@@ -181,11 +181,11 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
if (mDataChanged) {
|
||||
handleDataChanged();
|
||||
}
|
||||
|
||||
|
||||
int preferredHeight = 0;
|
||||
int preferredWidth = 0;
|
||||
boolean needsMeasuring = true;
|
||||
|
||||
|
||||
int selectedPosition = getSelectedItemPosition();
|
||||
if (selectedPosition >= 0 && mAdapter != null && selectedPosition < mAdapter.getCount()) {
|
||||
// Try looking in the recycler. (Maybe we were measured once already)
|
||||
@@ -205,14 +205,14 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
mBlockLayoutRequests = false;
|
||||
}
|
||||
measureChild(view, widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
|
||||
preferredHeight = getChildHeight(view) + mSpinnerPadding.top + mSpinnerPadding.bottom;
|
||||
preferredWidth = getChildWidth(view) + mSpinnerPadding.left + mSpinnerPadding.right;
|
||||
|
||||
|
||||
needsMeasuring = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (needsMeasuring) {
|
||||
// No views -- just use padding
|
||||
preferredHeight = mSpinnerPadding.top + mSpinnerPadding.bottom;
|
||||
@@ -235,18 +235,18 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
int getChildHeight(View child) {
|
||||
return child.getMeasuredHeight();
|
||||
}
|
||||
|
||||
|
||||
int getChildWidth(View child) {
|
||||
return child.getMeasuredWidth();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
void recycleAllViews() {
|
||||
final int childCount = getChildCount();
|
||||
final AbsSpinner.RecycleBin recycleBin = mRecycler;
|
||||
@@ -257,7 +257,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
View v = getChildAt(i);
|
||||
int index = position + i;
|
||||
recycleBin.put(index, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,14 +276,14 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
requestLayout();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Makes the item at the supplied position selected.
|
||||
*
|
||||
*
|
||||
* @param position Position to select
|
||||
* @param animate Should the transition be animated
|
||||
*
|
||||
*
|
||||
*/
|
||||
void setSelectionInt(int position, boolean animate) {
|
||||
if (position != mOldSelectedPosition) {
|
||||
@@ -305,11 +305,11 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override to prevent spamming ourselves with layout requests
|
||||
* as we place views
|
||||
*
|
||||
*
|
||||
* @see android.view.View#requestLayout()
|
||||
*/
|
||||
@Override
|
||||
@@ -331,7 +331,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
|
||||
/**
|
||||
* Maps a point to a position in the list.
|
||||
*
|
||||
*
|
||||
* @param x X in local coordinate
|
||||
* @param y Y in local coordinate
|
||||
* @return The position of the item which contains the specified point, or
|
||||
@@ -353,7 +353,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
return mFirstPosition + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return INVALID_POSITION;
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
public void put(int position, View v) {
|
||||
mScrapHeap.put(position, v);
|
||||
}
|
||||
|
||||
|
||||
View get(int position) {
|
||||
// System.out.print("Looking for " + position);
|
||||
View result = mScrapHeap.get(position);
|
||||
@@ -388,4 +388,4 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
scrapHeap.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.view.ViewGroup;
|
||||
* underlying data for that view. The Adapter provides access to the data items.
|
||||
* The Adapter is also responsible for making a {@link android.view.View} for
|
||||
* each item in the data set.
|
||||
*
|
||||
*
|
||||
* @see android.widget.ArrayAdapter
|
||||
* @see android.widget.CursorAdapter
|
||||
* @see android.widget.SimpleCursorAdapter
|
||||
@@ -46,15 +46,15 @@ public interface Adapter {
|
||||
void unregisterDataSetObserver(DataSetObserver observer);
|
||||
/**
|
||||
* How many items are in the data set represented by this Adapter.
|
||||
*
|
||||
*
|
||||
* @return Count of items.
|
||||
*/
|
||||
int getCount();
|
||||
int getCount();
|
||||
|
||||
/**
|
||||
* Get the data item associated with the specified position in the data set.
|
||||
*
|
||||
* @param position Position of the item whose data we want within the adapter's
|
||||
*
|
||||
* @param position Position of the item whose data we want within the adapter's
|
||||
* data set.
|
||||
* @return The data at the specified position.
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ public interface Adapter {
|
||||
|
||||
/**
|
||||
* Get the row id associated with the specified position in the list.
|
||||
*
|
||||
*
|
||||
* @param position The position of the item within the adapter's data set whose row id we want.
|
||||
* @return The id of the item at the specified position.
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ public interface Adapter {
|
||||
/**
|
||||
* Indicates whether the item ids are stable across changes to the
|
||||
* underlying data.
|
||||
*
|
||||
*
|
||||
* @return True if the same id always refers to the same object.
|
||||
*/
|
||||
boolean hasStableIds();
|
||||
@@ -82,7 +82,7 @@ public interface Adapter {
|
||||
* parent View (GridView, ListView...) will apply default layout parameters unless you use
|
||||
* {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)}
|
||||
* to specify a root view and to prevent attachment to the root.
|
||||
*
|
||||
*
|
||||
* @param position The position of the item within the adapter's data set of the item whose view
|
||||
* we want.
|
||||
* @param convertView The old view to reuse, if possible. Note: You should check that this view
|
||||
@@ -100,7 +100,7 @@ public interface Adapter {
|
||||
* view. For example, this can be used if the client does not want a
|
||||
* particular view to be given for conversion in
|
||||
* {@link #getView(int, View, ViewGroup)}.
|
||||
*
|
||||
*
|
||||
* @see #getItemViewType(int)
|
||||
* @see #getViewTypeCount()
|
||||
*/
|
||||
@@ -108,7 +108,7 @@ public interface Adapter {
|
||||
|
||||
/**
|
||||
* Get the type of View that will be created by {@link #getView} for the specified item.
|
||||
*
|
||||
*
|
||||
* @param position The position of the item within the adapter's data set whose view type we
|
||||
* want.
|
||||
* @return An integer representing the type of View. Two views should share the same type if one
|
||||
@@ -130,13 +130,13 @@ public interface Adapter {
|
||||
* This method will only be called when when the adapter is set on the
|
||||
* the {@link AdapterView}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return The number of types of Views that will be created by this adapter
|
||||
*/
|
||||
int getViewTypeCount();
|
||||
|
||||
static final int NO_SELECTION = Integer.MIN_VALUE;
|
||||
|
||||
|
||||
/**
|
||||
* @return true if this adapter doesn't contain any data. This is used to determine
|
||||
* whether the empty view should be displayed. A typical implementation will return
|
||||
|
||||
@@ -185,7 +185,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
||||
* The last selected position we used when notifying
|
||||
*/
|
||||
int mOldSelectedPosition = INVALID_POSITION;
|
||||
|
||||
|
||||
/**
|
||||
* The id of the last selected position we used when notifying
|
||||
*/
|
||||
@@ -702,7 +702,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
||||
// Force one here to make sure that the state of the list matches
|
||||
// the state of the adapter.
|
||||
if (mDataChanged) {
|
||||
this.onLayout(false, getLeft(), getTop(), getRight(), getBottom());
|
||||
this.onLayout(false, getLeft(), getTop(), getRight(), getBottom());
|
||||
}
|
||||
} else {
|
||||
if (mEmptyView != null) mEmptyView.setVisibility(View.GONE);
|
||||
@@ -1091,4 +1091,4 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,4 @@ public class AutoCompleteTextView extends EditText {
|
||||
|
||||
public void performCompletion() {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ public interface Checkable {
|
||||
public void setChecked(boolean checked);
|
||||
|
||||
public boolean isChecked();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import android.util.Log;
|
||||
*/
|
||||
public abstract class Filter {
|
||||
private static final String LOG_TAG = "Filter";
|
||||
|
||||
|
||||
private static final String THREAD_NAME = "Filter";
|
||||
private static final int FILTER_TOKEN = 0xD0D0F00D;
|
||||
private static final int FINISH_TOKEN = 0xDEADBEEF;
|
||||
@@ -103,16 +103,16 @@ public abstract class Filter {
|
||||
mThreadHandler = new RequestHandler(thread.getLooper());
|
||||
}
|
||||
final long delay = (mDelayer == null) ? 0 : mDelayer.getPostingDelay(constraint);
|
||||
|
||||
|
||||
Message message = mThreadHandler.obtainMessage(FILTER_TOKEN);
|
||||
|
||||
|
||||
RequestArguments args = new RequestArguments();
|
||||
// make sure we use an immutable copy of the constraint, so that
|
||||
// it doesn't change while the filter operation is in progress
|
||||
args.constraint = constraint != null ? constraint.toString() : null;
|
||||
args.listener = listener;
|
||||
message.obj = args;
|
||||
|
||||
|
||||
mThreadHandler.removeMessages(FILTER_TOKEN);
|
||||
mThreadHandler.removeMessages(FINISH_TOKEN);
|
||||
mThreadHandler.sendMessageDelayed(message, delay);
|
||||
@@ -204,7 +204,7 @@ public abstract class Filter {
|
||||
public RequestHandler(Looper looper) {
|
||||
super(looper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>Handles filtering requests by calling
|
||||
* {@link Filter#performFiltering} and then sending a message
|
||||
@@ -257,7 +257,7 @@ public abstract class Filter {
|
||||
* {@link Filter#publishResults(CharSequence,
|
||||
* android.widget.Filter.FilterResults)}
|
||||
* to post the results back in the UI and then notifying the listener,
|
||||
* if any.</p>
|
||||
* if any.</p>
|
||||
*
|
||||
* @param msg the filtering results
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -224,7 +224,7 @@ public class HeaderViewListAdapter implements ListAdapter, Filterable {
|
||||
mAdapter.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ListAdapter getWrappedAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ public class ListView extends AbsListView {
|
||||
* data backing this list and for producing a view to represent an
|
||||
* item in that data set.
|
||||
*
|
||||
* @see #getAdapter()
|
||||
* @see #getAdapter()
|
||||
*/
|
||||
@Override
|
||||
public void setAdapter(ListAdapter adapter) {
|
||||
@@ -1072,18 +1072,18 @@ public class ListView extends AbsListView {
|
||||
private class FocusSelector implements Runnable {
|
||||
private int mPosition;
|
||||
private int mPositionTop;
|
||||
|
||||
|
||||
public FocusSelector setup(int position, int top) {
|
||||
mPosition = position;
|
||||
mPositionTop = top;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
setSelectionFromTop(mPosition, mPositionTop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
if (getChildCount() > 0) {
|
||||
@@ -1457,7 +1457,7 @@ public class ListView extends AbsListView {
|
||||
adjustViewsUpOrDown();
|
||||
}
|
||||
} else if (lastPosition == mItemCount - 1) {
|
||||
adjustViewsUpOrDown();
|
||||
adjustViewsUpOrDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1767,7 +1767,7 @@ public class ListView extends AbsListView {
|
||||
&& focusLayoutRestoreView.getWindowToken() != null) {
|
||||
// focusLayoutRestoreView.onFinishTemporaryDetach();
|
||||
}
|
||||
|
||||
|
||||
mLayoutMode = LAYOUT_NORMAL;
|
||||
mDataChanged = false;
|
||||
if (mPositionScrollAfterLayout != null) {
|
||||
@@ -1979,7 +1979,7 @@ public class ListView extends AbsListView {
|
||||
|
||||
/**
|
||||
* Makes the item at the supplied position selected.
|
||||
*
|
||||
*
|
||||
* @param position the position of the item to select
|
||||
*/
|
||||
@Override
|
||||
@@ -2924,7 +2924,7 @@ public class ListView extends AbsListView {
|
||||
/**
|
||||
* Determine the distance to the nearest edge of a view in a particular
|
||||
* direction.
|
||||
*
|
||||
*
|
||||
* @param descendant A descendant of this list.
|
||||
* @return The distance, or 0 if the nearest edge is already on screen.
|
||||
*/
|
||||
@@ -3174,7 +3174,7 @@ public class ListView extends AbsListView {
|
||||
final int listBottom = getBottom() - getTop() - effectivePaddingBottom + getScrollY();
|
||||
if (!mStackFromBottom) {
|
||||
int bottom = 0;
|
||||
|
||||
|
||||
// Draw top divider or header for overscroll
|
||||
final int scrollY = getScrollY();
|
||||
if (count > 0 && scrollY < 0) {
|
||||
@@ -3271,7 +3271,7 @@ public class ListView extends AbsListView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count > 0 && scrollY > 0) {
|
||||
if (drawOverscrollFooter) {
|
||||
final int absListBottom = getBottom();
|
||||
@@ -3345,7 +3345,7 @@ public class ListView extends AbsListView {
|
||||
public int getDividerHeight() {
|
||||
return mDividerHeight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the height of the divider that will be drawn between each item in the list. Calling
|
||||
* this will override the intrinsic height as set by {@link #setDivider(Drawable)}
|
||||
@@ -3403,7 +3403,7 @@ public class ListView extends AbsListView {
|
||||
public boolean areFooterDividersEnabled() {
|
||||
return mFooterDividersEnabled;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the drawable that will be drawn above all other list content.
|
||||
* This area can become visible when the user overscrolls the list.
|
||||
@@ -3517,10 +3517,10 @@ public class ListView extends AbsListView {
|
||||
/**
|
||||
* Returns the set of checked items ids. The result is only valid if the
|
||||
* choice mode has not been set to {@link #CHOICE_MODE_NONE}.
|
||||
*
|
||||
*
|
||||
* @return A new array which contains the id of each checked item in the
|
||||
* list.
|
||||
*
|
||||
*
|
||||
* @deprecated Use {@link #getCheckedItemIds()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -3626,4 +3626,4 @@ public class ListView extends AbsListView {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ public class MultiAutoCompleteTextView extends AutoCompleteTextView {
|
||||
}
|
||||
|
||||
public void setTokenizer(Tokenizer tokenizer) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ public class OverScroller {
|
||||
}
|
||||
|
||||
void notifyEdgeReached(int start, int end, int over) {
|
||||
// mState is used to detect successive notifications
|
||||
// mState is used to detect successive notifications
|
||||
if (mState == SPLINE) {
|
||||
mOver = over;
|
||||
mStartTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
@@ -882,8 +882,8 @@ public class OverScroller {
|
||||
final float t = (float) (currentTime) / mDuration;
|
||||
final float t2 = t * t;
|
||||
final float sign = Math.signum(mVelocity);
|
||||
distance = sign * mOver * (3.0f * t2 - 2.0f * t * t2);
|
||||
mCurrVelocity = sign * mOver * 6.0f * (- t + t2);
|
||||
distance = sign * mOver * (3.0f * t2 - 2.0f * t * t2);
|
||||
mCurrVelocity = sign * mOver * 6.0f * (- t + t2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class PopupMenu {
|
||||
* calling {@code popupMenu.getMenuInflater().inflate(menuRes, popupMenu.getMenu())}.
|
||||
*
|
||||
* @param menuRes Menu resource to inflate
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public void inflate(int menuRes) throws Exception {
|
||||
getMenuInflater().inflate(menuRes, getMenu());
|
||||
@@ -336,7 +336,7 @@ public class PopupMenu {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'clearHeader'");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private class MenuItemImpl implements MenuItem {
|
||||
|
||||
@@ -36,4 +36,4 @@ public class RadioButton extends CompoundButton {
|
||||
@Override
|
||||
public void setTextSize(float size) {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1672,7 +1672,7 @@ public class RelativeLayout extends ViewGroup {
|
||||
private static final int POOL_LIMIT = 100;
|
||||
// private static final SynchronizedPool<Node> sPool =
|
||||
// new SynchronizedPool<Node>(POOL_LIMIT);
|
||||
|
||||
|
||||
static Node acquire(View view) {
|
||||
Node node;// = sPool.acquire();
|
||||
// if (node == null) {
|
||||
@@ -1681,7 +1681,7 @@ public class RelativeLayout extends ViewGroup {
|
||||
node.view = view;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void release() {
|
||||
view = null;
|
||||
dependents.clear();
|
||||
|
||||
@@ -168,7 +168,7 @@ public class Scroller {
|
||||
/**
|
||||
* The amount of friction applied to flings. The default value
|
||||
* is {@link ViewConfiguration#getScrollFriction}.
|
||||
*
|
||||
*
|
||||
* @param friction A scalar dimension-less value representing the coefficient of
|
||||
* friction.
|
||||
*/
|
||||
@@ -176,7 +176,7 @@ public class Scroller {
|
||||
mDeceleration = computeDeceleration(friction);
|
||||
mFlingFriction = friction;
|
||||
}
|
||||
|
||||
|
||||
private float computeDeceleration(float friction) {
|
||||
return SensorManager.GRAVITY_EARTH // g (m/s^2)
|
||||
* 39.37f // inch/meter
|
||||
@@ -185,51 +185,51 @@ public class Scroller {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns whether the scroller has finished scrolling.
|
||||
*
|
||||
*
|
||||
* @return True if the scroller has finished scrolling, false otherwise.
|
||||
*/
|
||||
public final boolean isFinished() {
|
||||
return mFinished;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force the finished field to a particular value.
|
||||
*
|
||||
*
|
||||
* @param finished The new finished value.
|
||||
*/
|
||||
public final void forceFinished(boolean finished) {
|
||||
mFinished = finished;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns how long the scroll event will take, in milliseconds.
|
||||
*
|
||||
*
|
||||
* @return The duration of the scroll in milliseconds.
|
||||
*/
|
||||
public final int getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current X offset in the scroll.
|
||||
*
|
||||
* Returns the current X offset in the scroll.
|
||||
*
|
||||
* @return The new X offset as an absolute distance from the origin.
|
||||
*/
|
||||
public final int getCurrX() {
|
||||
return mCurrX;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current Y offset in the scroll.
|
||||
*
|
||||
* Returns the current Y offset in the scroll.
|
||||
*
|
||||
* @return The new Y offset as an absolute distance from the origin.
|
||||
*/
|
||||
public final int getCurrY() {
|
||||
return mCurrY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current velocity.
|
||||
*
|
||||
@@ -242,35 +242,35 @@ public class Scroller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start X offset in the scroll.
|
||||
*
|
||||
* Returns the start X offset in the scroll.
|
||||
*
|
||||
* @return The start X offset as an absolute distance from the origin.
|
||||
*/
|
||||
public final int getStartX() {
|
||||
return mStartX;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the start Y offset in the scroll.
|
||||
*
|
||||
* Returns the start Y offset in the scroll.
|
||||
*
|
||||
* @return The start Y offset as an absolute distance from the origin.
|
||||
*/
|
||||
public final int getStartY() {
|
||||
return mStartY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns where the scroll will end. Valid only for "fling" scrolls.
|
||||
*
|
||||
*
|
||||
* @return The final X offset as an absolute distance from the origin.
|
||||
*/
|
||||
public final int getFinalX() {
|
||||
return mFinalX;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns where the scroll will end. Valid only for "fling" scrolls.
|
||||
*
|
||||
*
|
||||
* @return The final Y offset as an absolute distance from the origin.
|
||||
*/
|
||||
public final int getFinalY() {
|
||||
@@ -280,13 +280,13 @@ public class Scroller {
|
||||
/**
|
||||
* Call this when you want to know the new location. If it returns true,
|
||||
* the animation is not yet finished.
|
||||
*/
|
||||
*/
|
||||
public boolean computeScrollOffset() {
|
||||
if (mFinished) {
|
||||
return false;
|
||||
}
|
||||
int timePassed = (int)(AnimationUtils.currentAnimationTimeMillis() - mStartTime);
|
||||
|
||||
|
||||
if (timePassed < mDuration) {
|
||||
switch (mMode) {
|
||||
case SCROLL_MODE:
|
||||
@@ -308,12 +308,12 @@ public class Scroller {
|
||||
distanceCoef = d_inf + (t - t_inf) * velocityCoef;
|
||||
}
|
||||
mCurrVelocity = velocityCoef * mDistance / mDuration * 1000.0f;
|
||||
|
||||
|
||||
mCurrX = mStartX + Math.round(distanceCoef * (mFinalX - mStartX));
|
||||
// Pin to mMinX <= mCurrX <= mMaxX
|
||||
mCurrX = Math.min(mCurrX, mMaxX);
|
||||
mCurrX = Math.max(mCurrX, mMinX);
|
||||
|
||||
|
||||
mCurrY = mStartY + Math.round(distanceCoef * (mFinalY - mStartY));
|
||||
// Pin to mMinY <= mCurrY <= mMaxY
|
||||
mCurrY = Math.min(mCurrY, mMaxY);
|
||||
@@ -331,12 +331,12 @@ public class Scroller {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start scrolling by providing a starting point and the distance to travel.
|
||||
* The scroll will use the default value of 250 milliseconds for the
|
||||
* duration.
|
||||
*
|
||||
*
|
||||
* @param startX Starting horizontal scroll offset in pixels. Positive
|
||||
* numbers will scroll the content to the left.
|
||||
* @param startY Starting vertical scroll offset in pixels. Positive numbers
|
||||
@@ -353,7 +353,7 @@ public class Scroller {
|
||||
/**
|
||||
* Start scrolling by providing a starting point, the distance to travel,
|
||||
* and the duration of the scroll.
|
||||
*
|
||||
*
|
||||
* @param startX Starting horizontal scroll offset in pixels. Positive
|
||||
* numbers will scroll the content to the left.
|
||||
* @param startY Starting vertical scroll offset in pixels. Positive numbers
|
||||
@@ -381,7 +381,7 @@ public class Scroller {
|
||||
/**
|
||||
* Start scrolling based on a fling gesture. The distance travelled will
|
||||
* depend on the initial velocity of the fling.
|
||||
*
|
||||
*
|
||||
* @param startX Starting point of the scroll (X)
|
||||
* @param startY Starting point of the scroll (Y)
|
||||
* @param velocityX Initial velocity of the fling (X) measured in pixels per
|
||||
@@ -418,7 +418,7 @@ public class Scroller {
|
||||
mMode = FLING_MODE;
|
||||
mFinished = false;
|
||||
float velocity = (float) Math.hypot(velocityX, velocityY);
|
||||
|
||||
|
||||
mVelocity = velocity;
|
||||
mDuration = getSplineFlingDuration(velocity);
|
||||
mStartTime = AnimationUtils.currentAnimationTimeMillis();
|
||||
@@ -428,7 +428,7 @@ public class Scroller {
|
||||
float coeffY = velocity == 0 ? 1.0f : velocityY / velocity;
|
||||
double totalDistance = getSplineFlingDistance(velocity);
|
||||
mDistance = (int) (totalDistance * Math.signum(velocity));
|
||||
|
||||
|
||||
mMinX = minX;
|
||||
mMaxX = maxX;
|
||||
mMinY = minY;
|
||||
@@ -437,13 +437,13 @@ public class Scroller {
|
||||
// Pin to mMinX <= mFinalX <= mMaxX
|
||||
mFinalX = Math.min(mFinalX, mMaxX);
|
||||
mFinalX = Math.max(mFinalX, mMinX);
|
||||
|
||||
|
||||
mFinalY = startY + (int) Math.round(totalDistance * coeffY);
|
||||
// Pin to mMinY <= mFinalY <= mMaxY
|
||||
mFinalY = Math.min(mFinalY, mMaxY);
|
||||
mFinalY = Math.max(mFinalY, mMinY);
|
||||
}
|
||||
|
||||
|
||||
private double getSplineDeceleration(float velocity) {
|
||||
return Math.log(INFLEXION * Math.abs(velocity) / (mFlingFriction * mPhysicalCoeff));
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public class Scroller {
|
||||
mCurrY = mFinalY;
|
||||
mFinished = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extend the scroll animation. This allows a running animation to scroll
|
||||
* further and longer, when used with {@link #setFinalX(int)} or {@link #setFinalY(int)}.
|
||||
|
||||
@@ -14,4 +14,4 @@ public class Space extends View {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,4 @@ public class Spinner extends AbsSpinner {
|
||||
@Override
|
||||
void layout(int delta, boolean animate) {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user