Lint issues fixed
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
@@ -31,7 +30,6 @@ import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.*;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import com.squareup.otto.Bus;
|
||||
@@ -172,20 +170,10 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
||||
}
|
||||
|
||||
public static void showEvaluationError(@Nonnull Context context,
|
||||
@Nonnull final String errorMessage) {
|
||||
final LayoutInflater layoutInflater =
|
||||
(LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
final View errorMessageView = layoutInflater.inflate(R.layout.display_error_message, null);
|
||||
((TextView) errorMessageView.findViewById(R.id.error_message_text_view))
|
||||
.setText(errorMessage);
|
||||
|
||||
final AlertDialog.Builder builder =
|
||||
new AlertDialog.Builder(context, App.getTheme().alertDialogTheme)
|
||||
.setPositiveButton(R.string.cpp_cancel, null)
|
||||
.setView(errorMessageView);
|
||||
|
||||
builder.create().show();
|
||||
@Nonnull final String errorMessage) {
|
||||
new AlertDialog.Builder(context, App.getTheme().alertDialogTheme)
|
||||
.setPositiveButton(R.string.cpp_cancel, null)
|
||||
.setMessage(errorMessage).create().show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -38,7 +38,7 @@ public class ExpressionFunction extends Function {
|
||||
name = function.toString();
|
||||
}
|
||||
if (name.length() > 10) {
|
||||
name = name.substring(0, 10) + "...";
|
||||
name = name.substring(0, 10) + "…";
|
||||
}
|
||||
}
|
||||
return imaginary ? "Im(" + name + ")" : name;
|
||||
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 serso aka se.solovyev
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Contact details
|
||||
*
|
||||
* Email: se.solovyev@gmail.com
|
||||
* Site: http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.prefs;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import org.solovyev.common.text.Mapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class CollectionSetPreference<C extends Collection<T>, T> extends AbstractPreference<C> {
|
||||
|
||||
@Nonnull
|
||||
private final Mapper<T> mapper;
|
||||
|
||||
protected CollectionSetPreference(@Nonnull String id, @Nonnull C defaultValue, @Nonnull Mapper<T> mapper) {
|
||||
super(id, defaultValue);
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected C getPersistedValue(@Nonnull SharedPreferences preferences) {
|
||||
final Set<String> stringValues = preferences.getStringSet(getKey(), null);
|
||||
|
||||
final C result = createCollection(stringValues.size());
|
||||
for (String stringValue : stringValues) {
|
||||
result.add(mapper.parseValue(stringValue));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected abstract C createCollection(int size);
|
||||
|
||||
@Override
|
||||
protected void putPersistedValue(@Nonnull SharedPreferences.Editor editor, @Nonnull C values) {
|
||||
|
||||
final Set<String> result = new HashSet<String>(values.size());
|
||||
for (T value : values) {
|
||||
result.add(mapper.formatValue(value));
|
||||
}
|
||||
|
||||
editor.putStringSet(getKey(), result);
|
||||
}
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 serso aka se.solovyev
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Contact details
|
||||
*
|
||||
* Email: se.solovyev@gmail.com
|
||||
* Site: http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.prefs;
|
||||
|
||||
import org.solovyev.common.text.EnumMapper;
|
||||
import org.solovyev.common.text.Mapper;
|
||||
import org.solovyev.common.text.StringMapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class HashSetPreference<T> extends CollectionSetPreference<Set<T>, T> {
|
||||
|
||||
private HashSetPreference(@Nonnull String id, @Nonnull Set<T> defaultValue, @Nonnull Mapper<T> mapper) {
|
||||
super(id, defaultValue, mapper);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static HashSetPreference<String> ofStrings(@Nonnull String key, @Nonnull Set<String> defaultValue) {
|
||||
return new HashSetPreference<String>(key, defaultValue, StringMapper.getInstance());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static <T> HashSetPreference<T> ofTypedValues(@Nonnull String key, @Nonnull Set<T> defaultValue, @Nonnull Mapper<T> parser) {
|
||||
return new HashSetPreference<T>(key, defaultValue, parser);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static <T extends Enum> HashSetPreference<T> ofEnums(@Nonnull String id, @Nonnull Set<T> defaultValue, @Nonnull Class<T> enumType) {
|
||||
return new HashSetPreference<T>(id, defaultValue, EnumMapper.of(enumType));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected Set<T> createCollection(int size) {
|
||||
return new HashSet<T>(size);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user