public class DownloadsManager extends MenuActivity
Modifier and Type | Class and Description |
---|---|
private class |
DownloadsManager.onGroupSelectedListener
Listener associated with the spinner.
|
Modifier and Type | Field and Description |
---|---|
private long |
chosenGroupCode
Specifies chosen group to show its documents
0 -
|
private String |
chosenNodeName |
private TextView |
currentPathText |
private int |
downloadsAreaCode
Specifies whether to display the documents or the shared area of the
subject 1 specifies documents area 2 specifies shared area
|
private long |
fileSize
fileSize stores the size of the last file name chosen to be downloaded
|
private GridView |
grid |
private int |
groupPosition
Indicates the selected position in the groups spinner
by default the whole course is selected
|
private boolean |
groupsRequested
Indicates if the groups has been requested
|
private ImageView |
moduleIcon |
private TextView |
moduleText |
private List<Group> |
myGroups
List of group of the selected course to which the user belongs
|
private DirectoryNavigator |
navigator
Class that contains the directory tree and gives information of each
level
|
private TextView |
noConnectionText |
private boolean |
noConnectionView
Indicates if the menu no connection is visible
|
private boolean |
previousConnection
Indicates if the state before the activity was brought to background has o not connection
|
private ProgressBar |
progressbar |
private boolean |
refresh
Indicates whether the refresh button was pressed
|
private boolean |
saveState
Indicates that the current state should be saved in case the activity is brought to background
|
private static String |
TAG
Downloads tag name for Logcat
|
private String |
tree
String that contains the xml files recevied from the web service
|
private ImageButton |
updateButton |
dbHelper, isDebuggable
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAPTIONING_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
DownloadsManager() |
Modifier and Type | Method and Description |
---|---|
private int |
checkMediaAvailability()
It checks if the external storage is available
|
private AlertDialog |
createFileInfoDialog(String name,
long size,
long time,
String uploader,
long fileCode)
Method that shows information file and allows its download
It has a button to confirm the download.
|
private void |
downloadFile(String directory,
String url,
long fileSize)
it initializes the download the file from the url @a url and stores it in the directory name @directory
|
private String |
getDirectoryPath()
it gets the directory path where the files will be located.This will be /$EXTERNAL_STORAGE/$DOWNLOADS
|
private List<Group> |
getFilteredGroups()
Get the list of the groups of the course with a documents zone to whom the user belongs
|
private static String |
humanReadableByteCount(long bytes,
boolean si)
Method to show file size in bytes in a human readable way
http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-java
|
private void |
loadGroupsSpinner(List<Group> currentGroups)
If there are not groups to which the user belong in the database, it makes the request
|
protected void |
onActivityResult(int requestCode,
int resultCode,
Intent data) |
protected void |
onCreate(Bundle savedInstanceState) |
void |
onRefreshClick(View v)
Launches an action when refresh button is pushed.
|
protected void |
onSaveInstanceState(Bundle outState) |
protected void |
onStart() |
private void |
refresh()
This method is called after the new file tree is received when the refresh button is pressed
|
private void |
requestDirectoryTree()
Method to request files tree to SWAD thought the web services GETDIRECTORYTREE
|
private void |
requestGetFile(long fileCode)
Method to request info file identified with @a fileCode to SWAD thought the web services GETFILE
|
private void |
setMainView()
This method set the grid of nodes visible and paints the directory tree in its root node
|
private void |
setNoConnectionView()
Having connection is mandatory for the Download Module.
|
private void |
updateView(ArrayList<DirectoryItem> items)
When the user moves into a new directory, this method updates the set of new directories and files and paints it
|
error, onCreateOptionsMenu, onOptionsItemSelected, onPause, onResume, showDialog
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDestroy, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onNewIntent, onOptionsMenuClosed, onPanelClosed, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistData, onRestart, onRestoreInstanceState, onRetainNonConfigurationInstance, onSearchRequested, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, reportFullyDrawn, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
applyOverrideConfiguration, attachBaseContext, getResources, getTheme, setTheme
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getObbDirs, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
private DirectoryNavigator navigator
private int downloadsAreaCode
private long chosenGroupCode
private String tree
private static final String TAG
private List<Group> myGroups
private boolean groupsRequested
private boolean refresh
private ImageButton updateButton
private ProgressBar progressbar
private TextView noConnectionText
private GridView grid
private ImageView moduleIcon
private TextView moduleText
private TextView currentPathText
private String chosenNodeName
private long fileSize
private int groupPosition
private boolean noConnectionView
private boolean saveState
private boolean previousConnection
protected void onCreate(Bundle savedInstanceState)
onCreate
in class MenuActivity
protected void onSaveInstanceState(Bundle outState)
onSaveInstanceState
in class Activity
protected void onActivityResult(int requestCode, int resultCode, Intent data)
onActivityResult
in class Activity
private void setNoConnectionView()
private void setMainView()
private void refresh()
private void updateView(ArrayList<DirectoryItem> items)
private List<Group> getFilteredGroups()
private void loadGroupsSpinner(List<Group> currentGroups)
private void requestDirectoryTree()
private int checkMediaAvailability()
private String getDirectoryPath()
private void downloadFile(String directory, String url, long fileSize)
directory
- - directory where the downloaded file will be storedurl
- - url from which the file is downloadedfileSize
- - file size of the file. It is used to show the download progress in the notificationprivate void requestGetFile(long fileCode)
fileCode
- file codeprivate AlertDialog createFileInfoDialog(String name, long size, long time, String uploader, long fileCode)
private static String humanReadableByteCount(long bytes, boolean si)
public void onRefreshClick(View v)
v
- Actual view