[android] Added debug info to ugc object with null feature id

This commit is contained in:
Александр Зацепин 2017-11-02 15:58:12 +03:00 committed by r.kuznetsov
parent d0a1705369
commit 3de61b7db4
4 changed files with 66 additions and 2 deletions

View file

@ -19,6 +19,12 @@ class EditParams
private final int mDefaultRating;
private final boolean mCanBeReviewed;
private final boolean mFromPP;
// TODO: mLat, mLon, mAddress are added just for debugging null feature id for ugc object.
// Remove they after problem is fixed.
private double mLat;
private double mLon;
@Nullable
private String mAddress;
private EditParams(@NonNull Builder builder)
{
@ -28,6 +34,9 @@ class EditParams
mDefaultRating = builder.mDefaultRating;
mCanBeReviewed = builder.mCanBeReviewed;
mFromPP = builder.mFromPP;
mLat = builder.mLat;
mLon = builder.mLon;
mAddress = builder.mAddress;
}
@NonNull
@ -63,6 +72,22 @@ class EditParams
return mFromPP;
}
double getLat()
{
return mLat;
}
double getLon()
{
return mLon;
}
@Nullable
String getAddress()
{
return mAddress;
}
public static class Builder
{
@NonNull
@ -75,6 +100,10 @@ class EditParams
private int mDefaultRating;
private boolean mCanBeReviewed;
private boolean mFromPP;
private double mLat;
private double mLon;
@Nullable
private String mAddress;
public Builder(@NonNull String title, @NonNull FeatureId featureId)
{
@ -106,6 +135,24 @@ class EditParams
return this;
}
public Builder setLat(double lat)
{
mLat = lat;
return this;
}
public Builder setLon(double lon)
{
mLon = lon;
return this;
}
public Builder setAddress(@Nullable String address)
{
mAddress = address;
return this;
}
public EditParams build()
{
return new EditParams(this);

View file

@ -255,7 +255,10 @@ public class UGCController implements View.OnClickListener, UGC.UGCListener
{
return new EditParams.Builder(mapObject.getTitle(), mapObject.getFeatureId())
.setRatings(mapObject.getDefaultRatings())
.setCanBeReviewed(mapObject.canBeReviewed());
.setCanBeReviewed(mapObject.canBeReviewed())
.setLat(mapObject.getLat())
.setLon(mapObject.getLon())
.setAddress(mapObject.getAddress());
}
private void setUserReviewAndRatingsView(@Nullable UGCUpdate update)

View file

@ -23,6 +23,9 @@ public class UGCEditorActivity extends BaseMwmFragmentActivity
args.putInt(UGCEditorFragment.ARG_DEFAULT_RATING, params.getDefaultRating());
args.putParcelableArrayList(UGCEditorFragment.ARG_RATING_LIST, params.getRatings());
args.putBoolean(UGCEditorFragment.ARG_CAN_BE_REVIEWED, params.canBeReviewed());
args.putDouble(UGCEditorFragment.ARG_LAT, params.getLat());
args.putDouble(UGCEditorFragment.ARG_LON, params.getLon());
args.putString(UGCEditorFragment.ARG_ADDRESS, params.getAddress());
i.putExtras(args);
activity.startActivity(i);
}

View file

@ -14,6 +14,7 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.auth.BaseMwmAuthorizationFragment;
import com.mapswithme.maps.bookmarks.data.FeatureId;
import com.mapswithme.maps.widget.ToolbarController;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.Language;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.statistics.Statistics;
@ -27,6 +28,9 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment
static final String ARG_DEFAULT_RATING = "arg_default_rating";
static final String ARG_RATING_LIST = "arg_rating_list";
static final String ARG_CAN_BE_REVIEWED = "arg_can_be_reviewed";
static final String ARG_LAT = "arg_lat";
static final String ARG_LON = "arg_lon";
static final String ARG_ADDRESS = "arg_address";
@NonNull
private final UGCRatingAdapter mUGCRatingAdapter = new UGCRatingAdapter();
@SuppressWarnings("NullableProblems")
@ -96,7 +100,14 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment
System.currentTimeMillis(), Language.getDefaultLocale());
FeatureId featureId = getArguments().getParcelable(ARG_FEATURE_ID);
if (featureId == null)
throw new AssertionError("Feature ID must be passed to this fragment!");
{
throw new AssertionError("Feature ID must be non-null for ugc object! " +
"Title = " + getArguments().getString(ARG_TITLE) +
"; address = " + getArguments().getString(ARG_ADDRESS) +
"; lat = " + getArguments().getDouble(ARG_LAT) +
"; lon = " + getArguments().getDouble(ARG_LON));
}
UGC.setUGCUpdate(featureId, update);
Statistics.INSTANCE.trackEvent(Statistics.EventName.UGC_REVIEW_SUCCESS);
}