[android] Changed arrays to lists for CatalogCustomProperty, implemented new categories interfaces, modified exception

This commit is contained in:
Dmitry Donskoy 2018-10-31 15:57:43 +03:00 committed by Aleksandr Zatsepin
parent c7038e710e
commit 7ef5f6d69c
8 changed files with 29 additions and 19 deletions

View file

@ -2402,7 +2402,4 @@
<string name="type.wheelchair.limited">wheelchair-limited</string>
<string name="type.wheelchair.no">wheelchair-no</string>
<string name="type.wheelchair.yes">wheelchair-yes</string>
<string name="ugc_route_tags_desc">Please, select tags to help other travelers find your guide. This is mandatory.</string>
<string name="ugc_route_tags_progress_msg">Loading tags…</string>
<string name="ugc_route_tags_screen_label">Select tags</string>
</resources>

View file

@ -1169,7 +1169,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
@Override
public void onCustomPropertiesReceived(boolean successful,
@NonNull CatalogCustomProperty[] properties)
@NonNull List<CatalogCustomProperty> properties)
{
//TODO(@alexzatsepin): Implement me if necessary
}

View file

@ -96,12 +96,12 @@ public class RecyclerCompositeAdapter extends RecyclerView.Adapter<RecyclerView.
@Override
public int toAbsoluteViewType(int relViewType, int adapterIndex)
{
AdapterIndexAndViewType type = new AdapterIndexAndViewTypeImpl(adapterIndex, relViewType);
AdapterIndexAndViewType indexAndViewType = new AdapterIndexAndViewTypeImpl(adapterIndex, relViewType);
List<AdapterIndexAndViewType> items = getIndexAndViewTypeItems();
int indexOf = items.indexOf(type);
int indexOf = items.indexOf(indexAndViewType);
if (indexOf < 0)
{
throw new IllegalArgumentException("Item " + relViewType + " not found in list : " +
throw new IllegalArgumentException("Item " + indexAndViewType + " not found in list : " +
Arrays.toString(items.toArray()));
}
return indexOf;

View file

@ -222,7 +222,7 @@ public class CachedBookmarkCategoriesFragment extends BaseBookmarkCategoriesFrag
@Override
public void onCustomPropertiesReceived(boolean successful,
@NonNull CatalogCustomProperty[] properties)
@NonNull List<CatalogCustomProperty> properties)
{
//TODO(@alexzatsepin): Implement me if necessary
}

View file

@ -303,8 +303,9 @@ public enum BookmarkManager
public void onCustomPropertiesReceived(boolean successful,
@NonNull CatalogCustomProperty[] properties)
{
List<CatalogCustomProperty> unmodifiableProperties = Collections.unmodifiableList(Arrays.asList(properties));
for (BookmarksCatalogListener listener : mCatalogListeners)
listener.onCustomPropertiesReceived(successful, properties);
listener.onCustomPropertiesReceived(successful, unmodifiableProperties);
}
// Called from JNI.
@ -832,12 +833,11 @@ public enum BookmarkManager
/**
* The method is called when the custom properties were received from the server.
*
* @param successful is the result of the receiving.
* @param successful is the result of the receiving.
* @param properties is the properties collection.
*/
void onCustomPropertiesReceived(boolean successful,
@NonNull CatalogCustomProperty[] properties);
@NonNull List<CatalogCustomProperty> properties);
/**
* The method is called when the uploading to the catalog is started.
@ -882,7 +882,7 @@ public enum BookmarkManager
@Override
public void onCustomPropertiesReceived(boolean successful,
@NonNull CatalogCustomProperty[] properties)
@NonNull List<CatalogCustomProperty> properties)
{
/* do noting by default */
}

View file

@ -2,6 +2,10 @@ package com.mapswithme.maps.bookmarks.data;
import android.support.annotation.NonNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class CatalogCustomProperty
{
@NonNull
@ -13,7 +17,7 @@ public class CatalogCustomProperty
private final boolean mRequired;
@NonNull
private final CatalogCustomPropertyOption[] mOptions;
private final List<CatalogCustomPropertyOption> mOptions;
public CatalogCustomProperty(@NonNull String key, @NonNull String localizedName,
boolean required, @NonNull CatalogCustomPropertyOption[] options)
@ -21,7 +25,7 @@ public class CatalogCustomProperty
mKey = key;
mLocalizedName = localizedName;
mRequired = required;
mOptions = options;
mOptions = Collections.unmodifiableList(Arrays.asList(options));
}
@NonNull
@ -33,5 +37,5 @@ public class CatalogCustomProperty
public boolean isRequired() { return mRequired; }
@NonNull
public CatalogCustomPropertyOption[] getOptions() { return mOptions; }
public List<CatalogCustomPropertyOption> getOptions() { return mOptions; }
}

View file

@ -26,13 +26,13 @@ import com.mapswithme.maps.adapter.TagsCompositeAdapter;
import com.mapswithme.maps.base.BaseMwmFragment;
import com.mapswithme.maps.adapter.OnItemClickListener;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.bookmarks.data.CatalogCustomProperty;
import com.mapswithme.maps.bookmarks.data.CatalogTag;
import com.mapswithme.maps.bookmarks.data.CatalogTagsGroup;
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
import com.mapswithme.util.UiUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -175,6 +175,13 @@ public class UgcRoutesFragment extends BaseMwmFragment implements BookmarkManage
installTags(tagsGroups);
}
@Override
public void onCustomPropertiesReceived(boolean successful,
@NonNull List<CatalogCustomProperty> properties)
{
/* Not ready yet */
}
private void installTags(@NonNull List<CatalogTagsGroup> tagsGroups)
{
List<CatalogTag> savedStateTags = validateSavedState(mSavedInstanceState);

View file

@ -28,6 +28,8 @@ import com.mapswithme.maps.widget.ToolbarController;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.UiUtils;
import java.util.List;
public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment implements BookmarkManager.BookmarksCatalogListener
{
private static final String NO_NETWORK_CONNECTION_DIALOG_TAG = "no_network_connection_dialog";
@ -244,14 +246,14 @@ public class UgcSharingOptionsFragment extends BaseMwmAuthorizationFragment impl
}
@Override
public void onTagsReceived(boolean successful, @NonNull CatalogTagsGroup[] tagsGroups)
public void onTagsReceived(boolean successful, @NonNull List<CatalogTagsGroup> tagsGroups)
{
}
@Override
public void onCustomPropertiesReceived(boolean successful,
@NonNull CatalogCustomProperty[] properties)
@NonNull List<CatalogCustomProperty> properties)
{
}