Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Romanov <rromanov@65apps.com>2017-05-04 06:50:26 +0300
committerGitHub <noreply@github.com>2017-05-04 06:50:26 +0300
commitcac7c63098ee8a2232094ded71f87fe37fd376c8 (patch)
tree3647b716485aa4855d651b3c7399ec86e7c984e9
parent407cd771000e3e95d710d24cf80b403affc73d5f (diff)
parent56d5fda8a431ab39943877234c27598085316e7a (diff)
Merge pull request #5967 from alexzatsepin/MAPSME-4417-crash-during-deserialization-of-uberinfo
[android] Fixed the crash while deserialization of uber info array
-rw-r--r--android/src/com/mapswithme/maps/routing/RoutingPlanController.java7
-rw-r--r--android/src/com/mapswithme/maps/uber/UberAdapter.java10
-rw-r--r--android/src/com/mapswithme/maps/uber/UberInfo.java17
3 files changed, 20 insertions, 14 deletions
diff --git a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
index 0062f83f61..395fa3f66d 100644
--- a/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
+++ b/android/src/com/mapswithme/maps/routing/RoutingPlanController.java
@@ -46,6 +46,7 @@ import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
+import java.util.List;
import java.util.Locale;
public class RoutingPlanController extends ToolbarController implements SlotFrame.SlotClickListener
@@ -497,9 +498,9 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
{
UiUtils.hide(getViewById(R.id.error), mAltitudeChartFrame);
- final UberInfo.Product[] products = info.getProducts();
+ final List<UberInfo.Product> products = info.getProducts();
mUberInfo = info;
- mUberProduct = products[0];
+ mUberProduct = products.get(0);
final PagerAdapter adapter = new UberAdapter(mActivity, products);
DotPager pager = new DotPager.Builder(mActivity, (ViewPager) mUberFrame.findViewById(R.id.pager), adapter)
.setIndicatorContainer((ViewGroup) mUberFrame.findViewById(R.id.indicator))
@@ -508,7 +509,7 @@ public class RoutingPlanController extends ToolbarController implements SlotFram
@Override
public void onPageChanged(int position)
{
- mUberProduct = products[position];
+ mUberProduct = products.get(position);
}
}).build();
pager.show();
diff --git a/android/src/com/mapswithme/maps/uber/UberAdapter.java b/android/src/com/mapswithme/maps/uber/UberAdapter.java
index 2fc7ab98f4..7fb0a658b0 100644
--- a/android/src/com/mapswithme/maps/uber/UberAdapter.java
+++ b/android/src/com/mapswithme/maps/uber/UberAdapter.java
@@ -11,14 +11,16 @@ import android.widget.TextView;
import com.mapswithme.maps.R;
import com.mapswithme.maps.routing.RoutingController;
+import java.util.List;
+
public class UberAdapter extends PagerAdapter
{
@NonNull
private final Context mContext;
@NonNull
- private final UberInfo.Product[] mProducts;
+ private final List<UberInfo.Product> mProducts;
- public UberAdapter(@NonNull Context context, @NonNull UberInfo.Product[] products)
+ public UberAdapter(@NonNull Context context, @NonNull List<UberInfo.Product> products)
{
mContext = context;
mProducts = products;
@@ -27,7 +29,7 @@ public class UberAdapter extends PagerAdapter
@Override
public int getCount()
{
- return mProducts.length;
+ return mProducts.size();
}
@Override
@@ -39,7 +41,7 @@ public class UberAdapter extends PagerAdapter
@Override
public Object instantiateItem(ViewGroup container, int position)
{
- UberInfo.Product product = mProducts[position];
+ UberInfo.Product product = mProducts.get(position);
View v = LayoutInflater.from(mContext).inflate(R.layout.uber_pager_item, container, false);
TextView name = (TextView) v.findViewById(R.id.product_name);
diff --git a/android/src/com/mapswithme/maps/uber/UberInfo.java b/android/src/com/mapswithme/maps/uber/UberInfo.java
index f1b8ade10c..26495f22ef 100644
--- a/android/src/com/mapswithme/maps/uber/UberInfo.java
+++ b/android/src/com/mapswithme/maps/uber/UberInfo.java
@@ -3,9 +3,10 @@ package com.mapswithme.maps.uber;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
public class UberInfo implements Parcelable
{
@@ -25,20 +26,22 @@ public class UberInfo implements Parcelable
};
@NonNull
- private final Product[] mProducts;
+ private final List<Product> mProducts;
private UberInfo(@NonNull Product[] products)
{
- mProducts = products;
+ mProducts = new ArrayList<>(Arrays.asList(products));
}
private UberInfo(@NonNull Parcel parcel)
{
- mProducts = (Product[]) parcel.readParcelableArray(Product.class.getClassLoader());
+ List<Product> products = new ArrayList<>();
+ parcel.readTypedList(products, Product.CREATOR);
+ mProducts = products;
}
@NonNull
- public Product[] getProducts()
+ public List<Product> getProducts()
{
return mProducts;
}
@@ -47,7 +50,7 @@ public class UberInfo implements Parcelable
public String toString()
{
return "UberInfo{" +
- "mProducts=" + Arrays.toString(mProducts) +
+ "mProducts=" + mProducts +
'}';
}
@@ -60,7 +63,7 @@ public class UberInfo implements Parcelable
@Override
public void writeToParcel(Parcel dest, int flags)
{
- dest.writeParcelableArray(mProducts, 0);
+ dest.writeTypedList(mProducts);
}
public static class Product implements Parcelable