mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Merge pull request #1176 from hismaeel/1119
Fixed Hard Coded Column issue. #1119
This commit is contained in:
		
						commit
						eaba96b509
					
				
					 3 changed files with 31 additions and 23 deletions
				
			
		|  | @ -108,10 +108,10 @@ public class CategoryDao { | |||
|     Category fromCursor(Cursor cursor) { | ||||
|         // Hardcoding column positions! | ||||
|         return new Category( | ||||
|                 CategoryContentProvider.uriForId(cursor.getInt(0)), | ||||
|                 cursor.getString(1), | ||||
|                 new Date(cursor.getLong(2)), | ||||
|                 cursor.getInt(3) | ||||
|                 CategoryContentProvider.uriForId(cursor.getInt(cursor.getColumnIndex(Table.COLUMN_ID))), | ||||
|                 cursor.getString(cursor.getColumnIndex(Table.COLUMN_NAME)), | ||||
|                 new Date(cursor.getLong(cursor.getColumnIndex(Table.COLUMN_LAST_USED))), | ||||
|                 cursor.getInt(cursor.getColumnIndex(Table.COLUMN_TIMES_USED)) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ import android.net.Uri; | |||
| import android.os.RemoteException; | ||||
| import android.support.annotation.Nullable; | ||||
| import android.text.TextUtils; | ||||
| import android.util.Log; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
|  | @ -115,23 +116,30 @@ public class ContributionDao { | |||
|         // Hardcoding column positions! | ||||
|         //Check that cursor has a value to avoid CursorIndexOutOfBoundsException | ||||
|         if (cursor.getCount() > 0) { | ||||
|             int index; | ||||
|             if (cursor.getColumnIndex(Table.COLUMN_LICENSE) == -1){ | ||||
|                 index = 15; | ||||
|             } else { | ||||
|                 index = cursor.getColumnIndex(Table.COLUMN_LICENSE); | ||||
|             } | ||||
|             return new Contribution( | ||||
|                     uriForId(cursor.getInt(0)), | ||||
|                     cursor.getString(1), | ||||
|                     parseUri(cursor.getString(2)), | ||||
|                     cursor.getString(3), | ||||
|                     parseTimestamp(cursor.getLong(4)), | ||||
|                     cursor.getInt(5), | ||||
|                     cursor.getLong(6), | ||||
|                     parseTimestamp(cursor.getLong(7)), | ||||
|                     cursor.getLong(8), | ||||
|                     cursor.getString(9), | ||||
|                     cursor.getString(10), | ||||
|                     cursor.getString(11), | ||||
|                     cursor.getInt(12) == 1, | ||||
|                     cursor.getInt(13), | ||||
|                     cursor.getInt(14), | ||||
|                     cursor.getString(15)); | ||||
|                     uriForId(cursor.getInt(cursor.getColumnIndex(Table.COLUMN_ID))), | ||||
|                     cursor.getString(cursor.getColumnIndex(Table.COLUMN_FILENAME)), | ||||
|                     parseUri(cursor.getString(cursor.getColumnIndex(Table.COLUMN_LOCAL_URI))), | ||||
|                     cursor.getString(cursor.getColumnIndex(Table.COLUMN_IMAGE_URL)), | ||||
|                     parseTimestamp(cursor.getLong(cursor.getColumnIndex(Table.COLUMN_TIMESTAMP))), | ||||
|                     cursor.getInt(cursor.getColumnIndex(Table.COLUMN_STATE)), | ||||
|                     cursor.getLong(cursor.getColumnIndex(Table.COLUMN_LENGTH)), | ||||
|                     parseTimestamp(cursor.getLong(cursor.getColumnIndex(Table.COLUMN_UPLOADED))), | ||||
|                     cursor.getLong(cursor.getColumnIndex(Table.COLUMN_TRANSFERRED)), | ||||
|                     cursor.getString(cursor.getColumnIndex(Table.COLUMN_SOURCE)), | ||||
|                     cursor.getString(cursor.getColumnIndex(Table.COLUMN_DESCRIPTION)), | ||||
|                     cursor.getString(cursor.getColumnIndex(Table.COLUMN_CREATOR)), | ||||
|                     cursor.getInt(cursor.getColumnIndex(Table.COLUMN_MULTIPLE)) == 1, | ||||
|                     cursor.getInt(cursor.getColumnIndex(Table.COLUMN_WIDTH)), | ||||
|                     cursor.getInt(cursor.getColumnIndex(Table.COLUMN_HEIGHT)), | ||||
|                     cursor.getString(index) | ||||
|             ); | ||||
|         } | ||||
| 
 | ||||
|         return null; | ||||
|  |  | |||
|  | @ -54,12 +54,12 @@ public class ModifierSequenceDao { | |||
|         // Hardcoding column positions! | ||||
|         ModifierSequence ms; | ||||
|         try { | ||||
|             ms = new ModifierSequence(Uri.parse(cursor.getString(1)), | ||||
|                     new JSONObject(cursor.getString(2))); | ||||
|             ms = new ModifierSequence(Uri.parse(cursor.getString(cursor.getColumnIndex(Table.COLUMN_MEDIA_URI))), | ||||
|                     new JSONObject(cursor.getString(cursor.getColumnIndex(Table.COLUMN_DATA)))); | ||||
|         } catch (JSONException e) { | ||||
|             throw new RuntimeException(e); | ||||
|         } | ||||
|         ms.setContentUri( ModificationsContentProvider.uriForId(cursor.getInt(0))); | ||||
|         ms.setContentUri( ModificationsContentProvider.uriForId(cursor.getInt(cursor.getColumnIndex(Table.COLUMN_ID)))); | ||||
| 
 | ||||
|         return ms; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 neslihanturan
						neslihanturan