Browse Source

呼叫信息分两行显示

weizhengliang 2 năm trước cách đây
mục cha
commit
ecba2ac714

+ 64 - 32
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/led/LedC2MManager.java

@@ -431,39 +431,71 @@ public class LedC2MManager extends LedManager {
 
     private long createCallingProgram(String ledResolution, int fontSize) {
         long hProgram = 0;
-        if (LedItem.TYPE_192_32.equals(ledResolution)) {
-            //192x32
-            hProgram = ledC2M.CreateProgram(192, 32, 1, 1, 3);
-            for (int i = 0; i < programTextList.size(); i++) {
-                ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 192, 32, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
-            }
-        } else if (LedItem.TYPE_64_16.equals(ledResolution)) {
-            //64x16
-            hProgram = ledC2M.CreateProgram(64, 16, 1, 1, 3);
-            for (int i = 0; i < programTextList.size(); i++) {
-                String text = programTextList.get(i).getText();
-                ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 64, 16, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, text, Constants.Companion.getC2M_LED_FONT_PATH(), 16, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
-            }
-        } else if (LedItem.TYPE_128_16.equals(ledResolution)){
-            //128x16
-            hProgram = ledC2M.CreateProgram(128, 16, 1, 1, 3);
-            for (int i = 0; i < programTextList.size(); i++) {
-                ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 16, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
-            }
-        } else {
-            //128x32
-            hProgram = ledC2M.CreateProgram(128, 32, 1, 1, 3);
-            for (int i = 0; i < programTextList.size(); i++) {
-                ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
-                ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 32, 0);
-                ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+        try {
+            if (LedItem.TYPE_192_32.equals(ledResolution)) {
+                //192x32,双行显示
+                hProgram = ledC2M.CreateProgram(192, 32, 1, 1, 3);
+                int programTextCount = programTextList.size(); //呼叫信息数量
+                if (programTextCount == 1) {
+                    ledC2M.AddProgram(hProgram, 0, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, 0, 1, 0, 0, 192, 16, 0);
+                    //ledC2M.AddSinglelineTextToImageTextArea(hProgram, 0, 1, 0, programTextList.get(0).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, 0, 1, 0, programTextList.get(0).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 2, 8, 1, 1);
+                } else {
+                    //一个节目分上下两块区域显示,一个区域显示一个呼叫信息,所以一共需要显示(pSize/2)个节目
+                    int pSize;
+                    if (programTextCount % 2 == 0) {
+                        pSize = programTextCount / 2;
+                    } else {
+                        pSize = programTextCount / 2 + 1;
+                    }
+
+                    Log.e(TAG, "programTextCount= " + programTextCount + ", pSize= " + pSize);
+                    for (int i = 0; i < pSize; i++) {
+                        int textIndex = i * 2;
+                        ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                        //上面一行
+                        ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 192, 16, 0);
+                        //ledC2M.AddSinglelineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(textIndex).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3);
+                        ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(textIndex).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 2, 8, 1, 1);
+
+                        if (textIndex + 1 < programTextCount) {
+                            //下面一行
+                            ledC2M.AddImageTextArea(hProgram, i, 2, 0, 16, 192, 16, 0);
+                            //ledC2M.AddSinglelineTextToImageTextArea(hProgram, i, 2, 0, programTextList.get(textIndex + 1).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3);
+                            ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 2, 0, programTextList.get(textIndex + 1).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 2, 8, 1, 1);
+                        }
+                    }
+                }
+            } else if (LedItem.TYPE_64_16.equals(ledResolution)) {
+                //64x16
+                hProgram = ledC2M.CreateProgram(64, 16, 1, 1, 3);
+                for (int i = 0; i < programTextList.size(); i++) {
+                    String text = programTextList.get(i).getText();
+                    ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 64, 16, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, text, Constants.Companion.getC2M_LED_FONT_PATH(), 16, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+                }
+            } else if (LedItem.TYPE_128_16.equals(ledResolution)) {
+                //128x16
+                hProgram = ledC2M.CreateProgram(128, 16, 1, 1, 3);
+                for (int i = 0; i < programTextList.size(); i++) {
+                    ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 16, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+                }
+            } else {
+                //128x32
+                hProgram = ledC2M.CreateProgram(128, 32, 1, 1, 3);
+                for (int i = 0; i < programTextList.size(); i++) {
+                    ledC2M.AddProgram(hProgram, i, SettingConfig.getLedProgramTime(BaseApplication.appContext), 1);
+                    ledC2M.AddImageTextArea(hProgram, i, 1, 0, 0, 128, 32, 0);
+                    ledC2M.AddMultiLineTextToImageTextArea(hProgram, i, 1, 0, programTextList.get(i).getText(), Constants.Companion.getC2M_LED_FONT_PATH(), fontSize, 0xff, 0, 0, 0, 4, 5, 3, 1, 1);
+                }
             }
+        } catch (Exception e) {
+            Log.e(TAG, "createCallingProgram call exception...");
+            e.printStackTrace();
         }
 
         return hProgram;