abis = new LinkedList<>();
abis.add(Build.CPU_ABI);
if (Build.CPU_ABI2 != null && !"unknown".equals(Build.CPU_ABI2)) {
abis.add(Build.CPU_ABI2);
}
return abis;
}
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
*
* See the Android Training lesson Communicating with Other Fragments for more information.
*/
public interface OnLogSubmittedListener {
public void onSuccess();
public void onFailure();
public void onCancel();
}
private static final class LogPreviewAdapter extends RecyclerView.Adapter {
private String[] lines = new String[0];
@Override
public LogPreviewViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new LogPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_log_preview, parent, false));
}
@Override
public void onBindViewHolder(LogPreviewViewHolder holder, int position) {
holder.bind(lines, position);
}
@Override
public void onViewRecycled(LogPreviewViewHolder holder) {
holder.unbind();
}
@Override
public int getItemCount() {
return lines.length;
}
void setText(@NonNull String text) {
lines = text.split("\n");
notifyDataSetChanged();
}
String getText() {
return Util.join(lines, "\n");
}
}
private static final class LogPreviewViewHolder extends RecyclerView.ViewHolder {
private EditText text;
private String[] lines;
private int index;
LogPreviewViewHolder(View itemView) {
super(itemView);
text = (EditText) itemView;
}
void bind(String[] lines, int index) {
this.lines = lines;
this.index = index;
text.setText(lines[index]);
text.addTextChangedListener(textWatcher);
}
void unbind() {
text.removeTextChangedListener(textWatcher);
}
private final SimpleTextWatcher textWatcher = new SimpleTextWatcher() {
@Override
public void onTextChanged(String text) {
if (lines != null) {
lines[index] = text;
}
}
};
}
}