List of usage examples for android.widget ScrollView invalidate
public void invalidate()
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the CPU value for each core. * /*from w ww . ja v a 2 s.c om*/ * @return a ScrollView containing a list of BarView. */ private View createCPUListDialog() { ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getCpu_cores(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = Double.parseDouble(item.getValue()); LinearLayout row = createTableRow(LinearLayout.HORIZONTAL); AFBarView barView = createBarView(value); row.addView(barView); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk usage for each disk. * /* w w w.j a v a2 s . co m*/ * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskListDialog() { // use the scroll view to scale ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_percent_part(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = Double.parseDouble(item.getValue()); String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.HORIZONTAL); AFPieView pieView = createPieView(value); row.addView(pieView); TextView text = new TextView(this); text.setPadding(10, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(String.format("%s - %.1f %s used", name, value, "%")); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }
From source file:com.bq.robotic.robopad_plusplus.fragments.ScheduleRobotMovementsFragment.java
/** * Set the listeners to the views that need them. It must be done here in the fragment in order * to get the callback here and not in the FragmentActivity, that would be a mess with all the * callbacks of all the possible fragments *//*from w w w .ja v a 2 s .co m*/ private void setUiListeners() { gridView.setOnRearrangeListener(new OnRearrangeListener() { public void onRearrange(int oldIndex, int newIndex) { if (scheduledControls.isEmpty()) { return; } String scheduledControl = scheduledControls.remove(oldIndex); if (oldIndex < newIndex) scheduledControls.add(newIndex, scheduledControl); else scheduledControls.add(newIndex, scheduledControl); } public void onRearrange(boolean isDraggedDeleted, int draggedDeletedIndex) { if (scheduledControls.isEmpty()) { return; } if (isDraggedDeleted) { scheduledControls.remove(draggedDeletedIndex); } } }); GridLayout movementsViews = (GridLayout) getActivity().findViewById(R.id.type_of_movements_container); for (int i = 0; i < movementsViews.getChildCount(); i++) { movementsViews.getChildAt(i).setOnClickListener(onMovementsButtonClick); } LinearLayout optionsLayout = (LinearLayout) getActivity().findViewById(R.id.menu_options_container); for (int i = 0; i < optionsLayout.getChildCount(); i++) { optionsLayout.getChildAt(i).setOnClickListener(onOptionsButtonClick); } // Resize the GridLayout depending on the number of icons (depending on the current robot // selected). In order not to get too much number of columns in little screen, it is limited // to two and scroll the screen if there are more icons. If scroll is not needed the icons // are centered in the layout final GridLayout typeOfMovementsContainer = (GridLayout) getActivity() .findViewById(R.id.type_of_movements_container); final ViewTreeObserver vto = typeOfMovementsContainer.getViewTreeObserver(); final ViewTreeObserver.OnPreDrawListener preDrawListener = new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { Rect scrollBounds = new Rect(); ScrollView scroll = (ScrollView) getActivity().findViewById(R.id.scroll_container); scroll.getDrawingRect(scrollBounds); // int finalHeight = scrollBounds.bottom - getActivity().getResources().getDimensionPixelSize(R.dimen.scheduler_grid_margin); int finalHeight = scrollBounds.bottom; int childCount = typeOfMovementsContainer.getChildCount(); if (childCount > 1) { for (int i = 0; i < childCount; i++) { if (typeOfMovementsContainer.getChildAt(i).getBottom() > finalHeight) { typeOfMovementsContainer.setColumnCount(2); break; } } } scroll.invalidate(); final ViewTreeObserver vto = typeOfMovementsContainer.getViewTreeObserver(); vto.removeOnPreDrawListener(this); return true; } }; vto.addOnPreDrawListener(preDrawListener); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a ScrollView to display the Disk busy for each disk. * /*from w w w . j a v a2s .co m*/ * @return a ScrollView containing a list of AFBarView and AFPieView. */ private View createDiskBusyListDialog() { ScrollView container = createOuterContainer(); LinearLayout innerContainer = createInnerContainer(); List<BasicNameValuePair> items = data.getDisk_busy(); for (int i = 0; i < items.size(); i++) { BasicNameValuePair item = items.get(i); Double value = 0.0; try { value = Double.parseDouble(item.getValue()); } catch (Exception e) { e.printStackTrace(); continue; } String name = item.getName(); LinearLayout row = createTableRow(LinearLayout.VERTICAL); TextView text = new TextView(this); text.setPadding(5, 0, 0, 0); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); text.setText(name); AFBarView barView = createBarView(value); row.addView(barView); row.addView(text); innerContainer.addView(row); } container.addView(innerContainer); innerContainer.invalidate(); container.invalidate(); return container; }