List of usage examples for android.widget FrameLayout removeAllViews
public void removeAllViews()
From source file:com.mongolduu.android.ng.GDFragmentActivity.java
/** * <p>/*from w w w.j a va 2 s .co m*/ * Set the activity content from a layout resource. The resource will be * inflated, adding all top-level views to the activity. * </p> * <p> * This method is an equivalent to setContentView(int) that automatically * wraps the given layout in an {@link ActionBarHost} if needed.. * </p> * * @param resID Resource ID to be inflated. * @see #setActionBarContentView(View) * @see #setActionBarContentView(View, LayoutParams) */ public void setActionBarContentView(int resID) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); LayoutInflater.from(this).inflate(resID, contentView); }
From source file:com.mongolduu.android.ng.GDFragmentActivity.java
/** * <p>/*from www . j a v a2s . c o m*/ * Set the activity content to an explicit view. This view is placed * directly into the activity's view hierarchy. It can itself be a complex * view hierarchy. * </p> * <p> * This method is an equivalent to setContentView(View, LayoutParams) that * automatically wraps the given layout in an {@link ActionBarHost} if * needed. * </p> * * @param view The desired content to display. * @param params Layout parameters for the view. * @see #setActionBarContentView(View) * @see #setActionBarContentView(int) */ public void setActionBarContentView(View view, LayoutParams params) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); contentView.addView(view, params); }
From source file:com.mongolduu.android.ng.GDFragmentActivity.java
/** * <p>// www.ja va 2 s .c o m * Set the activity content to an explicit view. This view is placed * directly into the activity's view hierarchy. It can itself be a complex * view hierarchy. * </p> * <p> * This method is an equivalent to setContentView(View) that automatically * wraps the given layout in an {@link ActionBarHost} if needed. * </p> * * @param view The desired content to display. * @see #setActionBarContentView(int) * @see #setActionBarContentView(View, LayoutParams) */ public void setActionBarContentView(View view) { final FrameLayout contentView = getContentView(); contentView.removeAllViews(); contentView.addView(view); }
From source file:com.itude.mobile.mobbl.core.controller.MBDialogManager.java
public void removeDialog(String dialogName) { MBDialogController activeDialog = getActiveDialog(); if (activeDialog != null) { MBBasicViewController fragment = activeDialog.findFragment(dialogName); if (fragment != null) { View root = fragment.getView(); if (root != null) { ViewParent parent = root.getParent(); if (parent instanceof FrameLayout) { final FrameLayout fragmentContainer = (FrameLayout) parent; _activity.runOnUiThread(new Runnable() { @Override public void run() { fragmentContainer.removeAllViews(); }/*from w w w.ja va 2 s .com*/ }); } } } } }
From source file:com.osama.cryptofm.filemanager.ui.FilemanagerTabs.java
@Override public void removeNoFilesFragment() { isEmptyFolder = false;//from w w w . j a v a2 s .c om mCurrentFragment.setmIsEmptyFolder(false); FrameLayout layout = (FrameLayout) findViewById(R.id.no_files_frame_fragment); layout.removeAllViews(); }
From source file:com.osama.cgpacalculator.MainActivity.java
@SuppressLint("InflateParams") private void showAboutDialog() { final ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f); animation.setDuration(800);// www. ja va 2s .c o m Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.about_dialog); final FrameLayout frame = ((FrameLayout) dialog.findViewById(R.id.about_content_layout)); frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null)); dialog.findViewById(R.id.credit_dialog_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { frame.removeAllViews(); isShowingLi = false; if (!isShowingCr) { frame.addView(getLayoutInflater().inflate(R.layout.credits_layout, null)); isShowingCr = true; frame.setAnimation(animation); } else { frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null)); isShowingCr = false; frame.setAnimation(animation); } frame.animate(); } }); dialog.findViewById(R.id.license_dialog_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { frame.removeAllViews(); isShowingCr = false; if (!isShowingLi) { frame.addView(getLayoutInflater().inflate(R.layout.license_layout, null)); isShowingLi = true; frame.setAnimation(animation); } else { frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null)); isShowingLi = false; frame.setAnimation(animation); } frame.animate(); } }); dialog.show(); }
From source file:com.alexive.graphicalutils.view.CardBuilder.java
public CardView build(Context context, CardView mCardView, boolean overrideBackground, boolean overrideElevation, boolean overrideRadius) { if (!mCardView.getTag(CARD_TYPE_TAG).equals(mCardType)) throw new IllegalArgumentException("Attempting to recycle a card of another type."); LinkedList<TextView> textViews = new LinkedList<>(); View view = mCardView.findViewById(android.R.id.text1); if (view != null) { view.setTag(true);//from w w w . j a va2s . com textViews.add(((TextView) view)); ((TextView) view).setText(title); view.setVisibility(title != null ? View.VISIBLE : View.GONE); } view = mCardView.findViewById(android.R.id.text2); if (view != null) { textViews.add(((TextView) view)); ((TextView) view).setText(subTitle); view.setVisibility(subTitle != null ? View.VISIBLE : View.GONE); } view = mCardView.findViewById(R.id.content); if (view != null) { textViews.add(((TextView) view)); ((TextView) view).setText(text); view.setVisibility(text != null ? View.VISIBLE : View.GONE); } mCardView.setOnClickListener(mPrimaryAction); //TODO add the custom view FrameLayout mCustomViewParent = (FrameLayout) mCardView.findViewById(R.id.custom_view_container); if (mCustomViewParent != null) { mCustomViewParent.removeAllViews(); if (customMainView != null) mCustomViewParent.addView(customMainView); } view = mCardView.findViewById(android.R.id.content); if (view != null) { if (image instanceof Bitmap) ((ImageView) view).setImageBitmap((Bitmap) image); else if (image instanceof Drawable) ((ImageView) view).setImageDrawable((Drawable) image); else ((ImageView) view).setImageDrawable(null); } LinearLayout mActionContainer = (LinearLayout) mCardView.findViewById(R.id.action_container); if (actions.isEmpty()) mActionContainer.setVisibility(View.GONE); else { mActionContainer.setVisibility(View.VISIBLE); for (int i = 0; i < actions.size(); i++) { CardAction action = actions.get(i); // int j = i; // View optimalView = null; // Needs to be rewriten // while (j < mActionContainer.getChildCount()) { // optimalView = mActionContainer.getChildAt(j); // if ((action.drawable != null && optimalView instanceof ImageButton) || (action.title != // null && optimalView instanceof Button)) { // mActionContainer.removeViewAt(j); // mActionContainer.addView(optimalView, i); // break; // } else { // optimalView = null; // j++; // } // } // if (optimalView == null) { View actionView = null; if (action.title != null) { Button button = (Button) LayoutInflater.from(context).inflate(R.layout.card_bttn, null); textViews.add(button); button.setText(action.title); button.setOnClickListener(this); mActionContainer.addView(button); actionView = button; } else if (action.drawable != null) { ImageButton imageButton = (ImageButton) LayoutInflater.from(context) .inflate(R.layout.card_image_bttn, null); imageButton.setImageDrawable(action.drawable); imageButton.setOnClickListener(this); mActionContainer.addView(imageButton); actionView = imageButton; } //NASTY workaround for the padding View space = new View(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewUtils.convertDPtoPixels(context, 8), ViewUtils.convertDPtoPixels(context, 8)); mActionContainer.addView(space, params); assert actionView != null; actionView.setTag(ACTION_ID_TAG, action); } } if (useLightTheme) { if (overrideBackground) mCardView.setCardBackgroundColor(0xFFFFFF); setTextColor(textViews, ContextCompat.getColor(context, android.R.color.primary_text_light), ContextCompat.getColor(context, android.R.color.secondary_text_light)); } else { if (overrideBackground) mCardView.setCardBackgroundColor(0x424242); setTextColor(textViews, ContextCompat.getColor(context, android.R.color.primary_text_dark), ContextCompat.getColor(context, android.R.color.secondary_text_dark)); } //Material design guidelines: 2dp resting elevation (or 8dp when raised) //Let's assume the card is resting //Also: 2dp corner radius int dPtoPixels = ViewUtils.convertDPtoPixels(context, 2); if (overrideElevation) mCardView.setCardElevation(dPtoPixels); if (overrideRadius) mCardView.setRadius(dPtoPixels); return mCardView; }
From source file:com.launcher.silverfish.HomeScreenFragment.java
private void placeWidget(AppWidgetHostView hostView) { FrameLayout widget_area = (FrameLayout) rootView.findViewById(R.id.widget_area); widget_area.removeAllViews(); widget_area.addView(hostView);// w w w.ja v a2 s . co m // Let the widget host view take control of the long click action. hostView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { selectWidget(); return true; } }); hostView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { switch (MotionEventCompat.getActionMasked(event)) { case MotionEvent.ACTION_DOWN: updateTouchDown(event); break; case MotionEvent.ACTION_MOVE: tryConsumeSwipe(event); break; } return touchConsumed; } }); }
From source file:com.launcher.silverfish.launcher.homescreen.HomeScreenFragment.java
private void placeWidget(AppWidgetHostView hostView) { FrameLayout widget_area = (FrameLayout) rootView.findViewById(R.id.widget_area); widget_area.removeAllViews(); widget_area.addView(hostView);/* w w w . j a v a 2 s. co m*/ // Let the widget host view take control of the long click action. hostView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { popupSelectWidget(); return true; } }); hostView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { switch (MotionEventCompat.getActionMasked(event)) { case MotionEvent.ACTION_DOWN: updateTouchDown(event); break; case MotionEvent.ACTION_MOVE: tryConsumeSwipe(event); break; } return touchConsumed; } }); }
From source file:io.tehtotalpwnage.musicphp_android.NavigationActivity.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_camera) { // Everything after this point is actually my code. StringRequest req = new StringRequest(Request.Method.GET, UrlGenerator.getServerUrl(this) + "/api/user", new Response.Listener<String>() { @Override/*w w w.j a va2 s . c om*/ public void onResponse(String response) { TextView view = new TextView(getApplicationContext()); view.setText(response); FrameLayout layout = (FrameLayout) findViewById(R.id.navFrame); layout.removeAllViews(); layout.addView(view); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.v(TAG, "Connection error"); TextView view = new TextView(getApplicationContext()); view.setText(getResources().getString(R.string.error_connection)); FrameLayout layout = (FrameLayout) findViewById(R.id.navFrame); layout.removeAllViews(); layout.addView(view); NetworkResponse networkResponse = error.networkResponse; if (networkResponse != null && networkResponse.statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) { Log.v(TAG, "Request was unauthorized, meaning that a new token is needed"); AccountManager manager = AccountManager.get(getApplicationContext()); manager.invalidateAuthToken(MusicPhpAccount.ACCOUNT_TYPE, getIntent().getStringExtra(AccountManager.KEY_AUTHTOKEN)); Intent intent = new Intent(NavigationActivity.this, MainActivity.class); startActivity(intent); } } }) { @Override public Map<String, String> getHeaders() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("Accept", "application/json"); params.put("Authorization", "Bearer " + getIntent().getStringExtra(AccountManager.KEY_AUTHTOKEN)); return params; } }; VolleySingleton.getInstance(this).addToRequestQueue(req); } else if (id == R.id.nav_gallery) { final Context context = this; getListing(Item.albums, 0, new VolleyCallback() { @Override public void onSuccess(JSONArray result) { Log.d(TAG, "Volley callback reached"); String albums[][] = new String[result.length()][3]; for (int i = 0; i < result.length(); i++) { try { JSONObject object = result.getJSONObject(i); albums[i][0] = object.getString("name"); albums[i][1] = object.getJSONObject("artist").getString("name"); albums[i][2] = object.getString("id"); } catch (Exception e) { e.printStackTrace(); } } AlbumListingAdapter adapter = new AlbumListingAdapter(context, albums, getIntent().getStringExtra(AccountManager.KEY_AUTHTOKEN)); GridView view = new GridView(context); view.setLayoutParams(new DrawerLayout.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setNumColumns(GridView.AUTO_FIT); view.setColumnWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 148, getResources().getDisplayMetrics())); view.setStretchMode(GridView.STRETCH_SPACING_UNIFORM); view.setAdapter(adapter); view.setVerticalSpacing((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics())); FrameLayout layout = (FrameLayout) findViewById(R.id.navFrame); layout.removeAllViews(); layout.addView(view); Log.d(TAG, "Adapter setup complete"); } }); } else if (id == R.id.nav_slideshow) { getListing(Item.artists, 0, new VolleyCallback() { @Override public void onSuccess(JSONArray result) { } }); } else if (id == R.id.nav_manage) { getListing(Item.tracks, 0, new VolleyCallback() { @Override public void onSuccess(JSONArray result) { } }); } else if (id == R.id.nav_share) { Log.d(TAG, "Queue contains " + queue.size() + " items. Displaying queue..."); ListView view = new ListView(this); view.setLayoutParams(new DrawerLayout.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); String tracks[][] = new String[queue.size()][2]; for (int i = 0; i < queue.size(); i++) { MediaSessionCompat.QueueItem queueItem = queue.get(i); tracks[i][0] = queueItem.getDescription().getMediaId(); tracks[i][1] = (String) queueItem.getDescription().getTitle(); } AlbumAdapter adapter = new AlbumAdapter(this, tracks, getIntent().getStringExtra(AccountManager.KEY_AUTHTOKEN), this); view.setAdapter(adapter); view.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // String sAddress = getApplicationContext().getSharedPreferences("Prefs", 0).getString("server", null); // Bundle bundle = new Bundle(); // bundle.putString("Authorization", "Bearer " + token); // bundle.putString("Title", tracks[position][1]); // bundle.putString("art", getIntent().getStringExtra("art")); // bundle.putString("ID", tracks[position][0]); // MediaControllerCompat.getMediaController(AlbumActivity.this).getTransportControls().playFromUri(Uri.parse(sAddress + "/api/tracks/" + tracks[position][0] + "/audio"), bundle); } }); FrameLayout layout = (FrameLayout) findViewById(R.id.navFrame); layout.removeAllViews(); layout.addView(view); } else if (id == R.id.nav_send) { String sAddress = getSharedPreferences("Prefs", 0).getString("server", null); StringRequest request = new StringRequest(Request.Method.POST, sAddress + "/api/logout", new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject object = new JSONObject(response); if (object.getString("status").equals("OK")) { Log.v(TAG, "Logged out successfully. Now redirecting to MainActivity..."); AccountManager manager = AccountManager.get(getApplicationContext()); Account accounts[] = manager.getAccountsByType(MusicPhpAccount.ACCOUNT_TYPE); int account = 0; for (int i = 0; i < accounts.length; i++) { if (accounts[i].name.equals( getIntent().getStringExtra(AccountManager.KEY_ACCOUNT_NAME))) { account = i; break; } } final AccountManagerFuture future; if (Build.VERSION.SDK_INT >= 22) { future = manager.removeAccount(accounts[account], NavigationActivity.this, new AccountManagerCallback<Bundle>() { @Override public void run(AccountManagerFuture<Bundle> future) { } }, null); } else { future = manager.removeAccount(accounts[account], new AccountManagerCallback<Boolean>() { @Override public void run(AccountManagerFuture<Boolean> future) { } }, null); } AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { future.getResult(); Intent intent = new Intent(NavigationActivity.this, MainActivity.class); startActivity(intent); } catch (Exception e) { e.printStackTrace(); } return null; } }; task.execute(); } else { Log.v(TAG, "Issue with logging out..."); } } catch (JSONException e) { Log.e(TAG, "Issue with parsing JSON..."); e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e(TAG, "Error on logging out..."); } }) { @Override public Map<String, String> getHeaders() { Map<String, String> params = new HashMap<>(); params.put("Accept", "application/json"); params.put("Authorization", "Bearer " + getIntent().getStringExtra(AccountManager.KEY_AUTHTOKEN)); return params; } }; VolleySingleton.getInstance(this).addToRequestQueue(request); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }