Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Resolved conflicts in PlanUtils
  • Loading branch information
nbradbury committed Feb 24, 2016
commit 3164acfcccb58da9fc135d2a55baba83eb4e7379
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class PlansUtils {

Expand Down Expand Up @@ -75,8 +74,7 @@ public static boolean downloadAvailablePlansForSite(int localTableBlogID, final
return false;
}

Map<String, String> params = getDefaultRestCallParameters();
WordPress.getRestClientUtils().get("sites/" + blog.getDotComBlogId() + "/plans", params, null, new RestRequest.Listener() {
WordPress.getRestClientUtils().get("sites/" + blog.getDotComBlogId() + "/plans", WordPress.getRestLocaleParams(), null, new RestRequest.Listener() {
@Override
public void onResponse(JSONObject response) {
if (response == null) {
Expand Down Expand Up @@ -202,8 +200,7 @@ public static HashMap<String, Feature> getFeatures() {
}

public static void downloadGlobalPlans() {
Map<String, String> params = getDefaultRestCallParameters();
WordPress.getRestClientUtilsV1_3().get("plans/", params, null, new RestRequest.Listener() {
WordPress.getRestClientUtilsV1_3().get("plans/", WordPress.getRestLocaleParams(), null, new RestRequest.Listener() {
@Override
public void onResponse(JSONObject response) {
if (response != null) {
Expand All @@ -228,8 +225,7 @@ public void onErrorResponse(VolleyError volleyError) {
* Return true if the request is enqueued. False otherwise.
*/
public static void downloadFeatures() {
Map<String, String> params = getDefaultRestCallParameters();
WordPress.getRestClientUtilsV1_2().get("plans/features/", params, null, new RestRequest.Listener() {
WordPress.getRestClientUtilsV1_2().get("plans/features/", WordPress.getRestLocaleParams(), null, new RestRequest.Listener() {
@Override
public void onResponse(JSONObject response) {
if (response != null) {
Expand All @@ -248,23 +244,6 @@ public void onErrorResponse(VolleyError volleyError) {
});
}

/**
* This function returns default parameters used in all REST Calls in Plans.
*
* The "locale" parameter fox example is one of those we need to add to the request. It must be set to retrieve
* the localized version of plans descriptions and avoid hardcode them in code.
*
* @return The map with default parameters.
*/
private static Map<String, String> getDefaultRestCallParameters() {
String deviceLanguageCode = Locale.getDefault().getLanguage();
Map<String, String> params = new HashMap<>();
if (!TextUtils.isEmpty(deviceLanguageCode)) {
params.put("locale", deviceLanguageCode);
}
return params;
}

/**
* This function return true if Plans are available for a blog.
* Basically this means that Plans data were downloaded from the server,
Expand Down