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);
}
Aggregations