Search in sources :

Example 1 with CallSuper

use of android.support.annotation.CallSuper in project remusic by aa112901.

the class RoundViewPager method onPageScrolled.

/**
     * This method will be invoked when the currentPosition page is scrolled, either as part
     * of a programmatically initiated smooth scroll or a user initiated touch scroll.
     * If you override this method you must call through to the superclass implementation
     * (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled
     * returns.
     *
     * @param position Position index of the first page currently being displayed.
     *                 Page position+1 will be visible if positionOffset is nonzero.
     * @param offset Value from [0, 1) indicating the offset from the page at position.
     * @param offsetPixels Value in pixels indicating the offset from position.
     */
@CallSuper
protected void onPageScrolled(int position, float offset, int offsetPixels) {
    // Offset any decor views if needed - keep them on-screen at all times.
    if (mDecorChildCount > 0) {
        final int scrollX = getScrollX();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        final int width = getWidth();
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (!lp.isDecor)
                continue;
            final int hgrav = lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
            int childLeft = 0;
            switch(hgrav) {
                default:
                    childLeft = paddingLeft;
                    break;
                case Gravity.LEFT:
                    childLeft = paddingLeft;
                    paddingLeft += child.getWidth();
                    break;
                case Gravity.CENTER_HORIZONTAL:
                    childLeft = Math.max((width - child.getMeasuredWidth()) / 2, paddingLeft);
                    break;
                case Gravity.RIGHT:
                    childLeft = width - paddingRight - child.getMeasuredWidth();
                    paddingRight += child.getMeasuredWidth();
                    break;
            }
            childLeft += scrollX;
            final int childOffset = childLeft - child.getLeft();
            if (childOffset != 0) {
                child.offsetLeftAndRight(childOffset);
            }
        }
    }
    dispatchOnPageScrolled(position, offset, offsetPixels);
    if (mPageTransformer != null) {
        final int scrollX = getScrollX();
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View child = getChildAt(i);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (lp.isDecor)
                continue;
            final float transformPos = (float) (child.getLeft() - scrollX) / getClientWidth();
            mPageTransformer.transformPage(child, transformPos);
        }
    }
    mCalledSuper = true;
}
Also used : View(android.view.View) CallSuper(android.support.annotation.CallSuper)

Example 2 with CallSuper

use of android.support.annotation.CallSuper in project android-oss by kickstarter.

the class BaseFragment method onCreateView.

/**
   * Called when a fragment instantiates its user interface view, between `onCreate` and `onActivityCreated`.
   * Can return null for non-graphical fragments.
   */
@CallSuper
@Override
@Nullable
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    final View view = super.onCreateView(inflater, container, savedInstanceState);
    Timber.d("onCreateView %s", this.toString());
    lifecycle.onNext(FragmentEvent.CREATE_VIEW);
    return view;
}
Also used : View(android.view.View) CallSuper(android.support.annotation.CallSuper) Nullable(android.support.annotation.Nullable)

Example 3 with CallSuper

use of android.support.annotation.CallSuper in project android-oss by kickstarter.

the class BaseFragment method onSaveInstanceState.

@CallSuper
@Override
public void onSaveInstanceState(@NonNull final Bundle outState) {
    super.onSaveInstanceState(outState);
    final Bundle viewModelEnvelope = new Bundle();
    if (viewModel != null) {
        FragmentViewModelManager.getInstance().save(viewModel, viewModelEnvelope);
    }
    outState.putBundle(VIEW_MODEL_KEY, viewModelEnvelope);
}
Also used : Bundle(android.os.Bundle) CallSuper(android.support.annotation.CallSuper)

Example 4 with CallSuper

use of android.support.annotation.CallSuper in project PocketHub by pockethub.

the class BaseActivity method onCreate.

@CallSuper
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    lifecycleSubject.onNext(ActivityEvent.CREATE);
    finder = new ViewFinder(this);
}
Also used : ViewFinder(com.github.kevinsawicki.wishlist.ViewFinder) CallSuper(android.support.annotation.CallSuper)

Example 5 with CallSuper

use of android.support.annotation.CallSuper in project material-components-android by material-components.

the class AppBarLayoutBaseTest method configureContent.

@CallSuper
protected void configureContent(@LayoutRes final int layoutResId, @StringRes final int titleResId) throws Throwable {
    onView(withId(R.id.coordinator_stub)).perform(inflateViewStub(layoutResId));
    mAppBar = (AppBarLayout) mCoordinatorLayout.findViewById(R.id.app_bar);
    mCollapsingToolbar = (CollapsingToolbarLayout) mAppBar.findViewById(R.id.collapsing_app_bar);
    mToolbar = (Toolbar) mAppBar.findViewById(R.id.toolbar);
    final AppCompatActivity activity = activityTestRule.getActivity();
    activityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            activity.setSupportActionBar(mToolbar);
        }
    });
    final CharSequence activityTitle = activity.getString(titleResId);
    activityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            activity.setTitle(activityTitle);
        }
    });
    getInstrumentation().waitForIdleSync();
    if (mCollapsingToolbar != null) {
        onView(withId(R.id.collapsing_app_bar)).perform(setTitle(activityTitle)).perform(setContentScrimColor(Color.MAGENTA));
    }
    TextView dialog = (TextView) mCoordinatorLayout.findViewById(R.id.textview_dialogue);
    if (dialog != null) {
        onView(withId(R.id.textview_dialogue)).perform(setText(TextUtils.concat(Shakespeare.DIALOGUE)));
    }
    mDefaultElevationValue = mAppBar.getResources().getDimension(R.dimen.design_appbar_elevation);
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) TextView(android.widget.TextView) CallSuper(android.support.annotation.CallSuper)

Aggregations

CallSuper (android.support.annotation.CallSuper)28 Intent (android.content.Intent)6 MenuItem (android.view.MenuItem)6 View (android.view.View)5 Spinner (android.widget.Spinner)5 Date (java.util.Date)5 Bundle (android.os.Bundle)2 TextView (android.widget.TextView)2 SharedPreferences (android.content.SharedPreferences)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 ConnectivityManager (android.net.ConnectivityManager)1 NetworkInfo (android.net.NetworkInfo)1 PowerManager (android.os.PowerManager)1 RecognizerIntent (android.speech.RecognizerIntent)1 Nullable (android.support.annotation.Nullable)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 MotionEvent (android.view.MotionEvent)1 ViewGroup (android.view.ViewGroup)1 LinearLayout (android.widget.LinearLayout)1