private void onTabChangedIndex(int index, boolean byself) { // Utils.platformLog("#$#$#$#$#$#$#$#$#$", "onTabChangedIndex( "+String.valueOf(index)+" )"); int new_tabIndex = index; sel_col = 0; sel_col_enable = false; TabData data = tabData.elementAt(new_tabIndex); if (data == null) { return; } if (data.disabled) { // return to previous selected tabHost.setCurrentTab(tabIndex); return; } boolean real_change = (tabIndex != new_tabIndex); if (real_change && byself) { tabHost.setCurrentTab(new_tabIndex); // all will processed when onTabChanged received return; } tabIndex = new_tabIndex; if (real_change && (mChangeTabCallback != null)) { callChangeTabCallback(tabIndex); } if ((data.reload /*|| real_change*/) || !data.loaded) { if (mIsReallyOnScreen) { RhodesService.loadUrl(data.url); data.loaded = true; } } sel_col = data.selected_color; sel_col_enable = data.selected_color_enabled; if (mIsReallyOnScreen && real_change) { processTabHostColors(tabHost, sel_col, sel_col_enable); } }
public void loadFirstPage() { int sel_col = 0; boolean sel_col_enable = false; int cur_tabIndex = 0; TabData data = null; boolean founded_not_disabled = false; while ((!founded_not_disabled) && (cur_tabIndex < tabData.size())) { data = tabData.elementAt(cur_tabIndex); if ((data != null) && (!data.disabled)) { founded_not_disabled = true; } else { cur_tabIndex++; } } if (!founded_not_disabled) { Logger.E(TAG, "ERROR : All tabs is disabled !!! "); } if ((tabIndex != cur_tabIndex) && (tabIndex != 0)) { data = tabData.elementAt(tabIndex); } else { tabIndex = cur_tabIndex; } if (data != null) { sel_col = data.selected_color; sel_col_enable = data.selected_color_enabled; } // processTabHostColors(host, sel_col, sel_col_enable); host.requestLayout(); TabHostClickListener listener = new TabHostClickListener(); listener.tabHost = host; host.setOnTabChangedListener(listener); for (int i = 0; i < host.getTabWidget().getChildCount(); i++) { host.getTabWidget().getChildAt(i).setOnTouchListener(listener); host.getTabWidget().getChildAt(i).setOnClickListener(listener); } if (data != null) { try { if (!data.loaded) { RhodesService.loadUrl(data.url); data.loaded = true; } sel_col = data.selected_color; sel_col_enable = data.selected_color_enabled; } catch (NumberFormatException e) { Logger.E(TAG, e); } processTabHostColors(host, sel_col, sel_col_enable); } host.setCurrentTab(tabIndex); RhodesActivity.safeGetInstance() .post( new Runnable() { public void run() { // Utils.platformLog("TabbedMainView", "invoke post setup code in UI thread"); // invoke in UI thread int i; for (i = 0; i < tabData.size(); i++) { TabData data = tabData.elementAt(i); if (i != tabIndex) { data.loaded = false; } if (i != tabIndex) { WebView wv = getWebView(i); wv.clearView(); wv.clearCache(true); wv.invalidate(); wv.loadData("", "", ""); } } TabData selected_data = tabData.elementAt(tabIndex); if (!selected_data.loaded) { RhodesService.loadUrl(selected_data.url); selected_data.loaded = true; } mIsReallyOnScreen = true; } }); }