getMulitiMessageFileIDV2 static method

Map<String, String> getMulitiMessageFileIDV2(
  1. Map<String, dynamic> elem,
  2. int image_type,
  3. bool isSnap
)

Implementation

static Map<String, String> getMulitiMessageFileIDV2(
  Map<String, dynamic> elem,
  int image_type,
  bool isSnap,
) {
  int elem_type = elem["elem_type"] ?? 0;
  String uuid = "";
  String name = "";
  if (elem_type == 1) {
    int picext = elem["image_elem_format"];
    String eext = "";
    switch (picext) {
      case 1:
        eext = ".jpg";
        break;
      case 2:
        eext = ".gif";
        break;
      case 3:
        eext = ".png";
        break;
      case 4:
        eext = ".bmp";
        break;
    }
    if (image_type == 0) {
      String id = (elem["image_elem_orig_id"] ?? "");
      uuid = id.split(".").first;
      bool hasext = id.contains(".");
      String fname = hasext ? id : "$id$eext";
      name = "origin-$fname";
    } else if (image_type == 1) {
      String id = (elem["image_elem_thumb_id"] ?? "");
      uuid = id.split(".").first;
      bool hasext = id.contains(".");
      String fname = hasext ? id : "$id$eext";
      name = "thumb-$fname";
    } else {
      String id = (elem["image_elem_large_id"] ?? "");
      uuid = id.split(".").first;
      bool hasext = id.contains(".");
      String fname = hasext ? id : "$id$eext";
      name = "large-$fname";
    }
  } else if (elem_type == 2) {
    // 声音
    String id = elem["sound_elem_file_id"] ?? "";
    uuid = id.split(".").first;
    name = id;
  } else if (elem_type == 4) {
    // file
    String id = elem["file_elem_file_id"] ?? "";
    uuid = id.split(".").first;
    name = elem["file_elem_file_name"];
  } else if (elem_type == 9) {
    if (isSnap) {
      String id = (elem["video_elem_image_id"] ?? "");
      uuid = id.split(".").first;
      bool hasext = id.contains(".");
      name = hasext ? id : "$id.${elem["video_elem_video_type"]}";
    } else {
      String id = (elem["video_elem_video_id"] ?? "");
      uuid = id.split(".").first;
      bool hasext = id.contains(".");
      name = hasext ? id : "$id.${elem["video_elem_video_type"]}";
    }
  }
  return Map.from({
    "uuid": uuid,
    "name": name,
  });
}