forked from getodk/collect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request getodk#3721 from grzesiek2010/network
Factored out NetworkStateProvider class
- Loading branch information
Showing
19 changed files
with
107 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,9 @@ | |
|
||
import android.app.AlertDialog; | ||
import android.app.ProgressDialog; | ||
import android.content.Context; | ||
import android.content.DialogInterface; | ||
import android.content.Intent; | ||
import android.database.Cursor; | ||
import android.net.ConnectivityManager; | ||
import android.net.NetworkInfo; | ||
import android.net.Uri; | ||
import android.os.AsyncTask; | ||
import android.os.Bundle; | ||
|
@@ -41,6 +38,7 @@ | |
import org.odk.collect.android.adapters.FormDownloadListAdapter; | ||
import org.odk.collect.android.application.Collect; | ||
import org.odk.collect.android.dao.FormsDao; | ||
import org.odk.collect.android.network.NetworkStateProvider; | ||
import org.odk.collect.android.openrosa.HttpCredentialsInterface; | ||
import org.odk.collect.android.injection.DaggerUtils; | ||
import org.odk.collect.android.listeners.DownloadFormsTaskListener; | ||
|
@@ -88,7 +86,7 @@ | |
* | ||
* @author Carl Hartung ([email protected]) | ||
*/ | ||
public class FormDownloadList extends FormListActivity implements FormListDownloaderListener, | ||
public class FormDownloadListActivity extends FormListActivity implements FormListDownloaderListener, | ||
DownloadFormsTaskListener, AuthDialogUtility.AuthDialogUtilityResultListener, AdapterView.OnItemClickListener { | ||
private static final String FORM_DOWNLOAD_LIST_SORTING_ORDER = "formDownloadListSortingOrder"; | ||
|
||
|
@@ -126,6 +124,9 @@ public class FormDownloadList extends FormListActivity implements FormListDownlo | |
@Inject | ||
FormListDownloader formListDownloader; | ||
|
||
@Inject | ||
NetworkStateProvider connectivityProvider; | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
|
@@ -145,7 +146,7 @@ public void granted() { | |
try { | ||
new StorageInitializer().createOdkDirsOnStorage(); | ||
} catch (RuntimeException e) { | ||
DialogUtils.showDialog(DialogUtils.createErrorDialog(FormDownloadList.this, e.getMessage(), EXIT), FormDownloadList.this); | ||
DialogUtils.showDialog(DialogUtils.createErrorDialog(FormDownloadListActivity.this, e.getMessage(), EXIT), FormDownloadListActivity.this); | ||
return; | ||
} | ||
|
||
|
@@ -297,11 +298,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id) | |
* Starts the download task and shows the progress dialog. | ||
*/ | ||
private void downloadFormList() { | ||
ConnectivityManager connectivityManager = | ||
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | ||
NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); | ||
|
||
if (ni == null || !ni.isConnected()) { | ||
if (!connectivityProvider.isDeviceOnline()) { | ||
ToastUtils.showShortToast(R.string.no_connection); | ||
|
||
if (viewModel.isDownloadOnlyMode()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.