Example usage for android.view ViewTreeObserver.OnGlobalLayoutListener ViewTreeObserver.OnGlobalLayoutListener

List of usage examples for android.view ViewTreeObserver.OnGlobalLayoutListener ViewTreeObserver.OnGlobalLayoutListener

Introduction

In this page you can find the example usage for android.view ViewTreeObserver.OnGlobalLayoutListener ViewTreeObserver.OnGlobalLayoutListener.

Prototype

ViewTreeObserver.OnGlobalLayoutListener

Source Link

Usage

From source file:uk.ac.hutton.ics.buntata.activity.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ButterKnife.bind(this);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   ww w  .j  a v a 2s  . c o m*/

    /* Set the toolbar as the action bar */
    if (getSupportActionBar() != null) {
        /* Set the title */
        getSupportActionBar().setTitle(" ");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    getWindow().getDecorView()
            .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getWindow().setStatusBarColor(Color.TRANSPARENT);

    /* Get the view pager and set the fragment adapter */
    viewPager.setAdapter(new AboutFragmentPagerAdapter(getSupportFragmentManager(), this));
    tabLayout.setupWithViewPager(viewPager);

    final float heightDp = getResources().getDisplayMetrics().heightPixels / 2f;
    final CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) aboutImage
            .getLayoutParams();

    aboutImage.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            aboutImage.getViewTreeObserver().removeOnGlobalLayoutListener(this);

            if (aboutImage.getHeight() > heightDp)
                lp.height = (int) heightDp;
        }
    });

    /* Get the CollapsingToolbarLayout and listen for offset change events to show/hide the toolbar title, i.e. it'll only be shown when the toolbar is fully collapsed */
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        boolean show = false;
        int scrollRange = -1;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (scrollRange == -1) {
                scrollRange = appBarLayout.getTotalScrollRange();
            }
            if (scrollRange + verticalOffset == 0) {
                collapsingToolbarLayout.setTitle(getString(R.string.title_activity_about));
                show = true;
            } else if (show) {
                collapsingToolbarLayout.setTitle(" "); // careful there should a space between double quote otherwise it won't work
                show = false;
            }
        }
    });
}

From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    mTickersContainer = (FixedGridView) getView().findViewById(R.id.tickersContainer);
    mTickersContainer.setExpanded(true);
    final int dashboardSpacing = getResources().getDimensionPixelSize(R.dimen.dashboard_spacing);
    final int dashboardItemSize = getResources().getDimensionPixelSize(R.dimen.dashboard_item_size);
    mTickersContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override//  w w w . j av a 2  s .  c o  m
                public void onGlobalLayout() {
                    if (mTickersDashboardAdapter.getNumColumns() == 0) {
                        final int numColumns = (int) Math
                                .floor(mTickersContainer.getWidth() / (dashboardSpacing + dashboardItemSize));
                        if (numColumns > 0) {
                            mTickersDashboardAdapter.setNumColumns(numColumns);
                            mTickersContainer.setNumColumns(numColumns);
                        }
                    }
                }
            });
    mTickersDashboardAdapter = new TickersDashboardAdapter(getActivity(), this);
    updateStorageWithTickers();
    mTickersDashboardAdapter.update();
    mTickersContainer.setAdapter(mTickersDashboardAdapter);
    TextView emptyView = (TextView) getView().findViewById(R.id.emptyView);
    mTickersContainer.setEmptyView(emptyView);
    mTickersContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return event.getAction() == MotionEvent.ACTION_MOVE;
        }
    });

    //Broadcast receiver initialization
    mGetStatsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (isVisible()) {
                if (mRefreshItem != null) {
                    mRefreshItem.collapseActionView();
                    mRefreshItem.setActionView(null);
                }
                mTickersDashboardAdapter.update();
            }
        }
    };

    LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(mGetStatsReceiver,
            new IntentFilter("UpdateTickers"));

    //Trade listener, once "Buy" or "Sell" clicked, send the order to server
    View.OnClickListener tradeListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new RegisterTradeRequestTask().execute((v.getId() == R.id.BuyButton) ? "buy" : "sell");
        }
    };

    Button SellButton = (Button) getView().findViewById(R.id.SellButton);
    Button BuyButton = (Button) getView().findViewById(R.id.BuyButton);
    SellButton.setOnClickListener(tradeListener);
    BuyButton.setOnClickListener(tradeListener);

    Button UpdateAccountInfoButton = (Button) getView().findViewById(R.id.UpdateAccountInfoButton);

    UpdateAccountInfoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new UpdateFundsTask().execute();
        }
    });

    //start service to get new data once Dashboard is opened
    getActivity().sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class));
}

From source file:org.anothermonitor.ActivityPreferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preferences);
    mPrefs = getSharedPreferences(getString(R.string.app_name) + "Prefs", MODE_PRIVATE);
    res = getResources();/*from ww  w  .  j a v  a2s .c  o  m*/
    navigationBarHeight = res
            .getDimensionPixelSize(res.getIdentifier("navigation_bar_height", "dimen", "android"));

    mLTabs = (LinearLayout) findViewById(R.id.LTabs);

    if (Build.VERSION.SDK_INT >= 19) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

        sSW = res.getConfiguration().smallestScreenWidthDp;

        int statusBarHeight = res
                .getDimensionPixelSize(res.getIdentifier("status_bar_height", "dimen", "android"));

        if (!ViewConfiguration.get(this).hasPermanentMenuKey()
                && (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || sSW > 560)) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
            FrameLayout nb = (FrameLayout) findViewById(R.id.LNavigationBar);
            nb.setVisibility(View.VISIBLE);
            ((FrameLayout.LayoutParams) nb.getLayoutParams()).height = navigationBarHeight;
        }

        int paddingTop = mLTabs.getPaddingTop();
        int paddingBottom = mLTabs.getPaddingBottom();
        int paddingLeft = mLTabs.getPaddingLeft();
        int paddingRight = mLTabs.getPaddingRight();
        mLTabs.setPadding(paddingLeft, paddingTop + statusBarHeight, paddingRight, paddingBottom);
    }

    findViewById(R.id.TVTabMain).setActivated(true);
    findViewById(R.id.TVTabMain).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mVP.setCurrentItem(0);
        }
    });
    findViewById(R.id.TVTabShowRecord).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mVP.setCurrentItem(1);
        }
    });

    mVP = (ViewPager) findViewById(R.id.VP);
    mVP.setAdapter(new MyPreferencesAdapter());
    //      mVP.setOffscreenPageLimit(2);
    mVP.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            int currentItem = 0;
            if (position == 1)
                currentItem = 2;
            mLTabs.getChildAt(currentItem).setActivated(true);
            mLTabs.getChildAt(previousSelected).setActivated(false);
            previousSelected = currentItem;
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
    mVP.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mVP.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            if (currentItem != -1)
                mVP.setCurrentItem(currentItem, false);
        }
    });

    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        mB = savedInstanceState;
        currentItem = savedInstanceState.getInt(C.currentItem);

        currentItem = savedInstanceState.getInt(C.currentItem);
        currentItem = savedInstanceState.getInt(C.currentItem);
        currentItem = savedInstanceState.getInt(C.currentItem);
    }
}

From source file:net.wespot.pim.view.InqImageGridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.fragment_data_collect_grid, container, false);
    final GridView mGridView = (GridView) v.findViewById(R.id.gridView);
    mGridView.setAdapter(mAdapter);//  w  w  w . jav a2  s. co  m
    mGridView.setOnItemClickListener(this);
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause fetcher to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                // Before Honeycomb pause image loading on scroll to help with performance
                if (!Utils.hasHoneycomb()) {
                    mImageFetcher.setPauseWork(true);
                }
            } else {
                mImageFetcher.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
        }
    });

    // This listener is used to get the final width of the GridView and then calculate the
    // number of columns and the width of each column. The width of each column is variable
    // as the GridView has stretchMode=columnWidth. The column width is used to set the height
    // of each view so we get nice square thumbnails.
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @TargetApi(VERSION_CODES.JELLY_BEAN)
        @Override
        public void onGlobalLayout() {
            if (mAdapter.getNumColumns() == 0) {
                final int numColumns = (int) Math
                        .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                if (numColumns > 0) {
                    final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                    mAdapter.setNumColumns(numColumns);
                    mAdapter.setItemHeight(columnWidth);
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "onCreateView - numColumns set to " + numColumns);
                    }
                    if (Utils.hasJellyBean()) {
                        mGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }
            }
        }
    });

    return v;
}

From source file:uk.ac.hutton.ics.buntata.fragment.NodeFragment.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    /*//from www.j av  a 2s  .com
     * We wait for the orientation change to take full effect, i.e. wait until the new layout has finished.
     * Then let the adapter know about it so that it can resize its children accordingly.
     */
    recyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            /* Remember to remove this listener again */
            recyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);

            updateItemDecorator();
            adapter.notifyDataSetChanged();
        }
    });
}

From source file:com.mklodoss.SexyGirl.displayingbitmaps.ui.ImageGridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.image_grid_fragment, container, false);
    mGridView = (GridView) v.findViewById(R.id.gridView);
    mGridView.setAdapter(mAdapter);/*ww  w .  ja  v  a 2 s .c  om*/
    mGridView.setBackgroundColor(Color.GRAY);
    mGridView.setOnItemClickListener(this);
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause fetcher to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                // Before Honeycomb pause image loading on scroll to help with performance
                if (!Utils.hasHoneycomb()) {
                    //mImageFetcher.setPauseWork(true);
                }
            } else {
                //mImageFetcher.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
        }
    });

    // This listener is used to get the final width of the GridView and then calculate the
    // number of columns and the width of each column. The width of each column is variable
    // as the GridView has stretchMode=columnWidth. The column width is used to set the height
    // of each view so we get nice square thumbnails.
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @TargetApi(VERSION_CODES.JELLY_BEAN)
        @Override
        public void onGlobalLayout() {
            if (mAdapter.getNumColumns() == 0) {
                final int numColumns = (int) Math
                        .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                if (numColumns > 0) {
                    final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                    mAdapter.setNumColumns(numColumns);
                    mAdapter.setItemHeight((int) (columnWidth * 1.46));
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "onCreateView - numColumns set to " + numColumns);
                    }
                    if (Utils.hasJellyBean()) {
                        mGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }
            }
        }
    });

    return v;
}

From source file:net.wespot.pim.controller.ImageGridFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.fragment_image_grid, container, false);
    mGridView = (GridView) v.findViewById(R.id.gridView1);

    mGridView.setAdapter(mAdapter);/*from  ww w . j  av a 2 s.  c om*/

    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause fetcher to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                // Before Honeycomb pause image loading on scroll to help with performance
                if (!Utils.hasHoneycomb()) {
                    mImageFetcher.setPauseWork(true);
                }
            } else {
                mImageFetcher.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
        }
    });

    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (mAdapter.getNumColumns() == 0) {
                final int numColumns = (int) Math
                        .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                if (numColumns > 0) {
                    final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                    mAdapter.setNumColumns(numColumns);
                    mAdapter.setItemHeight(columnWidth);
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "onCreateView - numColumns set to " + numColumns);
                    }
                    if (Utils.hasJellyBean()) {
                        mGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    } else {
                        mGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                    }
                }
            }
        }
    });

    return v;
}

From source file:uk.ac.hutton.ics.buntata.activity.NodeDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ButterKnife.bind(this);

    /* Get parameters */
    Bundle args = getIntent().getExtras();
    Uri data = getIntent().getData();/*  www.j  a  va2 s.c  om*/

    int preferedMediumId = -1;

    /* If this Activity has been called based on deep linking, then get the parameters from the request */
    if (data != null) {
        String paramDatasourceId = data.getQueryParameter("d");
        try {
            datasourceId = Integer.parseInt(paramDatasourceId);
            PreferenceUtils.setPreferenceAsInt(this, PreferenceUtils.PREFS_SELECTED_DATASOURCE_ID,
                    datasourceId);
        } catch (NullPointerException | NumberFormatException e) {
        }
        String paramNodeId = data.getQueryParameter("n");
        try {
            nodeId = Integer.parseInt(paramNodeId);
        } catch (NullPointerException | NumberFormatException e) {
        }

        List<BuntataDatasource> datasources = new DatasourceManager(this, -1).getAll();

        BuntataDatasource datasource = null;
        if (datasources != null) {
            for (BuntataDatasource ds : datasources) {
                if (ds.getId() == datasourceId)
                    datasource = ds;
            }
        }

        if (datasource == null) {
            ToastUtils.INSTANCE.createToast(this, R.string.toast_datasource_not_found, Toast.LENGTH_LONG);
            this.finish();
        } else {
            BuntataNodeAdvanced node = new NodeManager(this, datasourceId).getById(nodeId);

            if (node == null) {
                ToastUtils.INSTANCE.createToast(this, R.string.toast_node_not_found, Toast.LENGTH_LONG);
                this.finish();
            }
        }
    }
    /* Otherwise get the parameters from the calling Activity */
    else if (args != null) {
        datasourceId = args.getInt(PARAM_DATASOURCE_ID, -1);
        nodeId = args.getInt(PARAM_NODE_ID, -1);
        preferedMediumId = args.getInt(PARAM_PREFERED_FIRST_MEDIUM, -1);
    }

    /* Initialize the media manager */
    MediaManager mediaManager = new MediaManager(this, datasourceId);
    NodeManager nodeManager = new NodeManager(this, datasourceId);

    setSupportActionBar(toolbar);

    /* Get the node */
    BuntataNode node = new NodeManager(this, datasourceId).getById(nodeId);

    GoogleAnalyticsUtils.trackEvent(this, getTracker(TrackerName.APP_TRACKER),
            getString(R.string.ga_event_category_node), getString(R.string.ga_event_action_node_view),
            node.getName());

    /* Set the toolbar as the action bar */
    if (getSupportActionBar() != null) {
        /* Set the title */
        getSupportActionBar().setTitle(node.getName());
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    /* Get all the media */
    List<BuntataMediaAdvanced> media = mediaManager.getForNode(null, nodeId);
    Map<String, List<BuntataMediaAdvanced>> splitByType = mediaManager.splitByType(media);

    int imageCount = splitByType.get(BuntataMediaType.TYPE_IMAGE).size();
    if (imageCount > 0) {
        /* Set to the pager */
        final ImagePagerAdapter adapter = new ImagePagerAdapter(getSupportFragmentManager(), datasourceId,
                nodeId, false, splitByType.get(BuntataMediaType.TYPE_IMAGE), preferedMediumId);
        pager.setAdapter(adapter);
        circleIndicator.setViewPager(pager);
        circleIndicator.setVisibility(imageCount > 1 ? View.VISIBLE : View.GONE);

        float heightDp = getResources().getDisplayMetrics().heightPixels / 1.5f;
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
        lp.height = (int) heightDp;
    } else {
        /* Hide the views */
        pager.setVisibility(View.GONE);
        circleIndicator.setVisibility(View.GONE);

        /* Tell the coordinator to wrap its content */
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
        lp.height = CoordinatorLayout.LayoutParams.WRAP_CONTENT;
        appBarLayout.setFitsSystemWindows(false);
    }

    /* Get all the attributes */
    List<BuntataAttributeValueAdvanced> attributeValues = new AttributeValueManager(this, datasourceId)
            .getForNode(nodeId);

    /* Set them to the recycler view */
    attributeRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    attributeRecyclerView.setAdapter(new AttributeValueVideoAdapter(this, datasourceId, attributeValues,
            splitByType.get(BuntataMediaType.TYPE_VIDEO)));

    /* Set the separator width */
    final int valueInPixels = getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
    final int horizontalMargin = getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
    final int verticalMargin = getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);

    /* Add the item decorator */
    attributeRecyclerView.addItemDecoration(
            new GridSpacingItemDecoration(1, horizontalMargin, verticalMargin, valueInPixels / 2));

    /* Get all the similar nodes */
    final List<BuntataNodeAdvanced> similarNodeList = nodeManager.getSimilarNodes(nodeId);

    if (similarNodeList.size() > 0) {
        similarNodesLayout.setVisibility(View.VISIBLE);

        /* Wait for the view to fully become visible */
        similarNodesLayout.getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        similarNodesLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);

                        /* Then add the data */
                        similarNodes.setLayoutManager(new LinearLayoutManager(NodeDetailsActivity.this,
                                LinearLayoutManager.HORIZONTAL, false));
                        similarNodes.addItemDecoration(new GridSpacingItemDecoration(similarNodeList.size(),
                                horizontalMargin, verticalMargin, valueInPixels / 2));
                        similarNodes.setAdapter(new NodeAdapter(NodeDetailsActivity.this, similarNodes,
                                datasourceId, -1, similarNodeList) {
                            @Override
                            public void onNodeClicked(View transitionRoot, View title,
                                    BuntataMediaAdvanced medium, BuntataNodeAdvanced node) {
                                /* Open the details activity */
                                Intent intent = new Intent(getApplicationContext(), NodeDetailsActivity.class);

                                /* Pass parameters */
                                Bundle args = new Bundle();
                                args.putInt(NodeDetailsActivity.PARAM_NODE_ID, node.getId());
                                args.putInt(NodeDetailsActivity.PARAM_DATASOURCE_ID, node.getDatasourceId());
                                args.putInt(NodeDetailsActivity.PARAM_PREFERED_FIRST_MEDIUM, -1);
                                intent.putExtras(args);

                                startActivity(intent);
                            }
                        });

                        /* Snap the recyclerview items */
                        SnapHelper helper = new LinearSnapHelper();
                        helper.attachToRecyclerView(similarNodes);
                    }
                });
    }
}