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:org.runnerup.tracker.component.TrackerWear.java

public TrackerWear(Tracker tracker) {
    this.tracker = tracker;
    items.add(new Pair<Scope, Dimension>(Scope.ACTIVITY, Dimension.TIME));
    items.add(new Pair<Scope, Dimension>(Scope.ACTIVITY, Dimension.DISTANCE));
    items.add(new Pair<Scope, Dimension>(Scope.LAP, Dimension.PACE));
}

From source file:conexionSiabra.ConexionSiabra.java

public JSONObject modificarPermisosPorCodigo(String permisos) {
    Pair<String, String> elemento = new Pair<String, String>("permisos", permisos);
    ArrayList<Pair<String, String>> elementos = new ArrayList<Pair<String, String>>();
    elementos.add(elemento);//from w w w.  j a va 2s. c o m
    return oauth.peticionPost(elementos, url_modificar_permisos_por_codigo);
}

From source file:ca.farrelltonsolar.classic.MonitorApplication.java

private void InitializeMessageLookup() {
    messages.put(0x00000001, new Pair(Severity.alert, getString(R.string.info_message_1)));
    messages.put(0x00000002, new Pair(Severity.alert, getString(R.string.info_message_2)));
    messages.put(0x00000100, new Pair(Severity.info, getString(R.string.info_message_100)));
    messages.put(0x00000200, new Pair(Severity.warning, getString(R.string.info_message_200)));
    messages.put(0x00000400, new Pair(Severity.warning, getString(R.string.info_message_400)));
    messages.put(0x00004000, new Pair(Severity.info, getString(R.string.info_message_4000)));
    messages.put(0x00008000, new Pair(Severity.info, getString(R.string.info_message_8000)));
    messages.put(0x00010000, new Pair(Severity.alert, getString(R.string.info_message_10000)));
    messages.put(0x00020000, new Pair(Severity.alert, getString(R.string.info_message_20000)));
    messages.put(0x00040000, new Pair(Severity.alert, getString(R.string.info_message_40000)));
    messages.put(0x00100000, new Pair(Severity.alert, getString(R.string.info_message_100000)));
    messages.put(0x00400000, new Pair(Severity.warning, getString(R.string.info_message_400000)));
    messages.put(0x08000000, new Pair(Severity.warning, getString(R.string.info_message_8000000)));
}

From source file:com.example.sabeeh.helloworld.AuthService.java

/**
 * Handles logging in with custom auth//from   w  ww .  j a v a2s.  c om
 * @param username
 * @param password
 * @param callback
 */

public void login(String username, String password, TableJsonOperationCallback callback) {
    JsonObject customUser = new JsonObject();
    customUser.addProperty("username", username);
    customUser.addProperty("password", password);

    List<Pair<String, String>> parameters = new ArrayList<Pair<String, String>>();
    parameters.add(new Pair<String, String>("login", "true"));

    mTableAccounts.insert(customUser, parameters, callback);
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);//w w  w.j  av  a 2s .  c om

    final String id = getArguments().getString(ARG_ZOP_ID);
    InputStream is = getResources().openRawResource(R.raw.zops);
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));

    ArrayList<FullMobileZop> zops = new ArrayList<>(Collections2.filter(
            (ArrayList<FullMobileZop>) new Gson().fromJson(reader, new TypeToken<ArrayList<FullMobileZop>>() {
            }.getType()), new Predicate<FullMobileZop>() {
                @Override
                public boolean apply(FullMobileZop input) {
                    return input.id.equals(id);
                }
            }));
    if (zops.size() == 1) {
        zop = zops.get(0);
    }

    ArrayList<Pair<String, String>> parameters = new ArrayList<Pair<String, String>>() {
        {
            add(new Pair<>("fullId", id));
        }
    };

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

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

        @Override
        public void onSuccess(JsonElement result) {
            JsonObject typesAsJson = result.getAsJsonObject();
            if (typesAsJson != null) {
                zop = new Gson().fromJson(result, FullMobileZop.class);
            }

            setZop(activity);
        }

        @Override
        public void onFailure(@NonNull Throwable t) {
            if (zop == null) {
                LinearLayout itemZop = (LinearLayout) activity.findViewById(R.id.itemZop);
                RelativeLayout loader = (RelativeLayout) activity.findViewById(R.id.relativeLayoutLoader);
                itemZop.setVisibility(View.INVISIBLE);
                loader.setVisibility(View.VISIBLE);
            }
        }
    });
}

From source file:com.nure.sigma.wimk.wimk.gcm.RegistrationIntentService.java

/**
 * Persist registration to third-party servers.
 *
 * Modify this method to associate the user's GCM registration token with any server-side account
 * maintained by your application.// w  w  w.j  a  v  a2s . c  om
 *
 * @param token The new token.
 */
private void sendRegistrationToServer(String token) {

    Log.e("andstepko", "sendRegistrationToServer");

    SharedPreferences settings = getSharedPreferences(Info.PASSWORD, 0);
    DataSender dataSender = new DataSender();
    List<Pair<String, String>> pairs = Info.getInstance().getParentAndChildLoginsListForHttp();
    pairs.add(new Pair<String, String>(Info.TOKEN, token));

    Log.e("andstepko", "Got token==>" + token);

    MyHttpResponse myHttpResponse = dataSender.httpPostQuery(Info.TOKEN_SERVER_URL, pairs, Info.WAIT_TIME);

    Log.e("andstepko", "Sending token errorCode==>" + myHttpResponse.getErrorCode() + "response==>"
            + myHttpResponse.getResponse());
}

From source file:io.relayr.tellmewhen.gcm.GcmIntentService.java

private void sendNotification(Bundle msg) {
    Storage.startRuleScreen(false);//from   w  w  w.j  av a2 s  .  c o  m

    String ruleId = msg.getString("rule_id", "null");
    if (ruleId == null) {
        sendNotification(getBaseContext().getString(R.string.please_open_app));
        return;
    }

    TMWRule rule = new Select().from(TMWRule.class).where("dbId = ?", ruleId).executeSingle();
    if (rule == null) {
        sendNotification(getBaseContext().getString(R.string.please_open_app));
        return;
    }

    Float notificationValue = 0f;
    try {
        notificationValue = Float.parseFloat(msg.getString("val", "0"));
    } catch (NumberFormatException e) {
        Log.e(GcmIntentService.class.getSimpleName(), e.getMessage());
    }

    pushedRules.put(new Pair<>(rule.getSensorType(), rule.name), notificationValue);

    String title = pushedRules.size() + " "
            + (pushedRules.size() > 1 ? getString(R.string.push_notification_title)
                    : getString(R.string.push_notification_title_one_rule));

    Spannable spanTitle = new SpannableString(title);
    spanTitle.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    Notification notification = new Builder(getApplicationContext()).setContentIntent(createContentIntent())
            .setDeleteIntent(createDeleteIntent()).setSmallIcon(R.drawable.icon_notifications)
            .setContentTitle(spanTitle).setContentText(getString(R.string.push_notification_summary))
            .setAutoCancel(true).setStyle(prepareBigNotificationDetails(spanTitle)).build();

    showNotification(TMW_NOTIFICATION_ID, notification);

    playSound();
}

From source file:cl.smartcities.isci.transportinspector.detectionService.StateLocationSender.java

public void addMultiplesLocations(ArrayList<Location> locations, boolean b) {
    for (Location location : locations) {
        addLocations(new Pair<>(location, b));
    }// w  ww.  ja  v  a2  s  .  c o  m
}

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

private byte[] encodeMorpheuzMessage(int key, int value) {
    ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>();
    pairs.add(new Pair<Integer, Object>(key, value));

    return mPebbleProtocol.encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID,
            pairs);/*  www .  j ava 2s .c  o m*/
}

From source file:moe.minori.androidoauthtutorialproject.MainActivity.java

/**
 * Called when button is pressed - calling method's name is defined by layout XML, and must have View param.
 *
 * @param v/* w  w w.  j av  a 2s  .com*/
 */
public void onClick(View v) {
    if (v.getId() == R.id.getTokensViaOAuthButton) // First button, get Access Token & Refresh Token via Chrome Custom Tab
    {
        // In order to use Chrome Custom Tab, phone must have modern Chrome for Android installed

        // We will use Support Library to avoid using AIDL interface
        CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();

        // Since some API requires user to use Custom Tabs, we will not provide failback to webview - notice null param.
        CustomTabActivityHelper customTabActivityHelper = new CustomTabActivityHelper();

        // Implicit grant flow request URL params variable - since we don't have web server.
        ArrayList<Pair<String, String>> urlParams = new ArrayList<>();

        urlParams.add(new Pair<>("client_id", Constants.clientId));
        urlParams.add(new Pair<>("response_type", "token"));
        urlParams.add(new Pair<>("scope", "profile"));
        urlParams.add(new Pair<>("redirect_uri", "http://kawaii.na.minori.ga/fitbitDuctTapeParser.html"));
        urlParams.add(new Pair<>("prompt", "consent"));

        CustomTabActivityHelper.openCustomTab(this, customTabsIntent,
                Uri.parse(RESTRequestParamUtil.paramURLfier(Constants.authURL, urlParams)), null);

    } else if (v.getId() == R.id.accessApiButton) // Second button, Access to API with Access Token
    {
        // Since we are dealing with network methods, we will use AsyncTask.

        new AsyncTask<Void, Void, String>() {
            @Override
            protected String doInBackground(Void... params) {
                // this block will not be executed in UI thread

                // try simple API request - profile reading

                // for API request, we need access token and HTTP GET request

                String result = null;

                try {
                    HttpClient httpClient = new DefaultHttpClient();
                    HttpGet request = new HttpGet();
                    request.setURI(new URI(Constants.accessEndpointURL));

                    // add authorization params - BASIC
                    request.setHeader("Authorization", "Bearer " + accessToken);

                    HttpResponse response = httpClient.execute(request);

                    result = StreamUtil.convertStreamToString(response.getEntity().getContent());

                } catch (URISyntaxException | IOException e) {
                    e.printStackTrace();
                }

                accessResult = result;

                return result;
            }

            @Override
            protected void onPostExecute(String s) {
                super.onPostExecute(s);
                // this block will be executed in UI thread

                // from onResume()
                EditText accessResultEditText = (EditText) findViewById(R.id.accessResultEditText);
                if (accessResult != null)
                    accessResultEditText.setText(accessResult);
            }
        }.execute();
    }
}