示例#1
0
 private boolean findDropDownPosition(View anchor, android.view.WindowManager.LayoutParams p) {
   anchor.getLocationOnScreen(mDrawingLocation);
   p.x = mDrawingLocation[0];
   p.y = mDrawingLocation[1] + anchor.getMeasuredHeight();
   boolean onTop = false;
   View root = anchor.getRootView();
   int delta = (p.y + p.height) - root.getWindowTop() - root.getHeight();
   if (delta > 0) {
     if (p.y != anchor.getWindowBottom()) {
       ScrollView scrollView =
           (ScrollView) anchor.findParentViewOfType(android / widget / ScrollView);
       if (scrollView != null) {
         int bottom = anchor.getWindowBottom() + p.height;
         if (bottom > scrollView.getChildAt(scrollView.getChildCount() - 1).getWindowBottom())
           onTop = true;
         else if (bottom > scrollView.getWindowBottom()) {
           boolean enabled = scrollView.isVerticalScrollBarEnabled();
           if (enabled) scrollView.setVerticalScrollBarEnabled(false);
           scrollView.smoothScrollBy(0, delta);
           if (enabled) scrollView.setVerticalScrollBarEnabled(enabled);
           p.y -= delta;
         } else {
           onTop = true;
         }
       } else {
         onTop = true;
       }
     } else {
       onTop = true;
     }
     if (onTop) p.y -= anchor.getMeasuredHeight() + p.height;
   }
   return onTop;
 }
 private void addAttribute(Attribute a) {
   View v =
       x.inflater.new Builder(attributesLayout, R.layout.select_entry_simple_minus)
           .withId(R.id.edit_attribute, this)
           .create();
   setAttributeData(v, a);
   ImageView plusImageView = (ImageView) v.findViewById(R.id.plus_minus);
   plusImageView.setId(R.id.remove_attribute);
   plusImageView.setOnClickListener(this);
   plusImageView.setTag(v.getTag());
   v.setTag(a);
   scrollView.fullScroll(ScrollView.FOCUS_DOWN);
 }
        @Override
        public void onCompleted(Exception e, PlusPerson plusPerson) {
          progressBarSpinner.setVisibility(View.GONE);
          d(
              "[DEBUG] fucverg.saulmm.gdg.gui.fragments.GroupFragment.onCompleted ",
              "Posts completed...");

          if (plusPerson != null) {
            baseLayout.setVisibility(View.VISIBLE);
            scrollView.setVisibility(View.VISIBLE);
            errorLayout.setVisibility(View.INVISIBLE);

            String content = plusPerson.getAboutMe().replaceAll("<br />", "");

            fillUrlsLayout(plusPerson.getUrls());

            GroupInfo apiGroupInfo = new GroupInfo();
            apiGroupInfo.setAbout(content);
            apiGroupInfo.setId(plusPerson.getId());
            apiGroupInfo.setTagLine(plusPerson.getTagline());
            apiGroupInfo.setName(plusPerson.getDisplayName());

            fillAboutUIElements(apiGroupInfo);

            dbHandler.insertElement(GroupInfo.class, apiGroupInfo.getFields());

          } else {
            e(
                "[ERROR] fucverg.saulmm.gdg.gui.fragments.AboutFragment.onCompleted ",
                "Error retrieving the gdg about data.");

            errorLayout.setVisibility(View.VISIBLE);
            scrollView.setVisibility(View.INVISIBLE);

            GuiUtils.showShortToast(getActivity(), "No hay red");
          }
        }
 @Override
 protected void onClick(View v, int id) {
   switch (id) {
     case R.id.category:
       x.select(
           this,
           R.id.category,
           R.string.parent,
           categoryCursor,
           categoryAdapter,
           CategoryColumns._id.name(),
           category.getParentId());
       break;
     case R.id.new_attribute:
       x.select(
           this,
           R.id.new_attribute,
           R.string.attribute,
           attributeCursor,
           attributeAdapter,
           AttributeColumns.ID,
           -1);
       break;
     case R.id.add_attribute:
       {
         Intent intent = new Intent(this, AttributeActivity.class);
         startActivityForResult(intent, NEW_ATTRIBUTE_REQUEST);
       }
       break;
     case R.id.edit_attribute:
       {
         Object o = v.getTag();
         if (o instanceof Attribute) {
           Intent intent = new Intent(this, AttributeActivity.class);
           intent.putExtra(AttributeColumns.ID, ((Attribute) o).id);
           startActivityForResult(intent, EDIT_ATTRIBUTE_REQUEST);
         }
       }
       break;
     case R.id.remove_attribute:
       attributesLayout.removeView((View) v.getTag());
       attributesLayout.removeView((View) v.getParent());
       scrollView.fullScroll(ScrollView.FOCUS_DOWN);
       break;
   }
 }