Search in sources :

Example 11 with Space

use of android.support.v4.widget.Space in project AntennaPod by AntennaPod.

the class CustomMRControllerDialog method onCreateMediaControlView.

@Override
public View onCreateMediaControlView(Bundle savedInstanceState) {
    boolean landscape = getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    if (landscape) {
        /*
             * When a horizontal LinearLayout measures itself, it first measures its children and
             * settles their widths on the first pass, and only then figures out its height, never
             * revisiting the widths measurements.
             * When one has a child view that imposes a certain aspect ratio (such as an ImageView),
             * then its width and height are related to each other, and so if one allows for a large
             * height, then it will request for itself a large width as well. However, on the first
             * child measurement, the LinearLayout imposes a very relaxed height bound, that the
             * child uses to tell the width it wants, a value which the LinearLayout will interpret
             * as final, even though the child will want to change it once a more restrictive height
             * bound is imposed later.
             *
             * Our solution is, given that the heights of the children do not depend on their widths
             * in this case, we first figure out the layout's height and only then perform the
             * usual sequence of measurements.
             *
             * Note: this solution does not take into account any vertical paddings nor children's
             * vertical margins in determining the height, as this View as well as its children are
             * defined in code and no paddings/margins that would influence these computations are
             * introduced.
             *
             * There were no resources online for this type of issue as far as I could gather.
             */
        rootView = new LinearLayout(getContext()) {

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                // We'd like to find the overall height before adjusting the widths within the LinearLayout
                int maxHeight = Integer.MIN_VALUE;
                if (MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY) {
                    for (int i = 0; i < getChildCount(); i++) {
                        int height = Integer.MIN_VALUE;
                        View child = getChildAt(i);
                        ViewGroup.LayoutParams lp = child.getLayoutParams();
                        // we only measure children whose layout_height is not MATCH_PARENT
                        if (lp.height >= 0) {
                            height = lp.height;
                        } else if (lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
                            child.measure(widthMeasureSpec, heightMeasureSpec);
                            height = child.getMeasuredHeight();
                        }
                        maxHeight = Math.max(maxHeight, height);
                    }
                }
                if (maxHeight > 0) {
                    super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY));
                } else {
                    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                }
            }
        };
        rootView.setOrientation(LinearLayout.HORIZONTAL);
    } else {
        rootView = new LinearLayout(getContext());
        rootView.setOrientation(LinearLayout.VERTICAL);
    }
    FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    rootParams.setMargins(0, 0, 0, getContext().getResources().getDimensionPixelSize(R.dimen.media_router_controller_bottom_margin));
    rootView.setLayoutParams(rootParams);
    // Start the session activity when a content item (album art, title or subtitle) is clicked.
    View.OnClickListener onClickListener = v -> {
        if (mediaController != null) {
            PendingIntent pi = mediaController.getSessionActivity();
            if (pi != null) {
                try {
                    pi.send();
                    dismiss();
                } catch (PendingIntent.CanceledException e) {
                    Log.e(TAG, pi + " was not sent, it had been canceled.");
                }
            }
        }
    };
    LinearLayout.LayoutParams artParams;
    /*
         * On portrait orientation, we want to limit the artView's height to 9/16 of the available
         * width. Reason is that we need to choose the height wisely otherwise we risk the dialog
         * being much larger than the screen, and there doesn't seem to be a good way to know the
         * available height beforehand.
         *
         * On landscape orientation, we want to limit the artView's width to its available height.
         * Otherwise, horizontal images would take too much space and severely restrict the space
         * for episode title and play/pause button.
         *
         * Internal implementation of ImageView only uses the source image's aspect ratio, but we
         * want to impose our own and fallback to the source image's when it is more favorable.
         * Solutions were inspired, among other similar sources, on
         * http://stackoverflow.com/questions/18077325/scale-image-to-fill-imageview-width-and-keep-aspect-ratio
         */
    if (landscape) {
        artView = new ImageView(getContext()) {

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                int desiredWidth = widthMeasureSpec;
                int desiredMeasureMode = MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY ? MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
                if (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY) {
                    Drawable drawable = getDrawable();
                    if (drawable != null) {
                        int intrHeight = drawable.getIntrinsicHeight();
                        int intrWidth = drawable.getIntrinsicWidth();
                        int originalHeight = MeasureSpec.getSize(heightMeasureSpec);
                        if (intrHeight < intrWidth) {
                            desiredWidth = MeasureSpec.makeMeasureSpec(originalHeight, desiredMeasureMode);
                        } else {
                            desiredWidth = MeasureSpec.makeMeasureSpec(Math.round((float) originalHeight * intrWidth / intrHeight), desiredMeasureMode);
                        }
                    }
                }
                super.onMeasure(desiredWidth, heightMeasureSpec);
            }
        };
        artParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        MarginLayoutParamsCompat.setMarginStart(artParams, getContext().getResources().getDimensionPixelSize(R.dimen.media_router_controller_playback_control_horizontal_spacing));
    } else {
        artView = new ImageView(getContext()) {

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                int desiredHeight = heightMeasureSpec;
                if (MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY) {
                    Drawable drawable = getDrawable();
                    if (drawable != null) {
                        int originalWidth = MeasureSpec.getSize(widthMeasureSpec);
                        int intrHeight = drawable.getIntrinsicHeight();
                        int intrWidth = drawable.getIntrinsicWidth();
                        float scale;
                        if (intrHeight * 16 > intrWidth * 9) {
                            // image is taller than 16:9
                            scale = (float) originalWidth * 9 / 16 / intrHeight;
                        } else {
                            // image is more horizontal than 16:9
                            scale = (float) originalWidth / intrWidth;
                        }
                        desiredHeight = MeasureSpec.makeMeasureSpec(Math.round(intrHeight * scale), MeasureSpec.EXACTLY);
                    }
                }
                super.onMeasure(widthMeasureSpec, desiredHeight);
            }
        };
        artParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    // When we fetch the bitmap, we want to know if we should set a background color or not.
    artView.setTag(landscape);
    artView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    artView.setOnClickListener(onClickListener);
    artView.setLayoutParams(artParams);
    rootView.addView(artView);
    ViewGroup wrapper = rootView;
    if (landscape) {
        // Here we wrap with a frame layout because we want to set different layout parameters
        // for landscape orientation.
        wrapper = new FrameLayout(getContext());
        wrapper.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
        rootView.addView(wrapper);
        rootView.setWeightSum(1f);
    }
    View playbackControlLayout = View.inflate(getContext(), R.layout.media_router_controller, wrapper);
    titleView = (TextView) playbackControlLayout.findViewById(R.id.mrc_control_title);
    subtitleView = (TextView) playbackControlLayout.findViewById(R.id.mrc_control_subtitle);
    playbackControlLayout.findViewById(R.id.mrc_control_title_container).setOnClickListener(onClickListener);
    playPauseButton = (ImageButton) playbackControlLayout.findViewById(R.id.mrc_control_play_pause);
    playPauseButton.setOnClickListener(v -> {
        PlaybackStateCompat state;
        if (mediaController != null && (state = mediaController.getPlaybackState()) != null) {
            boolean isPlaying = state.getState() == PlaybackStateCompat.STATE_PLAYING;
            if (isPlaying) {
                mediaController.getTransportControls().pause();
            } else {
                mediaController.getTransportControls().play();
            }
            AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
            if (accessibilityManager != null && accessibilityManager.isEnabled()) {
                AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEventCompat.TYPE_ANNOUNCEMENT);
                event.setPackageName(getContext().getPackageName());
                event.setClassName(getClass().getName());
                int resId = isPlaying ? android.support.v7.mediarouter.R.string.mr_controller_pause : android.support.v7.mediarouter.R.string.mr_controller_play;
                event.getText().add(getContext().getString(resId));
                accessibilityManager.sendAccessibilityEvent(event);
            }
        }
    });
    viewsCreated = true;
    updateViews();
    return rootView;
}
Also used : Context(android.content.Context) ImageButton(android.widget.ImageButton) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) Palette(android.support.v7.graphics.Palette) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AccessibilityEventCompat(android.support.v4.view.accessibility.AccessibilityEventCompat) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) RemoteException(android.os.RemoteException) PendingIntent(android.app.PendingIntent) NonNull(android.support.annotation.NonNull) MediaSessionCompat(android.support.v4.media.session.MediaSessionCompat) MarginLayoutParamsCompat(android.support.v4.view.MarginLayoutParamsCompat) ApGlideSettings(de.danoeh.antennapod.core.glide.ApGlideSettings) Drawable(android.graphics.drawable.Drawable) Observable(rx.Observable) AccessibilityManager(android.view.accessibility.AccessibilityManager) MediaMetadataCompat(android.support.v4.media.MediaMetadataCompat) Schedulers(rx.schedulers.Schedulers) View(android.view.View) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) PlaybackStateCompat(android.support.v4.media.session.PlaybackStateCompat) Log(android.util.Log) R(de.danoeh.antennapod.R) Target(com.bumptech.glide.request.target.Target) TextUtils(android.text.TextUtils) ViewGroup(android.view.ViewGroup) ExecutionException(java.util.concurrent.ExecutionException) MediaRouter(android.support.v7.media.MediaRouter) TextView(android.widget.TextView) Glide(com.bumptech.glide.Glide) MediaRouteControllerDialog(android.support.v7.app.MediaRouteControllerDialog) TypedValue(android.util.TypedValue) Bitmap(android.graphics.Bitmap) Pair(android.support.v4.util.Pair) Configuration(android.content.res.Configuration) MediaControllerCompat(android.support.v4.media.session.MediaControllerCompat) Subscription(rx.Subscription) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) PlaybackStateCompat(android.support.v4.media.session.PlaybackStateCompat) AccessibilityManager(android.view.accessibility.AccessibilityManager) FrameLayout(android.widget.FrameLayout) PendingIntent(android.app.PendingIntent) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 12 with Space

use of android.support.v4.widget.Space in project instructure-android by instructure.

the class ParentFragment method configureRecyclerViewAsGrid.

@Override
public void configureRecyclerViewAsGrid(View rootView, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, int emptyViewStringResId, final int span, View.OnClickListener emptyImageListener, Drawable... emptyImage) {
    final int cardPadding = getResources().getDimensionPixelOffset(R.dimen.card_outer_margin);
    EmptyViewInterface emptyViewInterface = rootView.findViewById(emptyViewResId);
    final PandaRecyclerView recyclerView = rootView.findViewById(recyclerViewResId);
    baseRecyclerAdapter.setSelectedItemId(getDefaultSelectedId());
    emptyViewInterface.emptyViewText(emptyViewStringResId);
    emptyViewInterface.setNoConnectionText(getString(R.string.noConnection));
    if (emptyImage != null && emptyImage.length > 0) {
        emptyViewInterface.emptyViewImage(emptyImage[0]);
        if (emptyImageListener != null && emptyViewInterface.getEmptyViewImage() != null) {
            emptyViewInterface.getEmptyViewImage().setOnClickListener(emptyImageListener);
        }
    }
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), span, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            if (position < recyclerView.getAdapter().getItemCount()) {
                int viewType = recyclerView.getAdapter().getItemViewType(position);
                if (Types.TYPE_HEADER == viewType || PaginatedRecyclerAdapter.LOADING_FOOTER_TYPE == viewType) {
                    return span;
                }
            } else {
                // if something goes wrong it will take up the entire space, but at least it won't crash
                return span;
            }
            return 1;
        }
    });
    if (mSpacingDecoration != null) {
        recyclerView.removeItemDecoration(mSpacingDecoration);
    }
    if (baseRecyclerAdapter instanceof ExpandableRecyclerAdapter) {
        mSpacingDecoration = new ExpandableGridSpacingDecorator(cardPadding);
    } else {
        mSpacingDecoration = new GridSpacingDecorator(cardPadding);
    }
    recyclerView.addItemDecoration(mSpacingDecoration);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setEmptyView(emptyViewInterface);
    recyclerView.setAdapter(baseRecyclerAdapter);
    mSwipeRefreshLayout = rootView.findViewById(swipeRefreshLayoutResId);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(getContext())) {
                mSwipeRefreshLayout.setRefreshing(false);
            } else {
                baseRecyclerAdapter.refresh();
            }
        }
    });
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) ExpandableGridSpacingDecorator(com.instructure.candroid.decorations.ExpandableGridSpacingDecorator) GridSpacingDecorator(com.instructure.candroid.decorations.GridSpacingDecorator) PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView) EmptyViewInterface(com.instructure.pandarecycler.interfaces.EmptyViewInterface) ExpandableGridSpacingDecorator(com.instructure.candroid.decorations.ExpandableGridSpacingDecorator) ExpandableRecyclerAdapter(com.instructure.candroid.adapter.ExpandableRecyclerAdapter) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) Point(android.graphics.Point) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 13 with Space

use of android.support.v4.widget.Space in project instructure-android by instructure.

the class ParentFragment method configureRecyclerViewAsGrid.

public void configureRecyclerViewAsGrid(View rootView, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, int emptyViewStringResId, final int span, View.OnClickListener emptyImageListener, Drawable... emptyImage) {
    final int cardPadding = getResources().getDimensionPixelOffset(R.dimen.card_outer_margin);
    EmptyViewInterface emptyViewInterface = (EmptyViewInterface) rootView.findViewById(emptyViewResId);
    final PandaRecyclerView recyclerView = (PandaRecyclerView) rootView.findViewById(recyclerViewResId);
    emptyViewInterface.emptyViewText(emptyViewStringResId);
    emptyViewInterface.setNoConnectionText(getString(R.string.noConnection));
    if (emptyImage != null && emptyImage.length > 0) {
        emptyViewInterface.emptyViewImage(emptyImage[0]);
        if (emptyImageListener != null && emptyViewInterface.getEmptyViewImage() != null) {
            emptyViewInterface.getEmptyViewImage().setOnClickListener(emptyImageListener);
        }
    }
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), span, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            if (position < recyclerView.getAdapter().getItemCount()) {
                int viewType = recyclerView.getAdapter().getItemViewType(position);
                if (Types.TYPE_HEADER == viewType || PaginatedRecyclerAdapter.LOADING_FOOTER_TYPE == viewType) {
                    return span;
                }
            } else {
                // if something goes wrong it will take up the entire space, but at least it won't crash
                return span;
            }
            return 1;
        }
    });
    if (mSpacingDecoration != null) {
        recyclerView.removeItemDecoration(mSpacingDecoration);
    }
    if (baseRecyclerAdapter instanceof ExpandableRecyclerAdapter) {
        mSpacingDecoration = new ExpandableGridSpacingDecorator(cardPadding);
    } else {
        mSpacingDecoration = new GridSpacingDecorator(cardPadding);
    }
    recyclerView.addItemDecoration(mSpacingDecoration);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new ExpandCollapseItemAnimator());
    recyclerView.setEmptyView(emptyViewInterface);
    recyclerView.setAdapter(baseRecyclerAdapter);
    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(swipeRefreshLayoutResId);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(getContext())) {
                mSwipeRefreshLayout.setRefreshing(false);
            } else {
                baseRecyclerAdapter.refresh();
            }
        }
    });
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridSpacingDecorator(com.instructure.speedgrader.decorations.GridSpacingDecorator) ExpandableGridSpacingDecorator(com.instructure.speedgrader.decorations.ExpandableGridSpacingDecorator) PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView) ExpandCollapseItemAnimator(com.instructure.speedgrader.animators.ExpandCollapseItemAnimator) EmptyViewInterface(com.instructure.pandarecycler.interfaces.EmptyViewInterface) ExpandableGridSpacingDecorator(com.instructure.speedgrader.decorations.ExpandableGridSpacingDecorator) ExpandableRecyclerAdapter(com.instructure.speedgrader.adapters.ExpandableRecyclerAdapter) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) Point(android.graphics.Point)

Example 14 with Space

use of android.support.v4.widget.Space in project instructure-android by instructure.

the class RecyclerViewUtils method configureRecyclerViewAsGrid.

public static PandaRecyclerView configureRecyclerViewAsGrid(View rootView, final Context context, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, final int span, String emptyViewString) {
    EmptyViewInterface emptyViewInterface = (EmptyViewInterface) rootView.findViewById(emptyViewResId);
    final PandaRecyclerView recyclerView = (PandaRecyclerView) rootView.findViewById(recyclerViewResId);
    emptyViewInterface.emptyViewText(emptyViewString);
    emptyViewInterface.setNoConnectionText(context.getString(R.string.noConnection));
    GridLayoutManager layoutManager = new GridLayoutManager(context, span, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            if (position < recyclerView.getAdapter().getItemCount()) {
                int viewType = recyclerView.getAdapter().getItemViewType(position);
                if (Types.TYPE_HEADER == viewType || PaginatedRecyclerAdapter.LOADING_FOOTER_TYPE == viewType) {
                    return 1;
                }
            } else {
                // if something goes wrong it will take up the entire space, but at least it won't crash
                return 1;
            }
            return 1;
        }
    });
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setEmptyView(emptyViewInterface);
    recyclerView.setAdapter(baseRecyclerAdapter);
    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(swipeRefreshLayoutResId);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(context)) {
                swipeRefreshLayout.setRefreshing(false);
            } else {
                baseRecyclerAdapter.refresh();
            }
        }
    });
    return recyclerView;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView) EmptyViewInterface(com.instructure.pandarecycler.interfaces.EmptyViewInterface) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 15 with Space

use of android.support.v4.widget.Space in project instructure-android by instructure.

the class RecyclerViewUtils method configureRecyclerViewAsGrid.

public static PandaRecyclerView configureRecyclerViewAsGrid(final Activity context, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, final int span, String emptyViewString) {
    EmptyViewInterface emptyViewInterface = (EmptyViewInterface) context.findViewById(emptyViewResId);
    final PandaRecyclerView recyclerView = (PandaRecyclerView) context.findViewById(recyclerViewResId);
    emptyViewInterface.emptyViewText(emptyViewString);
    emptyViewInterface.setNoConnectionText(context.getString(R.string.noConnection));
    GridLayoutManager layoutManager = new GridLayoutManager(context, span, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            if (position < recyclerView.getAdapter().getItemCount()) {
                int viewType = recyclerView.getAdapter().getItemViewType(position);
                if (Types.TYPE_HEADER == viewType || PaginatedRecyclerAdapter.LOADING_FOOTER_TYPE == viewType) {
                    return 1;
                }
            } else {
                // if something goes wrong it will take up the entire space, but at least it won't crash
                return 1;
            }
            return 1;
        }
    });
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setEmptyView(emptyViewInterface);
    recyclerView.setAdapter(baseRecyclerAdapter);
    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) context.findViewById(swipeRefreshLayoutResId);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(context)) {
                swipeRefreshLayout.setRefreshing(false);
            } else {
                baseRecyclerAdapter.refresh();
            }
        }
    });
    return recyclerView;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView) EmptyViewInterface(com.instructure.pandarecycler.interfaces.EmptyViewInterface) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

Space (android.support.v4.widget.Space)8 View (android.view.View)8 LinearLayout (android.widget.LinearLayout)6 TextView (android.widget.TextView)6 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)5 Point (android.graphics.Point)4 Bundle (android.os.Bundle)4 GridLayoutManager (android.support.v7.widget.GridLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 ViewGroup (android.view.ViewGroup)4 FrameLayout (android.widget.FrameLayout)4 ImageButton (android.widget.ImageButton)4 ImageView (android.widget.ImageView)4 PandaRecyclerView (com.instructure.pandarecycler.PandaRecyclerView)4 EmptyViewInterface (com.instructure.pandarecycler.interfaces.EmptyViewInterface)4 Context (android.content.Context)3 PackageManager (android.content.pm.PackageManager)3 ContextCompat (android.support.v4.content.ContextCompat)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3 SuppressLint (android.annotation.SuppressLint)2