Example #1
0
 static String formatArrivalTime(int seconds) {
   Calendar current = Calendar.getInstance();
   current.set(Calendar.SECOND, 0);
   current.add(Calendar.SECOND, seconds);
   return StringUtils.formatUsingUsLocale(
       "%d:%02d", current.get(Calendar.HOUR_OF_DAY), current.get(Calendar.MINUTE));
 }
  View buildSingleMapView(CountryItem map) {
    @SuppressLint("InflateParams")
    final View countryView = View.inflate(getActivity(), R.layout.dialog_missed_map, null);
    ((TextView) countryView.findViewById(R.id.tv__title)).setText(map.name);

    final TextView szView = (TextView) countryView.findViewById(R.id.tv__size);
    szView.setText(
        MapManager.nativeIsLegacyMode()
            ? ""
            : StringUtils.getFileSizeString(map.totalSize - map.size));
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) szView.getLayoutParams();
    lp.rightMargin = 0;
    szView.setLayoutParams(lp);

    return countryView;
  }
  private ExpandableListAdapter buildAdapter() {
    List<Map<String, String>> countries = new ArrayList<>();
    long size = 0;
    boolean legacy = MapManager.nativeIsLegacyMode();

    for (CountryItem item : mMissingMaps) {
      Map<String, String> data = new HashMap<>();
      data.put(COUNTRY_NAME, item.name);
      countries.add(data);

      if (!legacy) size += (item.totalSize - item.size);
    }

    Map<String, String> group = new HashMap<>();
    group.put(GROUP_NAME, getString(R.string.maps) + " (" + mMissingMaps.size() + ") ");
    group.put(GROUP_SIZE, (legacy ? "" : StringUtils.getFileSizeString(size)));

    List<Map<String, String>> groups = new ArrayList<>();
    groups.add(group);

    List<List<Map<String, String>>> children = new ArrayList<>();
    children.add(countries);

    return new DisabledChildSimpleExpandableListAdapter(
        getActivity(),
        groups,
        R.layout.item_missed_map_group,
        R.layout.item_missed_map,
        new String[] {GROUP_NAME, GROUP_SIZE},
        new int[] {R.id.tv__title, R.id.tv__size},
        children,
        R.layout.item_missed_map,
        new String[] {COUNTRY_NAME},
        new int[] {R.id.tv__title}) {
      @Override
      public View getGroupView(
          int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        View res = super.getGroupView(groupPosition, isExpanded, convertView, parent);
        bindGroup(res);
        return res;
      }
    };
  }