Commit a1a3e349 authored by Geoffrey Métais's avatar Geoffrey Métais

MediaParsingService only discovers new device

Device adding is automated
parent 130c1b52
...@@ -119,18 +119,16 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb { ...@@ -119,18 +119,16 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
discover(intent.getStringExtra(EXTRA_PATH)); discover(intent.getStringExtra(EXTRA_PATH));
break; break;
case ACTION_DISCOVER_DEVICE: case ACTION_DISCOVER_DEVICE:
discoverStorage(intent.getStringExtra(EXTRA_PATH), intent.getStringExtra(EXTRA_UUID)); discoverStorage(intent.getStringExtra(EXTRA_PATH));
break; break;
} }
return START_NOT_STICKY; return START_NOT_STICKY;
} }
private void discoverStorage(final String path, final String uuid) { private void discoverStorage(final String path) {
mThreadPool.execute(new Runnable() { mThreadPool.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!TextUtils.isEmpty(uuid))
mMedialibrary.addDevice(uuid, path, true);
for (String folder : Medialibrary.getBlackList()) for (String folder : Medialibrary.getBlackList())
mMedialibrary.banFolder(path + folder); mMedialibrary.banFolder(path + folder);
mMedialibrary.discover(path); mMedialibrary.discover(path);
...@@ -144,7 +142,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb { ...@@ -144,7 +142,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
mThreadPool.execute(new Runnable() { mThreadPool.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
addDeviceIfNeeded(path);
mMedialibrary.discover(path); mMedialibrary.discover(path);
} }
}); });
......
...@@ -67,7 +67,6 @@ public class DialogActivity extends BaseActivity { ...@@ -67,7 +67,6 @@ public class DialogActivity extends BaseActivity {
ExternalStorageDialog dialog = new ExternalStorageDialog(); ExternalStorageDialog dialog = new ExternalStorageDialog();
Bundle b = new Bundle(2); Bundle b = new Bundle(2);
b.putString(MediaParsingService.EXTRA_PATH, getIntent().getStringExtra(MediaParsingService.EXTRA_PATH)); b.putString(MediaParsingService.EXTRA_PATH, getIntent().getStringExtra(MediaParsingService.EXTRA_PATH));
b.putString(MediaParsingService.EXTRA_UUID, getIntent().getStringExtra(MediaParsingService.EXTRA_UUID));
dialog.setArguments(b); dialog.setArguments(b);
dialog.show(getSupportFragmentManager(), "fragment_storage"); dialog.show(getSupportFragmentManager(), "fragment_storage");
} }
......
...@@ -37,8 +37,7 @@ public class ExternalStorageDialog extends AppCompatDialogFragment { ...@@ -37,8 +37,7 @@ public class ExternalStorageDialog extends AppCompatDialogFragment {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
Intent serviceInent = new Intent(MediaParsingService.ACTION_DISCOVER_DEVICE, null, getActivity(), MediaParsingService.class) Intent serviceInent = new Intent(MediaParsingService.ACTION_DISCOVER_DEVICE, null, getActivity(), MediaParsingService.class)
.putExtra(MediaParsingService.EXTRA_PATH, path) .putExtra(MediaParsingService.EXTRA_PATH, path);
.putExtra(MediaParsingService.EXTRA_UUID, uuid);
if (getActivity() != null) { if (getActivity() != null) {
getActivity().startService(serviceInent); getActivity().startService(serviceInent);
getActivity().finish(); getActivity().finish();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment