private void InitDownloadManager() { lock (_lock) { if (downloadManager == null) { DownloaderConstructorHelper downloaderConstructorHelper = new DownloaderConstructorHelper( GetDownloadCache(), BuildHttpDataSourceFactory(/* listener= */ null)); downloadManager = new Offline.DownloadManager( downloaderConstructorHelper, MAX_SIMULTANEOUS_DOWNLOADS, Offline.DownloadManager.DefaultMinRetryCount, new File(GetDownloadDirectory(), DOWNLOAD_ACTION_FILE), DOWNLOAD_DESERIALIZERS); downloadTracker = new DownloadTracker( /* context= */ this, BuildDataSourceFactory(/* listener= */ null), new File(GetDownloadDirectory(), DOWNLOAD_TRACKER_ACTION_FILE), DOWNLOAD_DESERIALIZERS); downloadManager.AddListener(downloadTracker); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.sample_chooser_activity); sampleAdapter = new SampleAdapter(this); ExpandableListView sampleListView = (ExpandableListView)FindViewById(Resource.Id.sample_list); sampleListView.SetAdapter(sampleAdapter); sampleListView.SetOnChildClickListener(this); Intent intent = Intent; string dataUri = intent.DataString; string[] uris; if (dataUri != null) { uris = new string[] { dataUri }; } else { List <string> uriList = new List <string>(); AssetManager assetManager = Assets; try { foreach (string asset in assetManager.List("")) { if (asset.EndsWith(".exolist.json")) { uriList.Add("asset:///" + asset); } } } catch (Java.IO.IOException e) { Toast.MakeText(ApplicationContext, Resource.String.sample_list_load_error, ToastLength.Long).Show(); } uriList.Sort(); uris = uriList.ToArray(); } downloadTracker = ((DemoApplication)Application).GetDownloadTracker(); SampleListLoader loaderTask = new SampleListLoader(this); loaderTask.Execute(uris); // Start the download service if it should be running but it's not currently. // Starting the service in the foreground causes notification flicker if there is no scheduled // action. Starting it in the background throws an exception if the app is in the background too // (e.g. if device screen is locked). try { Offline.DownloadService.Start(this, Java.Lang.Class.FromType(typeof(DemoDownloadService))); } catch (IllegalStateException e) { Offline.DownloadService.StartForeground(this, Java.Lang.Class.FromType(typeof(DemoDownloadService))); } }
public StartDownloadDialogHelper(Activity activity, DownloadHelper downloadHelper, DownloadTracker downloadTracker, string name) { this.downloadHelper = downloadHelper; this.downloadTracker = downloadTracker; this.name = name; builder = new AlertDialog.Builder(activity) .SetTitle(Resource.String.exo_download_description) .SetPositiveButton(android.Resource.String.Ok, this) .SetNegativeButton(android.Resource.String.Cancel, (IDialogInterfaceOnClickListener)null); // Inflate with the builder's context to ensure the correct style is used. LayoutInflater dialogInflater = LayoutInflater.From(builder.Context); dialogView = dialogInflater.Inflate(Resource.Layout.start_download_dialog, null); trackKeys = new List <TrackKey>(); trackTitles = new ArrayAdapter <string>(builder.Context, android.Resource.Layout.SimpleListItemMultipleChoice); representationList = (ListView)dialogView.FindViewById(Resource.Id.representation_list); representationList.ChoiceMode = ChoiceMode.Multiple; representationList.Adapter = trackTitles; }