Search in sources :

Example 21 with CallSuper

use of androidx.annotation.CallSuper in project SmoothRefreshLayout by dkzwm.

the class SmoothRefreshLayout method init.

@CallSuper
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    sId++;
    createIndicator();
    if (mIndicator == null || mIndicatorSetter == null) {
        throw new IllegalArgumentException("You must create a IIndicator, current indicator is null");
    }
    ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
    mTouchSlop = viewConfiguration.getScaledTouchSlop();
    mMaximumFlingVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
    mMinimumFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    createScrollerChecker();
    mSpringInterpolator = SPRING_INTERPOLATOR;
    mSpringBackInterpolator = SPRING_BACK_INTERPOLATOR;
    mDelayToPerformAutoRefresh = new DelayToPerformAutoRefresh();
    TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.SmoothRefreshLayout, defStyleAttr, defStyleRes);
    int mode = Constants.MODE_DEFAULT;
    if (arr != null) {
        try {
            mContentResId = arr.getResourceId(R.styleable.SmoothRefreshLayout_sr_content, mContentResId);
            float resistance = arr.getFloat(R.styleable.SmoothRefreshLayout_sr_resistance, IIndicator.DEFAULT_RESISTANCE);
            mIndicatorSetter.setResistance(resistance);
            mIndicatorSetter.setResistanceOfHeader(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_resistanceOfHeader, resistance));
            mIndicatorSetter.setResistanceOfFooter(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_resistanceOfFooter, resistance));
            mDurationOfBackToHeaderHeight = arr.getInt(R.styleable.SmoothRefreshLayout_sr_backToKeepDuration, mDurationOfBackToHeaderHeight);
            mDurationOfBackToFooterHeight = arr.getInt(R.styleable.SmoothRefreshLayout_sr_backToKeepDuration, mDurationOfBackToFooterHeight);
            mDurationOfBackToHeaderHeight = arr.getInt(R.styleable.SmoothRefreshLayout_sr_backToKeepHeaderDuration, mDurationOfBackToHeaderHeight);
            mDurationOfBackToFooterHeight = arr.getInt(R.styleable.SmoothRefreshLayout_sr_backToKeepFooterDuration, mDurationOfBackToFooterHeight);
            mDurationToCloseHeader = arr.getInt(R.styleable.SmoothRefreshLayout_sr_closeDuration, mDurationToCloseHeader);
            mDurationToCloseFooter = arr.getInt(R.styleable.SmoothRefreshLayout_sr_closeDuration, mDurationToCloseFooter);
            mDurationToCloseHeader = arr.getInt(R.styleable.SmoothRefreshLayout_sr_closeHeaderDuration, mDurationToCloseHeader);
            mDurationToCloseFooter = arr.getInt(R.styleable.SmoothRefreshLayout_sr_closeFooterDuration, mDurationToCloseFooter);
            float ratio = arr.getFloat(R.styleable.SmoothRefreshLayout_sr_ratioToRefresh, IIndicator.DEFAULT_RATIO_TO_REFRESH);
            mIndicatorSetter.setRatioToRefresh(ratio);
            mIndicatorSetter.setRatioOfHeaderToRefresh(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_ratioOfHeaderToRefresh, ratio));
            mIndicatorSetter.setRatioOfFooterToRefresh(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_ratioOfFooterToRefresh, ratio));
            ratio = arr.getFloat(R.styleable.SmoothRefreshLayout_sr_ratioToKeep, IIndicator.DEFAULT_RATIO_TO_REFRESH);
            mIndicatorSetter.setRatioToKeepHeader(ratio);
            mIndicatorSetter.setRatioToKeepFooter(ratio);
            mIndicatorSetter.setRatioToKeepHeader(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_ratioToKeepHeader, ratio));
            mIndicatorSetter.setRatioToKeepFooter(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_ratioToKeepFooter, ratio));
            ratio = arr.getFloat(R.styleable.SmoothRefreshLayout_sr_maxMoveRatio, IIndicator.DEFAULT_MAX_MOVE_RATIO);
            mIndicatorSetter.setMaxMoveRatio(ratio);
            mIndicatorSetter.setMaxMoveRatioOfHeader(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_maxMoveRatioOfHeader, ratio));
            mIndicatorSetter.setMaxMoveRatioOfFooter(arr.getFloat(R.styleable.SmoothRefreshLayout_sr_maxMoveRatioOfFooter, ratio));
            mStickyHeaderResId = arr.getResourceId(R.styleable.SmoothRefreshLayout_sr_stickyHeader, NO_ID);
            mStickyFooterResId = arr.getResourceId(R.styleable.SmoothRefreshLayout_sr_stickyFooter, NO_ID);
            setEnableKeepRefreshView(arr.getBoolean(R.styleable.SmoothRefreshLayout_sr_enableKeep, true));
            setEnablePinContentView(arr.getBoolean(R.styleable.SmoothRefreshLayout_sr_enablePinContent, false));
            setEnableOverScroll(arr.getBoolean(R.styleable.SmoothRefreshLayout_sr_enableOverScroll, true));
            setEnablePullToRefresh(arr.getBoolean(R.styleable.SmoothRefreshLayout_sr_enablePullToRefresh, false));
            setDisableRefresh(!arr.getBoolean(R.styleable.SmoothRefreshLayout_sr_enableRefresh, true));
            setDisableLoadMore(!arr.getBoolean(R.styleable.SmoothRefreshLayout_sr_enableLoadMore, false));
            mode = arr.getInt(R.styleable.SmoothRefreshLayout_sr_mode, 0);
            setEnabled(arr.getBoolean(R.styleable.SmoothRefreshLayout_android_enabled, true));
        } finally {
            arr.recycle();
        }
    }
    setMode(mode);
    if (mNestedScrollingChildHelper == null) {
        setNestedScrollingEnabled(true);
    }
}
Also used : ViewConfiguration(android.view.ViewConfiguration) TypedArray(android.content.res.TypedArray) CallSuper(androidx.annotation.CallSuper)

Example 22 with CallSuper

use of androidx.annotation.CallSuper in project butter-android by butterproject.

the class BaseProvider method cancel.

/**
 * This method will be called when user is done with data that he required. Provider should at this point
 * clean after itself. For example cancel all ongoing network request.
 */
@CallSuper
public void cancel() {
    final Dispatcher dispatcher = client.dispatcher();
    dispatcher.executorService().execute(new Runnable() {

        @Override
        public void run() {
            if (dispatcher.queuedCallsCount() > 0) {
                for (Call call : dispatcher.queuedCalls()) {
                    if (getClass().equals(call.request().tag())) {
                        call.cancel();
                    }
                }
            }
            if (dispatcher.runningCallsCount() > 0) {
                for (Call call : dispatcher.runningCalls()) {
                    if (getClass().equals(call.request().tag())) {
                        call.cancel();
                    }
                }
            }
        }
    });
}
Also used : Call(okhttp3.Call) Dispatcher(okhttp3.Dispatcher) CallSuper(androidx.annotation.CallSuper)

Example 23 with CallSuper

use of androidx.annotation.CallSuper in project butter-android by butterproject.

the class AbsPlayerFragment method setupControls.

@CallSuper
@Override
public void setupControls(String title, int actions) {
    mediaController = new MediaControllerCompat(getContext(), mediaSession);
    mediaController.registerCallback(controllerCallback);
    MediaControllerCompat.setMediaController(getActivity(), mediaController);
    long stateActions = PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SEEK_TO;
    if ((actions & StreamPlayerPresenterImpl.PLAYER_ACTION_SKIP_NEXT) > 0) {
        stateActions |= PlaybackStateCompat.ACTION_FAST_FORWARD;
        forwardButton.setVisibility(View.VISIBLE);
    } else {
        forwardButton.setVisibility(View.GONE);
    }
    if ((actions & StreamPlayerPresenterImpl.PLAYER_ACTION_SKIP_PREVIOUS) > 0) {
        stateActions |= PlaybackStateCompat.ACTION_REWIND;
        rewindButton.setVisibility(View.VISIBLE);
    } else {
        rewindButton.setVisibility(View.GONE);
    }
    stateBuilder.setActions(stateActions);
    if ((actions & StreamPlayerPresenterImpl.PLAYER_ACTION_CC) > 0) {
        stateBuilder.addCustomAction(ACTION_CLOSE_CAPTION, getString(R.string.subtitles), R.drawable.ic_av_subs);
        subsButton.setVisibility(View.VISIBLE);
    } else {
        subsButton.setVisibility(View.GONE);
    }
    if ((actions & StreamPlayerPresenterImpl.PLAYER_ACTION_SCALE) > 0) {
        stateBuilder.addCustomAction(ACTION_SCALE, getString(R.string.scale), R.drawable.ic_av_aspect_ratio);
        scaleButton.setVisibility(View.VISIBLE);
    } else {
        scaleButton.setVisibility(View.GONE);
    }
    mediaSession.setPlaybackState(stateBuilder.build());
    metadataBuilder.putText(MediaMetadataCompat.METADATA_KEY_TITLE, title);
    mediaSession.setMetadata(metadataBuilder.build());
// TODO actions visibility by glue host
// TODO actions
}
Also used : MediaControllerCompat(android.support.v4.media.session.MediaControllerCompat) CallSuper(androidx.annotation.CallSuper)

Example 24 with CallSuper

use of androidx.annotation.CallSuper in project android_packages_apps_Settings by DirtyUnicorns.

the class BaseSearchIndexProvider method getDynamicRawDataToIndex.

@Override
@CallSuper
public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context, boolean enabled) {
    final List<SearchIndexableRaw> dynamicRaws = new ArrayList<>();
    final List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
    if (controllers == null || controllers.isEmpty()) {
        return dynamicRaws;
    }
    for (AbstractPreferenceController controller : controllers) {
        if (controller instanceof PreferenceControllerMixin) {
            ((PreferenceControllerMixin) controller).updateDynamicRawDataToIndex(dynamicRaws);
        } else if (controller instanceof BasePreferenceController) {
            ((BasePreferenceController) controller).updateDynamicRawDataToIndex(dynamicRaws);
        } else {
            Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the dynamic indexable");
        }
    }
    return dynamicRaws;
}
Also used : BasePreferenceController(com.android.settings.core.BasePreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) PreferenceControllerMixin(com.android.settings.core.PreferenceControllerMixin) ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) CallSuper(androidx.annotation.CallSuper)

Example 25 with CallSuper

use of androidx.annotation.CallSuper in project android_packages_apps_Settings by DirtyUnicorns.

the class BaseSearchIndexProvider method getNonIndexableKeys.

@Override
@CallSuper
public List<String> getNonIndexableKeys(Context context) {
    if (!isPageSearchEnabled(context)) {
        // Entire page should be suppressed, mark all keys from this page as non-indexable.
        return getNonIndexableKeysFromXml(context, true);
    }
    final List<String> nonIndexableKeys = new ArrayList<>();
    nonIndexableKeys.addAll(getNonIndexableKeysFromXml(context, false));
    final List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
    if (controllers != null && !controllers.isEmpty()) {
        for (AbstractPreferenceController controller : controllers) {
            if (controller instanceof PreferenceControllerMixin) {
                ((PreferenceControllerMixin) controller).updateNonIndexableKeys(nonIndexableKeys);
            } else if (controller instanceof BasePreferenceController) {
                ((BasePreferenceController) controller).updateNonIndexableKeys(nonIndexableKeys);
            } else {
                Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the key non-indexable");
                nonIndexableKeys.add(controller.getPreferenceKey());
            }
        }
    }
    return nonIndexableKeys;
}
Also used : BasePreferenceController(com.android.settings.core.BasePreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) PreferenceControllerMixin(com.android.settings.core.PreferenceControllerMixin) ArrayList(java.util.ArrayList) CallSuper(androidx.annotation.CallSuper)

Aggregations

CallSuper (androidx.annotation.CallSuper)45 BasePreferenceController (com.android.settings.core.BasePreferenceController)8 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)8 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)8 ArrayList (java.util.ArrayList)8 Bundle (android.os.Bundle)6 Nullable (androidx.annotation.Nullable)6 View (android.view.View)4 TextView (android.widget.TextView)4 FragmentActivity (androidx.fragment.app.FragmentActivity)4 BaseRegistrationViewModel (org.thoughtcrime.securesms.registration.viewmodel.BaseRegistrationViewModel)4 SuppressLint (android.annotation.SuppressLint)3 TypedArray (android.content.res.TypedArray)3 SearchIndexableRaw (com.android.settingslib.search.SearchIndexableRaw)3 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 Resources (android.content.res.Resources)2 Paint (android.graphics.Paint)2 InputType (android.text.InputType)2 EditorInfo (android.view.inputmethod.EditorInfo)2