Example usage for android.widget LinearLayout removeAllViews

List of usage examples for android.widget LinearLayout removeAllViews

Introduction

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

Prototype

public void removeAllViews() 

Source Link

Document

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

Usage

From source file:com.fullmeadalchemist.mustwatch.ui.batch.form.BatchFormFragment.java

private void updateUiIngredientsTable() {
    if (viewModel.batch.ingredients != null) {
        // FIXME: this is not performant and looks ghetto.
        Timber.d("Found %s BatchIngredients for this Batch; adding them to the ingredientsList",
                viewModel.batch.ingredients.size());
        LinearLayout ingredientsList = activity.findViewById(R.id.ingredients_list);
        ingredientsList.removeAllViews();
        for (BatchIngredient ingredient : viewModel.batch.ingredients) {
            BatchIngredientView ingredientView = new BatchIngredientView(activity);
            ingredientView.setBatchIngredient(ingredient);
            ingredientsList.addView(ingredientView);
        }/*from   w ww.  ja v a  2s  .  c om*/
    } else {
        Timber.d("No Ingredients found for this Recipe.");
    }
}

From source file:com.thinkthinkdo.pff_appsettings.PermissionDetailFragment.java

private void displayButtons(LinearLayout buttonListView, String permName) {
    buttonListView.removeAllViews();
    int spacing = (int) (8 * mContext.getResources().getDisplayMetrics().density);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.topMargin = spacing * 2;/*from ww  w.  j a  v  a  2s .co  m*/
    View view = getSpoofButtonView(mContext, mInflater, permName, mUsedPerms, true);
    buttonListView.addView(view, lp);
    view = getSpoofButtonView(mContext, mInflater, permName, mUsedPerms, false);
    lp.topMargin = spacing / 2;
    buttonListView.addView(view, lp);
}

From source file:cz.muni.fi.japanesedictionary.fragments.DisplayCharacterInfo.java

@Override
public void kanjiVgLoaded(final List<SVG> svgs) {
    if (svgs == null || svgs.size() == 0) {
        Log.d(LOG_TAG, "svg is null");
        return;//from  w w w .j  av  a  2 s.com
    }
    if (getView() == null) {
        Log.d(LOG_TAG, "view is null");
        return;
    }
    if (getActivity() == null) {
        Log.d(LOG_TAG, "activity is null");
        return;
    }
    mSvgs = svgs;
    LinearLayout container = (LinearLayout) getView().findViewById(R.id.kanjidict_kanjivg_image_container);
    container.removeAllViews();
    /*
            int minSize;
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
    minSize = Math.min(width/2, height/2);
            }else {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    int width = display.getWidth();  // deprecated
    int height = display.getHeight();  // deprecated
    minSize = Math.min(width/2, height/2);
            }*/
    Resources r = getResources();
    int minSize = Math
            .round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, r.getDisplayMetrics()));

    mImageView = new SVGImageView(getActivity());
    mImageView.setMinimumHeight(minSize);
    mImageView.setMinimumWidth(minSize);
    mImageView.setSVG(mSvgs.get(mStep > mSvgs.size() - 1 ? 0 : mStep));
    container.addView(mImageView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    mTimerHandler.removeCallbacks(mTimerRunnable);
    mTimerHandler.postDelayed(mTimerRunnable, 0);
}

From source file:org.mifos.androidclient.main.CustomerDetailsActivity.java

private void updateContent(CustomerDetailsEntity details) {
    if (details != null) {
        mDetails = details;/*from  w w w.  j  a  v a  2 s  .c  om*/
        LinearLayout tabContent = (LinearLayout) findViewById(R.id.customer_overview);
        ViewBuilderFactory factory = new ViewBuilderFactory(this);
        CustomerDetailsViewBuilder builder = factory.createCustomerDetailsViewBuilder(details);
        View view;

        if (tabContent.getChildCount() > 0) {
            tabContent.removeAllViews();
        }
        tabContent.addView(builder.buildOverviewView());

        tabContent = (LinearLayout) findViewById(R.id.customer_accounts);
        if (tabContent.getChildCount() > 0) {
            tabContent.removeAllViews();
        }
        view = builder.buildAccountsView();
        setupAccountsListListeners(view);
        tabContent.addView(view);

        tabContent.addView(builder.buildAccountsView());

        tabContent = (LinearLayout) findViewById(R.id.customer_additional);
        if (tabContent.getChildCount() > 0) {
            tabContent.removeAllViews();
        }
        tabContent.addView(builder.buildAdditionalView());
    }
}

From source file:com.activiti.android.app.fragments.settings.AccountSettingsFragment.java

private void updateIntegrations() {
    Map<Long, Integration> integrationMap = IntegrationManager.getInstance(getActivity())
            .getByAccountId(accountId);// w  w w. j  a v  a 2  s  . c  o  m

    // No integration. Display nothing
    if (integrationMap == null || integrationMap.isEmpty()) {
        hide(R.id.settings_intregration_alfresco_parent_container);
        hide(R.id.settings_intregration_alfresco_parent_title);
        return;
    }

    LinearLayout integrationContainer = (LinearLayout) viewById(R.id.settings_intregration_alfresco_container);
    integrationContainer.removeAllViews();
    ThreeLinesViewHolder vh;
    View integrationView;
    int iconId, descriptionId;
    for (Map.Entry<Long, Integration> entry : integrationMap.entrySet()) {
        integrationView = LayoutInflater.from(getActivity()).inflate(R.layout.row_three_lines_caption,
                integrationContainer, false);
        integrationView.setTag(entry.getValue().getProviderId());

        vh = new ThreeLinesViewHolder(integrationView);
        vh.topText.setText(entry.getValue().getName());
        vh.middleText.setText(entry.getValue().getAccountUsername());
        vh.icon.setVisibility(View.VISIBLE);

        switch (entry.getValue().getOpenType()) {
        case Integration.OPEN_NATIVE_APP:
            iconId = R.drawable.alfresco_logo;
            descriptionId = R.string.settings_account_integration_alfresco_mobile;
            break;
        case Integration.OPEN_BROWSER:
            iconId = R.drawable.ic_open_in_browser_grey;
            descriptionId = R.string.settings_account_integration_alfresco_browser;
            break;
        default:
            iconId = R.drawable.ic_wrong_grey;
            descriptionId = R.string.settings_account_integration_alfresco_none;
            break;
        }
        vh.bottomText.setText(descriptionId);
        vh.icon.setImageResource(iconId);
        vh.choose.setVisibility(View.VISIBLE);
        vh.choose.setBackgroundResource(R.drawable.activititheme_list_selector_holo_light);
        vh.choose.setClickable(true);
        vh.choose.setPadding(16, 16, 16, 16);
        vh.choose.setImageResource(R.drawable.ic_more_grey);
        vh.choose.setTag(entry.getValue());
        vh.choose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                PopupMenu popup = new PopupMenu(getActivity(), v);
                if (((Integration) v.getTag()).getOpenType() == Integration.OPEN_UNDEFINED) {
                    popup.getMenuInflater().inflate(R.menu.integration_alfresco_add, popup.getMenu());
                } else {
                    popup.getMenuInflater().inflate(R.menu.integration_alfresco_remove, popup.getMenu());
                }
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        switch (item.getItemId()) {
                        case R.id.integration_alfresco_remove:
                            // Analytics
                            AnalyticsHelper.reportOperationEvent(getActivity(),
                                    AnalyticsManager.CATEGORY_SETTINGS,
                                    AnalyticsManager.ACTION_ALFRESCO_INTEGRATION, AnalyticsManager.LABEL_REMOVE,
                                    1, false);

                            IntegrationManager.getInstance(getActivity())
                                    .update(((Integration) v.getTag()).getProviderId(), -1l, null, null);
                            updateIntegrations();
                            break;
                        case R.id.integration_alfresco_mobile:
                            // Analytics
                            AnalyticsHelper.reportOperationEvent(getActivity(),
                                    AnalyticsManager.CATEGORY_SETTINGS,
                                    AnalyticsManager.ACTION_ALFRESCO_INTEGRATION,
                                    AnalyticsManager.LABEL_LINK_MOBILE, 1, false);

                            AlfrescoIntegrationFragment.with(getActivity())
                                    .integrationProviverId(((Integration) v.getTag()).getProviderId())
                                    .accountId(accountId).display();
                            break;
                        case R.id.integration_alfresco_web:
                            // Analytics
                            AnalyticsHelper.reportOperationEvent(getActivity(),
                                    AnalyticsManager.CATEGORY_SETTINGS,
                                    AnalyticsManager.ACTION_ALFRESCO_INTEGRATION,
                                    AnalyticsManager.LABEL_LINK_WEB, 1, false);

                            IntegrationManager.getInstance(getActivity()).update(
                                    ((Integration) v.getTag()).getProviderId(),
                                    IntegrationSchema.COLUMN_OPEN_TYPE, Integration.OPEN_BROWSER);
                            updateIntegrations();
                            break;
                        }
                        return true;
                    }
                });

                popup.show(); // showing popup menu
            }
        });
        integrationContainer.addView(integrationView);
    }
}

From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java

private boolean showPickupsInfo(final LocalDate date) {
    final List<PickupInfo> from = DB.pickups().findByFrom(date, true);
    if (!from.isEmpty()) {

        TextView title = ((TextView) bottomSheet.findViewById(R.id.bottom_sheet_title));

        LayoutInflater i = getLayoutInflater();
        LinearLayout list = (LinearLayout) findViewById(R.id.pickup_list);
        list.removeAllViews();
        for (final PickupInfo p : from) {

            Medicine m = DB.medicines().findById(p.medicine().getId());
            Patient pat = DB.patients().findById(m.patient().id());

            if (selectedPatientIdx == 0 || pat.id() == selectedPatientId) {

                View v = i.inflate(R.layout.calendar_pickup_list_item, null);
                TextView tv1 = ((TextView) v.findViewById(R.id.textView));
                TextView tv2 = ((TextView) v.findViewById(R.id.textView2));
                ImageView avatar = ((ImageView) v.findViewById(R.id.avatar));
                String interval = getResources().getString(R.string.pickup_interval, p.to().toString(df));

                if (p.taken()) {
                    interval += " ";
                    tv1.setAlpha(0.5f);//ww  w  .  j  a  va 2  s. c o  m
                } else {
                    tv1.setAlpha(1f);
                    tv2.setAlpha(1f);
                }

                tv1.setText(p.medicine().name());
                tv2.setText(interval);
                avatar.setImageResource(AvatarMgr.res(pat.avatar()));

                tv1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        p.taken(!p.taken());
                        DB.pickups().save(p);
                        showPickupsInfo(date);
                    }
                });
                list.addView(v);
            }
        }
        nestedScrollView.scrollBy(0, bottomSheet.getHeight());
        showBottomSheet();
        int total = list.getChildCount();
        title.setText(
                total + " " + getResources().getString(R.string.title_pickups_bottom_sheet, date.toString(df)));
        appBarLayout.setExpanded(false, true);
        return true;
    }
    return false;
}

From source file:org.alfresco.mobile.android.application.fragments.preferences.GeneralPreferences.java

private void recreate() {
    account = getAccount();//from   ww  w  .ja  va 2  s . c o m

    // Accounts
    List<AlfrescoAccount> accounts = AlfrescoAccountManager.retrieveAccounts(getActivity());
    View accountView;
    LinearLayout accountContainer = (LinearLayout) viewById(R.id.settings_accounts_container);
    accountContainer.removeAllViews();
    TwoLinesViewHolder vh;
    for (AlfrescoAccount account : accounts) {
        accountView = LayoutInflater.from(getActivity()).inflate(R.layout.row_two_lines_borderless_rounded,
                accountContainer, false);
        accountView.setTag(account.getId());
        vh = HolderUtils.configure(accountView, account.getUsername(), account.getTitle(),
                R.drawable.ic_account_circle_grey);
        AccountsAdapter.displayAvatar(getActivity(), account, R.drawable.ic_account_light, vh.icon);

        if (SessionManager.getInstance(getActivity()).getSession(account.getId()) != null) {
            vh.choose.setVisibility(View.VISIBLE);
            vh.choose.setTag(account);
            vh.choose.setImageResource(R.drawable.ic_validate);
            vh.choose.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    AlfrescoAccount acc = (AlfrescoAccount) v.getTag();
                    SessionManager.getInstance(getActivity()).saveAccount(acc);
                    if (getActivity() instanceof PrivateDialogActivity) {
                        getActivity().setResult(PrivateRequestCode.RESULT_REFRESH_SESSION);
                        getActivity().finish();
                    } else if (getActivity() instanceof MainActivity) {
                        EventBusManager.getInstance().post(new RequestSessionEvent(acc, true));
                    }
                }
            });
        }

        accountView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (mdmManager.hasConfig()) {
                    AlfrescoAccount selectedAccount = AlfrescoAccountManager.getInstance(getActivity())
                            .retrieveAccount((Long) v.getTag());
                    AccountSignInFragment.with(getActivity()).account(selectedAccount).display();
                } else {
                    AccountSettingsFragment.with(getActivity()).accountId((Long) v.getTag()).display();
                }
            }
        });
        accountContainer.addView(accountView);
    }

    // Add Account
    if (!mdmManager.hasConfig()) {
        HolderUtils.configure(viewById(R.id.settings_accounts_create), getString(R.string.action_add_account),
                R.drawable.ic_add);
        viewById(R.id.settings_accounts_create_container).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), WelcomeActivity.class);
                i.putExtra(WelcomeActivity.EXTRA_ADD_ACCOUNT, true);
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                getActivity().startActivity(i);
            }
        });
    } else {
        hide(R.id.settings_accounts_create_container);
    }

    // Preferences
    final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    // DATA PROTECTION
    dataProtectionVH = HolderUtils.configure(viewById(R.id.settings_privatefolder),
            getString(R.string.settings_privatefolder_title),
            getString(R.string.settings_privatefolder_summary), -1);
    HolderUtils.makeMultiLine(dataProtectionVH.bottomText, 2);

    if (!sharedPref.getBoolean(HAS_ACCESSED_PAID_SERVICES, false)) {
        viewById(R.id.settings_privatefolder_container).setFocusable(false);
        viewById(R.id.settings_privatefolder_container).setClickable(false);
        viewById(R.id.settings_privatefolder_container).setEnabled(false);
        dataProtectionVH.bottomText.setText(R.string.data_protection_unavailable);
        DataProtectionManager.getInstance(getActivity()).setDataProtectionEnable(false);
    } else {
        viewById(R.id.settings_privatefolder_container).setFocusable(true);
        viewById(R.id.settings_privatefolder_container).setClickable(true);
        viewById(R.id.settings_privatefolder_container).setEnabled(true);
        dataProtectionVH.bottomText
                .setText(DataProtectionManager.getInstance(getActivity()).hasDataProtectionEnable()
                        ? R.string.data_protection_on
                        : R.string.data_protection_off);
    }

    DataProtectionConfigFeature feature = new DataProtectionConfigFeature(getActivity());
    if (feature.isProtected()) {
        viewById(R.id.settings_privatefolder_container).setFocusable(false);
        viewById(R.id.settings_privatefolder_container).setClickable(false);
        viewById(R.id.settings_privatefolder_container).setEnabled(false);
        dataProtectionVH.bottomText.setText(R.string.mdm_managed);
    } else if (sharedPref.getBoolean(HAS_ACCESSED_PAID_SERVICES, false)) {
        viewById(R.id.settings_privatefolder_container).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final File folder = AlfrescoStorageManager.getInstance(getActivity()).getPrivateFolder("",
                        null);
                if (folder != null) {
                    DataProtectionUserDialogFragment.newInstance(false).show(
                            getActivity().getSupportFragmentManager(), DataProtectionUserDialogFragment.TAG);
                } else {
                    AlfrescoNotificationManager.getInstance(getActivity())
                            .showLongToast(getString(R.string.sdinaccessible));
                }

            }
        });
    }

    // PASSCODE
    passcodeVH = HolderUtils.configure(viewById(R.id.passcode_preference), getString(R.string.passcode_title),
            getString(R.string.passcode_preference), -1);

    // PASSCODE
    Boolean passcodeEnable = sharedPref.getBoolean(PasscodePreferences.KEY_PASSCODE_ENABLE, false);
    boolean isActivate = sharedPref.getBoolean(HAS_ACCESSED_PAID_SERVICES, false);
    viewById(R.id.passcode_preference_container).setFocusable(isActivate);
    viewById(R.id.passcode_preference_container).setClickable(isActivate);
    viewById(R.id.passcode_preference_container).setEnabled(isActivate);
    passcodeVH.bottomText.setText(passcodeEnable ? R.string.passcode_enable : R.string.passcode_disable);
    viewById(R.id.passcode_preference_container).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PasscodePreferences.with(getActivity()).display();
        }
    });

    PasscodeConfigFeature passcodeConfig = new PasscodeConfigFeature(getActivity());
    if (passcodeConfig.isProtected()) {
        passcodeVH.bottomText.setText(R.string.mdm_managed);
    }

    // In case of MDM we disable all enterprise feature
    if (mdmManager.hasConfig()) {
        viewById(R.id.settings_privatefolder_container).setEnabled(false);
        dataProtectionVH.bottomText.setText(R.string.mdm_managed);
        viewById(R.id.passcode_preference_container).setEnabled(false);
        passcodeVH.bottomText.setText(R.string.mdm_managed);
    }

    // Feedback - Analytics
    if (AnalyticsManager.getInstance(getActivity()) == null
            || AnalyticsManager.getInstance(getActivity()).isBlocked()) {
        boolean isEnable = AnalyticsManager.getInstance(getActivity()) != null
                && AnalyticsManager.getInstance(getActivity()).isEnable();

        diagnosticVH = HolderUtils.configure(viewById(R.id.settings_diagnostic),
                getString(R.string.settings_feedback_diagnostic),
                getString(R.string.settings_custom_menu_disable), isEnable);
        HolderUtils.makeMultiLine(diagnosticVH.bottomText, 3);
        diagnosticVH.choose.setVisibility(View.GONE);
        diagnosticVH.choose.setEnabled(false);
    } else {
        boolean isEnable = AnalyticsManager.getInstance(getActivity()) != null
                && AnalyticsManager.getInstance(getActivity()).isEnable();

        diagnosticVH = HolderUtils.configure(viewById(R.id.settings_diagnostic),
                getString(R.string.settings_feedback_diagnostic),
                getString(R.string.settings_feedback_diagnostic_summary), isEnable);
        HolderUtils.makeMultiLine(diagnosticVH.bottomText, 4);
        diagnosticVH.choose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (diagnosticVH.choose.isChecked()) {
                    AnalyticHelper.optIn(getActivity(), getAccount());
                } else {
                    AnalyticHelper.optOut(getActivity(), getAccount());
                }
            }
        });
    }
}

From source file:oyagev.projects.android.ArduCopter.BluetoothChat.java

private void cleanControls() {
    LinearLayout controls = ((LinearLayout) findViewById(R.id.controls_layout));
    controls.removeAllViews();
}

From source file:net.nakama.duckdroid.ui.Duckdroid.java

/**
 * //from  w  w w.jav  a 2s  .com
 * @param result
 */
private void manageResult(ZeroClickResponse result) {

    if (result.isBang() && result.getRedirect() != null && !result.getRedirect().equals("")) {
        startBrowserIntent(result.getRedirect());

    } else if (result.getFlatResults().size() == 0) {

        TextView nt = new TextView(this);
        nt.setText("^_^ No result...");
        LinearLayout ll = (LinearLayout) findViewById(R.id.lt_main);
        ll.removeAllViews();
        ll.addView(nt);

    } else {

        FragmentManager manager = getFragmentManager();
        FragmentTransaction trx = manager.beginTransaction();
        ResultFragment resultFragment = new ResultFragment(result);
        trx.replace(R.id.lt_main, resultFragment);
        //trx.add(R.id.lt_main, resultFragment);
        trx.addToBackStack(null);
        trx.commit();
    }
}

From source file:com.ess.tudarmstadt.de.sleepsense.mgraph.SleepEstimGPlotFragment.java

private void createGraph(String graphTitle, GraphViewSeries series, final int Rid, boolean isBarChart) {
    GraphView graphView = null;//from  www .  j av a 2 s.  c  o  m

    if (isBarChart) {
        graphView = new BarGraphView(getActivity().getApplicationContext(), graphTitle);
        // ((BarGraphView) graphView).setColWidth(1.09f);
        // graphView.setVerticalLabels(new String[] { "high", "mid", "low"
        // });
        // graphView.setManualYAxisBounds(11.0d, 9.0d);
    } else {
        graphView = new LineGraphView(getActivity().getApplicationContext(), graphTitle);

    }
    // add data
    graphView.addSeries(series);
    // graphView.setScrollable(true);
    // graphView.setViewPort(0, 23);
    // optional - activate scaling / zooming
    // graphView.setScalable(true);
    // optional - legend
    // graphView.setShowLegend(true);

    graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
        @Override
        public String formatLabel(double axis_value, boolean isValueX) {
            if (isValueX) {
                // X-Axis
                // decompose x_axis from adding up before
                double value = axis_value;
                if (axis_value >= 200) {
                    value = axis_value - 200;
                } else if (axis_value >= 100)
                    value = axis_value - 100;

                // convert (double) hour.mm to hour:mm
                // make sure not have smth like 4:60 or 11:83 in the time frame!
                double whole = value;
                double fractionalPart = value % 1;
                double integralPart = value - fractionalPart;
                if (fractionalPart >= 0.60) {
                    whole = integralPart + 1.0d + (fractionalPart - 0.60);
                }

                return new DecimalFormat("00.00").format(whole).replaceAll("\\,", ":");
            } else {
                // Y-Axis
                return ""; //new DecimalFormat("#0.0").format(axis_value);
            }
        }
    });

    graphView.getGraphViewStyle().setNumVerticalLabels(4);
    graphView.getGraphViewStyle().setNumHorizontalLabels(0); //AUTO
    graphView.getGraphViewStyle().setTextSize(17f);
    graphView.getGraphViewStyle().setVerticalLabelsAlign(Align.CENTER);
    graphView.getGraphViewStyle().setVerticalLabelsWidth(0);
    graphView.getGraphViewStyle().setGridColor(Color.WHITE);

    LinearLayout layout = (LinearLayout) rootView.findViewById(Rid);
    layout.removeAllViews();
    layout.addView(graphView);
    rootView.postInvalidate();
    layout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            openBig();
        }
    });

}