com.pluscubed.logcat.data.LogFileAdapter Java Examples
The following examples show how to use
com.pluscubed.logcat.data.LogFileAdapter.
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: LogcatActivity.java From matlog with GNU General Public License v3.0 | 4 votes |
private void startDeleteSavedLogsDialog() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, DELETE_SAVED_LOG_REQUEST); return; } if (!SaveLogHelper.checkSdCard(this)) { return; } List<CharSequence> filenames = new ArrayList<>(SaveLogHelper.getLogFilenames()); if (filenames.isEmpty()) { Toast.makeText(this, R.string.no_saved_logs, Toast.LENGTH_SHORT).show(); return; } final CharSequence[] filenameArray = ArrayUtil.toArray(filenames, CharSequence.class); final LogFileAdapter logFileAdapter = new LogFileAdapter(this, filenames, -1, true); @SuppressLint("InflateParams") LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_delete_logfiles, null); ListView view = layout.findViewById(R.id.list); view.setAdapter(logFileAdapter); MaterialDialog.Builder builder = new MaterialDialog.Builder(this); builder.title(R.string.manage_saved_logs) .customView(layout, false) .negativeText(android.R.string.cancel) .neutralText(R.string.delete_all) .onNeutral((dialog, which) -> { boolean[] allChecked = new boolean[logFileAdapter.getCount()]; for (int i = 0; i < allChecked.length; i++) { allChecked[i] = true; } verifyDelete(filenameArray, allChecked, dialog); }) .onPositive((dialog, which) -> verifyDelete(filenameArray, logFileAdapter.getCheckedItems(), dialog)) .positiveText(R.string.delete); builder.show(); view.setOnItemClickListener((parent, view1, position, id) -> logFileAdapter.checkOrUncheck(position)); }
Example #2
Source File: LogcatActivity.java From matlog with GNU General Public License v3.0 | 4 votes |
private void showOpenLogFileDialog() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, OPEN_LOG_REQUEST); return; } if (!SaveLogHelper.checkSdCard(this)) { return; } final List<CharSequence> filenames = new ArrayList<>(SaveLogHelper.getLogFilenames()); if (filenames.isEmpty()) { Toast.makeText(this, R.string.no_saved_logs, Toast.LENGTH_SHORT).show(); return; } int logToSelect = mCurrentlyOpenLog != null ? filenames.indexOf(mCurrentlyOpenLog) : -1; ArrayAdapter<CharSequence> logFileAdapter = new LogFileAdapter(this, filenames, logToSelect, false); ListView view = new ListView(this); view.setAdapter(logFileAdapter); view.setDivider(null); view.setDividerHeight(0); MaterialDialog.Builder builder = new MaterialDialog.Builder(this); builder.title(R.string.open_log) .customView(view, false); final MaterialDialog dialog = builder.show(); view.setOnItemClickListener((parent, view1, position, id) -> { dialog.dismiss(); String filename = filenames.get(position).toString(); openLogFile(filename); }); }