Exemplo n.º 1
0
  private LinearLayout getTriggerStatuslayout(Trigger trigger) {
    LinearLayout triggerStatusLayout = new LinearLayout(ctx);
    triggerStatusLayout.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    triggerStatusLayout.setGravity(Gravity.CENTER);
    triggerStatusLayout.setOrientation(VERTICAL);

    ImageView triggerAckImg = new ImageView(ctx);
    triggerAckImg.setImageResource(trigger.getAckImg());
    triggerAckImg.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    triggerAckImg.setPadding(0, 5, 0, 0);

    ImageView triggerStatusImage = new ImageView(ctx);
    triggerStatusImage.setImageResource(trigger.getActiveImg());
    triggerStatusImage.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    triggerStatusLayout.addView(triggerStatusImage);
    if (!showask()) {
      triggerStatusLayout.addView(triggerAckImg);
      // triggerStatusLayout.setGravity(Gravity.RIGHT);
      triggerStatusLayout.setPadding(0, 10, 0, 0);
    } else {
      // triggerStatusLayout.setGravity(Gravity.RIGHT);
      triggerStatusLayout.setPadding(0, 20, 0, 10);
    }

    return triggerStatusLayout;
  }
Exemplo n.º 2
0
  public TriggerAdapterView(Context context, Trigger trigger) {
    super(context);
    ctx = this.getContext();
    this.setBackgroundColor(Color.parseColor(trigger.getSeverity()));
    this.setOrientation(HORIZONTAL);

    addView(getTable(trigger));
    addView(getTriggerStatuslayout(trigger));
  }
Exemplo n.º 3
0
  private TableLayout getTable(Trigger trigger) {
    WindowManager mWinMgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    int displayWidth = mWinMgr.getDefaultDisplay().getWidth();

    TextView description = new TextView(ctx);
    description.setText(trigger.getDescription());
    description.setTextColor(Color.BLACK);
    description.setTextSize(16);

    TextView hostName = new TextView(ctx);
    hostName.setText(trigger.getHost());
    hostName.setTextColor(Color.BLACK);
    hostName.setTextSize(14);

    TextView age = new TextView(ctx);
    age.setText(trigger.getAgeTime());
    age.setTextColor(Color.DKGRAY);
    age.setTextSize(12);
    age.setPadding(0, 10, 0, 0);

    // ##############################################################################3
    TableLayout table = new TableLayout(ctx);
    // ##############################################################################3

    TableRow row1 = new TableRow(ctx);

    if (!showage()) {
      TableRow.LayoutParams hostNameparam =
          new TableRow.LayoutParams(displayWidth / 2, LayoutParams.WRAP_CONTENT);
      hostNameparam.gravity = Gravity.LEFT;

      row1.addView(hostName, hostNameparam);
      TableRow.LayoutParams ageparam =
          new TableRow.LayoutParams(displayWidth / 3, LayoutParams.WRAP_CONTENT);
      ageparam.gravity = Gravity.RIGHT;
      row1.addView(age, ageparam);
    } else {
      TableRow.LayoutParams hostNameparam =
          new TableRow.LayoutParams(displayWidth - 40, LayoutParams.WRAP_CONTENT);
      hostNameparam.gravity = Gravity.LEFT;

      row1.addView(hostName, hostNameparam);
    }

    table.addView(row1, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    // ##############################################################################3

    TableRow row2 = new TableRow(ctx);

    LinearLayout descripionLayout = new LinearLayout(ctx);

    TableRow.LayoutParams params = new TableRow.LayoutParams();
    params.span = 2;
    descripionLayout.addView(description);
    descripionLayout.setLayoutParams(params);
    row2.addView(descripionLayout);

    table.addView(row2);

    return table;
  }