mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +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
				
			
		|  | @ -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; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 neslihanturan
						neslihanturan