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:com.taobao.weex.dom.WXDomStatement.java

/**
 * Update styles according to the given style. Then creating a
 * command object for updating corresponding view and put the command object in the queue.
 * @param ref Reference of the dom./*from  w  ww .  j  av a2 s .  c o  m*/
 * @param style the new style. This style is only a part of the full style, and will be merged
 *              into styles
 * @param byPesudo updateStyle by pesduo class
 * @see #updateAttrs(String, JSONObject)
 */
void updateStyle(String ref, JSONObject style, boolean byPesudo) {
    if (mDestroy || style == null) {
        return;
    }
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
    WXDomObject domObject = mRegistry.get(ref);
    if (domObject == null) {
        if (instance != null) {
            instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
        }
        return;
    }

    Map<String, Object> animationMap = new ArrayMap<>(2);
    animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
    animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
    animations.add(new Pair<>(ref, animationMap));

    if (!style.isEmpty()) {
        domObject.updateStyle(style, byPesudo);
        domObject.traverseTree(ApplyStyleConsumer.getInstance());
        updateStyle(domObject, style);
    }
    mDirty = true;

    if (instance != null) {
        instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    }
}

From source file:com.landenlabs.all_devtool.PackageFragment.java

private void toggleActivities(PackingItem packingItem, int row) {
    PackageInfo packInfo = packingItem.m_packInfo;
    ArrayListPairString valueListStr = packingItem.valueListStr();
    row++;/*w  w w  .j  a v  a2s  .c  om*/
    if (row < valueListStr.size() && valueListStr.get(row).first.startsWith(PERM_PREFIX)) {
        do {
            if (valueListStr.get(row).first.startsWith(PERM_PREFIX)) {
                valueListStr.remove(row);
            } else {
                break;
            }
        } while (row < valueListStr.size());
    } else {
        for (int aidx = 0; aidx != packInfo.activities.length; aidx++) {
            ActivityInfo aInfo = packInfo.activities[aidx];
            String name = aInfo.name.replaceAll(packInfo.packageName, "");
            if (name.length() > 30)
                name = name.substring(0, 30);
            valueListStr.add(row++, new Pair<String, String>(String.format("  %2d", aidx), name));
        }
    }
}

From source file:com.microsoft.windowsazure.mobileservices.table.MobileServiceJsonTable.java

/**
 * Executes the query against the table//ww w.ja v  a2 s  .c o  m
 *
 * @param request        Request to execute
 * @param content        The content of the request body
 * @param httpMethod     The method of the HTTP request
 * @param requestHeaders Additional request headers used in the HTTP request
 * @param parameters     A list of user-defined parameters and values to include in the
 *                       request URI query string
 * @param features       The features used in the request
 */
private ListenableFuture<Pair<JsonObject, ServiceFilterResponse>> executeTableOperation(String path,
        String content, String httpMethod, List<Pair<String, String>> requestHeaders,
        List<Pair<String, String>> parameters, EnumSet<MobileServiceFeatures> features) {
    final SettableFuture<Pair<JsonObject, ServiceFilterResponse>> future = SettableFuture.create();

    MobileServiceHttpClient httpClient = new MobileServiceHttpClient(mClient);
    if (requestHeaders == null) {
        requestHeaders = new ArrayList<Pair<String, String>>();
    }

    if (content != null) {
        requestHeaders
                .add(new Pair<String, String>(HTTP.CONTENT_TYPE, MobileServiceConnection.JSON_CONTENTTYPE));
    }

    ListenableFuture<ServiceFilterResponse> internalFuture = httpClient.request(path, content, httpMethod,
            requestHeaders, parameters, features);

    Futures.addCallback(internalFuture, new FutureCallback<ServiceFilterResponse>() {
        @Override
        public void onFailure(Throwable exc) {
            future.setException(transformHttpException(exc));
        }

        @Override
        public void onSuccess(ServiceFilterResponse result) {
            String content = null;
            content = result.getContent();

            if (content == null) {
                future.set(null);
            } else {
                JsonObject newEntityJson = new JsonParser().parse(content).getAsJsonObject();
                future.set(Pair.create(newEntityJson, result));
            }
        }
    });

    return future;
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java

private void updateUserParameterWithSystemProperties(
        final EnumSet<MobileServiceSystemProperty> systemProperties) throws Throwable {

    final String tableName = "MyTableName";

    final String responseContent = "{\"id\":\"an id\",\"String\":\"Hey\"}";
    final JsonObject obj = new JsonParser().parse("{\"id\":\"an id\",\"String\":\"what\"}").getAsJsonObject();

    MobileServiceClient client = null;/*  w  w w . ja v  a2s.  com*/

    try {
        client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    // Add a filter to handle the request and create a new json
    // object with an id defined
    client = client.withFilter(getTestFilter(responseContent));

    client = client.withFilter(new ServiceFilter() {
        @Override
        public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request,
                NextServiceFilterCallback nextServiceFilterCallback) {

            assertTrue(request.getUrl().contains("__systemproperties=createdAt"));

            return nextServiceFilterCallback.onNext(request);
        }
    });

    // Create get the MobileService table
    MobileServiceJsonTable msTable = client.getTable(tableName);

    msTable.setSystemProperties(systemProperties);

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

    try {
        // Call the update method
        JsonObject jsonObject = msTable.update(obj, parameters).get();

        // Asserts
        if (jsonObject == null) {
            fail("Expected result");
        }

    } catch (Exception exception) {
        fail(exception.getMessage());
    }
}

From source file:com.landenlabs.all_devtool.PackageFragment.java

private void toggleServices(PackingItem packingItem, int row) {
    PackageInfo packInfo = packingItem.m_packInfo;
    ArrayListPairString valueListStr = packingItem.valueListStr();
    row++;/*from  ww  w. j  a va 2s. com*/
    if (row < valueListStr.size() && valueListStr.get(row).first.startsWith(PERM_PREFIX)) {
        do {
            if (valueListStr.get(row).first.startsWith(PERM_PREFIX)) {
                valueListStr.remove(row);
            } else {
                break;
            }
        } while (row < valueListStr.size());
    } else {
        for (int aidx = 0; aidx != packInfo.services.length; aidx++) {
            ServiceInfo sInfo = packInfo.services[aidx];
            String name = sInfo.name;
            if (name.length() > 30)
                name = name.substring(0, 30);
            valueListStr.add(row++, new Pair<String, String>(String.format("  %2d", aidx), name));
        }
    }
}

From source file:com.microsoft.windowsazure.mobileservices.zumoe2etestapp.tests.CustomApiTests.java

protected List<Pair<String, String>> createQuery(Random rndGen) {
    if (rndGen.nextInt(2) == 0) {
        return null;
    } else {/* www. j  ava2 s  .com*/
        List<Pair<String, String>> query = new ArrayList<Pair<String, String>>();

        int size = rndGen.nextInt(5);

        for (int i = 0; i < size; i++) {
            query.add(new Pair<String, String>(
                    Util.createSimpleRandomString(rndGen, rndGen.nextInt(10) + 1, 'a', 'z'),
                    Util.createComplexRandomString(rndGen, rndGen.nextInt(30))));
        }

        return query;
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.ExperimentDesignerActivity.java

@Override
public ProgramComponentAdapter<Rule> getRuleAdapter(long sceneId) {
    if (mCurrentRuleAdapter != null && mCurrentRuleAdapter.first == sceneId) {
        return mCurrentRuleAdapter.second;
    }//  ww  w .  java  2  s .  co m

    ProgramComponentAdapter<Rule> adapter = new ProgramComponentAdapter<Rule>(mExperiment.rules,
            mExperiment.scenes.get(sceneId).rules, new RuleListItemViewBinder(this, this));

    mCurrentRuleAdapter = new Pair<Long, ProgramComponentAdapter<Rule>>(sceneId, adapter);

    return adapter;
}

From source file:com.landenlabs.all_devtool.PackageFragment.java

private void toggleProviders(PackingItem packingItem, int row) {
    PackageInfo packInfo = packingItem.m_packInfo;
    ArrayListPairString valueListStr = packingItem.valueListStr();
    row++;// ww w .j  ava2  s . c  o  m
    if (row < valueListStr.size() && valueListStr.get(row).first.startsWith(PERM_PREFIX)) {
        do {
            if (valueListStr.get(row).first.startsWith(PERM_PREFIX)) {
                valueListStr.remove(row);
            } else {
                break;
            }
        } while (row < valueListStr.size());
    } else {
        for (int pidx = 0; pidx != packInfo.providers.length; pidx++) {
            ProviderInfo providerInfo = packInfo.providers[pidx];
            String provStr = providerInfo.name;
            if (provStr.length() > 30)
                provStr = provStr.substring(provStr.length() - 30);
            valueListStr.add(row++, new Pair<String, String>(String.format("  %2d", pidx), provStr));
        }
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.ExperimentDesignerActivity.java

@Override
public ProgramComponentAdapter<Scene> getScenesAdapter(long loopId) {
    if (mCurrentSceneAdapter != null && mCurrentSceneAdapter.first == loopId) {
        return mCurrentSceneAdapter.second;
    }//from  ww  w  .j  a v a2s.c  o m

    ProgramComponentAdapter<Scene> adapter = new ProgramComponentAdapter<Scene>(mExperiment.scenes,
            mExperiment.loops.get(loopId).scenes, new SceneListItemViewBinder(this, this));
    mCurrentSceneAdapter = new Pair<Long, ProgramComponentAdapter<Scene>>(loopId, adapter);

    return adapter;
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.MobileServiceFeaturesTests.java

public void testJsonTableUpdateWithVersionFeatureHeader() {
    testOpportunisticConcurrencyOperationsFeatureHeader(new OpportunisticConcurrencyTestOperation() {

        @Override//from w ww .j  av a2s  . c  o m
        public void executeOperation(MobileServiceClient client) throws Exception {
            MobileServiceJsonTable jsonTable = client.getTable("Person");
            jsonTable.setSystemProperties(EnumSet.of(MobileServiceSystemProperty.Version));
            JsonObject jo = createJsonObject();
            jo.addProperty("__version", "abc");
            List<Pair<String, String>> queryParams = new ArrayList<Pair<String, String>>();
            queryParams.add(new Pair<String, String>("a", "b"));
            jsonTable.update(jo, queryParams).get();
        }
    }, "OC,QS,TU");
}