FileBrowserActivity.java
Go to the documentation of this file.
1 package com.intel.realsense.camera;
2 
3 import android.content.Intent;
4 import android.os.Bundle;
5 import android.os.Environment;
6 import androidx.appcompat.app.AppCompatActivity;
7 import android.view.View;
8 import android.widget.AdapterView;
9 import android.widget.ArrayAdapter;
10 import android.widget.ListView;
11 import android.widget.TextView;
12 
13 import java.io.File;
14 
15 public class FileBrowserActivity extends AppCompatActivity {
16 
17  private String mFolder = "";
18 
19  @Override
20  protected void onCreate(Bundle savedInstanceState) {
21  super.onCreate(savedInstanceState);
22  setContentView(R.layout.activity_list_view);
23  mFolder = getIntent().getStringExtra(getString(R.string.browse_folder));
24  }
25 
26  @Override
27  protected void onResume() {
28  super.onResume();
29 
30  TextView message = findViewById(R.id.list_view_title);
31 
32  File folder = new File(getExternalFilesDir(null).getAbsolutePath() + File.separator + mFolder);
33  if(!folder.exists()) {
34  message.setText("No RealSense files found");
35  return;
36  }
37  final File[] files = folder.listFiles();
38 
39  if(files.length == 0) {
40  message.setText("No RealSense files found");
41  return;
42  }
43 
44  message.setText("Select a file to play from:");
45 
46  String[] filesNames = new String[files.length];
47  final ListView listview = findViewById(R.id.list_view);
48 
49  for (int i = 0; i < files.length; ++i) {
50  String path = files[i].getAbsolutePath();
51  String[] split = path.split("/");
52  filesNames[i] = split[split.length - 1];
53  }
54 
55  final ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.files_list_view, filesNames);
56  listview.setAdapter(adapter);
57 
58  listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
59 
60  @Override
61  public void onItemClick(AdapterView<?> parent, final View view,
62  int position, long id) {
63  final String item = files[position].getAbsolutePath();
64  Intent intent = new Intent();
65  intent.putExtra(getString(R.string.intent_extra_file_path), item);
66  setResult(RESULT_OK, intent);
67  finish();
68  }
69 
70  });
71  }
72 }
GLenum GLuint GLenum GLsizei const GLchar * message
uvc_xu_option< int > super
Definition: l500-options.h:32
std::vector< uint32_t > split(const std::string &s, char delim)
GLsizei const GLchar *const * path
Definition: glext.h:4276
::std_msgs::String_< std::allocator< void > > String
Definition: String.h:47
files_container files
def finish()
Definition: test.py:373
int i


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:14