Search in sources :

Example 1 with CardUI

use of com.fima.cardsui.views.CardUI in project Rashr by DsLNeXuS.

the class FlashFragment method optimizeLayout.

/**
     * optimizeLayout checks which cards need to be added to UI. So if you device doesn't support
     * kernel flashing optimizeLayout will not add it to UI.
     *
     * @param root RootView from Fragment
     * @throws NullPointerException layout can't be inflated
     */
@SuppressLint("PrivateResource")
public void optimizeLayout(View root) throws NullPointerException {
    CardUI RashrCards = (CardUI) root.findViewById(R.id.RashrCards);
    if (RashrApp.DEVICE.isRecoverySupported() || RashrApp.DEVICE.isKernelSupported() || BuildConfig.DEBUG) {
        /** If device is supported start setting up layout */
        setupSwipeUpdater(root);
        /** Avoid overlapping scroll on CardUI and SwipeRefreshLayout */
        RashrCards.getListView().setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                int topRowVerticalPosition = (view == null || view.getChildCount() == 0) ? 0 : view.getChildAt(0).getTop();
                if (mSwipeUpdater != null)
                    mSwipeUpdater.setEnabled((topRowVerticalPosition >= 0));
            }
        });
        if (RashrApp.DEVICE.isRecoverySupported() || BuildConfig.DEBUG) {
            addRecoveryCards(RashrCards);
        }
        if (RashrApp.DEVICE.isKernelSupported() || BuildConfig.DEBUG) {
            addKernelCards(RashrCards);
        }
        //Device has been flashed over Rashr so you can choose previously used images
        if (getHistoryFiles().size() > 0) {
            final IconCard HistoryCard = new IconCard(getString(R.string.history), R.drawable.ic_history, getString(R.string.history_description));
            HistoryCard.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    showFlashHistory();
                }
            });
            RashrCards.addCard(HistoryCard, true);
        }
    }
    addRebooterCards(RashrCards);
}
Also used : CardUI(com.fima.cardsui.views.CardUI) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) IconCard(com.fima.cardsui.views.IconCard) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 CardUI (com.fima.cardsui.views.CardUI)1 IconCard (com.fima.cardsui.views.IconCard)1