diff --git a/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java b/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java index d8099214..129f7e83 100644 --- a/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java +++ b/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java @@ -70,7 +70,6 @@ public class ProteusActivity extends AppCompatActivity { private static final String BASE_URL = "http://10.0.2.2:8080/data/"; - private Proteus proteus; private Retrofit retrofit; private JsonResource resources; @@ -137,6 +136,7 @@ protected void onPostExecute(@Nullable Bitmap result) { if (result != null) { callback.setBitmap(result); } else { + //noinspection deprecation callback.setDrawable(ProteusActivity.this.getResources().getDrawable(R.drawable.ic_launcher)); } } @@ -159,9 +159,8 @@ public ProteusView onUnknownViewType(ProteusContext context, String type, Layout @NonNull @Override - public View onEvent(ProteusView view, EventType eventType, Value value) { - //noinspection ConstantConditions because we want to crash here - return null; + public void onEvent(ProteusView view, EventType eventType, Value value) { + } }; @@ -183,7 +182,7 @@ protected void onStart() { resources = retrofit.create(JsonResource.class); } - proteus = new ProteusBuilder() + Proteus proteus = new ProteusBuilder() .register(SupportV4Collection.create()) .register(new CircleViewParser()) .build(); diff --git a/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonRequestBodyConverter.java b/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonRequestBodyConverter.java index d1749736..d611a4c0 100644 --- a/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonRequestBodyConverter.java +++ b/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonRequestBodyConverter.java @@ -49,6 +49,7 @@ final class GsonRequestBodyConverter implements Converter { private TypeAdapter getAdapter() { if (null == typeAdapter) { + //noinspection unchecked typeAdapter = (TypeAdapter) gson.getAdapter(TypeToken.get(type)); } return typeAdapter; diff --git a/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonResponseBodyConverter.java b/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonResponseBodyConverter.java index dd6bf141..d9703122 100644 --- a/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonResponseBodyConverter.java +++ b/demo/src/main/java/com/flipkart/android/proteus/demo/converter/GsonResponseBodyConverter.java @@ -41,6 +41,7 @@ final class GsonResponseBodyConverter implements Converter { private TypeAdapter getAdapter() { if (null == typeAdapter) { + //noinspection unchecked typeAdapter = (TypeAdapter) gson.getAdapter(TypeToken.get(type)); } return typeAdapter; diff --git a/demo/src/main/java/com/flipkart/android/proteus/demo/converter/UrlEncodedGsonRequestBodyConverter.java b/demo/src/main/java/com/flipkart/android/proteus/demo/converter/UrlEncodedGsonRequestBodyConverter.java index 339dc9d7..458686ed 100755 --- a/demo/src/main/java/com/flipkart/android/proteus/demo/converter/UrlEncodedGsonRequestBodyConverter.java +++ b/demo/src/main/java/com/flipkart/android/proteus/demo/converter/UrlEncodedGsonRequestBodyConverter.java @@ -47,6 +47,7 @@ class UrlEncodedGsonRequestBodyConverter implements Converter @Override public RequestBody convert(T value) throws IOException { + //noinspection unchecked TypeAdapter adapter = (TypeAdapter) gson.getAdapter(TypeToken.get(type)); Writer writer = new StringWriter(); JsonWriter jsonWriter = gson.newJsonWriter(writer); diff --git a/demo/src/main/java/com/flipkart/android/proteus/demo/customviews/CircleView.java b/demo/src/main/java/com/flipkart/android/proteus/demo/customviews/CircleView.java index 1da8f8a8..2976d0f9 100644 --- a/demo/src/main/java/com/flipkart/android/proteus/demo/customviews/CircleView.java +++ b/demo/src/main/java/com/flipkart/android/proteus/demo/customviews/CircleView.java @@ -95,6 +95,7 @@ public void onGlobalLayout() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void removeOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener) { if (Build.VERSION.SDK_INT < 16) { + //noinspection deprecation getViewTreeObserver().removeGlobalOnLayoutListener(listener); } else { getViewTreeObserver().removeOnGlobalLayoutListener(listener); diff --git a/proteus-core/AndroidManifest.xml b/proteus-core/AndroidManifest.xml index 39fff374..9a46ff0f 100644 --- a/proteus-core/AndroidManifest.xml +++ b/proteus-core/AndroidManifest.xml @@ -18,18 +18,4 @@ ~ specific language governing permissions and limitations under the License. --> - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/proteus-core/build.gradle b/proteus-core/build.gradle index 67eb1f9f..7761b5b1 100644 --- a/proteus-core/build.gradle +++ b/proteus-core/build.gradle @@ -40,6 +40,7 @@ android { } } } + task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusLayoutInflater.java b/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusLayoutInflater.java index 3e95ab6b..934dacf7 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusLayoutInflater.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusLayoutInflater.java @@ -140,8 +140,7 @@ interface Callback { * @param view The view that triggered the event * @param value Value set to the event attribute */ - @NonNull - View onEvent(ProteusView view, EventType eventType, Value value); + void onEvent(ProteusView view, EventType eventType, Value value); } diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusResources.java b/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusResources.java index fb22bd2a..d0234f32 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusResources.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/ProteusResources.java @@ -62,7 +62,7 @@ public FormatterManager getFormatterManager() { @NonNull public Formatter getFormatter(@NonNull String name) { - return null != formatterManager ? formatterManager.get(name) : Formatter.NOOP; + return formatterManager.get(name); } @Nullable diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/IncludeParser.java b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/IncludeParser.java index bc2fa2ce..6474601e 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/IncludeParser.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/IncludeParser.java @@ -57,7 +57,9 @@ public String getParentType() { @NonNull @Override public ProteusView createView(@NonNull ProteusContext context, @NonNull Layout include, @NonNull ObjectValue data, @Nullable ViewGroup parent, int dataIndex) { + //noinspection ConstantConditions String type = include.extras.getAsString(ProteusConstants.LAYOUT); + //noinspection ConstantConditions return context.getInflater().inflate(type, data, parent, dataIndex); } diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ParseHelper.java b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ParseHelper.java index 7e3e3082..44d94858 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ParseHelper.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ParseHelper.java @@ -262,7 +262,8 @@ public static int parseVisibility(@Nullable Value value) { (attributeValue.isEmpty() || FALSE.equals(attributeValue) || ProteusConstants.DATA_NULL.equals(attributeValue))) { returnValue = View.GONE; } - } else if (value.isNull()) { + } else //noinspection ConstantConditions + if (value.isNull()) { returnValue = View.GONE; } return returnValue == null ? View.VISIBLE : returnValue; diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ViewParser.java b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ViewParser.java index 4cb8087f..f9814aa8 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ViewParser.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/ViewParser.java @@ -448,6 +448,7 @@ public void setString(V view, String value) { private void process(Map style, ProteusView proteusView, ViewTypeParser handler) { for (Map.Entry entry : style.entrySet()) { + //noinspection unchecked handler.handleAttribute(proteusView.getAsView(), handler.getAttributeId(entry.getKey()), entry.getValue()); } } diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/ImageViewParser.java b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/ImageViewParser.java index 74eb99ae..46534586 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/ImageViewParser.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/ImageViewParser.java @@ -74,7 +74,7 @@ public void setDrawable(T view, Drawable drawable) { addAttributeProcessor(Attributes.ImageView.ScaleType, new StringAttributeProcessor() { @Override public void setString(T view, String value) { - ProteusImageView.ScaleType scaleType = null; + ProteusImageView.ScaleType scaleType; scaleType = ParseHelper.parseScaleType(value); if (scaleType != null) view.setScaleType(scaleType); diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/TextViewParser.java b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/TextViewParser.java index cc19296b..1e80a822 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/TextViewParser.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/parser/custom/TextViewParser.java @@ -79,6 +79,7 @@ public void setString(T view, String value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { view.setText(Html.fromHtml(value, Html.FROM_HTML_MODE_LEGACY)); } else { + //noinspection deprecation view.setText(Html.fromHtml(value)); } } diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/toolbox/LazilyParsedNumber.java b/proteus-core/src/main/java/com/flipkart/android/proteus/toolbox/LazilyParsedNumber.java index 77de392a..999e1720 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/toolbox/LazilyParsedNumber.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/toolbox/LazilyParsedNumber.java @@ -92,6 +92,7 @@ public boolean equals(Object obj) { } if (obj instanceof LazilyParsedNumber) { LazilyParsedNumber other = (LazilyParsedNumber) obj; + //noinspection StringEquality return value == other.value || value.equals(other.value); } return false; diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/value/AttributeResource.java b/proteus-core/src/main/java/com/flipkart/android/proteus/value/AttributeResource.java index 43de2adb..778ea416 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/value/AttributeResource.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/value/AttributeResource.java @@ -82,7 +82,6 @@ private AttributeResource(String value, Context context) throws ClassNotFoundExc attributeId = field.getInt(null); } - @Nullable public static boolean isAttributeResource(String value) { return value.startsWith(ATTR_START_LITERAL) && value.contains(ATTR_LITERAL); } diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Binding.java b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Binding.java index a93838e9..426de87c 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Binding.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Binding.java @@ -117,8 +117,7 @@ public Expression getExpression(int index) { public Value evaluate(Value data, int index) { Value empty = StringAttributeProcessor.EMPTY; Result result; - // the string object compare can be safely used here, - // do not convert it to .equals() + //noinspection StringEquality the string object compare can be safely used here, do not convert it to .equals() if (expressions.length == 1 && template == EMPTY_TEMPLATE) { result = expressions[0].evaluate(data, index); return result.isSuccess() ? result.value : empty; @@ -128,6 +127,7 @@ public Value evaluate(Value data, int index) { for (int i = 0; i < expressions.length; i++) { result = expressions[i].evaluate(data, index); if (result.isSuccess()) { + //noinspection ConstantConditions if (result.value.isPrimitive()) { variable = result.value.getAsString(); } else { diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Color.java b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Color.java index 7f7d0cd2..d87803f4 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Color.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Color.java @@ -40,7 +40,6 @@ public abstract class Color extends Value { private static final String COLOR_PREFIX_LITERAL = "#"; - private static final String COLOR_RESOURCE_PREFIX = "@color/"; private static HashMap sAttributesMap = null; diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/value/DrawableValue.java b/proteus-core/src/main/java/com/flipkart/android/proteus/value/DrawableValue.java index 3a23f707..3071794f 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/value/DrawableValue.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/value/DrawableValue.java @@ -84,6 +84,7 @@ public static DrawableValue valueOf(String value, Context context) { @Nullable public static DrawableValue valueOf(ObjectValue value, Context context) { String type = value.getAsString(TYPE); + //noinspection ConstantConditions switch (type) { case DRAWABLE_SELECTOR: return StateListValue.valueOf(value.getAsArray(CHILDREN), context); @@ -164,6 +165,7 @@ private ShapeValue(ObjectValue value, Context context) { ObjectValue child = iterator.next().getAsObject(); String typeKey = child.getAsString(TYPE); DrawableElement element = null; + //noinspection ConstantConditions switch (typeKey) { case TYPE_CORNERS: element = Corners.valueOf(child, context); @@ -244,6 +246,7 @@ private LayerListValue(Array layers) { Iterator iterator = layers.iterator(); while (iterator.hasNext()) { pair = ParseHelper.parseLayer(iterator.next().getAsObject()); + //noinspection ConstantConditions this.ids[index] = pair.first; this.layers[index] = pair.second; index++; @@ -280,6 +283,7 @@ public static class StateListValue extends DrawableValue { private final Pair[] states; private StateListValue(Array states) { + //noinspection unchecked this.states = new Pair[states.size()]; Iterator iterator = states.iterator(); int index = 0; diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Layout.java b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Layout.java index ffa4dedb..eddc7101 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Layout.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Layout.java @@ -46,7 +46,7 @@ public class Layout extends Value { @Nullable public final ObjectValue extras; - public Layout(@NonNull String type, @Nullable List attributes, @Nullable Map data, ObjectValue extras) { + public Layout(@NonNull String type, @Nullable List attributes, @Nullable Map data, @Nullable ObjectValue extras) { this.type = type; this.attributes = attributes; this.data = data; diff --git a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Resource.java b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Resource.java index 53840371..f627fc2c 100644 --- a/proteus-core/src/main/java/com/flipkart/android/proteus/value/Resource.java +++ b/proteus-core/src/main/java/com/flipkart/android/proteus/value/Resource.java @@ -104,6 +104,7 @@ public static Integer getColor(int resId, Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getResources().getColor(resId, context.getTheme()); } else { + //noinspection deprecation return context.getResources().getColor(resId); } } catch (Resources.NotFoundException e) { @@ -117,6 +118,7 @@ public static ColorStateList getColorStateList(int resId, Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColorStateList(resId); } else { + //noinspection deprecation return context.getResources().getColorStateList(resId); } @@ -131,6 +133,7 @@ public static Drawable getDrawable(int resId, Context context) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { return context.getResources().getDrawable(resId, context.getTheme()); } else { + //noinspection deprecation return context.getResources().getDrawable(resId); } } catch (Resources.NotFoundException e) {