Răsfoiți Sursa

Fixed an error when opening gallery photos.

Due to the sync changes, some db values are now null instead of empty strings.
seavenois 10 ani în urmă
părinte
comite
502123a188

+ 3 - 3
app/src/main/java/com/ivalentin/margolariak/AlbumLayout.java

@@ -52,7 +52,7 @@ public class AlbumLayout extends Fragment {
         SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
 		String lang = GM.getLang();
-        cursor = db.rawQuery("SELECT id, name_" + lang + " AS name, description_" + lang + " AS description FROM album WHERE id = " + id + ";", null);
+        cursor = db.rawQuery("SELECT id, title_" + lang + " AS title, description_" + lang + " AS description FROM album WHERE id = " + id + ";", null);
         cursor.moveToFirst();
 
         //Set album elements
@@ -95,7 +95,7 @@ public class AlbumLayout extends Fragment {
 
             //Set title
             TextView tvTitleLeft = (TextView) entry.findViewById(R.id.tv_row_album_title_left);
-			if (imageCursor.getString(1).length() > 0) {
+			if (imageCursor.getString(1) != null && imageCursor.getString(1).length() > 0) {
 				tvTitleLeft.setText(imageCursor.getString(1));
 			}
 			else{
@@ -167,7 +167,7 @@ public class AlbumLayout extends Fragment {
 
                 //Set title
                 TextView tvTitleRight = (TextView) entry.findViewById(R.id.tv_row_album_title_right);
-				if (imageCursor.getString(1).length() > 0) {
+				if (imageCursor.getString(1) != null && imageCursor.getString(1).length() > 0) {
 					tvTitleRight.setText(imageCursor.getString(1));
 				}
 				else{

+ 2 - 2
app/src/main/java/com/ivalentin/margolariak/PhotoLayout.java

@@ -172,7 +172,7 @@ public class PhotoLayout extends Fragment {
 		LinearLayout llCommentList = (LinearLayout) v.findViewById(R.id.ll_comment_list);
 
 		//Set fields
-		if (cursor.getString(2).length() > 0) {
+		if (cursor.getString(2) != null && cursor.getString(2).length() > 0) {
 			tvTitle.setVisibility(View.VISIBLE);
 			tvTitle.setText(cursor.getString(2));
 			((MainActivity) getActivity()).setSectionTitle(cursor.getString(2));
@@ -182,7 +182,7 @@ public class PhotoLayout extends Fragment {
 			((MainActivity) getActivity()).setSectionTitle(albumName);
 		}
 
-		if (cursor.getString(3).length() > 0) {
+		if (cursor.getString(3) != null && cursor.getString(3).length() > 0) {
 			tvDescription.setVisibility(View.VISIBLE);
 			tvDescription.setText(cursor.getString(3));
 		}