Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.documentsui; |
| 18 | |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 19 | import android.app.Fragment; |
| 20 | import android.app.FragmentManager; |
| 21 | import android.app.FragmentTransaction; |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 22 | import android.app.LoaderManager.LoaderCallbacks; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 23 | import android.content.Context; |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 24 | import android.content.Intent; |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 25 | import android.content.Loader; |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 26 | import android.content.pm.PackageManager; |
| 27 | import android.content.pm.ResolveInfo; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 29 | import android.provider.DocumentsContract.Root; |
Jeff Sharkey | a35ac2d | 2013-09-10 12:04:26 -0700 | [diff] [blame] | 30 | import android.text.TextUtils; |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 31 | import android.text.format.Formatter; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 32 | import android.view.LayoutInflater; |
| 33 | import android.view.View; |
| 34 | import android.view.ViewGroup; |
| 35 | import android.widget.AdapterView; |
| 36 | import android.widget.AdapterView.OnItemClickListener; |
| 37 | import android.widget.ArrayAdapter; |
| 38 | import android.widget.ImageView; |
| 39 | import android.widget.ListView; |
Jeff Sharkey | 9656a53 | 2013-09-13 13:42:19 -0700 | [diff] [blame] | 40 | import android.widget.Space; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 41 | import android.widget.TextView; |
| 42 | |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 43 | import com.android.documentsui.DocumentsActivity.State; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 44 | import com.android.documentsui.SectionedListAdapter.SectionAdapter; |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 45 | import com.android.documentsui.model.DocumentInfo; |
| 46 | import com.android.documentsui.model.RootInfo; |
Jeff Sharkey | 42d2679 | 2013-09-06 13:22:09 -0700 | [diff] [blame] | 47 | import com.android.internal.util.Objects; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 48 | |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 49 | import java.util.Collection; |
Jeff Sharkey | b6a7f2c | 2013-08-27 18:26:48 -0700 | [diff] [blame] | 50 | import java.util.Comparator; |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 51 | import java.util.List; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Display list of known storage backend roots. |
| 55 | */ |
| 56 | public class RootsFragment extends Fragment { |
| 57 | |
| 58 | private ListView mList; |
| 59 | private SectionedRootsAdapter mAdapter; |
| 60 | |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 61 | private LoaderCallbacks<Collection<RootInfo>> mCallbacks; |
| 62 | |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 63 | private static final String EXTRA_INCLUDE_APPS = "includeApps"; |
| 64 | |
| 65 | public static void show(FragmentManager fm, Intent includeApps) { |
| 66 | final Bundle args = new Bundle(); |
| 67 | args.putParcelable(EXTRA_INCLUDE_APPS, includeApps); |
| 68 | |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 69 | final RootsFragment fragment = new RootsFragment(); |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 70 | fragment.setArguments(args); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 71 | |
| 72 | final FragmentTransaction ft = fm.beginTransaction(); |
| 73 | ft.replace(R.id.container_roots, fragment); |
| 74 | ft.commitAllowingStateLoss(); |
| 75 | } |
| 76 | |
| 77 | public static RootsFragment get(FragmentManager fm) { |
| 78 | return (RootsFragment) fm.findFragmentById(R.id.container_roots); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public View onCreateView( |
| 83 | LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
| 84 | final Context context = inflater.getContext(); |
| 85 | |
| 86 | final View view = inflater.inflate(R.layout.fragment_roots, container, false); |
| 87 | mList = (ListView) view.findViewById(android.R.id.list); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 88 | mList.setOnItemClickListener(mItemListener); |
Jeff Sharkey | 42d2679 | 2013-09-06 13:22:09 -0700 | [diff] [blame] | 89 | mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 90 | |
| 91 | return view; |
| 92 | } |
| 93 | |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 94 | @Override |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 95 | public void onActivityCreated(Bundle savedInstanceState) { |
| 96 | super.onActivityCreated(savedInstanceState); |
| 97 | |
| 98 | final Context context = getActivity(); |
| 99 | final RootsCache roots = DocumentsApplication.getRootsCache(context); |
| 100 | final State state = ((DocumentsActivity) context).getDisplayState(); |
| 101 | |
| 102 | mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() { |
| 103 | @Override |
| 104 | public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) { |
| 105 | return new RootsLoader(context, roots, state); |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public void onLoadFinished( |
| 110 | Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) { |
| 111 | if (!isAdded()) return; |
| 112 | |
| 113 | final Intent includeApps = getArguments().getParcelable(EXTRA_INCLUDE_APPS); |
| 114 | |
| 115 | mAdapter = new SectionedRootsAdapter(context, result, includeApps); |
| 116 | mList.setAdapter(mAdapter); |
| 117 | |
| 118 | onCurrentRootChanged(); |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public void onLoaderReset(Loader<Collection<RootInfo>> loader) { |
| 123 | mAdapter = null; |
| 124 | mList.setAdapter(null); |
| 125 | } |
| 126 | }; |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 127 | } |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 128 | |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 129 | @Override |
| 130 | public void onResume() { |
| 131 | super.onResume(); |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 132 | |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 133 | final Context context = getActivity(); |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 134 | final State state = ((DocumentsActivity) context).getDisplayState(); |
| 135 | state.showAdvanced = SettingsActivity.getDisplayAdvancedDevices(context); |
| 136 | |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 137 | getLoaderManager().restartLoader(2, null, mCallbacks); |
Jeff Sharkey | 42d2679 | 2013-09-06 13:22:09 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | public void onCurrentRootChanged() { |
| 141 | if (mAdapter == null) return; |
| 142 | |
| 143 | final RootInfo root = ((DocumentsActivity) getActivity()).getCurrentRoot(); |
| 144 | for (int i = 0; i < mAdapter.getCount(); i++) { |
| 145 | final Object item = mAdapter.getItem(i); |
| 146 | if (Objects.equal(item, root)) { |
| 147 | mList.setItemChecked(i, true); |
| 148 | return; |
| 149 | } |
| 150 | } |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 153 | private OnItemClickListener mItemListener = new OnItemClickListener() { |
| 154 | @Override |
| 155 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 156 | final DocumentsActivity activity = DocumentsActivity.get(RootsFragment.this); |
| 157 | final Object item = mAdapter.getItem(position); |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 158 | if (item instanceof RootInfo) { |
| 159 | activity.onRootPicked((RootInfo) item, true); |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 160 | } else if (item instanceof ResolveInfo) { |
| 161 | activity.onAppPicked((ResolveInfo) item); |
| 162 | } else { |
| 163 | throw new IllegalStateException("Unknown root: " + item); |
| 164 | } |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 165 | } |
| 166 | }; |
| 167 | |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 168 | private static class RootsAdapter extends ArrayAdapter<RootInfo> implements SectionAdapter { |
Jeff Sharkey | 9656a53 | 2013-09-13 13:42:19 -0700 | [diff] [blame] | 169 | public RootsAdapter(Context context) { |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 170 | super(context, 0); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public View getView(int position, View convertView, ViewGroup parent) { |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 175 | final Context context = parent.getContext(); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 176 | if (convertView == null) { |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 177 | convertView = LayoutInflater.from(context) |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 178 | .inflate(R.layout.item_root, parent, false); |
| 179 | } |
| 180 | |
| 181 | final ImageView icon = (ImageView) convertView.findViewById(android.R.id.icon); |
| 182 | final TextView title = (TextView) convertView.findViewById(android.R.id.title); |
| 183 | final TextView summary = (TextView) convertView.findViewById(android.R.id.summary); |
| 184 | |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 185 | final RootInfo root = getItem(position); |
Jeff Sharkey | b6a7f2c | 2013-08-27 18:26:48 -0700 | [diff] [blame] | 186 | icon.setImageDrawable(root.loadIcon(context)); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 187 | title.setText(root.title); |
| 188 | |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 189 | // Device summary is always available space |
| 190 | final String summaryText; |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 191 | if (root.rootType == Root.ROOT_TYPE_DEVICE && root.availableBytes >= 0) { |
Jeff Sharkey | c6cbdf1 | 2013-08-07 16:22:02 -0700 | [diff] [blame] | 192 | summaryText = context.getString(R.string.root_available_bytes, |
| 193 | Formatter.formatFileSize(context, root.availableBytes)); |
| 194 | } else { |
| 195 | summaryText = root.summary; |
| 196 | } |
| 197 | |
| 198 | summary.setText(summaryText); |
Jeff Sharkey | a35ac2d | 2013-09-10 12:04:26 -0700 | [diff] [blame] | 199 | summary.setVisibility(TextUtils.isEmpty(summaryText) ? View.GONE : View.VISIBLE); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 200 | |
| 201 | return convertView; |
| 202 | } |
| 203 | |
| 204 | @Override |
| 205 | public View getHeaderView(View convertView, ViewGroup parent) { |
| 206 | if (convertView == null) { |
Jeff Sharkey | 9656a53 | 2013-09-13 13:42:19 -0700 | [diff] [blame] | 207 | convertView = new Space(parent.getContext()); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 208 | } |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 209 | return convertView; |
| 210 | } |
| 211 | } |
| 212 | |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 213 | private static class AppsAdapter extends ArrayAdapter<ResolveInfo> implements SectionAdapter { |
| 214 | public AppsAdapter(Context context) { |
| 215 | super(context, 0); |
| 216 | } |
| 217 | |
| 218 | @Override |
| 219 | public View getView(int position, View convertView, ViewGroup parent) { |
| 220 | final Context context = parent.getContext(); |
| 221 | final PackageManager pm = context.getPackageManager(); |
| 222 | if (convertView == null) { |
| 223 | convertView = LayoutInflater.from(context) |
| 224 | .inflate(R.layout.item_root, parent, false); |
| 225 | } |
| 226 | |
| 227 | final ImageView icon = (ImageView) convertView.findViewById(android.R.id.icon); |
| 228 | final TextView title = (TextView) convertView.findViewById(android.R.id.title); |
| 229 | final TextView summary = (TextView) convertView.findViewById(android.R.id.summary); |
| 230 | |
| 231 | final ResolveInfo info = getItem(position); |
| 232 | icon.setImageDrawable(info.loadIcon(pm)); |
| 233 | title.setText(info.loadLabel(pm)); |
| 234 | |
| 235 | // TODO: match existing summary behavior from disambig dialog |
| 236 | summary.setVisibility(View.GONE); |
| 237 | |
| 238 | return convertView; |
| 239 | } |
| 240 | |
| 241 | @Override |
| 242 | public View getHeaderView(View convertView, ViewGroup parent) { |
| 243 | if (convertView == null) { |
| 244 | convertView = LayoutInflater.from(parent.getContext()) |
| 245 | .inflate(R.layout.item_root_header, parent, false); |
| 246 | } |
| 247 | |
| 248 | final TextView title = (TextView) convertView.findViewById(android.R.id.title); |
| 249 | title.setText(R.string.root_type_apps); |
| 250 | |
| 251 | return convertView; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | private static class SectionedRootsAdapter extends SectionedListAdapter { |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 256 | private final RootsAdapter mServices; |
| 257 | private final RootsAdapter mShortcuts; |
| 258 | private final RootsAdapter mDevices; |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 259 | private final AppsAdapter mApps; |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 260 | |
Jeff Sharkey | 8b99704 | 2013-09-19 15:25:56 -0700 | [diff] [blame^] | 261 | public SectionedRootsAdapter( |
| 262 | Context context, Collection<RootInfo> roots, Intent includeApps) { |
Jeff Sharkey | 9656a53 | 2013-09-13 13:42:19 -0700 | [diff] [blame] | 263 | mServices = new RootsAdapter(context); |
| 264 | mShortcuts = new RootsAdapter(context); |
| 265 | mDevices = new RootsAdapter(context); |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 266 | mApps = new AppsAdapter(context); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 267 | |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 268 | for (RootInfo root : roots) { |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 269 | switch (root.rootType) { |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 270 | case Root.ROOT_TYPE_SERVICE: |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 271 | mServices.add(root); |
| 272 | break; |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 273 | case Root.ROOT_TYPE_SHORTCUT: |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 274 | mShortcuts.add(root); |
| 275 | break; |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 276 | case Root.ROOT_TYPE_DEVICE: |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 277 | mDevices.add(root); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 278 | break; |
| 279 | } |
| 280 | } |
| 281 | |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 282 | if (includeApps != null) { |
| 283 | final PackageManager pm = context.getPackageManager(); |
| 284 | final List<ResolveInfo> infos = pm.queryIntentActivities( |
| 285 | includeApps, PackageManager.MATCH_DEFAULT_ONLY); |
| 286 | |
| 287 | // Omit ourselves from the list |
| 288 | for (ResolveInfo info : infos) { |
| 289 | if (!context.getPackageName().equals(info.activityInfo.packageName)) { |
| 290 | mApps.add(info); |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 295 | final RootComparator comp = new RootComparator(); |
| 296 | mServices.sort(comp); |
| 297 | mShortcuts.sort(comp); |
| 298 | mDevices.sort(comp); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 299 | |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 300 | if (mShortcuts.getCount() > 0) { |
| 301 | addSection(mShortcuts); |
| 302 | } |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 303 | if (mDevices.getCount() > 0) { |
| 304 | addSection(mDevices); |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 305 | } |
Jeff Sharkey | 9656a53 | 2013-09-13 13:42:19 -0700 | [diff] [blame] | 306 | if (mServices.getCount() > 0) { |
| 307 | addSection(mServices); |
| 308 | } |
Jeff Sharkey | 1d890e0 | 2013-08-15 11:24:03 -0700 | [diff] [blame] | 309 | if (mApps.getCount() > 0) { |
| 310 | addSection(mApps); |
| 311 | } |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
Jeff Sharkey | b6a7f2c | 2013-08-27 18:26:48 -0700 | [diff] [blame] | 314 | |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 315 | public static class RootComparator implements Comparator<RootInfo> { |
Jeff Sharkey | b6a7f2c | 2013-08-27 18:26:48 -0700 | [diff] [blame] | 316 | @Override |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 317 | public int compare(RootInfo lhs, RootInfo rhs) { |
Jeff Sharkey | 1c903cc | 2013-09-02 17:19:40 -0700 | [diff] [blame] | 318 | if (lhs.authority == null) { |
| 319 | return -1; |
| 320 | } else if (rhs.authority == null) { |
| 321 | return 1; |
| 322 | } |
| 323 | |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 324 | final int score = DocumentInfo.compareToIgnoreCaseNullable(lhs.title, rhs.title); |
Jeff Sharkey | b6a7f2c | 2013-08-27 18:26:48 -0700 | [diff] [blame] | 325 | if (score != 0) { |
| 326 | return score; |
| 327 | } else { |
Jeff Sharkey | 724deeb | 2013-08-31 15:02:20 -0700 | [diff] [blame] | 328 | return DocumentInfo.compareToIgnoreCaseNullable(lhs.summary, rhs.summary); |
Jeff Sharkey | b6a7f2c | 2013-08-27 18:26:48 -0700 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | } |
Jeff Sharkey | 7611221 | 2013-08-06 11:26:10 -0700 | [diff] [blame] | 332 | } |