Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions app/src/main/java/io/neurolab/activities/ShareDataActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ protected void onCreate(Bundle savedInstanceState) {
File appDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator +
CSV_DIRECTORY);
File[] files = appDir.listFiles();
fileList = new String[files.length];
newFileName = new String[files.length];

if (appDir.listFiles() != null && files.length > 0) {
fileList = new String[files.length];
newFileName = new String[files.length];
int j = 0;
for (int i = 0; i < files.length; i++) {
fileList[j] = files[i].getAbsolutePath();
Expand All @@ -79,18 +79,20 @@ protected void onCreate(Bundle savedInstanceState) {
Toast.makeText(this, R.string.share_screen_toast, Toast.LENGTH_SHORT).show();
}

if (appDir.listFiles().length == 0) {
if (appDir.listFiles() == null) {
numberOfFiles.setVisibility(View.VISIBLE);
numberOfFiles.setText(R.string.no_datasets_message);
shareButton.setVisibility(View.INVISIBLE);
}

final List<String> file_list = new ArrayList<String>(Arrays.asList(newFileName));
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_multiple_choice, file_list);
fileListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
fileListView.setItemsCanFocus(false);
fileListView.setAdapter(arrayAdapter);
if (newFileName != null) {
final List<String> file_list = new ArrayList<String>(Arrays.asList(newFileName));
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_multiple_choice, file_list);
fileListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
fileListView.setItemsCanFocus(false);
fileListView.setAdapter(arrayAdapter);
}

fileListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
Expand Down