Fixed minor bugs getting right file name

This commit is contained in:
Helena Rodriguez 2012-05-17 16:11:57 +02:00
parent cc151e4bd9
commit fd0f18fc99
2 changed files with 26 additions and 27 deletions

View File

@ -117,7 +117,7 @@ public class DirectoryNavigator
NodeList childs = node.getChildNodes();
DirectoryItem item;
System.out.println(childs.getLength());
System.out.println("Num of childs"+childs.getLength());
for(int i=0; i<childs.getLength(); i++)
{
Node currentChild = childs.item(i);
@ -133,7 +133,6 @@ public class DirectoryNavigator
{
if(childs.item(i).getNodeName().equals("file"))
{
String fullName;
String name = "";
String type = "";
@ -143,12 +142,10 @@ public class DirectoryNavigator
//PARSE THE NAME SEPARING NAME AND EXTENSION
NamedNodeMap attributes = currentChild.getAttributes();
fullName = attributes.getNamedItem("name").getNodeValue();
int lastDot = fullName.lastIndexOf(".");
name = fullName.substring(0, lastDot);
type = fullName.substring(lastDot+1, fullName.length());
name = attributes.getNamedItem("name").getNodeValue();
System.out.println("Name: "+name);
System.out.println("Type: "+type);
//WE GET THE REST OF THE INFO
NodeList fileData = currentChild.getChildNodes();
@ -161,6 +158,11 @@ public class DirectoryNavigator
{
url = data.getFirstChild().getNodeValue();
System.out.println("Url: "+url);
//from the url, gets the type
int lastDot = url.lastIndexOf(".");
type = url.substring(lastDot+1, url.length());
System.out.println("Type: "+type);
}
else
{

View File

@ -63,12 +63,7 @@ public class DownloadsManager extends MenuActivity {
*/
public static final String TAG = Global.APP_TAG + " Downloads";
/**
* Course name
* */
private String courseName;
GridView grid;
private GridView grid;
ImageView moduleIcon = null;
TextView moduleText = null;
@ -78,11 +73,6 @@ public class DownloadsManager extends MenuActivity {
@Override
protected void onStart() {
super.onStart();
Course courseSelected = ((Course) dbHelper.getRow(Global.DB_TABLE_COURSES, "id",String.valueOf( Global.getSelectedCourseCode())));
courseName =courseSelected.getShortName();
Intent activity;
activity = new Intent(getBaseContext(),DirectoryTreeDownload.class);
activity.putExtra("treeCode",downloadsCode);
@ -98,9 +88,13 @@ public class DownloadsManager extends MenuActivity {
grid.setOnItemClickListener((new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
TextView text = (TextView) v.findViewById(R.id.icon_text);
String path = text.getText().toString();//parent.getItemAtPosition(position).toString();
String path = text.getText().toString();
ArrayList<DirectoryItem> newBrowser = navigator.subDirectory(path);
((NodeAdapter)grid.getAdapter()).change(newBrowser);
actualPathText.setText(navigator.getPath());
((NodeAdapter)grid.getAdapter()).change(newBrowser);
}
}));
@ -143,9 +137,10 @@ public class DownloadsManager extends MenuActivity {
navigator = new DirectoryNavigator(tree);
//GridView
ArrayList<DirectoryItem> r = (ArrayList<DirectoryItem>) navigator.goToRoot();
String path = Global.getSelectedCourseShortName() ;
actualPathText.setText(courseName+ " "+navigator.getPath());
String path = navigator.getPath() ;
actualPathText.setText(path);
grid.setAdapter(new NodeAdapter(this,r));
}
@ -154,22 +149,24 @@ public class DownloadsManager extends MenuActivity {
}*/
public class GridViewOnItemSelectedListener implements OnItemSelectedListener {
/* public class GridViewOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
String path = parent.getItemAtPosition(pos).toString();
String directoryName = parent.getItemAtPosition(pos).toString();
ArrayList<DirectoryItem> newBrowser = navigator.subDirectory(directoryName);
String path = navigator.getPath();
actualPathText.setText(path);
ArrayList<DirectoryItem> newBrowser = navigator.subDirectory(path);
actualPathText.setText(courseName+ " "+navigator.getPath());
((NodeAdapter)grid.getAdapter()).change(newBrowser);
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
}*/
}