List of usage examples for android.view ViewGroup removeView
@Override public void removeView(View view)
Note: do not invoke this method from #draw(android.graphics.Canvas) , #onDraw(android.graphics.Canvas) , #dispatchDraw(android.graphics.Canvas) or any related method.
From source file:net.zionsoft.obadiah.ui.adapters.VersePagerAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object object) { for (Page page : mPages) { if (page.position == position) { page.inUse = false;/*from ww w. j a va2s .c o m*/ container.removeView(page.rootView); return; } } }
From source file:com.bullmobi.base.ui.fragments.dialogs.FeedbackDialog.java
/** * Removes Frequently asked questions panel from the view * and sets {@link #mFaqContainer} to null. * After calling this method you no longer able to get panel back. */// ww w .j a va2s . co m private void recycleFaqPanel() { ViewGroup viewGroup = (ViewGroup) mFaqContainer.getParent(); viewGroup.removeView(mFaqContainer); mFaqContainer = null; }
From source file:org.opensilk.common.mortarflow.MortarPagerAdapter.java
@Override public void destroyItem(ViewGroup container, int position, Object o) { Page oldPage = (Page) o;// w w w.ja v a 2s .c o m activePages.remove(position); ViewUtils.saveState(oldPage.view, savedState, oldPage.screen.getName()); contextFactory.tearDownContext(oldPage.view.getContext()); container.removeView(oldPage.view); }
From source file:com.memetro.android.alerts.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (inflaterMap != null) { ViewGroup parent = (ViewGroup) inflaterMap.getParent(); if (parent != null) parent.removeView(inflaterMap); }//from w ww .j av a2 s. c o m try { inflaterMap = inflater.inflate(R.layout.fragment_map, container, false); } catch (InflateException e) { // } map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map_fragment)).getMap(); // TODO Esto hay que revisarlo. if (map == null) { Crashlytics.log(1, TAG, "Map is null > " + map + " inflaterMap > " + inflaterMap); return inflaterMap; } locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); followMeLocationSource = new FollowMeLocationSource(); map.clear(); map.setLocationSource(followMeLocationSource); map.getUiSettings().setZoomControlsEnabled(true); map.getUiSettings().setZoomGesturesEnabled(true); map.getUiSettings().setCompassEnabled(true); map.setMyLocationEnabled(true); List<Alert> alerts = DataUtils.getAlerts(); MarkerOptions markerOptions = new MarkerOptions(); for (Alert alert : alerts) { latlng = new LatLng(alert.latitude, alert.longitude); markerOptions.icon(BitmapDescriptorFactory.fromResource(getMarkerResource(alert.date, alert.icon))); map.addMarker(markerOptions.position(latlng)); } map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 8)); return inflaterMap; }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert/*from w w w . jav a2 s. c o m*/ * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }
From source file:com.wms.opensource.shopfast.fragment.ProductsInCollectionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout); return layout; }/*from w w w. j a va2s .co m*/ if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewPreview = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewPreview.setLayoutParams(imageViewParams); imageViewPreview.setVisibility(View.INVISIBLE); imageViewPreview.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(ProductsInCollectionFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewPreview); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading products, display products if they have been saved before. String productsFilePath = StorageUtil.getTempDirectoryPath(getActivity()) + "/" + PersistFileNameProvider.getProductsFileName(collectionID, page); boolean productsFileExists = FileUtil.fileExist(productsFilePath); if (productsFileExists) { loadProductsFromLocalTask = new LoadCachedProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadProductsFromLocalTask.execute(collectionID); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkConnection(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { loadShopifyProductsTask = new LoadProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadShopifyProductsTask.execute(collectionID); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:jahirfiquitiva.iconshowcase.fragments.RequestsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int gridSpacing = getResources().getDimensionPixelSize(R.dimen.lists_padding); int columnsNumber = getResources().getInteger(R.integer.requests_grid_width); minutesLimit = getResources().getInteger(R.integer.limit_request_to_x_minutes); setHasOptionsMenu(true);//from w ww.ja va2 s. com context = getActivity(); mPrefs = new Preferences(context); setupMaxApps(); if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); if (parent != null) { parent.removeView(layout); } } try { layout = (ViewGroup) inflater.inflate(R.layout.icon_request_section, container, false); } catch (InflateException e) { // Do nothing } fab = (FloatingActionButton) layout.findViewById(R.id.requests_fab); requestList = RequestList.getRequestList(); if (requestList == null || requestList.size() <= 0) { fab.hide(); } else { fab.show(); } fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!PermissionUtils.canAccessStorage(getContext())) { PermissionUtils.requestStoragePermission(getActivity(), RequestsFragment.this); } else { startRequestProcess(); } } }); progressBar = (ProgressBar) layout.findViewById(R.id.requestProgress); mRecyclerView = (RecyclerView) layout.findViewById(R.id.appsToRequestList); mRecyclerView.setLayoutManager(new GridLayoutManager(context, columnsNumber)); mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(columnsNumber, gridSpacing, true)); fastScroller = (RecyclerFastScroller) layout.findViewById(R.id.rvFastScroller); hideStuff(); mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (dy > 0) { fab.hide(); } else { fab.show(); } } }); return layout; }
From source file:me.tylerbwong.pokebase.gui.activities.TeamViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_team); ButterKnife.bind(this); databaseHelper = DatabaseOpenHelper.getInstance(this); Glide.with(this).load(R.drawable.no_teams).into(noTeam); noTeamLabel.setText(getString(R.string.no_pokemon)); pokemonList.setHasFixedSize(true);//from w w w . j a va2 s . c o m LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); pokemonList.setLayoutManager(layoutManager); sheetLayout.setFab(fab); sheetLayout.setFabAnimationEndListener(this); Intent intent = getIntent(); Bundle extras = intent.getExtras(); teamId = extras.getInt(TEAM_ID_KEY); updateKey = extras.getBoolean(UPDATE_KEY, false); String teamTitle = extras.getString(TEAM_NAME, DEFAULT_NAME + (databaseHelper.queryLastTeamAddedId() + 1)); String description = extras.getString(DESCRIPTION, DEFAULT_DESCRIPTION); setSupportActionBar(toolbar); actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(teamTitle); } nameInput.setText(teamTitle); descriptionInput.setText(description); pokemonAdapter = new PokemonTeamMemberAdapter(this, null, teamId, nameInput.getText().toString().trim(), descriptionInput.getText().toString().trim()); pokemonList.setAdapter(pokemonAdapter); if (updateKey) { databaseHelper.queryPokemonTeamMembers(teamId).subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()).subscribe(pokemonTeamMembers -> { pokemon = pokemonTeamMembers; pokemonAdapter.setTeam(pokemon); if (pokemon.length == MAX_TEAM_SIZE) { ViewGroup viewGroup = (ViewGroup) fab.getParent(); viewGroup.removeView(fab); } checkEmpty(); }); } else { if (actionBar != null) { actionBar.setTitle(R.string.new_team); } } }
From source file:edu.cmu.android.restaurant.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Intent intent = new Intent(getActivity(), MyMapActivity.class); final Window w = getLocalActivityManager().startActivity("tag", intent); final View wd = w != null ? w.getDecorView() : null; if (wd != null) { ViewParent parent = wd.getParent(); if (parent != null) { ViewGroup v = (ViewGroup) parent; v.removeView(wd); }/*ww w. j av a 2s . c om*/ wd.setVisibility(View.VISIBLE); wd.setFocusableInTouchMode(true); if (wd instanceof ViewGroup) { ((ViewGroup) wd).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); } } ((MyMapActivity) mLocalActivityManager.getActivity("tag")).registerListener(mListener); setHasOptionsMenu(true); // add menu in fragment sensorManager = (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE); vibrator = (Vibrator) getActivity().getSystemService(Service.VIBRATOR_SERVICE); dealList = mListener.onDealsRequested(); return wd; }
From source file:io.bunnyblue.noticedog.app.lockscreen.ui.LockScreenWidgetPagerAdapter.java
public void destroyItem(ViewGroup container, int position, Object object) { if (object instanceof LockScreenMessageView) { container.removeView((LockScreenMessageView) object); } else if (object instanceof LockScreenMoreMessagesView) { container.removeView((LockScreenMoreMessagesView) object); }/*from w w w .ja v a2 s. c o m*/ }