List of usage examples for android.widget FrameLayout requestLayout
@CallSuper public void requestLayout()
From source file:com.esri.android.ecologicalmarineunitexplorer.map.MapActivity.java
public void showSummary(WaterColumn waterColumn) { final FragmentManager fm = getSupportFragmentManager(); SummaryFragment summaryFragment = (SummaryFragment) fm.findFragmentById(R.id.summary_container); if (summaryFragment == null) { summaryFragment = SummaryFragment.newInstance(); mSummaryPresenter = new SummaryPresenter(summaryFragment); }// ww w .j a v a 2 s. c om mSummaryPresenter.setWaterColumn(waterColumn); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Adjust the map's layout FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_container); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 7); layoutParams.setMargins(0, 0, 36, 0); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); FrameLayout summaryLayout = (FrameLayout) findViewById(R.id.summary_container); summaryLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 9)); summaryLayout.requestLayout(); // Replace whatever is in the summary_container view with this fragment, // and add the transaction to the back stack so the user can navigate back transaction.replace(R.id.summary_container, summaryFragment); transaction.addToBackStack("summary fragment"); // Commit the transaction transaction.commit(); WaterColumnFragment waterColumnFragment = (WaterColumnFragment) fm .findFragmentById(R.id.water_column_linear_layout_top); if (waterColumnFragment == null) { waterColumnFragment = WaterColumnFragment.newInstance(); } waterColumnFragment.setWaterColumn(waterColumn); FragmentTransaction wcTransaction = getSupportFragmentManager().beginTransaction(); wcTransaction.replace(R.id.column_container, waterColumnFragment); wcTransaction.commit(); }
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Show the list of directions/*w w w .java 2 s.c o m*/ * @param directions List of DirectionManeuver items containing navigation directions */ public final void showDirections(final List<DirectionManeuver> directions) { final FragmentManager fm = getSupportFragmentManager(); RouteDirectionsFragment routeDirectionsFragment = (RouteDirectionsFragment) fm .findFragmentById(R.id.route_directions_container); if (routeDirectionsFragment == null) { routeDirectionsFragment = RouteDirectionsFragment.newInstance(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), routeDirectionsFragment, R.id.route_directions_container, getString(R.string.route_fragment)); } // Show the fragment final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.requestLayout(); // Hide the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(0, 0); layoutParams.setMargins(0, 0, 0, 0); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); routeDirectionsFragment.setRoutingDirections(directions); }
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Restore map to original size and remove * views associated with displaying route segments. * @return MapFragment - The fragment containing the map *//*from w w w . j a v a2s . c o m*/ public final MapFragment restoreMapAndRemoveRouteDetail() { // Remove the route directions final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0)); layout.requestLayout(); // Show the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); final FragmentManager fm = getSupportFragmentManager(); final MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_fragment_container); mapFragment.removeRouteDetail(); return mapFragment; }
From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java
/** * Shrink layout for candlestick charts/*from ww w .jav a2 s . c om*/ */ private void shrinkChartContainer() { final FrameLayout layout = (FrameLayout) findViewById(R.id.chartContainer); if (layout != null) { layout.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); layout.requestLayout(); } }
From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java
/** * Show the view with the water column profiles * @param point - Point representing clicked geo location *//* w ww.j a v a 2s.co m*/ private void showWaterColumnProfile(final Point point) { // Remove water column, summary, text and button mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); // hideMapView(); setUpWaterProfileToolbar(); final FrameLayout layout = (FrameLayout) findViewById(R.id.chartContainer); if (layout != null) { layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.requestLayout(); } final WaterProfileFragment waterProfileFragment = WaterProfileFragment.newInstance(); new WaterProfilePresenter(point, waterProfileFragment, mDataManager); // Add the chart view to the column container final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); final Fragment f = fm.findFragmentById(R.id.chartContainer); if (f == null) { transaction.addToBackStack(getString(R.string.fragment_detail_chart)); } transaction.replace(R.id.chartContainer, waterProfileFragment); transaction.commit(); // Hide the FAB mFab.setVisibility(View.INVISIBLE); mInMapState = false; }
From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java
/** * Show the candlestick charts for a specific EMU layer * @param emuName - int representing an EMU layer name *///from w ww .jav a2 s. c om private void showSummaryDetail(final int emuName) { // Hide the bottom sheet containing the summary view mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); // Expand the layout for the charts final FrameLayout layout = (FrameLayout) findViewById(R.id.chartContainer); if (layout != null) { layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.requestLayout(); } if (mSummaryChartFragment == null) { mSummaryChartFragment = SummaryChartFragment.newInstance(); mSummaryChartPresenter = new SummaryChartPresenter(emuName, mSummaryChartFragment, mDataManager); } else { mSummaryChartPresenter.setEmuName(emuName); } // Add the chart view to the column container final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); final Fragment f = fm.findFragmentById(R.id.chartContainer); if (f == null) { transaction.addToBackStack(getString(R.string.fragment_detail_chart)); } transaction.replace(R.id.chartContainer, mSummaryChartFragment); transaction.commit(); // Hide the FAB mFab.setVisibility(View.INVISIBLE); mInMapState = false; setUpChartSummaryToolbar(emuName); }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override protected void onCreate(final @Nullable Bundle state) { super.onCreate(state); final Bundle extras = getIntent().getExtras(); if (extras != null) { this.account = new AccountsRegistry(this).getAccount(extras.getInt("selected_account")); } else {/*from ww w .j av a2 s . c o m*/ this.account = Simplified.getCurrentAccount(); } final ActionBar bar = this.getActionBar(); if (android.os.Build.VERSION.SDK_INT < 21) { bar.setDisplayHomeAsUpEnabled(false); bar.setHomeButtonEnabled(true); bar.setIcon(R.drawable.ic_arrow_back); } else { bar.setHomeAsUpIndicator(R.drawable.ic_arrow_back); bar.setDisplayHomeAsUpEnabled(true); bar.setHomeButtonEnabled(false); } final DocumentStoreType docs = Simplified.getDocumentStore(this.account, getResources()); final LayoutInflater inflater = NullCheck.notNull(this.getLayoutInflater()); final FrameLayout content_area = this.getContentFrame(); final ViewGroup layout = NullCheck .notNull((ViewGroup) inflater.inflate(R.layout.settings_account, content_area, false)); content_area.addView(layout); content_area.requestLayout(); final TextView in_barcode_label = NullCheck.notNull(this.findViewById(R.id.settings_barcode_label)); final TextView in_barcode_text = NullCheck.notNull(this.findViewById(R.id.settings_barcode_text)); final TextView in_pin_label = NullCheck.notNull(this.findViewById(R.id.settings_pin_label)); final ImageView in_barcode_image = NullCheck.notNull(this.findViewById(R.id.settings_barcode_image)); final TextView in_barcode_image_toggle = NullCheck .notNull(this.findViewById(R.id.settings_barcode_toggle_barcode)); final TextView in_pin_text = NullCheck.notNull(this.findViewById(R.id.settings_pin_text)); final CheckBox in_pin_reveal = NullCheck.notNull(this.findViewById(R.id.settings_reveal_password)); if (!this.account.pinRequired()) { in_pin_label.setVisibility(View.INVISIBLE); in_pin_text.setVisibility(View.INVISIBLE); in_pin_reveal.setVisibility(View.INVISIBLE); } final Button in_login = NullCheck.notNull(this.findViewById(R.id.settings_login)); final Button in_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup)); this.sync_switch = findViewById(R.id.sync_switch); this.sync_table_row = findViewById(R.id.sync_table_row); this.sync_table_row.setVisibility(View.GONE); this.advanced_table_row = findViewById(R.id.link_advanced); this.advanced_table_row.setVisibility(View.GONE); this.advanced_table_row.setOnClickListener(view -> { final FragmentManager mgr = getFragmentManager(); final FragmentTransaction transaction = mgr.beginTransaction(); final SettingsAccountAdvancedFragment fragment = new SettingsAccountAdvancedFragment(); transaction.add(R.id.settings_account_container, fragment).addToBackStack("advanced").commit(); }); final TableRow in_privacy = findViewById(R.id.link_privacy); final TableRow in_license = findViewById(R.id.link_license); final TextView account_name = NullCheck.notNull(this.findViewById(android.R.id.text1)); final TextView account_subtitle = NullCheck.notNull(this.findViewById(android.R.id.text2)); final ImageView in_account_icon = NullCheck.notNull(this.findViewById(R.id.account_icon)); in_pin_text.setTransformationMethod(PasswordTransformationMethod.getInstance()); if (android.os.Build.VERSION.SDK_INT >= 21) { this.handle_pin_reveal(in_pin_text, in_pin_reveal); } else { in_pin_reveal.setVisibility(View.GONE); } final TableRow in_report_issue = findViewById(R.id.report_issue); if (this.account.getSupportEmail() == null) { in_report_issue.setVisibility(View.GONE); } else { in_report_issue.setVisibility(View.VISIBLE); in_report_issue.setOnClickListener(view -> { final Intent intent = new Intent(this, ReportIssueActivity.class); final Bundle b = new Bundle(); b.putInt("selected_account", this.account.getId()); intent.putExtras(b); startActivity(intent); }); } final TableRow in_support_center = findViewById(R.id.support_center); if (this.account.supportsHelpCenter()) { in_support_center.setVisibility(View.VISIBLE); in_support_center.setOnClickListener(view -> { final HSHelpStack stack = HSHelpStack.getInstance(this); final HSDeskGear gear = new HSDeskGear("https://nypl.desk.com/", "4GBRmMv8ZKG8fGehhA", null); stack.setGear(gear); stack.showHelp(this); }); } else { in_support_center.setVisibility(View.GONE); } //Get labels from the current authentication document. final AuthenticationDocumentType auth_doc = docs.getAuthenticationDocument(); in_barcode_label.setText(auth_doc.getLabelLoginUserID()); in_pin_label.setText(auth_doc.getLabelLoginPassword()); final TableLayout in_table_with_code = NullCheck .notNull(this.findViewById(R.id.settings_login_table_with_code)); in_table_with_code.setVisibility(View.GONE); final TableLayout in_table_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup_table)); // boolean locationpermission = false; // if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { // locationpermission = true; // } // else // { // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1); // } if (this.account.supportsCardCreator() || this.account.getCardCreatorUrl() != null) { in_table_signup.setVisibility(View.VISIBLE); } else { in_table_signup.setVisibility(View.GONE); } in_login.setOnClickListener(v -> this.onLoginWithBarcode()); final CheckBox in_age13_checkbox = NullCheck.notNull(this.findViewById(R.id.age13_checkbox)); if (Simplified.getSharedPrefs().contains("age13")) { in_age13_checkbox.setChecked(Simplified.getSharedPrefs().getBoolean("age13")); } else if (account.getId() == 2) { showAgeGateOptionsDialog(in_age13_checkbox); } in_age13_checkbox.setOnCheckedChangeListener(this::showAgeChangeConfirmation); if (this.account.needsAuth()) { in_login.setVisibility(View.VISIBLE); in_age13_checkbox.setVisibility(View.GONE); } else { in_login.setVisibility(View.GONE); in_age13_checkbox.setVisibility(View.VISIBLE); } if (this.account.supportsCardCreator()) { in_signup.setOnClickListener(v -> { final Intent cardcreator = new Intent(this, CardCreatorActivity.class); startActivity(cardcreator); }); in_signup.setText(R.string.need_card_button); } else if (this.account.getCardCreatorUrl() != null) { in_signup.setOnClickListener(v -> { final Intent e_card = new Intent(Intent.ACTION_VIEW); e_card.setData(Uri.parse(this.account.getCardCreatorUrl())); startActivity(e_card); }); in_signup.setText(R.string.need_card_button); } final boolean permission = Simplified.getSharedPrefs().getBoolean("syncPermissionGranted", this.account.getId()); this.sync_switch.setChecked(permission); /* If switching on, disable user interaction until server has responded. If switching off, disable applicable network requests by updating shared prefs flags. */ this.sync_switch.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { buttonView.setEnabled(false); annotationsManager.updateServerSyncPermissionStatus(true, (success) -> { if (success) { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), true); this.sync_switch.setChecked(true); } else { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false); this.sync_switch.setChecked(false); } this.sync_switch.setEnabled(true); return kotlin.Unit.INSTANCE; }); } else { Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false); this.sync_switch.setChecked(false); } }); if (this.account.getPrivacyPolicy() != null) { in_privacy.setVisibility(View.VISIBLE); } else { in_privacy.setVisibility(View.GONE); } if (this.account.getContentLicense() != null) { in_license.setVisibility(View.VISIBLE); } else { in_license.setVisibility(View.GONE); } in_license.setOnClickListener(view -> { final Intent intent = new Intent(this, WebViewActivity.class); final Bundle b = new Bundle(); WebViewActivity.setActivityArguments(b, this.account.getContentLicense(), "Content Licenses", SimplifiedPart.PART_SETTINGS); intent.putExtras(b); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); }); in_privacy.setOnClickListener(view -> { final Intent intent = new Intent(this, WebViewActivity.class); final Bundle b = new Bundle(); WebViewActivity.setActivityArguments(b, this.account.getPrivacyPolicy(), "Privacy Policy", SimplifiedPart.PART_SETTINGS); intent.putExtras(b); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); }); this.navigationDrawerSetActionBarTitle(); this.account_name_text = account_name; this.account_subtitle_text = account_subtitle; this.account_icon = in_account_icon; this.barcode_text = in_barcode_text; this.pin_text = in_pin_text; this.barcode_image_toggle = in_barcode_image_toggle; this.barcode_image = in_barcode_image; this.login = in_login; this.table_with_code = in_table_with_code; this.table_signup = in_table_signup; final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox)); final OptionType<EULAType> eula_opt = docs.getEULA(); if (eula_opt.isSome()) { final Some<EULAType> some_eula = (Some<EULAType>) eula_opt; final EULAType eula = some_eula.get(); in_eula_checkbox.setChecked(eula.eulaHasAgreed()); in_eula_checkbox.setEnabled(true); in_eula_checkbox.setOnCheckedChangeListener((button, checked) -> eula.eulaSetHasAgreed(checked)); if (eula.eulaHasAgreed()) { LOG.debug("EULA: agreed"); } else { LOG.debug("EULA: not agreed"); } } else { LOG.debug("EULA: unavailable"); } this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); }
From source file:org.floens.chan.ui.activity.BoardActivity.java
private void updatePaneState() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; FrameLayout left = (FrameLayout) findViewById(R.id.left_pane); FrameLayout right = (FrameLayout) findViewById(R.id.right_pane); LayoutParams leftParams = left.getLayoutParams(); LayoutParams rightParams = right.getLayoutParams(); // Content view dp's: // Nexus 4 is 384 x 640 dp // Nexus 7 is 600 x 960 dp // Nexus 10 is 800 x 1280 dp if (width < Utils.dp(800)) { if (width < Utils.dp(400)) { leftParams.width = width - Utils.dp(30); } else {/*from w ww.ja v a 2 s . co m*/ leftParams.width = width - Utils.dp(150); } rightParams.width = width; } else { leftParams.width = Utils.dp(300); rightParams.width = width - Utils.dp(300); } left.setLayoutParams(leftParams); right.setLayoutParams(rightParams); threadPane.requestLayout(); left.requestLayout(); right.requestLayout(); }
From source file:com.example.angelina.travelapp.map.MapFragment.java
@Override public void showRouteDetail(final int position) { // Remove the route header view, ////from w w w .j av a 2s .com //since we're replacing it with a different header removeRouteHeaderView(); // State and stage flags mCurrentPosition = position; mShowingRouteDetail = true; // Hide action bar final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (ab != null) { ab.hide(); } // Display route detail header final LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LinearLayout.LayoutParams routeDetailLayout = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); if (mRouteHeaderDetail == null) { mRouteHeaderDetail = (LinearLayout) inflater.inflate(R.layout.route_detail_header, null); TextView title = (TextView) mRouteHeaderDetail.findViewById(R.id.route_txt_detail); title.setText("Route Detail"); mRouteHeaderDetail.setBackgroundColor(Color.WHITE); mMapView.addView(mRouteHeaderDetail, routeDetailLayout); mMapView.requestLayout(); // Attach a listener to the back arrow ImageView imageBtn = (ImageView) mRouteHeaderDetail.findViewById(R.id.btnDetailHeaderClose); imageBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Navigate back to directions list mShowingRouteDetail = false; ((MapActivity) getActivity()).showDirections(mRouteDirections); } }); } // Display arrows to scroll through directions if (mSegmentNavigator == null) { mSegmentNavigator = (LinearLayout) inflater.inflate(R.layout.navigation_arrows, null); final FrameLayout navigatorLayout = (FrameLayout) getActivity() .findViewById(R.id.map_fragment_container); FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.END); frameLayoutParams.setMargins(0, 0, 0, 80); navigatorLayout.addView(mSegmentNavigator, frameLayoutParams); navigatorLayout.requestLayout(); // Add button click listeners Button btnPrev = (Button) getActivity().findViewById(R.id.btnBack); btnPrev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mCurrentPosition > 0) { populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition - 1)); mCurrentPosition = mCurrentPosition - 1; } } }); Button btnNext = (Button) getActivity().findViewById(R.id.btnNext); btnNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mCurrentPosition < mRouteDirections.size() - 1) { populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition + 1)); mCurrentPosition = mCurrentPosition + 1; } } }); } // Populate with directions DirectionManeuver maneuver = mRouteDirections.get(position); populateViewWithRouteDetail(maneuver); }
From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java
private void updatePaneState() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; FrameLayout left = (FrameLayout) findViewById(R.id.left_pane); FrameLayout right = (FrameLayout) findViewById(R.id.right_pane); LayoutParams leftParams = left.getLayoutParams(); LayoutParams rightParams = right.getLayoutParams(); boolean wasSlidable = threadPane.isSlideable(); boolean isSlidable; // Content view dp's: // Nexus 4 is 384 x 640 dp // Nexus 7 is 600 x 960 dp // Nexus 10 is 800 x 1280 dp if (ChanPreferences.getForcePhoneLayout()) { leftParams.width = width - Utils.dp(30); rightParams.width = width;//from www . ja v a 2s. c o m isSlidable = true; } else { if (width < Utils.dp(400)) { leftParams.width = width - Utils.dp(30); rightParams.width = width; isSlidable = true; } else if (width < Utils.dp(800)) { leftParams.width = width - Utils.dp(60); rightParams.width = width; isSlidable = true; } else if (width < Utils.dp(1000)) { leftParams.width = Utils.dp(300); rightParams.width = width - Utils.dp(300); isSlidable = false; } else { leftParams.width = Utils.dp(400); rightParams.width = width - Utils.dp(400); isSlidable = false; } } left.setLayoutParams(leftParams); right.setLayoutParams(rightParams); threadPane.requestLayout(); left.requestLayout(); right.requestLayout(); LayoutParams drawerParams = pinDrawerView.getLayoutParams(); if (width < Utils.dp(340)) { drawerParams.width = Utils.dp(280); } else { drawerParams.width = Utils.dp(320); } pinDrawerView.setLayoutParams(drawerParams); updateActionBarState(); if (isSlidable != wasSlidable) { // Terrible hack to sync state for some devices when it changes slidable mode threadPane.postDelayed(new Runnable() { @Override public void run() { updateActionBarState(); } }, 1000); } }