Example #1
0
 public void setPreset(int left, int right, int top, int bottom) {
   Preset p = checkPreset(left, right, top, bottom);
   if (p != null) {
     spinner_presets.setSelection(p.getId());
     // Toast.makeText(this, "" + p.getId(), Toast.LENGTH_SHORT).show();
   }
 }
 public void choosePreset(int id) {
   Preset chosen = presetById(id);
   if (id != 0) {
     ET_left_margin.setText(Integer.toString((int) chosen.getLeft()));
     ET_right_margin.setText(Integer.toString((int) chosen.getRight()));
     ET_top_margin.setText(Integer.toString((int) chosen.getTop()));
     ET_bottom_margin.setText(Integer.toString((int) chosen.getBottom()));
   }
 }
  public Preset checkPreset(int left, int right, int top, int bottom) {
    Preset p = null;
    if (left == bottom_right.getLeft()
        && right == bottom_right.getRight()
        && top == bottom_right.getTop()
        && bottom == bottom_right.getBottom()) p = bottom_right;
    else if (left == bottom_left.getLeft()
        && right == bottom_left.getRight()
        && top == bottom_left.getTop()
        && bottom == bottom_left.getBottom()) p = bottom_left;
    else if (left == bottom_right_big.getLeft()
        && right == bottom_right_big.getRight()
        && top == bottom_right_big.getTop()
        && bottom == bottom_right_big.getBottom()) p = bottom_right_big;
    else if (left == bottom_left_big.getLeft()
        && right == bottom_left_big.getRight()
        && top == bottom_left_big.getTop()
        && bottom == bottom_left_big.getBottom()) p = bottom_left_big;
    else if (left == bottom_middle.getLeft()
        && right == bottom_middle.getRight()
        && top == bottom_middle.getTop()
        && bottom == bottom_middle.getBottom()) p = bottom_middle;
    else if (left == squash_down.getLeft()
        && right == squash_down.getRight()
        && top == squash_down.getTop()
        && bottom == squash_down.getBottom()) p = squash_down;

    return p;
  }