Преглед изворни кода

Fixed a bug with the past activity queries.

The fields "after_*" from the database now returns null instead of an empty string. This was creating errors on the activity lists. Code has been adapted for this change.
seavenois пре 10 година
родитељ
комит
6a3e6872eb

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -28,6 +28,7 @@
         android:supportsRtl="true"
         android:isGame="false"
         android:fullBackupContent="@xml/backup"
+        android:hardwareAccelerated="true"
         android:allowClearUserData="true"
         tools:ignore="UnusedAttribute"
         android:name="android.support.multidex.MultiDexApplication">

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

@@ -109,6 +109,7 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
 			wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
 		}
 		wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
+		//wvText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
         tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, false));
         tvPrice.setText(String.format(getString(R.string.price), cursor.getInt(5)));
         tvCity.setText(cursor.getString(4));
@@ -116,8 +117,9 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
         //Get images
         Cursor imageCursor = db.rawQuery("SELECT image, idx FROM activity_image WHERE activity = " + id + " ORDER BY idx LIMIT 5;", null);
         int i = 0;
+		String image;
         while (imageCursor.moveToNext()) {
-            String image = imageCursor.getString(0);
+            image = imageCursor.getString(0);
 
             //Check if image exists
             File f;
@@ -189,7 +191,7 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
                     tvSchAddress.setText(cursorItinerary.getString(5));
                 }
 
-				//Set clisk listener
+				//Set click listener
 				entry.setOnClickListener(new View.OnClickListener() {
 					@Override
 					public void onClick(View v) {

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

@@ -11,6 +11,7 @@ import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
 import android.text.Html;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -191,11 +192,15 @@ public class ActivityLayout extends Fragment{
 
             //Set text
             String text;
-            if (cursorPast.getString(5).length() < 1){
+            if (cursorPast.getString(5) == null){
                 text = Html.fromHtml(cursorPast.getString(4)).toString();
             }
-            else{
-                text = Html.fromHtml(cursorPast.getString(5)).toString();
+            else {
+                if (cursorPast.getString(5).length() < 1) {
+                    text = Html.fromHtml(cursorPast.getString(4)).toString();
+                } else {
+                    text = Html.fromHtml(cursorPast.getString(5)).toString();
+                }
             }
             if (text.length() > 130) {
                 text = text.substring(0, 130) + "...";

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

@@ -75,11 +75,15 @@ public class ActivityPastLayout extends Fragment {
         //Set fields
         tvTitle.setText(cursor.getString(1));
         ((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
-        if (cursor.getString(5).length() < 1) {
-            wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
+        if (cursor.getString(5) != null) {
+            if (cursor.getString(5).length() < 1) {
+                wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
+            } else {
+                wvText.loadDataWithBaseURL(null, cursor.getString(5), "text/html", "utf-8", null);
+            }
         }
         else{
-            wvText.loadDataWithBaseURL(null, cursor.getString(5), "text/html", "utf-8", null);
+            wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
         }
         tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, false));
         tvCity.setText(cursor.getString(4));

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/Sync.java

@@ -621,7 +621,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 					Log.e("SYNC", "The server returned a 403 code (Client Error: Forbidden) for the url \"" + uri + "\"");
 					break;
 				case 204:	//Success: No content
-					Log.d("SYNC", "The server returned a 204 code (Success: No content) for the url \"" + uri + "\". Stoping sync process...");
+					Log.d("SYNC", "The server returned a 204 code (Success: No content) for the url \"" + uri + "\". Stopping sync process...");
 					break;
 				case 200:	//Success: OK
 					Log.d("SYNC", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\". Now syncing...");

+ 3 - 2
app/src/main/res/layout/fragment_layout_activity_past.xml

@@ -3,7 +3,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="match_parent"
     android:id="@+id/scrollView3"
     android:background="@color/background_app"
     android:padding="7dp"
@@ -27,6 +27,7 @@
 
         <LinearLayout
             android:orientation="vertical"
+            android:transitionGroup="true"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:background="@drawable/entry"
@@ -65,7 +66,7 @@
                 android:maxHeight="70dp" />
 
             <WebView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:id="@+id/wv_activity_past_text"
                 android:layout_marginTop="10dp"

+ 1 - 1
build.gradle

@@ -4,7 +4,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.0'
+        classpath 'com.android.tools.build:gradle:2.2.1'
     }
 }