List of usage examples for android.view ViewGroup removeViewAt
public void removeViewAt(int index)
From source file:com.juick.android.JuickMessagesAdapter.java
public void recycleView(View view) { if (view instanceof ViewGroup) { ListRowRuntime lrr = (ListRowRuntime) view.getTag(); if (lrr != null) { if (lrr.userpicListener != null) { lrr.removeListenerIfExists(); }// w w w .j a v a 2 s .c o m } ViewGroup vg = (ViewGroup) view; if (vg.getChildCount() > 1 && vg.getChildAt(1) instanceof ImageGallery && vg instanceof PressableLinearLayout) { PressableLinearLayout pll = (PressableLinearLayout) vg; // our view ImageGallery gallery = (ImageGallery) vg.getChildAt(1); Object tag = gallery.getTag(); if (tag instanceof HashMap) { HashMap<Integer, ImageLoaderConfiguration> loaders = (HashMap<Integer, ImageLoaderConfiguration>) tag; for (ImageLoaderConfiguration imageLoader : loaders.values()) { imageLoader.loader.terminate(); } } pll.blockLayoutRequests = true; gallery.cleanup(); gallery.setTag(null); vg.removeViewAt(1); vg.measure(View.MeasureSpec.makeMeasureSpec(vg.getRight() - vg.getLeft(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); vg.layout(vg.getLeft(), vg.getTop(), vg.getRight(), vg.getTop() + vg.getMeasuredHeight()); pll.blockLayoutRequests = false; } } }
From source file:com.mooshim.mooshimeter.main.ScanActivity.java
private void refreshMeterTile(final MooshimeterDevice d, final ViewGroup wrapper) { if (wrapper.getChildCount() == 0) { Log.e(TAG, "Received empty wrapper"); }/*w ww. ja v a2s . c om*/ if (wrapper.getChildCount() > 0) { // Update the title bar int rssi = d.mRssi; String name; String build; if (d.mOADMode) { name = "Bootloader"; } else { name = d.getBLEDevice().getName(); if (name == null) { name = "Unknown device"; } } if (d.mBuildTime == 0) { build = "Invalid firmware"; } else { build = "Build: " + d.mBuildTime; } String descr = name + "\n" + build + "\nRssi: " + rssi + " dBm"; ((TextView) wrapper.findViewById(R.id.descr)).setText(descr); final Button bv = (Button) wrapper.findViewById(R.id.btnConnect); int bgid = d.mConnectionState == BluetoothProfile.STATE_CONNECTED ? R.drawable.connected : R.drawable.disconnected; bv.setBackground(getResources().getDrawable(bgid)); // Set the click listeners bv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleConnectionState(bv, d); } }); } if (d.mInitialized && !d.isInOADMode()) { // We are representing a connected meter if (wrapper.getChildCount() != 2) { // We need to create a new value pane wrapper.addView(mInflater.inflate(R.layout.element_mm_readingsbar, mDeviceScrollView, false)); } Util.dispatch(new Runnable() { @Override public void run() { if (!d.isNotificationEnabled(d.getChar(MooshimeterDevice.mUUID.METER_SAMPLE))) { // We need to enable notifications d.playSampleStream(new Runnable() { @Override public void run() { TextView ch1 = (TextView) wrapper.findViewById(R.id.ch1_value_label); TextView ch2 = (TextView) wrapper.findViewById(R.id.ch2_value_label); TextView ch1_unit = (TextView) wrapper.findViewById(R.id.ch1_unit_label); TextView ch2_unit = (TextView) wrapper.findViewById(R.id.ch2_unit_label); valueLabelRefresh(0, d, ch1, ch1_unit); valueLabelRefresh(1, d, ch2, ch2_unit); } }); } } }); } else { //We are representing a disconnected meter or a meter in OAD mode if (wrapper.getChildCount() == 2) { // We need to eliminate a pane wrapper.removeViewAt(1); } } }
From source file:com.android.launcher2.Launcher.java
public void showFirstRunWorkspaceCling() { // Enable the clings only if they have not been dismissed before if (isClingsEnabled() && !mSharedPrefs.getBoolean(Cling.WORKSPACE_CLING_DISMISSED_KEY, false) && !skipCustomClingIfNoAccounts()) { // If we're not using the default workspace layout, replace workspace cling // with a custom workspace cling (usually specified in an overlay) // For now, only do this on tablets if (mSharedPrefs.getInt(LauncherProvider.DEFAULT_WORKSPACE_RESOURCE_ID, 0) != 0 && getResources().getBoolean(R.bool.config_useCustomClings)) { // Use a custom cling View cling = findViewById(R.id.workspace_cling); ViewGroup clingParent = (ViewGroup) cling.getParent(); int clingIndex = clingParent.indexOfChild(cling); clingParent.removeViewAt(clingIndex); View customCling = mInflater.inflate(R.layout.custom_workspace_cling, clingParent, false); clingParent.addView(customCling, clingIndex); customCling.setId(R.id.workspace_cling); }/* ww w . j av a 2s . c om*/ initCling(R.id.workspace_cling, null, false, 0); } else { removeCling(R.id.workspace_cling); } }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
private void rebuildNotifications() { final long now = SystemClock.elapsedRealtime(); ViewGroup container = mIconsContainer; final int childCount = container.getChildCount(); // Count the number of non-notification fragments // such as unlock or music controls fragments. int start = 0; for (int i = 0; i < childCount; i++) { View child = container.getChildAt(i); Widget fragment = findWidgetByIcon(child); if (fragment instanceof NotifyWidget) { // Those fragments are placed at the begin of layout // so no reason to continue searching. break; } else {/* w w w . j a va2s . c om*/ start++; } } final ArrayList<OpenNotification> list = NotificationPresenter.getInstance().getList(); final int notifyCount = list.size(); final boolean[] notifyUsed = new boolean[notifyCount]; final boolean[] childUsed = new boolean[childCount]; for (int i = start; i < childCount; i++) { View child = container.getChildAt(i); NotifyWidget widget = (NotifyWidget) findWidgetByIcon(child); OpenNotification target = widget.getNotification(); for (int j = 0; j < notifyCount; j++) { OpenNotification n = list.get(j); if (NotificationUtils.hasIdenticalIds(target, n)) { notifyUsed[j] = true; childUsed[i] = true; if (target != n) { widget.setNotification(n); } break; } } } // Re-use free views and remove redundant views. boolean removeAllAfter = false; for (int a = start, j = 0, offset = 0; a < childCount; a++) { if (childUsed[a]) continue; final int i = a + offset; View child = container.getChildAt(i); removing_all_next_views: { if (!removeAllAfter) { for (; j < notifyCount; j++) { if (notifyUsed[j]) continue; assert child != null; notifyUsed[j] = true; NotifyWidget nw = (NotifyWidget) findWidgetByIcon(child); nw.setNotification(list.get(j)); break removing_all_next_views; } } removeAllAfter = true; internalReleaseWidget(child); // Remove widget's icon. container.removeViewAt(i); offset--; } } assert getActivity() != null; LayoutInflater inflater = getActivity().getLayoutInflater(); final int iconSize = getConfig().getIconSizePx(); for (int i = 0; i < notifyCount; i++) { if (notifyUsed[i]) continue; NotifyWidget nw = new NotifyWidget(this, this); if (isResumed()) nw.start(); View iconView = nw.createIconView(inflater, container); ViewUtils.setSize(iconView, iconSize); container.addView(iconView); nw.setNotification(list.get(i)); mWidgetsMap.put(iconView, nw); } // ///////////////////// // ~~ UPDATE HASH MAP ~~ // ///////////////////// HashMap<String, SceneCompat> map = (HashMap<String, SceneCompat>) mScenesMap.clone(); mScenesMap.clear(); for (Widget fragment : mWidgetsMap.values()) { String type = fragment.getClass().getName(); SceneCompat scene = map.get(type); if (scene != null) { fragment.createView(null, null, scene.getView()); } else { ViewGroup sceneView = fragment.createView(inflater, mSceneContainer, null); if (sceneView != null) { scene = new SceneCompat(mSceneContainer, sceneView); map.put(type, scene); } } if (scene != null) { mScenesMap.put(type, scene); } } if (DEBUG) { long delta = SystemClock.elapsedRealtime() - now; Log.d(TAG, "Fragment list updated in " + delta + "ms."); } // Do not animate divider's visibility change on // pause/resume, cause it _somehow_ confuses people. boolean animate = !mResuming; updateDividerVisibility(animate); }
From source file:com.android.soma.Launcher.java
public void showFirstRunCling() { if (isClingsEnabled() && !mSharedPrefs.getBoolean(Cling.FIRST_RUN_CLING_DISMISSED_KEY, false) && !skipCustomClingIfNoAccounts()) { // If we're not using the default workspace layout, replace workspace cling // with a custom workspace cling (usually specified in an overlay) // For now, only do this on tablets if (!DISABLE_CUSTOM_CLINGS) { if (mSharedPrefs.getInt(LauncherProvider.DEFAULT_WORKSPACE_RESOURCE_ID, 0) != 0 && getResources().getBoolean(R.bool.config_useCustomClings)) { // Use a custom cling View cling = findViewById(R.id.workspace_cling); ViewGroup clingParent = (ViewGroup) cling.getParent(); int clingIndex = clingParent.indexOfChild(cling); clingParent.removeViewAt(clingIndex); View customCling = mInflater.inflate(R.layout.custom_workspace_cling, clingParent, false); clingParent.addView(customCling, clingIndex); customCling.setId(R.id.workspace_cling); }//from w w w. j a va2 s .co m } Cling cling = (Cling) findViewById(R.id.first_run_cling); if (cling != null) { String sbHintStr = getFirstRunClingSearchBarHint(); String ccHintStr = getFirstRunCustomContentHint(); if (!sbHintStr.isEmpty()) { TextView sbHint = (TextView) cling.findViewById(R.id.search_bar_hint); sbHint.setText(sbHintStr); sbHint.setVisibility(View.VISIBLE); } setCustomContentHintVisibility(cling, ccHintStr, true, false); } initCling(R.id.first_run_cling, 0, false, true); } else { removeCling(R.id.first_run_cling); } }