Java Code Examples for com.pluscubed.logcat.util.ArrayUtil#indexOf()
The following examples show how to use
com.pluscubed.logcat.util.ArrayUtil#indexOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsActivity.java From matlog with GNU General Public License v3.0 | 6 votes |
private void setBufferPreferenceSummary(String value) { String[] commaSeparated = StringUtil.split(StringUtil.nullToEmpty(value), MultipleChoicePreference.DELIMITER); List<CharSequence> checkedEntries = new ArrayList<>(); for (String entryValue : commaSeparated) { int idx = ArrayUtil.indexOf(bufferPreference.getEntryValues(), entryValue); checkedEntries.add(bufferPreference.getEntries()[idx]); } String summary = TextUtils.join(getString(R.string.delimiter), checkedEntries); // add the word "simultaneous" to make it clearer what's going on with 2+ buffers if (checkedEntries.size() > 1) { summary += getString(R.string.simultaneous); } bufferPreference.setSummary(summary); }
Example 2
Source File: LogcatActivity.java From matlog with GNU General Public License v3.0 | 6 votes |
private void showLogLevelDialog() { String[] logLevels = getResources().getStringArray(R.array.log_levels); // put the word "default" after whatever the default log level is String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this)); int index = ArrayUtil.indexOf(getResources().getStringArray(R.array.log_levels_values), defaultLogLevel); logLevels[index] = logLevels[index] + " " + getString(R.string.default_in_parens); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.log_level) .setCancelable(true) .setSingleChoiceItems(logLevels, mLogListAdapter.getLogLevelLimit(), (dialog, which) -> { mLogListAdapter.setLogLevelLimit(which); logLevelChanged(); dialog.dismiss(); }); builder.show(); }
Example 3
Source File: LogcatActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private void showLogLevelDialog() { String[] logLevels = getResources().getStringArray(R.array.log_levels); // put the word "default" after whatever the default log level is String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this)); int index = ArrayUtil.indexOf(getResources().getStringArray(R.array.log_levels_values), defaultLogLevel); logLevels[index] = logLevels[index] + " " + getString(R.string.default_in_parens); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.log_level) .setCancelable(true) .setSingleChoiceItems(logLevels, mLogListAdapter.getLogLevelLimit(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mLogListAdapter.setLogLevelLimit(which); logLevelChanged(); dialog.dismiss(); } }); builder.show(); }
Example 4
Source File: SettingsActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private void setBufferPreferenceSummary(String value) { String[] commaSeparated = StringUtil.split(StringUtil.nullToEmpty(value), MultipleChoicePreference.DELIMITER); List<CharSequence> checkedEntries = new ArrayList<CharSequence>(); for (String entryValue : commaSeparated) { int idx = ArrayUtil.indexOf(bufferPreference.getEntryValues(), entryValue); checkedEntries.add(bufferPreference.getEntries()[idx]); } String summary = TextUtils.join(getString(R.string.delimiter), checkedEntries); // add the word "simultaneous" to make it clearer what's going on with 2+ buffers if (checkedEntries.size() > 1) { summary += getString(R.string.simultaneous); } bufferPreference.setSummary(summary); }
Example 5
Source File: SettingsActivity.java From javaide with GNU General Public License v3.0 | 6 votes |
private void setBufferPreferenceSummary(String value) { String[] commaSeparated = StringUtil.split(StringUtil.nullToEmpty(value), MultipleChoicePreference.DELIMITER); List<CharSequence> checkedEntries = new ArrayList<CharSequence>(); for (String entryValue : commaSeparated) { int idx = ArrayUtil.indexOf(bufferPreference.getEntryValues(), entryValue); checkedEntries.add(bufferPreference.getEntries()[idx]); } String summary = TextUtils.join(getString(R.string.delimiter), checkedEntries); // add the word "simultaneous" to make it clearer what's going on with 2+ buffers if (checkedEntries.size() > 1) { summary += getString(R.string.simultaneous); } bufferPreference.setSummary(summary); }
Example 6
Source File: LogcatActivity.java From javaide with GNU General Public License v3.0 | 6 votes |
private void showLogLevelDialog() { String[] logLevels = getResources().getStringArray(R.array.log_levels); // put the word "default" after whatever the default log level is String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this)); int index = ArrayUtil.indexOf(getResources().getStringArray(R.array.log_levels_values), defaultLogLevel); logLevels[index] = logLevels[index] + " " + getString(R.string.default_in_parens); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.log_level) .setCancelable(true) .setSingleChoiceItems(logLevels, mLogListAdapter.getLogLevelLimit(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mLogListAdapter.setLogLevelLimit(which); logLevelChanged(); dialog.dismiss(); } }); builder.show(); }
Example 7
Source File: LogcatActivity.java From javaide with GNU General Public License v3.0 | 5 votes |
private void resetFilter() { String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this)); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, defaultLogLevel); mLogListAdapter.setLogLevelLimit(logLevelLimit); logLevelChanged(); }
Example 8
Source File: LogcatActivity.java From matlog with GNU General Public License v3.0 | 5 votes |
private void resetFilter() { String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this)); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, defaultLogLevel); mLogListAdapter.setLogLevelLimit(logLevelLimit); logLevelChanged(); }
Example 9
Source File: LogcatActivity.java From matlog with GNU General Public License v3.0 | 5 votes |
private void doAfterInitialMessage(Intent intent) { // handle an intent that was sent from an external application if (intent != null && Intents.ACTION_LAUNCH.equals(intent.getAction())) { String filter = intent.getStringExtra(Intents.EXTRA_FILTER); String level = intent.getStringExtra(Intents.EXTRA_LEVEL); if (!TextUtils.isEmpty(filter)) { setSearchText(filter); } if (!TextUtils.isEmpty(level)) { CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, level.toUpperCase(Locale.US)); if (logLevelLimit == -1) { String invalidLevel = getString(R.string.toast_invalid_level, level); Toast.makeText(this, invalidLevel, Toast.LENGTH_LONG).show(); } else { mLogListAdapter.setLogLevelLimit(logLevelLimit); logLevelChanged(); } } } }
Example 10
Source File: LogcatActivity.java From javaide with GNU General Public License v3.0 | 5 votes |
private void doAfterInitialMessage(Intent intent) { // handle an intent that was sent from an external application if (intent != null && Intents.ACTION_LAUNCH.equals(intent.getAction())) { String filter = intent.getStringExtra(Intents.EXTRA_FILTER); String level = intent.getStringExtra(Intents.EXTRA_LEVEL); if (!TextUtils.isEmpty(filter)) { setSearchText(filter); } if (!TextUtils.isEmpty(level)) { CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, level.toUpperCase(Locale.US)); if (logLevelLimit == -1) { String invalidLevel = getString(R.string.toast_invalid_level, level); Toast.makeText(this, invalidLevel, Toast.LENGTH_LONG).show(); } else { mLogListAdapter.setLogLevelLimit(logLevelLimit); logLevelChanged(); } } } }
Example 11
Source File: LogcatActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
private void resetFilter() { String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(this)); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, defaultLogLevel); mLogListAdapter.setLogLevelLimit(logLevelLimit); logLevelChanged(); }
Example 12
Source File: LogcatActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
private void doAfterInitialMessage(Intent intent) { // handle an intent that was sent from an external application if (intent != null && Intents.ACTION_LAUNCH.equals(intent.getAction())) { String filter = intent.getStringExtra(Intents.EXTRA_FILTER); String level = intent.getStringExtra(Intents.EXTRA_LEVEL); if (!TextUtils.isEmpty(filter)) { setSearchText(filter); } if (!TextUtils.isEmpty(level)) { CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, level.toUpperCase(Locale.US)); if (logLevelLimit == -1) { String invalidLevel = getString(R.string.toast_invalid_level, level); Toast.makeText(this, invalidLevel, Toast.LENGTH_LONG).show(); } else { mLogListAdapter.setLogLevelLimit(logLevelLimit); logLevelChanged(); } } } }
Example 13
Source File: DialogHelper.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public static void showFilterDialogForRecording(final Context context, final String queryFilterText, final String logLevelText, final List<String> filterQuerySuggestions, final Callback<FilterQueryWithLevel> callback) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") View filterView = inflater.inflate(R.layout.dialog_recording_filter, null, false); // add suggestions to autocompletetextview final AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) filterView.findViewById(android.R.id.text1); autoCompleteTextView.setText(queryFilterText); SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<String>( context, R.layout.list_item_dropdown, filterQuerySuggestions); autoCompleteTextView.setAdapter(suggestionAdapter); // set values on spinner to be the log levels final Spinner spinner = (Spinner) filterView.findViewById(R.id.spinner); // put the word "default" after whatever the default log level is CharSequence[] logLevels = context.getResources().getStringArray(R.array.log_levels); String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(context)); int index = ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), defaultLogLevel); logLevels[index] = logLevels[index].toString() + " " + context.getString(R.string.default_in_parens); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>( context, android.R.layout.simple_spinner_item, logLevels); adapter.setDropDownViewResource(R.layout.list_item_dropdown); spinner.setAdapter(adapter); // in case the user has changed it, choose the pre-selected log level spinner.setSelection(ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), logLevelText)); // create alertdialog for the "Filter..." button new MaterialDialog.Builder(context) .title(R.string.title_filter) .customView(filterView, true) .negativeText(android.R.string.cancel) .positiveText(android.R.string.ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { int logLevelIdx = spinner.getSelectedItemPosition(); String[] logLevelValues = context.getResources().getStringArray(R.array.log_levels_values); String logLevelValue = logLevelValues[logLevelIdx]; String filterQuery = autoCompleteTextView.getText().toString(); callback.onCallback(new FilterQueryWithLevel(filterQuery, logLevelValue)); } }) .show(); }
Example 14
Source File: LogcatRecordingService.java From javaide with GNU General Public License v3.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(getApplicationContext()); while ((line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 15
Source File: DialogHelper.java From matlog with GNU General Public License v3.0 | 4 votes |
public static void showFilterDialogForRecording(final Context context, final String queryFilterText, final String logLevelText, final List<String> filterQuerySuggestions, final Callback<FilterQueryWithLevel> callback) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") View filterView = inflater.inflate(R.layout.dialog_recording_filter, null, false); // add suggestions to autocompletetextview final AutoCompleteTextView autoCompleteTextView = filterView.findViewById(android.R.id.text1); autoCompleteTextView.setText(queryFilterText); SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<>( context, R.layout.list_item_dropdown, filterQuerySuggestions); autoCompleteTextView.setAdapter(suggestionAdapter); // set values on spinner to be the log levels final Spinner spinner = filterView.findViewById(R.id.spinner); // put the word "default" after whatever the default log level is CharSequence[] logLevels = context.getResources().getStringArray(R.array.log_levels); String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(context)); int index = ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), defaultLogLevel); logLevels[index] = logLevels[index].toString() + " " + context.getString(R.string.default_in_parens); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>( context, android.R.layout.simple_spinner_item, logLevels); adapter.setDropDownViewResource(R.layout.list_item_dropdown); spinner.setAdapter(adapter); // in case the user has changed it, choose the pre-selected log level spinner.setSelection(ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), logLevelText)); // create alertdialog for the "Filter..." button new MaterialDialog.Builder(context) .title(R.string.title_filter) .customView(filterView, true) .negativeText(android.R.string.cancel) .positiveText(android.R.string.ok) .onPositive((dialog, which) -> { int logLevelIdx = spinner.getSelectedItemPosition(); String[] logLevelValues = context.getResources().getStringArray(R.array.log_levels_values); String logLevelValue = logLevelValues[logLevelIdx]; String filterQuery = autoCompleteTextView.getText().toString(); callback.onCallback(new FilterQueryWithLevel(filterQuery, logLevelValue)); }) .show(); }
Example 16
Source File: LogcatRecordingService.java From matlog with GNU General Public License v3.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(this); String filterPattern = PreferenceHelper.getFilterPatternPreference(this); while (mReader != null && (line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit, filterPattern)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }
Example 17
Source File: DialogHelper.java From javaide with GNU General Public License v3.0 | 4 votes |
public static void showFilterDialogForRecording(final Context context, final String queryFilterText, final String logLevelText, final List<String> filterQuerySuggestions, final Callback<FilterQueryWithLevel> callback) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @SuppressLint("InflateParams") View filterView = inflater.inflate(R.layout.dialog_recording_filter, null, false); // add suggestions to autocompletetextview final AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) filterView.findViewById(android.R.id.text1); autoCompleteTextView.setText(queryFilterText); SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<String>( context, R.layout.list_item_dropdown, filterQuerySuggestions); autoCompleteTextView.setAdapter(suggestionAdapter); // set values on spinner to be the log levels final Spinner spinner = (Spinner) filterView.findViewById(R.id.spinner); // put the word "default" after whatever the default log level is CharSequence[] logLevels = context.getResources().getStringArray(R.array.log_levels); String defaultLogLevel = Character.toString(PreferenceHelper.getDefaultLogLevelPreference(context)); int index = ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), defaultLogLevel); logLevels[index] = logLevels[index].toString() + " " + context.getString(R.string.default_in_parens); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>( context, android.R.layout.simple_spinner_item, logLevels); adapter.setDropDownViewResource(R.layout.list_item_dropdown); spinner.setAdapter(adapter); // in case the user has changed it, choose the pre-selected log level spinner.setSelection(ArrayUtil.indexOf(context.getResources().getStringArray(R.array.log_levels_values), logLevelText)); // create alertdialog for the "Filter..." button new MaterialDialog.Builder(context) .title(R.string.title_filter) .customView(filterView, true) .negativeText(android.R.string.cancel) .positiveText(android.R.string.ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { int logLevelIdx = spinner.getSelectedItemPosition(); String[] logLevelValues = context.getResources().getStringArray(R.array.log_levels_values); String logLevelValue = logLevelValues[logLevelIdx]; String filterQuery = autoCompleteTextView.getText().toString(); callback.onCallback(new FilterQueryWithLevel(filterQuery, logLevelValue)); } }) .show(); }
Example 18
Source File: LogcatRecordingService.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
private void handleIntent(Intent intent) { log.d("Starting up %s now with intent: %s", LogcatRecordingService.class.getSimpleName(), intent); String filename = intent.getStringExtra(EXTRA_FILENAME); String queryText = intent.getStringExtra(EXTRA_QUERY_FILTER); String logLevel = intent.getStringExtra(EXTRA_LEVEL); SearchCriteria searchCriteria = new SearchCriteria(queryText); CharSequence[] logLevels = getResources().getStringArray(R.array.log_levels_values); int logLevelLimit = ArrayUtil.indexOf(logLevels, logLevel); boolean searchCriteriaWillAlwaysMatch = searchCriteria.isEmpty(); boolean logLevelAcceptsEverything = logLevelLimit == 0; SaveLogHelper.deleteLogIfExists(filename); initializeReader(intent); StringBuilder stringBuilder = new StringBuilder(); try { String line; int lineCount = 0; int logLinePeriod = PreferenceHelper.getLogLinePeriodPreference(getApplicationContext()); while ((line = mReader.readLine()) != null && !mKilled) { // filter if (!searchCriteriaWillAlwaysMatch || !logLevelAcceptsEverything) { if (!checkLogLine(line, searchCriteria, logLevelLimit)) { continue; } } stringBuilder.append(line).append("\n"); if (++lineCount % logLinePeriod == 0) { // avoid OutOfMemoryErrors; flush now SaveLogHelper.saveLog(stringBuilder, filename); stringBuilder.delete(0, stringBuilder.length()); // clear } } } catch (IOException e) { log.e(e, "unexpected exception"); } finally { killProcess(); log.d("CatlogService ended"); boolean logSaved = SaveLogHelper.saveLog(stringBuilder, filename); if (logSaved) { makeToast(R.string.log_saved, Toast.LENGTH_SHORT); startLogcatActivityToViewSavedFile(filename); } else { makeToast(R.string.unable_to_save_log, Toast.LENGTH_LONG); } } }