Skip to content

Commit

Permalink
clean some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Sharat committed Mar 1, 2017
1 parent 481fde0 commit 478d055
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}
}
Expand All @@ -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) {

}
};

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ final class GsonRequestBodyConverter<T> implements Converter<T, RequestBody> {

private TypeAdapter<T> getAdapter() {
if (null == typeAdapter) {
//noinspection unchecked
typeAdapter = (TypeAdapter<T>) gson.getAdapter(TypeToken.get(type));
}
return typeAdapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ final class GsonResponseBodyConverter<T> implements Converter<ResponseBody, T> {

private TypeAdapter<T> getAdapter() {
if (null == typeAdapter) {
//noinspection unchecked
typeAdapter = (TypeAdapter<T>) gson.getAdapter(TypeToken.get(type));
}
return typeAdapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class UrlEncodedGsonRequestBodyConverter<T> implements Converter<T, RequestBody>

@Override
public RequestBody convert(T value) throws IOException {
//noinspection unchecked
TypeAdapter<T> adapter = (TypeAdapter<T>) gson.getAdapter(TypeToken.get(type));
Writer writer = new StringWriter();
JsonWriter jsonWriter = gson.newJsonWriter(writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 1 addition & 15 deletions proteus-core/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,4 @@
~ specific language governing permissions and limitations under the License.
-->

<manifest package="com.flipkart.layoutengine.library"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20"/>

<application
android:allowBackup="true"
android:label="@string/app_name">
</application>

</manifest>
<manifest package="com.flipkart.android.proteus"/>
1 change: 1 addition & 0 deletions proteus-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ android {
}
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ public void setString(V view, String value) {

private void process(Map<String, Value> style, ProteusView proteusView, ViewTypeParser handler) {
for (Map.Entry<String, Value> entry : style.entrySet()) {
//noinspection unchecked
handler.handleAttribute(proteusView.getAsView(), handler.getAttributeId(entry.getKey()), entry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void setDrawable(T view, Drawable drawable) {
addAttributeProcessor(Attributes.ImageView.ScaleType, new StringAttributeProcessor<T>() {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Integer> sAttributesMap = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -244,6 +246,7 @@ private LayerListValue(Array layers) {
Iterator<Value> 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++;
Expand Down Expand Up @@ -280,6 +283,7 @@ public static class StateListValue extends DrawableValue {
private final Pair<int[], Value>[] states;

private StateListValue(Array states) {
//noinspection unchecked
this.states = new Pair[states.size()];
Iterator<Value> iterator = states.iterator();
int index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Layout extends Value {
@Nullable
public final ObjectValue extras;

public Layout(@NonNull String type, @Nullable List<Attribute> attributes, @Nullable Map<String, Value> data, ObjectValue extras) {
public Layout(@NonNull String type, @Nullable List<Attribute> attributes, @Nullable Map<String, Value> data, @Nullable ObjectValue extras) {
this.type = type;
this.attributes = attributes;
this.data = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

Expand All @@ -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) {
Expand Down

0 comments on commit 478d055

Please sign in to comment.