Search in sources :

Example 6 with CustomRegion

use of net.osmand.plus.download.CustomRegion in project Osmand by osmandapp.

the class DownloadsItem method writeItemsToJson.

@NonNull
@Override
JSONObject writeItemsToJson(@NonNull JSONObject json) {
    JSONArray jsonArray = new JSONArray();
    if (!items.isEmpty()) {
        try {
            for (WorldRegion region : items) {
                if (region instanceof CustomRegion) {
                    JSONObject regionJson = ((CustomRegion) region).toJson();
                    jsonArray.put(regionJson);
                }
            }
            json.put("items", jsonArray);
        } catch (JSONException e) {
            warnings.add(app.getString(R.string.settings_item_write_error, String.valueOf(getType())));
            SettingsHelper.LOG.error("Failed write to json", e);
        }
    }
    return json;
}
Also used : WorldRegion(net.osmand.map.WorldRegion) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) CustomRegion(net.osmand.plus.download.CustomRegion) NonNull(androidx.annotation.NonNull)

Example 7 with CustomRegion

use of net.osmand.plus.download.CustomRegion in project Osmand by osmandapp.

the class DownloadResourceGroupFragment method updateDescriptionView.

private void updateDescriptionView() {
    if (descriptionView != null) {
        if (group != null && group.getRegion() instanceof CustomRegion) {
            CustomRegion customRegion = (CustomRegion) group.getRegion();
            DownloadDescriptionInfo descriptionInfo = customRegion.getDescriptionInfo();
            if (descriptionInfo != null) {
                OsmandApplication app = activity.getMyApplication();
                TextView description = descriptionView.findViewById(R.id.description);
                updateDescription(app, descriptionInfo, description);
                ViewGroup buttonsContainer = descriptionView.findViewById(R.id.buttons_container);
                updateActionButtons(activity, descriptionInfo, null, buttonsContainer, R.layout.download_description_button, nightMode);
                LockableViewPager viewPager = descriptionView.findViewById(R.id.images_pager);
                updateImagesPager(app, descriptionInfo, viewPager);
                descriptionView.findViewById(R.id.container).setVisibility(View.VISIBLE);
                return;
            }
        }
        descriptionView.findViewById(R.id.container).setVisibility(View.GONE);
    }
}
Also used : LockableViewPager(net.osmand.plus.LockableViewPager) OsmandApplication(net.osmand.plus.OsmandApplication) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) CustomRegion(net.osmand.plus.download.CustomRegion)

Aggregations

CustomRegion (net.osmand.plus.download.CustomRegion)7 WorldRegion (net.osmand.map.WorldRegion)4 OsmandApplication (net.osmand.plus.OsmandApplication)3 DownloadResources (net.osmand.plus.download.DownloadResources)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 SuppressLint (android.annotation.SuppressLint)1 Drawable (android.graphics.drawable.Drawable)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 LockableViewPager (net.osmand.plus.LockableViewPager)1 CustomIndexItem (net.osmand.plus.download.CustomIndexItem)1 DownloadActivity (net.osmand.plus.download.DownloadActivity)1 UiUtilities (net.osmand.plus.utils.UiUtilities)1 JSONException (org.json.JSONException)1