Example usage for android.util Pair Pair

List of usage examples for android.util Pair Pair

Introduction

In this page you can find the example usage for android.util Pair Pair.

Prototype

public Pair(F first, S second) 

Source Link

Document

Constructor for a Pair.

Usage

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PictureObj.java

@Override
public Pair<JSONObject, byte[]> splitRaw(JSONObject json) {
    byte[] raw = FastBase64.decode(json.optString(DATA));
    json.remove(DATA);/*from   ww  w  . j av  a2s.  c om*/
    return new Pair<JSONObject, byte[]>(json, raw);
}

From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleSupport.java

@Override
public void onAppConfiguration(UUID uuid, String config) {
    try {//from  w w  w.  j a  v  a  2s . c o  m
        ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>();

        JSONObject json = new JSONObject(config);
        Iterator<String> keysIterator = json.keys();
        while (keysIterator.hasNext()) {
            String keyStr = keysIterator.next();
            Object object = json.get(keyStr);
            if (object instanceof JSONArray) {
                JSONArray jsonArray = (JSONArray) object;
                byte[] byteArray = new byte[jsonArray.length()];
                for (int i = 0; i < jsonArray.length(); i++) {
                    byteArray[i] = ((Integer) jsonArray.get(i)).byteValue();
                }
                object = byteArray;
            }
            pairs.add(new Pair<>(Integer.parseInt(keyStr), object));
        }
        getDeviceIOThread().write(((PebbleProtocol) getDeviceProtocol())
                .encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, uuid, pairs));
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VoiceObj.java

@Override
public Pair<JSONObject, byte[]> splitRaw(JSONObject json) {
    byte[] raw = Base64.decode(json.optString(DATA), Base64.DEFAULT);
    json.remove(DATA);// ww  w  .  j a  v  a2s  .  c om
    return new Pair<JSONObject, byte[]>(json, raw);
}

From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.AppMessageHandlerTrekVolle.java

private byte[] encodeTrekVolleWeather(WeatherSpec weatherSpec) {

    if (weatherSpec == null) {
        return null;
    }//from  www. j av  a 2 s  .  c o  m

    boolean isNight = false; // FIXME
    ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>();
    pairs.add(new Pair<>(MESSAGE_KEY_WEATHER_TEMPERATURE, (Object) (weatherSpec.currentTemp - 273)));
    pairs.add(new Pair<>(MESSAGE_KEY_WEATHER_CONDITIONS, (Object) (weatherSpec.currentCondition)));
    pairs.add(new Pair<>(MESSAGE_KEY_WEATHER_ICON,
            (Object) (getIconForConditionCode(weatherSpec.currentConditionCode, isNight))));
    pairs.add(new Pair<>(MESSAGE_KEY_WEATHER_TEMPERATURE_MAX, (Object) (weatherSpec.todayMaxTemp - 273)));
    pairs.add(new Pair<>(MESSAGE_KEY_WEATHER_TEMPERATURE_MIN, (Object) (weatherSpec.todayMinTemp - 273)));
    pairs.add(new Pair<>(MESSAGE_KEY_WEATHER_LOCATION, (Object) weatherSpec.location));

    return mPebbleProtocol.encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID,
            pairs);
}

From source file:co.nerdart.ourss.adapter.CursorLoaderExpandableListAdapter.java

private void setAllChildrenCursorsAsObsolete() {
    int key;// w  w w  . j  a  v a  2s. com
    for (int i = 0; i < mChildrenCursors.size(); i++) {
        key = mChildrenCursors.keyAt(i);
        mChildrenCursors.put(key, new Pair<Cursor, Boolean>(mChildrenCursors.get(key).first, true));
    }
}

From source file:conexionSiabra.ConexionSiabra.java

public JSONObject obternerPemisosPorPalabras() {
    Pair<String, String> elemento = new Pair<String, String>("", "");
    return oauth.peticionGet(elemento, url_obtener_permisos_por_palabras);
}

From source file:dynamite.zafroshops.app.fragment.NearestZopsFragment.java

private void setZops() {
    adapter = new TypedZopListViewAdapter(getActivity(), R.id.listViewItem, nearestZops);

    final ArrayList<Pair<String, String>> parameters;
    if (MainActivity.LastLocation != null) {
        parameters = new ArrayList<Pair<String, String>>() {
            {/*from   www .  j  a v  a 2 s.c  o m*/
                add(new Pair<>("latitude", Double.toString(MainActivity.LastLocation.Latitude)));
                add(new Pair<>("longitude", Double.toString(MainActivity.LastLocation.Longitude)));
                add(new Pair<>("$top", Integer.toString(count)));
            }
        };
    } else {
        parameters = new ArrayList<Pair<String, String>>() {
            {
                add(new Pair<>("$top", Integer.toString(count)));
            }
        };
    }

    loading = true;
    ListenableFuture<JsonElement> result = MainActivity.MobileClient.invokeApi("mobileZop", "GET", parameters);

    Futures.addCallback(result, new FutureCallback<JsonElement>() {
        Activity activity = getActivity();

        @Override
        public void onSuccess(JsonElement result) {
            JsonArray typesAsJson = result.getAsJsonArray();
            if (typesAsJson != null) {
                nearestZops = new Gson().fromJson(result, new TypeToken<ArrayList<MobileZop>>() {
                }.getType());
            }

            loading = false;
            if (adapter != null) {
                adapter.setObjects(nearestZops);
                resetVisibility(false);
                adapter.notifyDataSetChanged();
            }
        }

        @Override
        public void onFailure(@NonNull Throwable t) {
            ListView zops = (ListView) activity.findViewById(R.id.listViewZops);
            RelativeLayout loader = (RelativeLayout) activity.findViewById(R.id.relativeLayoutLoader);
            LinearLayout noZops = (LinearLayout) activity.findViewById(R.id.noZops);

            resetVisibility(zops, noZops, loader, false);
        }
    });
}

From source file:conexionSiabra.ConexionSiabra.java

public JSONObject obtenerPermisosPorCodigo() {
    Pair<String, String> elemento = new Pair<String, String>("", "");
    return oauth.peticionGet(elemento, url_obtener_permisos_por_codigo);
}

From source file:com.tealeaf.util.HTTP.java

public Pair<String, Integer> getPush(URI uri) {
    AndroidHttpClient client = AndroidHttpClient.newInstance(userAgent);

    HttpGet request = new HttpGet();
    request.setURI(uri);//from  www.  j  a va  2 s  .  c  o m
    HttpResponse response = null;
    try {
        response = client.execute(request, localContext);
    } catch (SocketTimeoutException e) {
        // forget it--we don't care that the user couldn't connect
        // TODO log this to JS
    } catch (IOException e) {
        if (!caughtIOException) {
            caughtIOException = true;
            logger.log(e);
        }
    }
    if (response != null) {
        StatusLine statusLine = response.getStatusLine();
        int statusCode = 0;
        if (statusLine != null) {
            statusCode = statusLine.getStatusCode();
        }
        if (statusCode == 200) {
            String page = readContent(response);
            Header header = response.getFirstHeader("Retry-After");
            // default is to read the value from the manifest
            int retry = -1;
            if (header != null) {
                String retryAfter = header.getValue();
                try {
                    retry = Integer.parseInt(retryAfter);
                } catch (NumberFormatException e) {
                    // if we got a bad number, use the default
                    retry = -1;
                }
            }
            client.close();
            return new Pair<String, Integer>(page, retry);
        }
    }
    client.close();
    return null;
}

From source file:com.rastating.droidbeard.net.FetchShowTask.java

private TVShow getTVShow(long tvdbid) {
    ArrayList<Pair<String, Object>> params = new ArrayList<Pair<String, Object>>();
    params.add(new Pair<String, Object>("tvdbid", tvdbid));
    String json = getJson("show", params);

    try {// w ww.j av a2 s  .c  om
        if (json != null && !json.equals("")) {
            JSONObject data = new JSONObject(json).getJSONObject("data");
            TVShow show = new TVShow();

            show.setAirByDate(data.getInt("air_by_date") == 1);
            show.setAirs(data.getString("airs"));
            show.setFlattenFolders(data.getInt("flatten_folders") == 1);

            JSONArray genresJsonArray = data.getJSONArray("genre");
            String[] genres = new String[genresJsonArray.length()];
            for (int i = 0; i < genresJsonArray.length(); i++) {
                genres[i] = genresJsonArray.getString(i);
            }

            show.setGenres(genres);
            show.setLanguage(new Language(data.getString("language")));
            show.setLocation(data.getString("location"));
            show.setNetwork(data.getString("network"));

            try {
                String nextDateString = data.getString("next_ep_airdate");
                if (!nextDateString.equals("")) {
                    Date date = new SimpleDateFormat("yyyy-MM-dd").parse(nextDateString);
                    show.setNextAirdate(date);
                }
            } catch (ParseException e) {
                show.setNextAirdate(null);
            }

            show.setPaused(data.getInt("paused") == 1);
            show.setQuality(data.getString("quality"));
            show.setShowName(data.getString("show_name"));
            show.setStatus(data.getString("status"));

            return show;
        } else {
            return null;
        }
    } catch (Exception e) {
        setLastException(json, e);
        e.printStackTrace();
        return null;
    }
}