Example usage for android.widget ScrollView removeAllViews

List of usage examples for android.widget ScrollView removeAllViews

Introduction

In this page you can find the example usage for android.widget ScrollView removeAllViews.

Prototype

public void removeAllViews() 

Source Link

Document

Call this method to remove all child views from the ViewGroup.

Usage

From source file:edu.htl3r.schoolplanner.gui.timetable.Overlay.Info.ViewTypeSwitcherTask.java

@Override
protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    wvpageadapter.reset(weekView, weekView.getSettings());

    for (int i = 0; i < myViewPager.getChildCount(); i++) {
        ScrollView scr = (ScrollView) myViewPager.getChildAt(i);
        scr.removeAllViews();
    }//ww w  .  j  av  a2  s  .c  om
    myViewPager.removeAllViews();
    wvpageadapter.notifyDataSetChanged();

    Toast.makeText(weekView, vt.getName(), Toast.LENGTH_SHORT).show();
}

From source file:edu.htl3r.schoolplanner.gui.timetable.WeekViewPageAdapter.java

@Override
public void destroyItem(View collection, int arg1, Object view) {
    ScrollView s = (ScrollView) view;
    s.removeAllViews();
    ((ViewPager) collection).removeView(s);
}

From source file:li.klass.fhem.fragments.core.DeviceDetailFragment.java

@Override
public void update(boolean doUpdate) {
    hideEmptyView();/*from   w w w  .  j  a  va2 s.  c o  m*/

    if (doUpdate)
        getActivity().sendBroadcast(new Intent(Actions.SHOW_EXECUTING_DIALOG));

    Intent intent = new Intent(Actions.GET_DEVICE_FOR_NAME);
    intent.setClass(getActivity(), RoomListIntentService.class);
    intent.putExtra(BundleExtraKeys.DO_REFRESH, doUpdate);
    intent.putExtra(BundleExtraKeys.DEVICE_NAME, deviceName);
    intent.putExtra(BundleExtraKeys.RESULT_RECEIVER, new ResultReceiver(new Handler()) {
        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            super.onReceiveResult(resultCode, resultData);

            FragmentActivity activity = getActivity();
            if (activity == null)
                return;

            activity.sendBroadcast(new Intent(Actions.DISMISS_EXECUTING_DIALOG));

            if (resultCode == ResultCodes.SUCCESS && getView() != null) {
                FhemDevice device = (FhemDevice) resultData.getSerializable(BundleExtraKeys.DEVICE);
                long lastUpdate = resultData.getLong(BundleExtraKeys.LAST_UPDATE);

                if (device == null)
                    return;

                DeviceAdapter adapter = DeviceType.getAdapterFor(device);
                if (adapter == null) {
                    return;
                }
                adapter.attach(DeviceDetailFragment.this.getActivity());
                ScrollView scrollView = (ScrollView) getView().findViewById(R.id.deviceDetailView);
                if (scrollView != null) {
                    scrollView.removeAllViews();
                    scrollView.addView(adapter.createDetailView(activity, device, lastUpdate));
                }
            }
        }
    });
    getActivity().startService(intent);
}

From source file:ch.fixme.status.Main.java

private void populateDataHs() {
    try {/* www.  j  a va2  s  . c o m*/
        HashMap<String, Object> data = new ParseGeneric(mResultHs).getData();

        // Initialize views
        LayoutInflater inflater = getLayoutInflater();
        LinearLayout vg = (LinearLayout) inflater.inflate(R.layout.base, null);
        ScrollView scroll = (ScrollView) findViewById(R.id.scroll);
        scroll.removeAllViews();
        scroll.addView(vg);

        // Mandatory fields
        ((TextView) findViewById(R.id.space_name)).setText((String) data.get(ParseGeneric.API_NAME));
        ((TextView) findViewById(R.id.space_url)).setText((String) data.get(ParseGeneric.API_URL));
        getImageTask = new GetImage(R.id.space_image);
        getImageTask.execute((String) data.get(ParseGeneric.API_LOGO));

        // Status text
        String status_txt = "";
        if ((Boolean) data.get(ParseGeneric.API_STATUS)) {
            status_txt = OPEN;
            ((TextView) findViewById(R.id.status_txt))
                    .setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.presence_online, 0, 0, 0);
        } else {
            status_txt = CLOSED;
            ((TextView) findViewById(R.id.status_txt))
                    .setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.presence_busy, 0, 0, 0);
        }
        if (data.containsKey(ParseGeneric.API_STATUS_TXT)) {
            status_txt += ": " + (String) data.get(ParseGeneric.API_STATUS_TXT);
        }
        ((TextView) findViewById(R.id.status_txt)).setText(status_txt);

        // Status last change
        if (data.containsKey(ParseGeneric.API_LASTCHANGE)) {
            TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
            tv.setAutoLinkMask(0);
            tv.setText(
                    getString(R.string.api_lastchange) + " " + (String) data.get(ParseGeneric.API_LASTCHANGE));
            vg.addView(tv);
        }

        // Status duration
        if (data.containsKey(ParseGeneric.API_EXT_DURATION) && (Boolean) data.get(ParseGeneric.API_STATUS)) {
            TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
            tv.setText(getString(R.string.api_duration) + " " + (String) data.get(ParseGeneric.API_EXT_DURATION)
                    + getString(R.string.api_duration_hours));
            vg.addView(tv);
        }

        // Location
        Pattern ptn = Pattern.compile("^.*$", Pattern.DOTALL);
        if (data.containsKey(ParseGeneric.API_ADDRESS) || data.containsKey(ParseGeneric.API_LON)) {
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(getString(R.string.api_location));
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);
            // Address
            if (data.containsKey(ParseGeneric.API_ADDRESS)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setAutoLinkMask(0);
                tv.setText((String) data.get(ParseGeneric.API_ADDRESS));
                Linkify.addLinks(tv, ptn, MAP_SEARCH);
                vg.addView(tv);
            }
            // Lon/Lat
            if (data.containsKey(ParseGeneric.API_LON) && data.containsKey(ParseGeneric.API_LAT)) {
                String addr = (data.containsKey(ParseGeneric.API_ADDRESS))
                        ? (String) data.get(ParseGeneric.API_ADDRESS)
                        : getString(R.string.empty);
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setAutoLinkMask(0);
                tv.setText((String) data.get(ParseGeneric.API_LON) + ", "
                        + (String) data.get(ParseGeneric.API_LAT));
                Linkify.addLinks(tv, ptn, String.format(MAP_COORD, (String) data.get(ParseGeneric.API_LAT),
                        (String) data.get(ParseGeneric.API_LON), addr));
                vg.addView(tv);
            }
        }

        // Contact
        if (data.containsKey(ParseGeneric.API_PHONE) || data.containsKey(ParseGeneric.API_TWITTER)
                || data.containsKey(ParseGeneric.API_IRC) || data.containsKey(ParseGeneric.API_EMAIL)
                || data.containsKey(ParseGeneric.API_ML)) {
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(R.string.api_contact);
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);

            // Phone
            if (data.containsKey(ParseGeneric.API_PHONE)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_PHONE));
                vg.addView(tv);
            }
            // SIP
            if (data.containsKey(ParseGeneric.API_SIP)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_SIP));
                vg.addView(tv);
            }
            // Twitter
            if (data.containsKey(ParseGeneric.API_TWITTER)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText(TWITTER + (String) data.get(ParseGeneric.API_TWITTER));
                vg.addView(tv);
            }
            // Identica
            if (data.containsKey(ParseGeneric.API_IDENTICA)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_IDENTICA));
                vg.addView(tv);
            }
            // Foursquare
            if (data.containsKey(ParseGeneric.API_FOURSQUARE)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText(FOURSQUARE + (String) data.get(ParseGeneric.API_FOURSQUARE));
                vg.addView(tv);
            }
            // IRC
            if (data.containsKey(ParseGeneric.API_IRC)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setAutoLinkMask(0);
                tv.setText((String) data.get(ParseGeneric.API_IRC));
                vg.addView(tv);
            }
            // Email
            if (data.containsKey(ParseGeneric.API_EMAIL)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_EMAIL));
                vg.addView(tv);
            }
            // Jabber
            if (data.containsKey(ParseGeneric.API_JABBER)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_JABBER));
                vg.addView(tv);
            }
            // Mailing-List
            if (data.containsKey(ParseGeneric.API_ML)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_ML));
                vg.addView(tv);
            }
        }

        // Sensors
        if (data.containsKey(ParseGeneric.API_SENSORS)) {
            // Title
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(getString(R.string.api_sensors));
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);

            HashMap<String, ArrayList<HashMap<String, String>>> sensors = (HashMap<String, ArrayList<HashMap<String, String>>>) data
                    .get(ParseGeneric.API_SENSORS);
            Set<String> names = sensors.keySet();
            Iterator<String> it = names.iterator();
            while (it.hasNext()) {
                String name = it.next();
                // Subtitle
                String name_title = name.toLowerCase().replace("_", " ");
                name_title = name_title.substring(0, 1).toUpperCase()
                        + name_title.substring(1, name_title.length());
                TextView subtitle = (TextView) inflater.inflate(R.layout.subtitle, null);
                subtitle.setText(name_title);
                vg.addView(subtitle);
                // Sensors data
                ArrayList<HashMap<String, String>> sensorsData = sensors.get(name);
                for (HashMap<String, String> elem : sensorsData) {
                    RelativeLayout rl = (RelativeLayout) inflater.inflate(R.layout.entry_sensor, null);
                    if (elem.containsKey(ParseGeneric.API_VALUE)) {
                        ((TextView) rl.findViewById(R.id.entry_value))
                                .setText(elem.get(ParseGeneric.API_VALUE));
                    } else {
                        rl.findViewById(R.id.entry_value).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_UNIT)) {
                        ((TextView) rl.findViewById(R.id.entry_unit)).setText(elem.get(ParseGeneric.API_UNIT));
                    } else {
                        rl.findViewById(R.id.entry_unit).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_NAME2)) {
                        ((TextView) rl.findViewById(R.id.entry_name)).setText(elem.get(ParseGeneric.API_NAME2));
                    } else {
                        rl.findViewById(R.id.entry_name).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_LOCATION2)) {
                        ((TextView) rl.findViewById(R.id.entry_location))
                                .setText(elem.get(ParseGeneric.API_LOCATION2));
                    } else {
                        rl.findViewById(R.id.entry_location).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_DESCRIPTION)) {
                        ((TextView) rl.findViewById(R.id.entry_description))
                                .setText(elem.get(ParseGeneric.API_DESCRIPTION));
                    } else {
                        rl.findViewById(R.id.entry_description).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_PROPERTIES)) {
                        ((TextView) rl.findViewById(R.id.entry_properties))
                                .setText(elem.get(ParseGeneric.API_PROPERTIES));
                    } else {
                        rl.findViewById(R.id.entry_properties).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_MACHINES)) {
                        ((TextView) rl.findViewById(R.id.entry_other))
                                .setText(elem.get(ParseGeneric.API_MACHINES));
                    } else if (elem.containsKey(ParseGeneric.API_NAMES)) {
                        ((TextView) rl.findViewById(R.id.entry_other))
                                .setText(elem.get(ParseGeneric.API_NAMES));
                    } else {
                        rl.findViewById(R.id.entry_other).setVisibility(View.GONE);
                    }
                    vg.addView(rl);
                }
            }
        }

        // Stream and cam
        if (data.containsKey(ParseGeneric.API_STREAM) || data.containsKey(ParseGeneric.API_CAM)) {
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(getString(R.string.api_stream));
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);
            // Stream
            if (data.containsKey(ParseGeneric.API_STREAM)) {
                HashMap<String, String> stream = (HashMap<String, String>) data.get(ParseGeneric.API_STREAM);
                for (Entry<String, String> entry : stream.entrySet()) {
                    final String type = entry.getKey();
                    final String url = entry.getValue();
                    TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                    tv.setText(url);
                    tv.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            Intent i = new Intent(Intent.ACTION_VIEW);
                            i.setDataAndType(Uri.parse(url), type);
                            startActivity(i);
                        }
                    });
                    vg.addView(tv);
                }
            }
            // Cam
            if (data.containsKey(ParseGeneric.API_CAM)) {
                HashMap<String, String> cam = (HashMap<String, String>) data.get(ParseGeneric.API_CAM);
                for (String value : cam.values()) {
                    TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                    tv.setText(value);
                    vg.addView(tv);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        showError(e.getClass().getCanonicalName(), e.getLocalizedMessage() + getString(R.string.error_generic));
    }
}