Example usage for android.view ViewGroup removeView

List of usage examples for android.view ViewGroup removeView

Introduction

In this page you can find the example usage for android.view ViewGroup removeView.

Prototype

@Override
public void removeView(View view) 

Source Link

Document

Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.

Usage

From source file:com.concentricsky.android.khanacademy.app.ShowProfileActivity.java

/**
 * Show a loading indicator./*  w  w w . j  a  v a2  s  .c o m*/
 */
protected void showSpinner() {
    if (spinnerView == null) {
        spinnerView = getLayoutInflater().inflate(R.layout.spinner, null, false);
    }
    handler.post(new Runnable() {
        @Override
        public void run() {
            ViewGroup parent = (ViewGroup) spinnerView.getParent();
            if (parent != null)
                parent.removeView(spinnerView);
            ((FrameLayout) findViewById(R.id.popover_view)).addView(spinnerView);
        }
    });
}

From source file:com.concentricsky.android.khanacademy.app.ShowProfileActivity.java

/**
 * Hide any loading indicator./* w ww  .  ja v  a  2  s  . co  m*/
 */
protected void hideSpinner() {
    if (spinnerView != null) {
        handler.post(new Runnable() {
            @Override
            public void run() {
                ViewGroup parent = (ViewGroup) spinnerView.getParent();
                if (parent != null)
                    parent.removeView(spinnerView);
            }
        });
    }
}

From source file:br.com.bioscada.apps.biotracks.fragments.ChartFragment.java

@Override
public void onStop() {
    super.onStop();
    ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout);
    layout.removeView(chartView);
}

From source file:com.yahala.ui.ContactsActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (fragmentView == null) {
        fragmentView = inflater.inflate(R.layout.contacts_layout, container, false);

        emptyTextView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
        emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
        // searchListViewAdapter = new ContactsActivitySearchAdapter(parentActivity, ignoreUsers);
        // FileLog.e("Test", "Contact activity onCreateView");
        listView = (ListView) fragmentView.findViewById(R.id.listView);
        progressLayout = (FrameLayout) fragmentView.findViewById(R.id.progressLayout);

        listView.setVerticalScrollBarEnabled(true);
        progressLayout.setVisibility(View.GONE);

        listViewAdapter = new ContactsAdapter(parentActivity, R.id.listView, null);
        listView.setAdapter(listViewAdapter);
        /* else if(com.yahala.xmpp.ContactsController.getInstance().first){
        listViewAdapter.notifyDataSetChanged();
        }*//* w  ww  . j  a  va 2  s . co m*/
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                /* if (scrollState != 0)
                listViewAdapter.isScrolling = true;
                 else {
                listViewAdapter.isScrolling = false;
                listViewAdapter.notifyDataSetChanged();
                 }*/
            }

            @Override
            public void onScroll(AbsListView absListView, int i, int i2, int i3) {

            }
        });
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                TLRPC.User user = listViewAdapter.getItem(i);
                //FileLog.e("tmessages", i+"");
                if (i == 0) {

                    try {
                        Intent intent = new Intent(Intent.ACTION_SEND);
                        intent.setType("text/plain");
                        intent.putExtra(Intent.EXTRA_TEXT, inviteText != null ? inviteText
                                : LocaleController.getString("InviteText", R.string.InviteText));
                        startActivity(intent);
                    } catch (Exception e) {
                    }
                    return;
                }
                /*  if (i == 1) {
                FragmentActivity inflaterActivity = parentActivity;
                if (inflaterActivity == null) {
                    inflaterActivity = getActivity();
                }
                BaseFragment fragment = new GroupCreateActivity();
                fragment.parentActivity = parentActivity;
                //fragment3.applySelfActionBar();
                ((LaunchActivity) parentActivity).presentFragment(fragment, "GroupCreate_" + Math.random(), false);
                return;
                  }*/
                if (i == 1) {

                    listView.getChildAt(i).setEnabled(false);
                    return;
                } else {
                    FragmentActivity inflaterActivity = parentActivity;
                    if (inflaterActivity == null) {
                        inflaterActivity = getActivity();
                    }

                    ChatActivity fragment = new ChatActivity();
                    Bundle bundle = new Bundle();
                    bundle.putInt("user_id", 0);

                    bundle.putString("user_jid", user.jid);
                    // FileLog.e("Testing","listView onItemClick "+user.first_name);
                    //
                    // fragment.setArguments(bundle);
                    // ApplicationLoader.fragmentsStack.remove(ApplicationLoader.fragmentsStack.size() - 1);
                    // ApplicationLoader.fragmentsStack.add(fragment);

                    // ((LaunchActivity) parentActivity).current.onFragmentDestroy();

                    //fragment.setArguments(bundle);

                    fragment.setArguments(bundle);

                    ((LaunchActivity) inflaterActivity).presentFragment(fragment, "chat" + Math.random(),
                            false);
                    //((CallMainActivity) parentActivity).presentFragment(fragment, "chat" + Math.random(), destroyAfterSelect, false);
                    return;
                }

            }
        });

    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }

    return fragmentView;
}

From source file:com.android.ted.sample.viewpager.MainPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView;//from w w  w .  j  a  va  2  s . c  o  m
    Girl girl = mAllGirlList.get(position);
    if (mAllImageMap.containsKey(position)) {
        View oldView = mAllImageMap.get(position);
        Object tag = oldView.getTag();
        if (null != tag && tag instanceof Girl) {
            if (tag.equals(girl)) {
                itemView = oldView;
                container.addView(itemView);
                return itemView;
            }
        }
        container.removeView(oldView);
        mAllImageMap.remove(position);
    }

    ImageView imageView = new ImageView(mContext);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    Glide.with(mContext).load(girl.getImageUrl()).into(imageView);
    imageView.setTag(girl);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    mAllImageMap.put(position, imageView);
    itemView = imageView;
    itemView.setOnClickListener(this);
    container.addView(itemView);
    return itemView;
}

From source file:com.ayo.opensource.zlayout.MainPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView;//from   w w  w. ja v a 2  s  .c  om
    Girl girl = mAllGirlList.get(position);
    if (mAllImageMap.containsKey(position)) {
        View oldView = mAllImageMap.get(position);
        Object tag = oldView.getTag();
        if (null != tag && tag instanceof Girl) {
            if (tag.equals(girl)) {
                itemView = oldView;
                container.addView(itemView);
                return itemView;
            }
        }
        container.removeView(oldView);
        mAllImageMap.remove(position);
    }

    ImageView imageView = new ImageView(mContext);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    VanGogh.paper(imageView).paintMiddleImage(girl.getImageUrl(), null, null);
    //Glide.with(mContext).load(girl.getImageUrl()).into(imageView);
    imageView.setTag(girl);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    mAllImageMap.put(position, imageView);
    itemView = imageView;
    itemView.setOnClickListener(this);
    container.addView(itemView);
    return itemView;
}

From source file:android.support.v7.internal.widget.ActionBarContextView.java

@Override
public void setSplitToolbar(boolean split) {
    if (mSplitActionBar != split) {
        if (mActionMenuPresenter != null) {
            // Mode is already active; move everything over and adjust the menu itself.
            final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            if (!split) {
                mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
                mMenuView.setBackgroundDrawable(null);
                final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
                if (oldParent != null)
                    oldParent.removeView(mMenuView);
                addView(mMenuView, layoutParams);
            } else {
                // Allow full screen width in split mode.
                mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels,
                        true);//from  w ww.  j  a v  a  2 s  .co  m
                // No limit to the item count; use whatever will fit.
                mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
                // Span the whole width
                layoutParams.width = LayoutParams.MATCH_PARENT;
                layoutParams.height = mContentHeight;
                mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
                mMenuView.setBackgroundDrawable(mSplitBackground);
                final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
                if (oldParent != null)
                    oldParent.removeView(mMenuView);
                mSplitView.addView(mMenuView, layoutParams);
            }
        }
        super.setSplitToolbar(split);
    }
}

From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java

public void hideCustomView() {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    LogUtils.d("Hidding Custom View");
    if (mCustomView == null) {
        return;//  w  w  w.  j a v a  2 s .  co m
    }

    // Hide the custom view.
    mCustomView.setVisibility(View.GONE);

    // Remove the custom view from its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    if (background != null) {
        parent.setBackground(background);
    }
    parent.removeView(mCustomView);
    mCustomView = null;
    mCustomViewCallback.onCustomViewHidden();

    // Show the content view.
    this.setVisibility(View.VISIBLE);
    if (objects != null && objects.length > 0) {
        for (Object obj : objects) {
            if (obj instanceof View) {
                ((View) obj).setVisibility(View.VISIBLE);
            } else if (obj instanceof Fragment) {
                ((Fragment) obj).getView().setVisibility(View.VISIBLE);
            }
        }
    }
    ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    final WindowManager.LayoutParams attrs = ((Activity) mContext).getWindow().getAttributes();
    attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
    ((Activity) mContext).getWindow().setAttributes(attrs);
    ((Activity) mContext).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

From source file:com.actionbarsherlock.internal.widget.ActionBarContextView.java

@Override
public void setSplitActionBar(boolean split) {
    if (mSplitActionBar != split) {
        if (mActionMenuPresenter != null) {
            // Mode is already active; move everything over and adjust the menu itself.
            final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            if (!split) {
                mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
                mMenuView.setBackgroundDrawable(null);
                final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
                if (oldParent != null)
                    oldParent.removeView(mMenuView);
                addView(mMenuView, layoutParams);
            } else {
                // Allow full screen width in split mode.
                mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels,
                        true);// www .  j av a  2  s  . c  o m
                // No limit to the item count; use whatever will fit.
                mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
                // Span the whole width
                layoutParams.width = LayoutParams.MATCH_PARENT;
                layoutParams.height = mContentHeight;
                mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
                mMenuView.setBackgroundDrawable(mSplitBackground);
                final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
                if (oldParent != null)
                    oldParent.removeView(mMenuView);
                mSplitView.addView(mMenuView, layoutParams);
            }
        }
        super.setSplitActionBar(split);
    }
}

From source file:br.com.bioscada.apps.biotracks.fragments.ChartAndPacerFragment.java

@Override
public void onStop() {
    super.onStop();
    ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.bchart_view_layout);
    layout.removeView(chartView);
}