public void displayAjustView(RecyclingBitmapDrawable value) {
    if (value != null && value.getBitmap() != null) {
      this.value = value;
      adjustView =
          new AdjustView(
              context, value.getBitmap().getWidth(), value.getBitmap().getHeight(), value);
      adjustView.setBackgroundColor(Color.TRANSPARENT);
      //			adjustView.setImageBitmap(bitmap);

      relayout.removeAllViews();
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(
              android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT,
              android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);

      Tools.initWidth = value.getBitmap().getWidth();
      Tools.initHeight = value.getBitmap().getHeight();

      params.topMargin = (int) (screenHeight * 0.5 - value.getBitmap().getHeight() * 0.5);
      params.leftMargin = (int) (screenWidth * 0.5 - value.getBitmap().getWidth() * 0.5);
      relayout.addView(adjustView, params);

      float rate = (float) viewWidth / viewHeight;
      int mheight = (int) (value.getBitmap().getHeight() * 0.5);
      int mwidth = (int) (mheight * rate);

      adjustView.auto_setAdjustImg(0, 0, mwidth, mheight);
    } else relayout.removeAllViews();
  }
  @Override
  public void onBackPressed() {

    super.onBackPressed();
    skillsLayout.removeAllViews();
    gridLayout.removeAllViews();
    questionLayout.removeAllViews();
    scoreLayout.removeAllViews();
    Intent i = new Intent(NegativeCoordActivity.this, LevelSelect.class);
    startActivity(i);
    finish();
  }
 public void drawAnnotations() {
   mAnnotationLabelOverlay.removeAllViews();
   if (mQueryResult == null) {
     return;
   }
   int[] actImageRect = getBitmapPositionInsideImageView(mImageView);
   List<Annotation> annotations = mQueryResult.annotations;
   int index = -1;
   for (Annotation anno : annotations) {
     index++;
     LabelView label = new LabelView(getActivity());
     label.mLabelText.setVisibility(View.VISIBLE);
     label.mLabelText.setText(anno.text);
     label.mPosition = index;
     float padding = 100;
     float cx = anno.getCenterX() * actImageRect[2];
     float cy = anno.getCenterY() * actImageRect[3];
     if (cx > actImageRect[2] - padding) {
       cx = actImageRect[2] - padding + randomInt(-30, 30);
     } else if (cx < padding) {
       cx = padding + randomInt(-30, 30);
     }
     if (cy > actImageRect[3] - padding) {
       cy = actImageRect[3] - padding + randomInt(-30, 30);
     } else if (cy < padding) {
       cy = padding + randomInt(-30, 30);
     }
     RelativeLayout.LayoutParams params =
         new RelativeLayout.LayoutParams(
             ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
     params.leftMargin = (int) cx + actImageRect[0];
     params.topMargin = (int) cy + actImageRect[1];
     mAnnotationLabelOverlay.addView(label, params);
     label.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             LabelView view = (LabelView) v;
             Log.d("label position: ", "" + view.mPosition);
             int position = view.mPosition;
             if (position >= 0 && position < mAnnotationList.size()) {
               mLinearLayoutManager.scrollToPosition(position);
             }
             //                    String text = view.mLabelText.getText().toString();
             //                    AnnotationDetailFragment fragment = new
             // AnnotationDetailFragment();
             //                    Bundle args = new Bundle();
             //                    args.putString("annotation_text", text);
             //                    fragment.setArguments(args);
             //
             // getFragmentManager().beginTransaction().replace(R.id.frame_container,
             // fragment).addToBackStack(null).commit();
           }
         });
     if (mLabels == null) {
       mLabels = new ArrayList<>();
     }
     mLabels.add(label);
   }
 }
Example #4
0
 /**
  * 描述:用指定的View填充主界面.
  *
  * @param contentView 指定的View
  */
 public void setAbContentView(View contentView) {
   contentLayout.removeAllViews();
   contentLayout.addView(
       contentView,
       new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
   initIocView();
 }
Example #5
0
  protected void setRightButtonText(String text) {
    RelativeLayout rightView = (RelativeLayout) findViewById(R.id.right_view);
    rightView.removeAllViews();

    int padding = dp2px(6);
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.setMargins(0, 0, dp2px(8), 0);
    TextView tv = new TextView(this);
    tv.setText(text);
    tv.setTextColor(0xFF666666);
    tv.setTextSize(16.f);
    tv.setLayoutParams(lp);
    tv.setBackgroundResource(R.drawable.btn_gray);
    tv.setPadding(2 * padding, padding, 2 * padding, padding);
    tv.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onRightButtonClicked(v);
          }
        });

    rightView.addView(tv);
    rightView.setVisibility(View.VISIBLE);
  }
  @Override
  public void onDestroyView() {
    if (null != relativeMain) {
      relativeMain.removeAllViews();
    }

    super.onDestroyView();
  }
Example #7
0
 @Override
 public void removeAllViews() {
   for (int i = 0; i < tabs.size(); i++) {
     tabs.remove(i);
   }
   layout.removeAllViews();
   super.removeAllViews();
 }
 public void reDrawBoard() {
   screen.removeAllViews();
   for (int x = 0; x < gameSize.x; x++) {
     for (int y = 0; y < gameSize.y; y++) {
       if (tiles[x][y] == null) continue;
       screen.addView(tiles[x][y], tiles[x][y].params);
     }
   }
 }
  public AdjustSizeofInitpicWindow(
      int which,
      Context context,
      RecyclingBitmapDrawable value,
      OnClickListener sure_onClick,
      OnClickListener cancel_onClick,
      final int viewWidth,
      final int viewHeight,
      int screenHeight) {
    super(context);
    this.context = context;

    DisplayMetrics dm = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm);
    this.screenWidth = dm.widthPixels; // фад╩©М
    this.screenHeight = screenHeight;

    this.viewWidth = viewWidth;
    this.viewHeight = viewHeight;
    this.value = value;

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    adjustSizeview = inflater.inflate(R.layout.adjust_size, null);

    relayout = (RelativeLayout) adjustSizeview.findViewById(R.id.adjustSizeLayout);
    this.setContentView(adjustSizeview);
    this.setWidth(LayoutParams.FILL_PARENT);
    this.setHeight(LayoutParams.FILL_PARENT);
    this.setFocusable(true);

    if (which == 0) this.setAnimationStyle(R.style.AnimationFade1);
    else this.setAnimationStyle(R.style.AnimationFadefromleft);

    ColorDrawable dw = new ColorDrawable(0xb0000000);
    this.setBackgroundDrawable(dw);

    adjustBarSize();

    if (value != null) {
      displayAjustView(value);
    } else {
      mprogress = new ProgressBar(context);
      relayout.removeAllViews();
      float scale = context.getResources().getDisplayMetrics().density;

      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(Tools.Dp2Px(60, scale), Tools.Dp2Px(60, scale));
      params.addRule(RelativeLayout.CENTER_IN_PARENT);
      relayout.addView(mprogress, params);
      mprogress.setVisibility(View.VISIBLE);
    }
    Log.i("AdjustSizeofWindow", "onCreate");
    sure.setOnClickListener(sure_onClick);
    cancel.setOnClickListener(cancel_onClick);
  }
  public final void setupLayout() {
    RelativeLayout relativeLayout = new RelativeLayout(context);

    removeAllViews();
    relativeLayout.removeAllViews();

    relativeLayout.setBackgroundColor(Color.BLACK);
    relativeLayout.addView(preview);
    addView(relativeLayout);
  }
Example #11
0
  public int processJson(String json) {
    courseContainer.removeAllViews();
    int len = 0;
    try {
      L.d("解析所有课程", json);
      JSONArray jsonArray;
      jsonArray = new JSONArray(json);
      len = jsonArray.length();

      for (int i = 0; i < len; i++) {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        Course course = new Course(jsonObject);

        // 将dp转换成px,因为设置RelativeLayout.LayoutParams 的margin只能传入px
        int _60dp = dpToPx(getActivity(), 60);
        int marginDp = dpToPx(getActivity(), 1.5f);

        int colWidth = courseContainer.getWidth() / 7;
        int xStartOffset = (Integer.valueOf(course.getLessonsBegin()) - 1) * (_60dp + marginDp);
        int xEndOffset = (Integer.valueOf(course.getLessonsEnd()) - 1) * (_60dp + marginDp);
        int yStartOffset = (Integer.valueOf(course.getDayOfWeek()) - 1) * colWidth;

        LinearLayout ll =
            (LinearLayout)
                LayoutInflater.from(getActivity()).inflate(R.layout.layout_onecourse, null);

        TextView courseName = (TextView) ll.findViewById(R.id.courseName);
        //				TextView detail = (TextView) ll.findViewById(R.id.detail);
        //				TextView teacher = (TextView) ll.findViewById(R.id.teacher);
        TextView room = (TextView) ll.findViewById(R.id.room);

        courseName.setText(course.getCourseName());
        // detail.setText(course.getDetail());
        // teacher.setText(course.getTeacher());
        room.setText(course.getRoom());

        RelativeLayout.LayoutParams params =
            new RelativeLayout.LayoutParams(colWidth, xEndOffset - xStartOffset + _60dp);
        params.leftMargin = yStartOffset;
        params.topMargin = xStartOffset;

        courseContainer.addView(ll, params);

        ll.setOnClickListener(new CourseOnClickListener(course));
      }

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return len;
  }
Example #12
0
 void SwitchActivity(int id) {
   re.removeAllViews();
   Intent intent = null;
   if (id == 0) {
     intent = new Intent(PersonCenter.this, PersonInfo.class);
   } else if (id == 1) {
     intent = new Intent(PersonCenter.this, QccountInfo.class);
   } else if (id == 2) {
     intent = new Intent(PersonCenter.this, ChangePassword.class);
   }
   intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
   Window subActivity = getLocalActivityManager().startActivity("subActivity", intent);
   re.addView(subActivity.getDecorView(), LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
 }
  public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {

    if (key.equals(TiC.PROPERTY_HEADER_TITLE)) {
      setHeaderTitle(TiConvert.toString(newValue));
    } else if (key.equals(TiC.PROPERTY_FOOTER_TITLE)) {
      setFooterTitle(TiConvert.toString(newValue));
    } else if (key.equals(TiC.PROPERTY_SECTIONS) && newValue instanceof Object[]) {
      processSections((Object[]) newValue);
      if (adapter != null) {
        adapter.notifyDataSetChanged();
      }
    } else if (key.equals(TiC.PROPERTY_SEARCH_TEXT)) {
      this.searchText = TiConvert.toString(newValue);
      if (this.searchText != null) {
        reFilter(this.searchText);
      }
    } else if (key.equals(TiC.PROPERTY_CASE_INSENSITIVE_SEARCH)) {
      this.caseInsensitive = TiConvert.toBoolean(newValue, true);
      if (this.searchText != null) {
        reFilter(this.searchText);
      }
    } else if (key.equals(TiC.PROPERTY_SEARCH_VIEW)) {
      TiViewProxy searchView = (TiViewProxy) newValue;
      if (isSearchViewValid(searchView)) {
        TiUIView search = searchView.getOrCreateView();
        setSearchListener(searchView, search);
        if (searchLayout != null) {
          searchLayout.removeAllViews();
          addSearchLayout(searchLayout, searchView, search);
        } else {
          layoutSearchView(searchView);
        }
      } else {
        Log.e(TAG, "Searchview type is invalid");
      }

    } else if (key.equals(TiC.PROPERTY_SHOW_VERTICAL_SCROLL_INDICATOR) && newValue != null) {
      listView.setVerticalScrollBarEnabled(TiConvert.toBoolean(newValue));
    } else if (key.equals(TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE) && newValue != null) {
      defaultTemplateBinding = TiConvert.toString(newValue);
      refreshItems();
    } else if (key.equals(TiC.PROPERTY_SEPARATOR_COLOR)) {
      String color = TiConvert.toString(newValue);
      setSeparatorColor(color);
    } else {
      super.propertyChanged(key, oldValue, newValue, proxy);
    }
  }
  /**
   * ����������Ӧ��ͼƬ
   *
   * @param resId
   */
  private void setWeatherImage(int resId) {

    // �Ƴ�֮ǰ��ͼƬ
    if (layout != null) {
      layout.removeAllViews();
    }
    ImageView item = new ImageView(getParentFragment().getActivity());
    item.setImageResource(resId); // ����ͼƬ
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT); // �븸������������
    lp.topMargin = 10;
    item.setId(1); // �������View ��id
    item.setLayoutParams(lp); // ���ò��ֲ���
    layout.addView(item); // RelativeLayout�����View
  }
  private void updateHeader(Fragment fragment) {
    try {
      RelativeLayout placeholder = findView(R.id.activity_main_layout_header_placeholder);
      if (placeholder.getChildCount() > 0) {
        placeholder.removeAllViews();
      }

      if (fragment instanceof MainFragment) {
        View header = ((MainFragment) fragment).getHeader(this);
        if (header != null) {
          RelativeLayout.LayoutParams params =
              new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
          placeholder.addView(header, params);
        }
      }
    } catch (Throwable e) {
      LOG.error("Error updating main header", e);
    }
  }
Example #16
0
  /**
   * 描述:设置绝对定位的主标题栏覆盖到内容的上边.
   *
   * @param overlay the new title bar overlay
   */
  public void setTitleBarOverlay(boolean overlay) {
    ab_base.removeAllViews();
    if (overlay) {
      RelativeLayout.LayoutParams layoutParamsFW1 =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      layoutParamsFW1.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
      ab_base.addView(contentLayout, layoutParamsFW1);
      RelativeLayout.LayoutParams layoutParamsFW2 =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      layoutParamsFW2.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
      ab_base.addView(mAbTitleBar, layoutParamsFW2);

      RelativeLayout.LayoutParams layoutParamsFW3 =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      layoutParamsFW3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
      ab_base.addView(mAbBottomBar, layoutParamsFW3);

    } else {
      ab_base.addView(
          mAbTitleBar,
          new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

      RelativeLayout.LayoutParams layoutParamsFW2 =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      layoutParamsFW2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
      ab_base.addView(mAbBottomBar, layoutParamsFW2);

      RelativeLayout.LayoutParams layoutParamsFW1 =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
      layoutParamsFW1.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
      ab_base.addView(contentLayout, layoutParamsFW1);
    }
  }
 /** Removes all views from the second inner layout, below the first inner layout. */
 public void removeSecondLayoutFillerView() {
   mFillerLayout2.removeAllViews();
 }
 /** Removes all views from the first inner layout, below the title. */
 public void removeFirstLayoutFillerView() {
   mFillerLayout1.removeAllViews();
 }
Example #19
0
 /** Clear focus highlighting */
 public void clearOverlay() {
   mRelativeLayout.removeAllViews();
   mOverlay.hide();
 }
Example #20
0
  public void notifyDataSetChanged() {
    super.removeAllViews();
    layout.removeAllViews();

    if (!scrollable) { // not scrollable tabs
      int tabWidth = this.getWidth() / tabs.size();

      // set params for resizing tabs width
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(tabWidth, HorizontalScrollView.LayoutParams.MATCH_PARENT);
      for (MaterialTab t : tabs) {
        layout.addView(t.getView(), params);
      }

    } else { // scrollable tabs

      if (!isTablet) {
        for (int i = 0; i < tabs.size(); i++) {
          LinearLayout.LayoutParams params;
          MaterialTab tab = tabs.get(i);

          int tabWidth = (int) (tab.getTabMinWidth() + (24 * density)); // 12dp
          // +
          // text/icon
          // width
          // +
          // 12dp

          if (i == 0) {
            // first tab
            View view = new View(layout.getContext());
            view.setMinimumWidth((int) (60 * density));
            layout.addView(view);
          }

          params =
              new LinearLayout.LayoutParams(
                  tabWidth, HorizontalScrollView.LayoutParams.MATCH_PARENT);
          layout.addView(tab.getView(), params);

          if (i == tabs.size() - 1) {
            // last tab
            View view = new View(layout.getContext());
            view.setMinimumWidth((int) (60 * density));
            layout.addView(view);
          }
        }
      } else {
        // is a tablet
        for (int i = 0; i < tabs.size(); i++) {
          LinearLayout.LayoutParams params;
          MaterialTab tab = tabs.get(i);

          int tabWidth = (int) (tab.getTabMinWidth() + (48 * density)); // 24dp
          // +
          // text/icon
          // width
          // +
          // 24dp

          params =
              new LinearLayout.LayoutParams(
                  tabWidth, HorizontalScrollView.LayoutParams.MATCH_PARENT);
          layout.addView(tab.getView(), params);
        }
      }
    }

    if (isTablet && scrollable) {
      // if device is a tablet and have scrollable tabs add right and left
      // arrows
      Resources res = getResources();

      left = new ImageButton(this.getContext());
      left.setId(R.id.left);
      left.setImageDrawable(res.getDrawable(R.drawable.left_arrow));
      left.setBackgroundColor(Color.TRANSPARENT);
      left.setOnClickListener(this);

      // set 56 dp width and 48 dp height
      RelativeLayout.LayoutParams paramsLeft =
          new LayoutParams((int) (56 * density), (int) (48 * density));
      paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      paramsLeft.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      this.addView(left, paramsLeft);

      right = new ImageButton(this.getContext());
      right.setId(R.id.right);
      right.setImageDrawable(res.getDrawable(R.drawable.right_arrow));
      right.setBackgroundColor(Color.TRANSPARENT);
      right.setOnClickListener(this);

      RelativeLayout.LayoutParams paramsRight =
          new LayoutParams((int) (56 * density), (int) (48 * density));
      paramsRight.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      paramsRight.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      paramsRight.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      this.addView(right, paramsRight);

      RelativeLayout.LayoutParams paramsScroll =
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      paramsScroll.addRule(RelativeLayout.LEFT_OF, R.id.right);
      paramsScroll.addRule(RelativeLayout.RIGHT_OF, R.id.left);
      this.addView(scrollView, paramsScroll);
    } else {
      // if is not a tablet add only scrollable content
      RelativeLayout.LayoutParams paramsScroll =
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      this.addView(scrollView, paramsScroll);
    }

    this.setSelectedNavigationItem(tabSelected);
  }
Example #21
0
  // Draws the Events
  private void drawEvents() {

    int counter = 0;
    layout.removeAllViews();
    for (JSONObject j : events) {
      try {
        final String eid = j.getString("eid");
        final String name = j.getString("name");
        final int icon = j.getInt("icon");
        final int creator = j.getInt("creator");
        String update = j.getString("updated");
        final String temp = j.getString("datetime");
        String month = temp.substring(5, 7);
        String day = temp.substring(8, 10);
        String date = day + '-' + month;

        RelativeLayout.LayoutParams lp_icon = new RelativeLayout.LayoutParams(height, height);
        RelativeLayout.LayoutParams lp_button = new RelativeLayout.LayoutParams(width, height);
        RelativeLayout.LayoutParams lp_date = new RelativeLayout.LayoutParams(dateWidth, height);
        RelativeLayout.LayoutParams lp_div = new RelativeLayout.LayoutParams(width, divHeight);

        /**
         * Adds the icon: to limit the use of data we store the images in a local database, and in
         * an online database. Whenever someone uploads a new icon a new random icon_ID gets
         * generated when the icon_ID in your local DB doesn't equal the one in the online database,
         * the one in the online DB gets downloaded and the offline DB gets updated with this EID
         * and image.
         */
        lp_icon.setMargins(0, (height + divHeight) * counter, 0, 0);
        final ImageButton img = new ImageButton(this);
        if (icon == 0) {
          img.setImageResource(R.drawable.group);
          img.setPadding(12, 12, 12, 12);
          user_db.deleteBlob(eid);
        } else {
          if (icon == user_db.getVersion(eid)) {
            byte[] image = user_db.getBlob(eid);
            img.setImageBitmap(BitmapFactory.decodeByteArray(image, 0, image.length));
            img.setPadding(7, 7, 7, 7);
          } else {
            String tag_icon = "req_icon";
            StringRequest stringRequest =
                new StringRequest(
                    Request.Method.POST,
                    URL_ICON,
                    new Response.Listener<String>() {

                      @Override
                      public void onResponse(String response) {
                        try {
                          JSONObject jObj = new JSONObject(response);
                          boolean error = jObj.getBoolean("error");

                          if (!error) {
                            byte[] blob = Base64.decode(jObj.getString("blob"), Base64.DEFAULT);
                            if (user_db.getVersion(eid) == 0) {
                              user_db.addBLOB(eid, icon, blob);
                            } else {
                              user_db.updateBlob(eid, icon, blob);
                            }
                            img.setImageBitmap(BitmapFactory.decodeByteArray(blob, 0, blob.length));
                            img.setPadding(7, 7, 7, 7);
                          }
                        } catch (JSONException e) {
                          e.printStackTrace();
                        }
                      }
                    },
                    new Response.ErrorListener() {

                      @Override
                      public void onErrorResponse(VolleyError error) {}
                    }) {

                  @Override
                  protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("tag", "get");
                    params.put("eid", eid);
                    return params;
                  }
                };
            AppController.getInstance().addToRequestQueue(stringRequest, tag_icon);
          }
        }
        img.setLayoutParams(lp_icon);
        img.setBackground(null);
        img.setScaleType(ImageView.ScaleType.FIT_CENTER);
        layout.addView(img);

        // Add the button
        lp_button.setMargins(height, (height + divHeight) * counter, height, 0);
        TextView button = new TextView(this);
        button.setText(name);
        button.setTypeface(express);
        button.setTextSize(getResources().getDimension(R.dimen.button_text));
        button.setTextColor(getResources().getColor(R.color.black));
        button.setGravity(Gravity.CENTER_VERTICAL);
        button.setLayoutParams(lp_button);
        layout.addView(button);
        button.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, EventActivity.class);
                Bundle b = new Bundle();
                b.putString("eid", eid);
                b.putString("name", name);
                b.putInt("icon", icon);
                b.putInt("creator", creator);
                b.putString("date", temp);
                intent.putExtras(b);
                startActivity(intent);
              }
            });

        // Add the Date
        if (!month.equals("00") && !day.equals("00")) {
          lp_date.setMargins(0, (height + divHeight) * counter, 0, 0);
          lp_date.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
          TextView datetime = new TextView(this);
          datetime.setText(date);
          datetime.setGravity(Gravity.CENTER);
          datetime.setLayoutParams(lp_date);
          layout.addView(datetime);
        }

        // Add the Divider
        lp_div.setMargins(height, (height + divHeight) * counter + height, 20, 0);
        ImageView div = new ImageView(this);
        div.setImageResource(R.drawable.divider);
        div.setLayoutParams(lp_div);
        layout.addView(div);

        counter++;
      } catch (JSONException ex) {

      }
    }
  }
 public void setPanelView(View view) {
   mPanel.removeAllViews();
   mPanel.addView(view);
 }
Example #23
0
  public void drawHRLayout(double[] myHRs, Date[] myDates) {
    String[] titles = new String[] {"FitFormula User"};
    List<Date[]> dates = new ArrayList<Date[]>();
    List<double[]> values = new ArrayList<double[]>();
    for (int i = 0; i < titles.length; i++) {
      dates.add(myDates);
      values.add(myHRs);
    }

    int[] colors = new int[] {Color.YELLOW};
    PointStyle[] styles = new PointStyle[] {PointStyle.CIRCLE};
    XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
    int length = renderer.getSeriesRendererCount();
    for (int i = 0; i < length; i++) {
      ((XYSeriesRenderer) renderer.getSeriesRendererAt(i)).setFillPoints(true);
    }
    double hrMin = getMinValue(myHRs);
    double hrMax = getMaxValue(myHRs);
    setChartSettings(
        renderer,
        "Resting Heart Rate",
        "Date",
        "BPM",
        dates.get(0)[0].getTime(),
        dates.get(0)[myDates.length - 1].getTime(),
        hrMin - hrMin * 0.20,
        hrMax + hrMax * 0.20,
        Color.LTGRAY,
        Color.LTGRAY);
    renderer.setXLabels(myDates.length - 1);
    renderer.setYLabels(8);
    renderer.setShowGrid(true);
    renderer.setXLabelsAlign(Align.RIGHT);
    renderer.setYLabelsAlign(Align.RIGHT);
    renderer.setZoomButtonsVisible(false);
    renderer.setZoomEnabled(false, false);
    renderer.setPanEnabled(true, false);
    renderer.setPanLimits(new double[] {0, myDates.length - 1, 0, hrMax}); // minX, maxX, minY, maxY
    // renderer.setZoomLimits(new double[] { 0, 20, 60, 120 });

    mRelative.removeAllViews();

    titleText.setText(
        Html.fromHtml("<br><b><u><big>My Resting Heart Rate History</big></u></b><br>"));
    titleText.setId(1);
    RelativeLayout.LayoutParams relParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    relParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    mRelative.addView(titleText, relParams);

    // Add the view!
    chartView =
        ChartFactory.getTimeChartView(
            context, buildDateDataset(titles, dates, values), renderer, "MM/dd/yyyy");
    chartView.setId(2);
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int height = displaymetrics.heightPixels;
    int width = displaymetrics.widthPixels;
    int chartSize = (int) (width * 0.9);
    relParams = new RelativeLayout.LayoutParams(width, chartSize);
    relParams.addRule(RelativeLayout.BELOW, titleText.getId());
    relParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    mRelative.addView(chartView, relParams);

    hrButton = new Button(this);
    hrButton.setId(3);
    hrButton.setText("Measure Resting Heart Rate");
    // hrButton.setWidth(width);
    hrButton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            Intent i = new Intent(HcHeartRate.this, FitTestHR.class);
            i.putExtra("nextactivity", "HcHeartRate"); // Telling HR Class what is next activity
            getParent().startActivityForResult(i, HCHEARTRATE_REQUEST_CODE);
          }
        });
    relParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relParams.addRule(RelativeLayout.BELOW, chartView.getId());
    relParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    mRelative.addView(hrButton, relParams);
  }
  /** 生成IM布局(按钮、输入框、减号) */
  private void genImLayout(boolean isJSON, String label, String value) {
    /*final LinearLayout imMinusLayout = new LinearLayout(getApplicationContext());
    imMinusLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    imMinusLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams blp = new LayoutParams(120,LayoutParams.WRAP_CONTENT);
    Button label_btn = new Button(getApplicationContext());
    switch (imCount) {
    case 0:
    	label_btn.setText("QQ");
    	break;
    case 1:
    	label_btn.setText("MSN");
    	break;
    default:
    	label_btn.setText("QQ");
    	break;
    }
    if(isJSON){
    	label_btn.setText(label);
    }
    label_btn.setLayoutParams(blp);
    label_btn.setOnClickListener(new OnClickListener() {
    	@Override
    	public void onClick(View v) {
    		currentImBtn = (Button) v;
    		showDialog(DIALOG_IM_CHOICE);
    	}
    });

    LayoutParams nlp = new LayoutParams(260,LayoutParams.WRAP_CONTENT);
    EditText im = new EditText(getApplicationContext());
    im.setLayoutParams(nlp);
    if(isJSON){
    	im.setText(value);
    }

    ImageView minus = new ImageButton(getApplicationContext());
    LayoutParams mlp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    minus.setLayoutParams(mlp);
    minus.setBackgroundDrawable(getResources().getDrawable(R.drawable.minus));
    minus.setOnClickListener(new OnClickListener() {
    	@Override
    	public void onClick(View v) {
    		im_row_layout.removeView(imMinusLayout);
    	}
    });
    imMinusLayout.addView(label_btn);
    imMinusLayout.addView(im);
    imMinusLayout.addView(minus);*/

    final RelativeLayout imMinusLayout =
        (RelativeLayout) getLayoutInflater().inflate(R.layout.row_im_edit, null);
    Button label_btn = (Button) imMinusLayout.findViewById(R.id.im_btn);
    switch (imCount) {
      case 0:
        label_btn.setText("QQ");
        break;
      case 1:
        label_btn.setText("MSN");
        break;
      default:
        label_btn.setText("QQ");
        break;
    }
    if (isJSON) {
      label_btn.setText(label);
    }
    label_btn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            currentImBtn = (Button) v;
            showDialog(DIALOG_IM_CHOICE);
          }
        });

    EditText mobileNumber = (EditText) imMinusLayout.findViewById(R.id.im_edit);
    if (isJSON) {
      mobileNumber.setText(value);
    }

    ImageView minus = (ImageView) imMinusLayout.findViewById(R.id.im_minus);
    minus.setBackgroundDrawable(getResources().getDrawable(R.drawable.minus));
    minus.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            im_row_layout.removeView(imMinusLayout);
          }
        });

    imMinusLayout.removeAllViews();
    imMinusLayout.addView(label_btn);
    imMinusLayout.addView(mobileNumber);
    imMinusLayout.addView(minus);
    im_row_layout.addView(imMinusLayout);
  }