Search in sources :

Example 96 with Override

use of java.lang.Override in project LoganSquare by bluelinelabs.

the class PrivateFieldModel$$JsonObjectMapper method serialize.

@Override
public void serialize(PrivateFieldModel object, JsonGenerator jsonGenerator, boolean writeStartAndEnd) throws IOException {
    if (writeStartAndEnd) {
        jsonGenerator.writeStartObject();
    }
    if (object.getStringThatStartsWithM() != null) {
        jsonGenerator.writeStringField("string_to_test_m_vars", object.getStringThatStartsWithM());
    }
    jsonGenerator.writeBooleanField("privateBoolean", object.isPrivateBoolean());
    final List<String> lslocalprivateList = object.getPrivateList();
    if (lslocalprivateList != null) {
        jsonGenerator.writeFieldName("privateList");
        jsonGenerator.writeStartArray();
        for (String element1 : lslocalprivateList) {
            if (element1 != null) {
                jsonGenerator.writeString(element1);
            }
        }
        jsonGenerator.writeEndArray();
    }
    final Map<String, String> lslocalprivateMap = object.getPrivateMap();
    if (lslocalprivateMap != null) {
        jsonGenerator.writeFieldName("privateMap");
        jsonGenerator.writeStartObject();
        for (Map.Entry<String, String> entry1 : lslocalprivateMap.entrySet()) {
            jsonGenerator.writeFieldName(entry1.getKey().toString());
            if (entry1.getValue() != null) {
                jsonGenerator.writeString(entry1.getValue());
            }
        }
        jsonGenerator.writeEndObject();
    }
    if (object.getPrivateNamedString() != null) {
        jsonGenerator.writeStringField("private_named_string", object.getPrivateNamedString());
    }
    if (object.getPrivateString() != null) {
        jsonGenerator.writeStringField("privateString", object.getPrivateString());
    }
    if (writeStartAndEnd) {
        jsonGenerator.writeEndObject();
    }
}
Also used : String(java.lang.String) Map(java.util.Map) HashMap(java.util.HashMap) Override(java.lang.Override)

Example 97 with Override

use of java.lang.Override in project LoganSquare by bluelinelabs.

the class PrivateFieldModel$$JsonObjectMapper method parseField.

@Override
public void parseField(PrivateFieldModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("string_to_test_m_vars".equals(fieldName)) {
        instance.setStringThatStartsWithM(jsonParser.getValueAsString(null));
    } else if ("privateBoolean".equals(fieldName)) {
        instance.setPrivateBoolean(jsonParser.getValueAsBoolean());
    } else if ("privateList".equals(fieldName)) {
        if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
            ArrayList<String> collection1 = new ArrayList<String>();
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                String value1;
                value1 = jsonParser.getValueAsString(null);
                collection1.add(value1);
            }
            instance.setPrivateList(collection1);
        } else {
            instance.setPrivateList(null);
        }
    } else if ("privateMap".equals(fieldName)) {
        if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
            HashMap<String, String> map1 = new HashMap<String, String>();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String key1 = jsonParser.getText();
                jsonParser.nextToken();
                if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
                    map1.put(key1, null);
                } else {
                    map1.put(key1, jsonParser.getValueAsString(null));
                }
            }
            instance.setPrivateMap(map1);
        } else {
            instance.setPrivateMap(null);
        }
    } else if ("private_named_string".equals(fieldName)) {
        instance.setPrivateNamedString(jsonParser.getValueAsString(null));
    } else if ("privateString".equals(fieldName)) {
        instance.setPrivateString(jsonParser.getValueAsString(null));
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) String(java.lang.String) Override(java.lang.Override)

Example 98 with Override

use of java.lang.Override in project facebook-android-sdk by facebook.

the class BatchRequestTests method testBatchCallbackIsCalled.

@LargeTest
public void testBatchCallbackIsCalled() {
    final AtomicInteger count = new AtomicInteger();
    GraphRequest request1 = GraphRequest.newGraphPathRequest(null, "4", new GraphRequest.Callback() {

        @Override
        public void onCompleted(GraphResponse response) {
            count.incrementAndGet();
        }
    });
    GraphRequest request2 = GraphRequest.newGraphPathRequest(null, "4", new GraphRequest.Callback() {

        @Override
        public void onCompleted(GraphResponse response) {
            count.incrementAndGet();
        }
    });
    GraphRequestBatch batch = new GraphRequestBatch(request1, request2);
    batch.addCallback(new GraphRequestBatch.Callback() {

        @Override
        public void onBatchCompleted(GraphRequestBatch batch) {
            count.incrementAndGet();
        }
    });
    batch.executeAndWait();
    assertEquals(3, count.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Override(java.lang.Override) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 99 with Override

use of java.lang.Override in project facebook-android-sdk by facebook.

the class BatchRequestTests method testMixedBatchCallbacks.

@LargeTest
public void testMixedBatchCallbacks() {
    final AtomicInteger requestProgressCount = new AtomicInteger();
    final AtomicInteger requestCompletedCount = new AtomicInteger();
    final AtomicInteger batchProgressCount = new AtomicInteger();
    final AtomicInteger batchCompletedCount = new AtomicInteger();
    final AccessToken accessToken = getAccessTokenForSharedUser();
    String appId = getApplicationId();
    GraphRequest.setDefaultBatchApplicationId(appId);
    GraphRequest request1 = GraphRequest.newGraphPathRequest(null, "4", new GraphRequest.OnProgressCallback() {

        @Override
        public void onCompleted(GraphResponse response) {
            requestCompletedCount.incrementAndGet();
        }

        @Override
        public void onProgress(long current, long max) {
            if (current == max) {
                requestProgressCount.incrementAndGet();
            } else if (current > max) {
                requestProgressCount.set(0);
            }
        }
    });
    assertNotNull(request1);
    GraphRequest request2 = GraphRequest.newGraphPathRequest(null, "4", null);
    assertNotNull(request2);
    GraphRequestBatch batch = new GraphRequestBatch(request1, request2);
    batch.addCallback(new GraphRequestBatch.OnProgressCallback() {

        @Override
        public void onBatchCompleted(GraphRequestBatch batch) {
            batchCompletedCount.incrementAndGet();
        }

        @Override
        public void onBatchProgress(GraphRequestBatch batch, long current, long max) {
            if (current == max) {
                batchProgressCount.incrementAndGet();
            } else if (current > max) {
                batchProgressCount.set(0);
            }
        }
    });
    batch.executeAndWait();
    assertEquals(1, requestProgressCount.get());
    assertEquals(1, requestCompletedCount.get());
    assertEquals(1, batchProgressCount.get());
    assertEquals(1, batchCompletedCount.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Override(java.lang.Override) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 100 with Override

use of java.lang.Override in project facebook-android-sdk by facebook.

the class BatchRequestTests method testBatchLastOnProgressCallbackIsCalledOnce.

@LargeTest
public void testBatchLastOnProgressCallbackIsCalledOnce() {
    final AtomicInteger count = new AtomicInteger();
    final AccessToken accessToken = getAccessTokenForSharedUser();
    String appId = getApplicationId();
    GraphRequest.setDefaultBatchApplicationId(appId);
    GraphRequest request1 = GraphRequest.newGraphPathRequest(accessToken, "4", null);
    assertNotNull(request1);
    GraphRequest request2 = GraphRequest.newGraphPathRequest(accessToken, "4", null);
    assertNotNull(request2);
    GraphRequestBatch batch = new GraphRequestBatch(request1, request2);
    batch.addCallback(new GraphRequestBatch.OnProgressCallback() {

        @Override
        public void onBatchCompleted(GraphRequestBatch batch) {
        }

        @Override
        public void onBatchProgress(GraphRequestBatch batch, long current, long max) {
            if (current == max) {
                count.incrementAndGet();
            } else if (current > max) {
                count.set(0);
            }
        }
    });
    batch.executeAndWait();
    assertEquals(1, count.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Override(java.lang.Override) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

Override (java.lang.Override)176 StringBuilder (java.lang.StringBuilder)83 String (java.lang.String)35 NonNull (android.support.annotation.NonNull)24 ContentValues (android.content.ContentValues)12 ArrayList (java.util.ArrayList)11 View (android.view.View)10 Integer (java.lang.Integer)9 Long (java.lang.Long)9 HashMap (java.util.HashMap)9 Boolean (java.lang.Boolean)8 Double (java.lang.Double)8 Float (java.lang.Float)8 Short (java.lang.Short)8 Bitmap (android.graphics.Bitmap)5 Canvas (android.graphics.Canvas)5 Handler (android.os.Handler)5 HandlerThread (android.os.HandlerThread)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Map (java.util.Map)5