Esempio n. 1
0
  public boolean checkMigration(Activity activity) {
    if (!MapManager.nativeIsLegacyMode()) return false;

    if (!isNavigating() && !isPlanning()) return false;

    new AlertDialog.Builder(activity)
        .setTitle(R.string.migrate_title)
        .setMessage(R.string.no_migration_during_navigation)
        .setPositiveButton(android.R.string.ok, null)
        .show();

    return true;
  }
  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;
      }
    };
  }
Esempio n. 4
0
  @Override
  public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog res = super.onCreateDialog(savedInstanceState);
    res.requestWindowFeature(Window.FEATURE_NO_TITLE);

    View content = View.inflate(getActivity(), R.layout.fragment_news_single, null);
    res.setContentView(content);

    View done = content.findViewById(R.id.done);
    if (MapManager.nativeIsLegacyMode()) {
      UiUtils.hide(done);
      done = content.findViewById(R.id.close);

      content
          .findViewById(R.id.migrate)
          .setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  ((MwmActivity) getActivity()).showDownloader(false);
                  dismissAllowingStateLoss();
                }
              });
    } else {
      UiUtils.hide(content.findViewById(R.id.migrate_message));
      UiUtils.hide(content.findViewById(R.id.migrate_buttons));
    }

    done.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            dismissAllowingStateLoss();
          }
        });

    return res;
  }