зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1029682 - (Part 1) Remove AutoCompleteRowView. r=eedens
This commit is contained in:
Родитель
528d356c6d
Коммит
589d0ae7c8
|
@ -5,9 +5,14 @@
|
|||
package org.mozilla.search.autocomplete;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mozilla.search.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,6 +23,8 @@ class AutoCompleteAdapter extends ArrayAdapter<String> {
|
|||
|
||||
private final AcceptsJumpTaps acceptsJumpTaps;
|
||||
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public AutoCompleteAdapter(Context context, AcceptsJumpTaps acceptsJumpTaps) {
|
||||
// Uses '0' for the template id since we are overriding getView
|
||||
// and supplying our own view.
|
||||
|
@ -26,22 +33,30 @@ class AutoCompleteAdapter extends ArrayAdapter<String> {
|
|||
|
||||
// Disable notifying on change. We will notify ourselves in update.
|
||||
setNotifyOnChange(false);
|
||||
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
AutoCompleteRowView view;
|
||||
|
||||
if (convertView == null) {
|
||||
view = new AutoCompleteRowView(getContext());
|
||||
} else {
|
||||
view = (AutoCompleteRowView) convertView;
|
||||
convertView = inflater.inflate(R.layout.search_auto_complete_row, null);
|
||||
}
|
||||
|
||||
view.setOnJumpListener(acceptsJumpTaps);
|
||||
view.setMainText(getItem(position));
|
||||
final String text = getItem(position);
|
||||
|
||||
return view;
|
||||
final TextView textView = (TextView) convertView.findViewById(R.id.auto_complete_row_text);
|
||||
textView.setText(text);
|
||||
|
||||
final View jumpButton = convertView.findViewById(R.id.auto_complete_row_jump_button);
|
||||
jumpButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
acceptsJumpTaps.onJumpTap(text);
|
||||
}
|
||||
});
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.search.autocomplete;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mozilla.search.R;
|
||||
|
||||
/**
|
||||
* One row withing the autocomplete suggestion list.
|
||||
*/
|
||||
class AutoCompleteRowView extends LinearLayout {
|
||||
|
||||
private TextView textView;
|
||||
private AcceptsJumpTaps onJumpListener;
|
||||
|
||||
public AutoCompleteRowView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setOrientation(LinearLayout.HORIZONTAL);
|
||||
setGravity(Gravity.CENTER_VERTICAL);
|
||||
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.search_auto_complete_row, this, true);
|
||||
|
||||
textView = (TextView) findViewById(R.id.auto_complete_row_text);
|
||||
|
||||
findViewById(R.id.auto_complete_row_jump_button).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (null == onJumpListener) {
|
||||
Log.e("SuggestionRow.onJump", "jump listener is null");
|
||||
return;
|
||||
}
|
||||
|
||||
onJumpListener.onJumpTap(textView.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMainText(String s) {
|
||||
textView.setText(s);
|
||||
}
|
||||
|
||||
public void setOnJumpListener(AcceptsJumpTaps onJumpListener) {
|
||||
this.onJumpListener = onJumpListener;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ search_activity_sources = [
|
|||
'java/org/mozilla/search/autocomplete/AcceptsJumpTaps.java',
|
||||
'java/org/mozilla/search/autocomplete/AcceptsSearchQuery.java',
|
||||
'java/org/mozilla/search/autocomplete/AutoCompleteAdapter.java',
|
||||
'java/org/mozilla/search/autocomplete/AutoCompleteRowView.java',
|
||||
'java/org/mozilla/search/autocomplete/SearchFragment.java',
|
||||
'java/org/mozilla/search/autocomplete/SuggestClient.java',
|
||||
'java/org/mozilla/search/Constants.java',
|
||||
|
|
Загрузка…
Ссылка в новой задаче