Пример #1
0
  /** Checks if maintained view exists and removes if from the <tt>container</tt>. */
  protected void ensureViewDestroyed() {
    if (view != null) {
      final View viewToRemove = view;
      view = null;

      activity.runOnUiThread(
          new Runnable() {
            @Override
            public void run() {
              container.removeView(viewToRemove);
              container.setVisibility(View.GONE);
            }
          });
    }
  }
Пример #2
0
  /**
   * Checks if the view is currently created. If not creates new <tt>View</tt> and adds it to the
   * <tt>container</tt>.
   */
  protected void ensureViewCreated() {
    if (view == null) {
      activity.runOnUiThread(
          new Runnable() {
            @Override
            public void run() {
              view = createViewInstance();

              ViewGroup.LayoutParams params =
                  new ViewGroup.LayoutParams(
                      ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
              container.addView(view, params);

              container.setVisibility(View.VISIBLE);
            }
          });
    }
  }