Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.util.Log;

import java.util.ArrayList;

public class Main {
    public static String getCommandInputList(ArrayList<String> commands) {
        if (commands == null || commands.size() == 0) {
            return "";
        }

        StringBuilder sb = new StringBuilder();
        for (String commandPattern : commands) {
            String[] cmdSplit = commandPattern.split("~");
            if (cmdSplit.length != 3) {
                Log.e("DebugGhost", "Cannot read command pattern '" + commandPattern + "', skipping ...");
                continue;
            }
            if (cmdSplit[2].contains("[") == false && cmdSplit[2].contains("]") == false) {
                continue;
            }

            String realValue = cmdSplit[2].replace("[", "").replace("]", "");

            sb.append("<div class=\"input-group\" style=\"margin-bottom: 5px;\">");
            sb.append("<span class=\"input-group-btn\">");
            sb.append("<button class=\"btn btn-default\" type=\"button\" onclick=\"postCommandValue('/commands/");
            sb.append(cmdSplit[1]);
            sb.append("','");
            sb.append(cmdSplit[1]);
            sb.append("');\" >");
            sb.append(cmdSplit[0]);
            sb.append("</button></span>");
            sb.append("<input id=\"" + cmdSplit[1]
                    + "\" type=\"text\" class=\"form-control\" placeholder=\"set your value here\" value=\""
                    + realValue + "\">");
            sb.append("</div>");
        }

        return sb.toString();
    }
}