Commits

skarumuru  committed 2397857

changed url to backpapermusic

  • Participants
  • Parent commits faed468

Comments (0)

Files changed (3)

File project.properties

 
 # Project target.
 target=android-19
-android.library.reference.1=../workspace/appcompat_v7
+android.library.reference.1=../appcompat_v7

File src/com/w4rlock/backpapermusic/MusicActivity.java

 		}
 		com.nostra13.universalimageloader.utils.L.disableLogging();
 
-		// L.d("MusicActivity", "Calling Service");
-		// MusicDatabaseSyncerService musicDatabaseSyncerService = new
-		// MusicDatabaseSyncerService(getApplicationContext());
-		// musicDatabaseSyncerService.execute( );
+//		L.d("MusicActivity", "Calling Service");
+//		MusicDatabaseSyncerService musicDatabaseSyncerService = new MusicDatabaseSyncerService(getApplicationContext());
+//		musicDatabaseSyncerService.execute();
 
 		// Get the cursor for this query
-		Cursor songs = cupboard().withDatabase(MusicDb.getReadDatabase(getApplicationContext())).query(Song.class).getCursor();
+		Cursor songs = cupboard().withDatabase(MusicDb.getReadDatabase(getApplicationContext())).query(Song.class).groupBy("dirname").getCursor();
 		QueryResultIterable<Song> itr = cupboard().withCursor(songs).iterate(Song.class);
 		L.d("MusicActivity", "Calling results");
 		try
 			// Iterate books
 			for (Song song : itr)
 			{
-				L.d(this.getClass().toString(), song.getAlbum() + "/" + song.getName());
+				L.d("MusicActivity", song.getDirname()+"/"+song.getAlbum() + "/" + song.getName());
 			}
-		}catch(Exception e){
+		} catch (Exception e)
+		{
 			e.printStackTrace();
-		}
-		finally
+		} finally
 		{
-			
+
 			// close the cursor
 			songs.close();
 			itr.close();

File src/com/w4rlock/backpapermusic/database/service/MusicDatabaseSyncerService.java

 // using this as async task for now to test
 public class MusicDatabaseSyncerService extends AsyncTask<Void, Void, Void>
 {
-	private String url = "http://192.168.4.48:8000/api/music_list/";
+	private String url = "http://backpapermusic.w4rlock.in/api/music_list/";
 	private Context context;
 	private static final String DEBUG_TAG = MusicDatabaseSyncerService.class.toString();
 
 	{
 		this.context = context;
 	}
-
+ 
 	@Override
 	protected Void doInBackground(Void... params)
 	{
 			}.getType();
 			music = gson.fromJson(result, listType);
 			SQLiteDatabase db = MusicDb.getWriteDatabase(context);
+			try
+			{
+				cupboard().withDatabase(db).dropAllTables();
+				cupboard().withDatabase(db).createTables();
+			} catch (Exception e)
+			{
+				e.printStackTrace();
+			}
 			int i = 0;
 			for(ArrayList<Song> songs:music){
 				i++;