<commit_before>package org.mtransit.android.ui.view;

import java.lang.ref.WeakReference;

import org.mtransit.android.R;
import org.mtransit.android.commons.KeyboardUtils;
import org.mtransit.android.commons.MTLog;
import org.mtransit.android.ui.MainActivity;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SearchView;

public class MTSearchView extends SearchView implements MTLog.Loggable, View.OnFocusChangeListener, SearchView.OnCloseListener, SearchView.OnQueryTextListener {

	private static final String TAG = MTSearchView.class.getSimpleName();

	@Override
	public String getLogTag() {
		return TAG;
	}

	public MTSearchView(MainActivity mainActivity, Context context) {
		super(context);
		init(mainActivity);
	}

	public MTSearchView(MainActivity mainActivity, Context context, AttributeSet attrs) {
		super(context, attrs);
		init(mainActivity);
	}

	@TargetApi(Build.VERSION_CODES.LOLLIPOP)
	public MTSearchView(MainActivity mainActivity, Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		init(mainActivity);
	}

	@TargetApi(Build.VERSION_CODES.LOLLIPOP)
	public MTSearchView(MainActivity mainActivity, Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		super(context, attrs, defStyleAttr, defStyleRes);
		init(mainActivity);
	}

	private WeakReference<MainActivity> mainActivityWR;

	private void init(MainActivity mainActivity) {
		this.mainActivityWR = new WeakReference<MainActivity>(mainActivity);
		setQueryHint(getContext().getString(R.string.search_hint));
		setIconifiedByDefault(true);
		setOnQueryTextListener(this);
		setOnQueryTextFocusChangeListener(this);
		setOnCloseListener(this);
		setIconified(false);
	}

	@Override
	public boolean onQueryTextChange(String newText) {
		MainActivity mainActivity = this.mainActivityWR == null ? null : this.mainActivityWR.get();
		if (mainActivity != null) {
			mainActivity.onSearchRequested(newText);
		}
		return true; // handled
	}

	@Override
	public boolean onQueryTextSubmit(String query) {
		MainActivity mainActivity = this.mainActivityWR == null ? null : this.mainActivityWR.get();
		if (mainActivity != null) {
			mainActivity.onSearchRequested(query);
			KeyboardUtils.hideKeyboard(mainActivity, this);
		}
		return true; // handled
	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		if (!hasFocus) {
			MainActivity mainActivity = this.mainActivityWR == null ? null : this.mainActivityWR.get();
			if (mainActivity != null) {
				KeyboardUtils.hideKeyboard(mainActivity, this);
			}
		}
	}

	@Override
	public boolean onClose() {
		return true; // do not close
	}

}
<commit_msg>Lint cleanup<commit_after>package org.mtransit.android.ui.view;

import java.lang.ref.WeakReference;

import org.mtransit.android.R;
import org.mtransit.android.commons.KeyboardUtils;
import org.mtransit.android.commons.MTLog;
import org.mtransit.android.ui.MainActivity;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SearchView;

@SuppressLint("ViewConstructor")
public class MTSearchView extends SearchView implements MTLog.Loggable, View.OnFocusChangeListener, SearchView.OnCloseListener, SearchView.OnQueryTextListener {

	private static final String TAG = MTSearchView.class.getSimpleName();

	@Override
	public String getLogTag() {
		return TAG;
	}

	public MTSearchView(MainActivity mainActivity, Context context) {
		super(context);
		init(mainActivity);
	}

	public MTSearchView(MainActivity mainActivity, Context context, AttributeSet attrs) {
		super(context, attrs);
		init(mainActivity);
	}

	@TargetApi(Build.VERSION_CODES.LOLLIPOP)
	public MTSearchView(MainActivity mainActivity, Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		init(mainActivity);
	}

	@TargetApi(Build.VERSION_CODES.LOLLIPOP)
	public MTSearchView(MainActivity mainActivity, Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		super(context, attrs, defStyleAttr, defStyleRes);
		init(mainActivity);
	}

	private WeakReference<MainActivity> mainActivityWR;

	private void init(MainActivity mainActivity) {
		this.mainActivityWR = new WeakReference<MainActivity>(mainActivity);
		setQueryHint(getContext().getString(R.string.search_hint));
		setIconifiedByDefault(true);
		setOnQueryTextListener(this);
		setOnQueryTextFocusChangeListener(this);
		setOnCloseListener(this);
		setIconified(false);
	}

	@Override
	public boolean onQueryTextChange(String newText) {
		MainActivity mainActivity = this.mainActivityWR == null ? null : this.mainActivityWR.get();
		if (mainActivity != null) {
			mainActivity.onSearchRequested(newText);
		}
		return true; // handled
	}

	@Override
	public boolean onQueryTextSubmit(String query) {
		MainActivity mainActivity = this.mainActivityWR == null ? null : this.mainActivityWR.get();
		if (mainActivity != null) {
			mainActivity.onSearchRequested(query);
			KeyboardUtils.hideKeyboard(mainActivity, this);
		}
		return true; // handled
	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		if (!hasFocus) {
			MainActivity mainActivity = this.mainActivityWR == null ? null : this.mainActivityWR.get();
			if (mainActivity != null) {
				KeyboardUtils.hideKeyboard(mainActivity, this);
			}
		}
	}

	@Override
	public boolean onClose() {
		return true; // do not close
	}

}

{'fraction_non_alphanumeric': 0.10039020929407591, 'fraction_numerical': 0.0, 'mean_word_length': 5.721096543504172, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '249233', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1715, 'n_words': 358}