char data[1000000]; // One Million bytes unsigned int sum = 0; for ( int i = 0; i < 1000000; ++i ) { sum += data[ i ]; }
char data[16000000]; // Sixteen Million bytes unsigned int sum = 0; for ( int i = 0; i < 16000000; i += 16 ) { sum += data[ i ]; }
struct PhysicsObject { Vec3 mPosition; Vec3 mVelocity; float mMass; float mDrag; Vec3 mCenterOfMass; Vec3 mRotation; Vec3 mAngularVelocity; float mAngularDrag; };
class PhysicsSystem { private: size_t mNumObjects; std::vector< Vec3 > mPositions; std::vector< Vec3 > mVelocities; std::vector< float > mMasses; std::vector< float > mDrags; // ... };
void UpdatePositions( PhysicsObject* objects, const size_t num_objects, const float delta_time ) { for ( int i = 0; i < num_objects; ++i ) { objects[i].mPosition += objects[i].mVelocity * delta_time; } }
void PhysicsSystem::SimulateObjects( const float delta_time ) { for ( int i = 0; i < mNumObjects; ++i ) { mPositions[ i ] += mVelocities[i] * delta_time; } }
compileSdkVersion
targetSdkVersion
23
<resources> <string name="transition_avatar">AvatarTransition</string> </resources>
<ImageView android:id="@+id/avatar" android:layout_width="@dimen/avatar_size" android:layout_height="@dimen/avatar_size" android:layout_marginEnd="@dimen/keyline_16" android:transitionName="@string/transition_avatar"/>
private void performSignInWithTransition(View v) { Activity activity = getActivity(); ActivityOptions activityOptions = ActivityOptions .makeSceneTransitionAnimation(activity, v, activity.getString(R.string.transition_avatar)); CategorySelectionActivity.start(activity, mPlayer, activityOptions); activity.finishAfterTransition(); }
performScoreAnimation
private void addFloatingActionButton() { final int fabSize = getResources().getDimensionPixelSize(R.dimen.fab_size); int bottomOfQuestionView = findViewById(R.id.question_view).getBottom(); final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP); final int fabPadding = getResources().getDimensionPixelSize(R.dimen.padding_fab); final int halfAFab = fabSize / 2; fabLayoutParams.setMargins(0, // left bottomOfQuestionView - halfAFab, //top 0, // right fabPadding); // bottom addView(mSubmitAnswer, fabLayoutParams); }
addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int l, int t, int r, int b, int oldLeft, int oldTop, int oldRight, int oldBottom) { removeOnLayoutChangeListener(this); addFloatingActionButton(); } });
@Override public final void getOutline(View view, Outline outline) { final int size = view.getResources(). getDimensionPixelSize(R.id.view_size); outline.setOval(0, 0, size, size); }
setClipToOutline(true)
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="48" android:viewportHeight="48"> <path android:pathData="M40 22H15.66l11.17-11.17L24 8 8 24l16 16 2.83-2.83L15.66 26H40v-4z" android:fillColor="?android:attr/textColorPrimary" /> </vector>
// Property for animating the foreground public static final Property FOREGROUND_COLOR = new IntProperty("foregroundColor") { @Override public void setValue(FrameLayout layout, int value) { if (layout.getForeground() instanceof ColorDrawable) { ((ColorDrawable) layout.getForeground()).setColor(value); } else { layout.setForeground(new ColorDrawable(value)); } } @Override public Integer get(FrameLayout layout) { return ((ColorDrawable) layout.getForeground()).getColor(); } };
final ObjectAnimator foregroundAnimator = ObjectAnimator .ofArgb(this, FOREGROUND_COLOR, Color.WHITE, backgroundColor);