fix various lint warnings

This commit is contained in:
Jimmy Shih
2013-04-30 14:09:38 -07:00
parent 027ae7b2dd
commit b593fa3550
7 changed files with 61 additions and 17 deletions
@@ -59,12 +59,10 @@ public class TabsAdapter extends FragmentPagerAdapter
*/
private static final class TabInfo {
private final String tag;
private final Class<?> clss;
private final Bundle bundle;
public TabInfo(String tag, Class<?> clss, Bundle bunlde) {
this.tag = tag;
public TabInfo(Class<?> clss, Bundle bunlde) {
this.clss = clss;
this.bundle = bunlde;
}
@@ -106,9 +104,8 @@ public class TabsAdapter extends FragmentPagerAdapter
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle bundle) {
tabSpec.setContent(new DummyTabFactory(context));
String tag = tabSpec.getTag();
TabInfo info = new TabInfo(tag, clss, bundle);
TabInfo info = new TabInfo(clss, bundle);
tabInfos.add(info);
tabHost.addTab(tabSpec);
notifyDataSetChanged();
@@ -226,6 +226,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity
*
* @param value the icon value
*/
@SuppressWarnings("unchecked")
private void setActivityTypeIcon(String value) {
iconValue = value;
ArrayAdapter<StringBuilder> adapter =
@@ -25,6 +25,7 @@ import android.location.Location;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -80,7 +81,7 @@ public class SearchEngine {
public static class SearchQuery {
public SearchQuery(String textQuery, Location currentLocation, long currentTrackId,
long currentTimestamp) {
this.textQuery = textQuery.toLowerCase();
this.textQuery = textQuery.toLowerCase(Locale.getDefault());
this.currentLocation = currentLocation;
this.currentTrackId = currentTrackId;
this.currentTimestamp = currentTimestamp;
@@ -333,13 +334,13 @@ public class SearchEngine {
String name, String description, String category) {
// Title boost: track name > description > category.
double boost = 1.0;
if (name.toLowerCase().contains(query.textQuery)) {
if (name.toLowerCase(Locale.getDefault()).contains(query.textQuery)) {
boost *= TRACK_NAME_PROMOTION;
}
if (description.toLowerCase().contains(query.textQuery)) {
if (description.toLowerCase(Locale.getDefault()).contains(query.textQuery)) {
boost *= TRACK_DESCRIPTION_PROMOTION;
}
if (category.toLowerCase().contains(query.textQuery)) {
if (category.toLowerCase(Locale.getDefault()).contains(query.textQuery)) {
boost *= TRACK_CATEGORY_PROMOTION;
}
return boost;
@@ -20,7 +20,6 @@ import com.google.android.apps.mytracks.widgets.TrackWidgetProvider;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.os.Bundle;
/**
@@ -36,10 +35,12 @@ public class Api16Adapter extends Api14Adapter {
@Override
public int getAppWidgetSize(AppWidgetManager appWidgetManager, int appWidgetId) {
Bundle bundle = appWidgetManager.getAppWidgetOptions(appWidgetId);
boolean isKeyguard = bundle.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1)
== AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
return bundle.getInt(APP_WIDGET_SIZE_KEY, isKeyguard ? TrackWidgetProvider.KEYGUARD_DEFAULT_SIZE
: TrackWidgetProvider.HOME_SCREEN_DEFAULT_SIZE);
return bundle.getInt(APP_WIDGET_SIZE_KEY, getAppWidgetSizeDefault(bundle));
}
@SuppressWarnings("unused")
protected int getAppWidgetSizeDefault(Bundle bundle) {
return TrackWidgetProvider.HOME_SCREEN_DEFAULT_SIZE;
}
@Override
@@ -0,0 +1,41 @@
/*
* Copyright 2013 Google Inc.
*
* 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.
*/
package com.google.android.apps.mytracks.util;
import com.google.android.apps.mytracks.widgets.TrackWidgetProvider;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.os.Bundle;
/**
* API level 17 specific implementation of the {@link ApiAdapter}.
*
* @author Jimmy Shih
*/
@TargetApi(17)
public class Api17Adapter extends Api16Adapter {
@Override
protected int getAppWidgetSizeDefault(Bundle bundle) {
boolean isKeyguard = bundle.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1)
== AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD;
return isKeyguard ? TrackWidgetProvider.KEYGUARD_DEFAULT_SIZE
: TrackWidgetProvider.HOME_SCREEN_DEFAULT_SIZE;
}
}
@@ -31,7 +31,9 @@ public class ApiAdapterFactory {
*/
public static ApiAdapter getApiAdapter() {
if (apiAdapter == null) {
if (Build.VERSION.SDK_INT >= 16) {
if (Build.VERSION.SDK_INT >= 17) {
apiAdapter = new Api17Adapter();
} else if (Build.VERSION.SDK_INT >= 16) {
apiAdapter = new Api16Adapter();
} else if (Build.VERSION.SDK_INT >= 14) {
apiAdapter = new Api14Adapter();
@@ -29,6 +29,7 @@ import android.widget.Spinner;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* Activity to configure the track widget.
@@ -124,7 +125,7 @@ public class TrackWidgetConfigActivity extends Activity {
}
private void addItem(List<CharSequence> list, int id) {
list.add(getString(id).toUpperCase());
list.add(getString(id).toUpperCase(Locale.getDefault()));
}
private void configSpinner(Spinner spinner, List<CharSequence> list, int position) {