Commit 9857dc0fe2f0cf219151433edac3f5720c49184d

Authored by Imanol-Mikel Barba Sabariego
1 parent a9fb9749

Bug duplicates finally fixed

src/com/upc/pbe/upcnews/VideoActivity.java
@@ -232,12 +232,13 @@ public class VideoActivity extends Activity { @@ -232,12 +232,13 @@ public class VideoActivity extends Activity {
232 try 232 try
233 { 233 {
234 int index = 0; 234 int index = 0;
235 - String newFileName = fileName;  
236 - while(new File(filePath + newFileName).exists()) 235 + String newFileName = fileName.substring(0,fileName.lastIndexOf("."));
  236 + String extension = fileName.substring(fileName.lastIndexOf("."));
  237 + while(new File(filePath + (newFileName + extension)).exists())
237 { 238 {
238 - newFileName = fileName + index++; 239 + newFileName = fileName.substring(0,fileName.lastIndexOf(".")) + index++;
239 } 240 }
240 - fileName = newFileName; 241 + fileName = newFileName + extension;
241 FileOutputStream out = new FileOutputStream(filePath + fileName); 242 FileOutputStream out = new FileOutputStream(filePath + fileName);
242 BufferedInputStream in = new BufferedInputStream(urls[0].openStream()); 243 BufferedInputStream in = new BufferedInputStream(urls[0].openStream());
243 Log.d(TAG, "\nDescarregant: \n"); 244 Log.d(TAG, "\nDescarregant: \n");