Java Code Examples for android.widget.LinearLayout#requestLayout()

The following examples show how to use android.widget.LinearLayout#requestLayout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MidiPlayer.java    From MidiSheetMusic-Android with GNU General Public License v3.0 6 votes vote down vote up
/** The callback for pausing playback.
 *  If we're currently playing, pause the music.
 *  The actual pause is done when the timer is invoked.
 */
public void Pause() {
    this.setVisibility(View.VISIBLE);
    LinearLayout layout = (LinearLayout)this.getParent();
    layout.requestLayout();
    this.requestLayout();
    this.invalidate();

    if (midifile == null || sheet == null || numberTracks() == 0) {
        return;
    }

    // Cancel pending play events
    timer.removeCallbacks(DoPlay);

    if (playstate == playing) {
        playstate = initPause;
    }
    else if (playstate == midi) {
        playstate = paused;
    }
}
 
Example 2
Source File: MonitorFragment.java    From onpc with GNU General Public License v3.0 6 votes vote down vote up
private void updateListeningModeLayout()
{
    listeningModeLayout.requestLayout();
    if (listeningModeLayout.getChildCount() == 1)
    {
        final LinearLayout l = (LinearLayout) listeningModeLayout.getChildAt(0);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        if (l.getMeasuredWidth() < listeningModeLayout.getMeasuredWidth())
        {
            params.gravity = Gravity.CENTER;
        }
        l.setLayoutParams(params);
        l.requestLayout();
    }
}
 
Example 3
Source File: MapActivity.java    From nearby-android with Apache License 2.0 6 votes vote down vote up
/**
 * Show the list of directions
 * @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 = 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 = 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);
}
 
Example 4
Source File: MapActivity.java    From nearby-android with Apache License 2.0 6 votes vote down vote up
/**
 * Restore map to original size and remove
 * views associated with displaying route segments.
 * @return MapFragment - The fragment containing the map
 */
public final MapFragment restoreMapAndRemoveRouteDetail(){
  // Remove the route directions
  final LinearLayout layout = findViewById(R.id.route_directions_container);
  layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0));
  layout.requestLayout();

  // Show the map
  final FrameLayout mapLayout = 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;
}
 
Example 5
Source File: BaseCourseUnitVideoFragment.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
private void updateUIForOrientation() {
    final LinearLayout playerContainer = getView().findViewById(R.id.player_container);
    final int orientation = getResources().getConfiguration().orientation;
    if (playerContainer != null) {
        final DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            float screenHeight = displayMetrics.heightPixels;
            playerContainer.setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, (int) screenHeight));
            setFullScreen(true);
        } else {
            float screenWidth = displayMetrics.widthPixels;
            float ideaHeight = screenWidth * 9 / 16;
            playerContainer.setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT, (int) ideaHeight));
            setFullScreen(false);
        }
        playerContainer.requestLayout();
    }
    updateUI(orientation);
}
 
Example 6
Source File: MapActivity.java    From nearby-android with Apache License 2.0 5 votes vote down vote up
/**
 * Display the specific directions for the segment of the route
 * the user has clicked on.
 * @param position An integer representing the index in the
 *                 list of segment directions.
 */
public final void showRouteDetail(final int position){
  // Hide the list of directions
  final LinearLayout layout = findViewById(R.id.route_directions_container);
  layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0,0));
  layout.requestLayout();

  // Restore the map, removing any route segment detail
  final MapFragment  mapFragment = restoreMapAndRemoveRouteDetail();
  // Add specific route segment detail
  mapFragment.showRouteDetail(position);
}
 
Example 7
Source File: FormBuilderModifyAttributesActivity.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void fillTabControls(
        LinearLayout layout,
        Bundle savedState,
        JSONArray elements)
        throws JSONException {

    Cursor featureCursor = getFeatureCursor();
    List<Field> fields = mLayer.getFields();
    for (int i = 0; i < elements.length(); i++) {
        IFormControl control;
        JSONObject element = elements.getJSONObject(i);
        String type = element.optString(JSON_TYPE_KEY);
        if (type.equals(JSON_COORDINATES_VALUE)) {
            JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
            String fieldY = attributes.optString(JSON_FIELD_NAME_KEY + "_lat");
            attributes.put(JSON_FIELD_NAME_KEY, fieldY);
            element.put(JSON_TYPE_KEY, type + "_lat");
            control = getControl(this, element, mLayer, mFeatureId, mGeometry, mIsViewOnly);
            addToLayout(control, element, fields, savedState, featureCursor, layout);

            attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
            String fieldX = attributes.optString(JSON_FIELD_NAME_KEY + "_long");
            attributes.put(JSON_FIELD_NAME_KEY, fieldX);
            element.put(JSON_TYPE_KEY, type + "_lon");
        }

        control = getControl(this, element, mLayer, mFeatureId, mGeometry, mIsViewOnly);
        if (type.equals(JSON_TABS_KEY))
            ((Tabs) control).init(mLayer, mFeatureId, mGeometry, mTable, mRow, mSharedPreferences,
                                  mPreferences, getSupportFragmentManager(), mIsViewOnly);

        addToLayout(control, element, fields, savedState, featureCursor, layout);
    }

    if (null != featureCursor) {
        featureCursor.close();
    }

    layout.requestLayout();
}