List of usage examples for android.widget AbsListView setCacheColorHint
public void setCacheColorHint(@ColorInt int color)
From source file:ti.modules.titanium.ui.widget.abslistview.TiAbsListView.java
public TiAbsListView(TiViewProxy proxy, Activity activity) { super(proxy); //initializing variables sections = Collections.synchronizedList(new ArrayList<AbsListSectionProxy>()); itemTypeCount = new AtomicInteger(CUSTOM_TEMPLATE_ITEM_TYPE); templatesByBinding = new HashMap<String, TiAbsListViewTemplate>(); defaultTemplateBinding = defaultTemplateKey; templatesByBinding.put(defaultTemplateKey, defaultTemplate); defaultTemplate.setType(BUILT_IN_TEMPLATE_ITEM_TYPE); caseInsensitive = true;//from w w w. j a va 2 s . c o m ignoreExactMatch = false; //handling marker HashMap preloadMarker = ((AbsListViewProxy) proxy).getPreloadMarker(); if (preloadMarker != null) { setMarker(preloadMarker); } else { resetMarker(); } final KrollProxy fProxy = proxy; //initializing listView listView = createListView(activity); listView.setSelector(android.R.color.transparent); listView.setAreHeadersSticky(false); // listView.setDuplicateParentStateEnabled(true); AbsListView internalListView = getInternalListView(); if (TiC.LOLLIPOP_OR_GREATER) { listView.setNestedScrollingEnabled(true); internalListView.setNestedScrollingEnabled(true); } if (internalListView instanceof ListView) { ((ListView) internalListView).setHeaderDividersEnabled(false); ((ListView) internalListView).setFooterDividersEnabled(false); } if (listView instanceof CustomListView) { ((CustomListView) listView).setOnPullListener(new OnPullListener() { private boolean canUpdate = false; @Override public void onPull(boolean canUpdate) { if (canUpdate != this.canUpdate) { this.canUpdate = canUpdate; if (fProxy.hasListeners(TiC.EVENT_PULL_CHANGED, false)) { KrollDict event = dictForScrollEvent(); event.put("active", canUpdate); fProxy.fireEvent(TiC.EVENT_PULL_CHANGED, event, false, false); } } if (fProxy.hasListeners(TiC.EVENT_PULL, false)) { KrollDict event = dictForScrollEvent(); event.put("active", canUpdate); fProxy.fireEvent(TiC.EVENT_PULL, event, false, false); } } @Override public void onPullEnd(boolean canUpdate) { if (fProxy.hasListeners(TiC.EVENT_PULL_END, false)) { KrollDict event = dictForScrollEvent(); event.put("active", canUpdate); fProxy.fireEvent(TiC.EVENT_PULL_END, event, false, false); } } }); } adapter = new TiBaseAdapter(activity); listView.setOnScrollListener(new OnScrollListener() { private boolean scrollTouch = false; private int lastValidfirstItem = 0; private Timer endTimer = null; public void cancelEndCall() { if (endTimer != null) { endTimer.cancel(); endTimer = null; } } public void delayEndCall() { cancelEndCall(); endTimer = new Timer(); TimerTask action = new TimerTask() { public void run() { scrollTouch = false; if (fProxy.hasListeners(TiC.EVENT_SCROLLEND, false)) { fProxy.fireEvent(TiC.EVENT_SCROLLEND, dictForScrollEvent(), false, false); } } }; this.endTimer.schedule(action, 200); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { view.requestDisallowInterceptTouchEvent(scrollState != ViewPager.SCROLL_STATE_IDLE); if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) { if (scrollTouch) { delayEndCall(); } } else if (scrollState == OnScrollListener.SCROLL_STATE_FLING) { cancelEndCall(); } else if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { cancelEndCall(); if (hideKeyboardOnScroll && hasFocus()) { blur(); } if (scrollTouch == false) { scrollTouch = true; if (fProxy.hasListeners(TiC.EVENT_SCROLLSTART, false)) { fProxy.fireEvent(TiC.EVENT_SCROLLSTART, dictForScrollEvent(), false, false); } } } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // Log.d(TAG, "onScroll : " + scrollValid, Log.DEBUG_MODE); // boolean fireScroll = scrollValid; // if (!fireScroll && visibleItemCount > 0) { // //Items in a list can be selected with a track ball in which case // //we must check to see if the first visibleItem has changed. // fireScroll = (lastValidfirstItem != firstVisibleItem); // } if (fProxy.hasListeners(TiC.EVENT_SCROLL, false)) { int newScrollOffset = getScroll(); // Log.d(TAG, "newScrollOffset : " + newScrollOffset, Log.DEBUG_MODE); lastValidfirstItem = firstVisibleItem; if (newScrollOffset != currentScrollOffset) { currentScrollOffset = newScrollOffset; fProxy.fireEvent(TiC.EVENT_SCROLL, dictForScrollEvent(currentScrollOffset), false, false); } } } }); listView.setOnStickyHeaderChangedListener(new OnStickyHeaderChangedListener() { @Override public void onStickyHeaderChanged(StickyListHeadersListViewAbstract l, View header, int itemPosition, long headerId) { //for us headerId is the section index int sectionIndex = (int) headerId; if (fProxy.hasListeners(TiC.EVENT_HEADER_CHANGE, false)) { KrollDict data = new KrollDict(); AbsListSectionProxy section = null; synchronized (sections) { if (sectionIndex >= 0 && sectionIndex < sections.size()) { section = sections.get(sectionIndex); } else { return; } } data.put(TiC.PROPERTY_HEADER_VIEW, section.getHoldedProxy(TiC.PROPERTY_HEADER_VIEW)); data.put(TiC.PROPERTY_SECTION, section); data.put(TiC.PROPERTY_SECTION_INDEX, sectionIndex); fProxy.fireEvent(TiC.EVENT_HEADER_CHANGE, data, false, false); } } }); internalListView.setCacheColorHint(Color.TRANSPARENT); listView.setEnabled(true); getLayoutParams().autoFillsHeight = true; getLayoutParams().autoFillsWidth = true; // listView.setFocusable(false); listView.setFocusable(true); listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); // try { // // headerFooterId = TiRHelper.getApplicationResource("layout.titanium_ui_list_header_or_footer"); // // titleId = TiRHelper.getApplicationResource("id.titanium_ui_list_header_or_footer_title"); // isCheck = TiRHelper.getApplicationResource("drawable.btn_check_buttonless_on_64"); // hasChild = TiRHelper.getApplicationResource("drawable.btn_more_64"); // disclosure = TiRHelper.getApplicationResource("drawable.disclosure_64"); // } catch (ResourceNotFoundException e) { // Log.e(TAG, "XML resources could not be found!!!", Log.DEBUG_MODE); // } setNativeView(listView); }