forked from organicmaps/organicmaps
[android] Refactored KeyValue class to use getters instead of direct fields access
This commit is contained in:
parent
de92af7a23
commit
87dc27a90d
5 changed files with 27 additions and 14 deletions
|
@ -329,7 +329,7 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
|
|||
{
|
||||
HashMap<String, Object> paramsMap = new HashMap<>();
|
||||
for (KeyValue p : params)
|
||||
paramsMap.put(p.mKey, p.mValue);
|
||||
paramsMap.put(p.getKey(), p.getValue());
|
||||
AppsFlyerLib.getInstance().trackEvent(this, tag, paramsMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -303,8 +303,8 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
|
||||
for (KeyValue header : BookmarkManager.INSTANCE.getCatalogHeaders())
|
||||
{
|
||||
if (!TextUtils.isEmpty(header.mValue))
|
||||
headers.put(header.mKey, header.mValue);
|
||||
if (!TextUtils.isEmpty(header.getValue()))
|
||||
headers.put(header.getKey(), header.getValue());
|
||||
}
|
||||
|
||||
mWebView.loadUrl(getCatalogUrlOrThrow(), headers);
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
package com.mapswithme.util;
|
||||
|
||||
import android.os.Build;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
|
||||
|
@ -57,7 +57,6 @@ public final class HttpClient
|
|||
public static final String HEADER_AUTHORIZATION = "Authorization";
|
||||
public static final String HEADER_BEARER_PREFFIX = "Bearer ";
|
||||
public static final String HEADER_BUNDLE_TIERS = "X-Mapsme-Bundle-Tiers";
|
||||
public static final String HEADER_DEVICE_ID = "X-Mapsme-Device-Id";
|
||||
private final static String TAG = HttpClient.class.getSimpleName();
|
||||
// TODO(AlexZ): tune for larger files
|
||||
private final static int STREAM_BUFFER_SIZE = 1024 * 64;
|
||||
|
@ -104,7 +103,7 @@ public final class HttpClient
|
|||
|
||||
for (KeyValue header : p.headers)
|
||||
{
|
||||
connection.setRequestProperty(header.mKey, header.mValue);
|
||||
connection.setRequestProperty(header.getKey(), header.getValue());
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(p.inputFilePath) || p.data != null)
|
||||
|
|
|
@ -3,12 +3,16 @@ package com.mapswithme.util;
|
|||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -22,8 +26,6 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public final class HttpUploader extends AbstractHttpUploader
|
||||
{
|
||||
|
@ -184,13 +186,13 @@ public final class HttpUploader extends AbstractHttpUploader
|
|||
headers.add(new KeyValue("Content-Type", "multipart/form-data; boundary=" + mBoundary));
|
||||
headers.add(new KeyValue("Content-Length", String.valueOf(bodyLength)));
|
||||
for (KeyValue header : headers)
|
||||
connection.setRequestProperty(header.mKey, header.mValue);
|
||||
connection.setRequestProperty(header.getKey(), header.getValue());
|
||||
}
|
||||
|
||||
private void fillBodyParams(@NonNull StringBuilder builder)
|
||||
{
|
||||
for (KeyValue field : getPayload().getParams())
|
||||
addParam(builder, field.mKey, field.mValue);
|
||||
addParam(builder, field.getKey(), field.getValue());
|
||||
}
|
||||
|
||||
private void addParam(@NonNull StringBuilder builder, @NonNull String key, @NonNull String value)
|
||||
|
|
|
@ -5,16 +5,28 @@ import com.google.gson.annotations.SerializedName;
|
|||
|
||||
public final class KeyValue
|
||||
{
|
||||
@NonNull
|
||||
@SerializedName("key")
|
||||
private final String mKey;
|
||||
@NonNull
|
||||
@SerializedName("value")
|
||||
private final String mValue;
|
||||
|
||||
public KeyValue(@NonNull String key, @NonNull String value)
|
||||
{
|
||||
mKey = key;
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
@SerializedName("key")
|
||||
@NonNull
|
||||
public final String mKey;
|
||||
@SerializedName("value")
|
||||
public String getKey()
|
||||
{
|
||||
return mKey;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public final String mValue;
|
||||
public String getValue()
|
||||
{
|
||||
return mValue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue