Example #1
0
  // used when switching languages or building a hebrew page
  // reverse the order of every row in the grid
  private void flipViews(boolean flipTabsAlso) {

    int numChildren;
    if (tabRoot != null && flipTabsAlso) {
      numChildren = tabRoot.getChildCount();
      for (int i = 0; i < numChildren; i++) {
        View tempView = tabRoot.getChildAt(numChildren - 1);
        tabRoot.removeViewAt(numChildren - 1);
        tabRoot.addView(tempView, i);
      }
    }

    for (int i = 0; i < gridRoot.getChildCount(); i++) {
      View v = gridRoot.getChildAt(i);
      if (v instanceof LinearLayout) {
        LinearLayout ll = (LinearLayout) v;
        numChildren = ll.getChildCount();
        for (int j = 0; j < numChildren - 1; j++) {
          View tempView = ll.getChildAt(numChildren - 1);
          ll.removeViewAt(numChildren - 1);
          ll.addView(tempView, j);
        }
      }
    }
  }
  public boolean removeImage(Uri uri) {

    boolean result = mSelectedImages.remove(uri);

    if (result) {

      if (GalleryFragment.mGalleryAdapter != null) {
        GalleryFragment.mGalleryAdapter.notifyDataSetChanged();
      }

      for (int i = 0; i < mSelectedImagesContainer.getChildCount(); i++) {
        View childView = mSelectedImagesContainer.getChildAt(i);
        if (childView.getTag().equals(uri)) {
          mSelectedImagesContainer.removeViewAt(i);
          break;
        }
      }

      if (mSelectedImages.size() == 0) {
        mSelectedImagesContainer.setVisibility(View.GONE);
        mSelectedImageEmptyMessage.setVisibility(View.VISIBLE);
      }
    }
    return result;
  }
Example #3
0
  private MenuButton addElement(
      MenuNode menuNode, MenuNode sectionNode, LinearLayout ll, int childIndex) {

    ll.removeViewAt(childIndex);
    MenuButton mb = new MenuButton(context, menuNode, sectionNode, menuState.getLang());
    mb.setOnClickListener(menuButtonClick);
    mb.setOnLongClickListener(menuButtonLongClick);
    ll.addView(mb, childIndex);
    menuElementList.add(mb);

    return mb;
  }
  private void onMediaUnselected(MediaModel image) {

    for (int i = 0; i < mSelectedImagesContainer.getChildCount(); i++) {
      View childView = mSelectedImagesContainer.getChildAt(i);
      if (childView.getTag().equals(image.url)) {
        mSelectedImagesContainer.removeViewAt(i);
        break;
      }
    }
    // if (mImageSelectedCount == 0 && mVideoSelectedCount == 0) {
    if (mSelectedImagesContainer.getChildCount() == 0) {
      mSelectedImagesContainer.setVisibility(View.GONE);
      mSelectedImageEmptyMessage.setVisibility(View.VISIBLE);
    }
  }
 /**
  * Recycles items from specified layout. There are saved only items not included to specified
  * range. All the cached items are removed from original layout.
  *
  * @param layout the layout containing items to be cached
  * @param firstItem the number of first item in layout
  * @param range the range of current wheel items
  * @return the new value of first item number
  */
 public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
   int index = firstItem;
   for (int i = 0; i < layout.getChildCount(); ) {
     if (!range.contains(index)) {
       recycleView(layout.getChildAt(i), index);
       layout.removeViewAt(i);
       if (i == 0) { // first item
         firstItem++;
       }
     } else {
       i++; // go to next item
     }
     index++;
   }
   return firstItem;
 }
 @Override
 public void notifyDataSetChanged() {
   if (container == null) {
     return;
   }
   int numItems = this.getCount();
   int realChildCount = container.getChildCount();
   for (int i = 0; i < numItems; i++) {
     View child = null;
     if (realChildCount > i) {
       child = container.getChildAt(i);
     }
     if (child == null) {
       child = getView(i, null, container);
       container.addView(child, i);
     } else {
       getView(i, child, container);
     }
   }
   for (int i = numItems; i < container.getChildCount(); i++) {
     container.removeViewAt(i);
   }
 }
Example #7
0
 /**
  * Remove a action from the action bar.
  *
  * @param index position of action to remove
  */
 public void removeActionAt(int index) {
   mActionsView.removeViewAt(index);
 }
Example #8
0
 void removeCrumbAt(int index) {
   mCrumbs.remove(index);
   mChildFrame.removeViewAt(index);
 }
Example #9
0
 public void removeNavBar() {
   if (navBar == null) return;
   view.removeViewAt(0);
   navBar = null;
 }
Example #10
0
 private void onAccept() {
   LinearLayout requestLayout = (LinearLayout) findViewById(R.id.requestLayout);
   requestLayout.removeViewAt(requestLayout.getChildCount() - 1);
   accepted = true;
   for (HelperOrPinLocationUpdate l : locationUpdates) l.onLocationUpdate(lastLocation);
 }
Example #11
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    LinearLayout.LayoutParams lparams_img =
        new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1000);
    lparams_img.gravity = Gravity.CENTER_HORIZONTAL;
    ImageKeepAspectRatio iv = new ImageKeepAspectRatio(this);
    iv.setLayoutParams(lparams_img);

    Log.d("QA_APP", "RETURN...");
    if (requestCode == 1) {
      if (resultCode == RESULT_OK) {

        // A LOT OF RE-WRITTEN CODE THAT MUST BE REFACTORED
        Log.d("QA_APP", "RETURN SUCCESS");
        questionDataLayout.removeViewAt(chooserIndex);
        Bitmap tempBitmap = PicUtil.loadFromCacheFile();

        iv.setImageBitmap(PicUtil.loadFromCacheFile());

        PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(iv);
        photoViewAttacher.setOnLongClickListener(questionItemLongClickListener);
        photoViewAttacher.setOnViewTapListener(
            new PhotoViewAttacher.OnViewTapListener() {
              @Override
              public void onViewTap(View view, float x, float y) {
                int index = questionDataLayout.indexOfChild(view);
                //                           scrollView.scrollTo(0,
                // questionDataLayout.getChildAt(index).getTop());

                // reset colors/boxes
                for (int i = 0; i < elements.size(); i++) {
                  circleIndex.get(i).setBorderColor(getResources().getColor(R.color.blue));
                  questionDataLayout.getChildAt(i).setBackground(null);
                }
                circleIndex.get(index).setBorderColor(Color.WHITE);
                // TODO: WORKAROUND FOR API 16 CALL BELOW
                questionDataLayout.getChildAt(index).setBackground(rectShapeDrawable);
                selectedIndex = index;
              }
            });
        photoViewAttacher.update();

        elements.add(new QData(tempBitmap));

        questionDataLayout.addView(iv);
        addElementCircles();
        createScrollView();
      }
      if (resultCode == RESULT_CANCELED) {
        Log.d("QA_APP", "RETURN FAIL");
      }
    } else if (requestCode == 2) {
      if (resultCode == RESULT_OK) {
        Uri selectedImage = data.getData();
        InputStream imageStream = null;
        try {
          imageStream = getContentResolver().openInputStream(selectedImage);
        } catch (FileNotFoundException e) {
          e.printStackTrace();
        }
        Bitmap selectedImg = BitmapFactory.decodeStream(imageStream);
        iv.setImageBitmap(selectedImg);
        PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(iv);
        photoViewAttacher.setOnLongClickListener(questionItemLongClickListener);
        photoViewAttacher.setOnViewTapListener(
            new PhotoViewAttacher.OnViewTapListener() {
              @Override
              public void onViewTap(View view, float x, float y) {
                int index = questionDataLayout.indexOfChild(view);
                //                           scrollView.scrollTo(0,
                // questionDataLayout.getChildAt(index).getTop());

                // reset colors/boxes
                for (int i = 0; i < elements.size(); i++) {
                  circleIndex.get(i).setBorderColor(getResources().getColor(R.color.blue));
                  questionDataLayout.getChildAt(i).setBackground(null);
                }
                circleIndex.get(index).setBorderColor(Color.WHITE);
                // TODO: WORKAROUND FOR API 16 CALL BELOW
                questionDataLayout.getChildAt(index).setBackground(rectShapeDrawable);
                selectedIndex = index;
              }
            });
        photoViewAttacher.update();

        elements.add(new QData(selectedImg));

        addElementCircles();
        createScrollView();
      }
    }
  } // onActivityResult
 public void removeSystemIcon(String slot, int index, int viewIndex) {
   mStatusIcons.removeViewAt(viewIndex);
   mStatusIconsKeyguard.removeViewAt(viewIndex);
 }
Example #13
0
 @Override
 public void removeViewAt(int index) {
   addFlag = true;
   mHeight = mHeight - childHeight;
   super.removeViewAt(index);
 }
 @Override
 public void removeActionItem(int index) {
   mActionItemBar.removeViewAt(index);
   sActionItems.remove(index);
 }