Quellcode durchsuchen

User code now read.

seavenois vor 9 Jahren
Ursprung
Commit
989cde1476

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

@@ -626,7 +626,7 @@ public class MainActivity extends Activity {
 	/**
 	 * Performs a full sync against the remote database.
 	 */
-	private void sync() {
+	public void sync() {
 		ProgressBar pbSync = (ProgressBar) findViewById(R.id.pb_sync);
 		ImageView ivSync = (ImageView) findViewById(R.id.iv_logo);
 		new Sync(this, pbSync, ivSync).execute();

+ 9 - 5
app/src/main/java/com/ivalentin/margolariak/PostComment.java

@@ -1,6 +1,7 @@
 package com.ivalentin.margolariak;
 
 import android.annotation.SuppressLint;
+import android.app.Activity;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.database.sqlite.SQLiteDatabase;
@@ -15,7 +16,6 @@ import android.widget.LinearLayout;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
@@ -40,7 +40,7 @@ class PostComment extends AsyncTask<String, String, Integer> {
 
     private int code = 404;
 
-    public PostComment(String type, String user, String text, String language, int id, LinearLayout form, LinearLayout list, Context context) {
+    PostComment(String type, String user, String text, String language, int id, LinearLayout form, LinearLayout list, Context context) {
         super();
         this.type = type;
         this.user = user;
@@ -123,10 +123,10 @@ class PostComment extends AsyncTask<String, String, Integer> {
                     Log.e("COMMENT", "The server returned a 403 code (Client Error: Forbidden) for the url \"" + uri + "\"");
 					return(-403);
                 case 200:    //Success: OK
-                    Log.d("COMMENT", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\". Now syncing...");
+                    Log.d("COMMENT", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\".");
 					break;
 				default:
-					Log.e("COMMENT", "The server returned a " + code + " code for the url \"" + uri + "\". Stopping sync process...");
+					Log.e("COMMENT", "The server returned a " + code + " code for the url \"" + uri + "\".");
 					return(-6);
             }
 
@@ -172,7 +172,11 @@ class PostComment extends AsyncTask<String, String, Integer> {
             formText.setText("");
 
             //TODO: Update counter
-			//TODO: insert in database
+
+			//Perform a sync
+			((MainActivity) context).sync();
+
+
             //Insert comment in list
             LayoutInflater factory = LayoutInflater.from(context);
             LinearLayout entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);

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

@@ -88,7 +88,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			doProgress = true;
 
 		}
-		Log.d("Sync", "Starting full sync");
+		Log.d("SYNC", "Starting full sync");
 	}
 	
 	/**