diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java index b5c4877..6ead66f 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java @@ -47,7 +47,7 @@ public class MainActivity extends AppCompatActivity imageListener { private Context cntxt; - private static JSONObject userData; + public static JSONObject userData; public static Bitmap userAvatar; private String url; private ImageView avatarView; diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java b/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java index 238864c..b515d80 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/voteFragment/VoteFragment.java @@ -11,9 +11,11 @@ import android.view.View; import android.view.ViewGroup; import android.widget.*; +import gq.yigit.mycity.MainActivity; import gq.yigit.mycity.R; import gq.yigit.mycity.tools.*; import gq.yigit.mycity.tools.WebRequest.responseListener; +import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; @@ -164,7 +166,12 @@ public class VoteFragment extends Fragment implements responseListener, imageLis HashMap params = new HashMap<>(); params.put("voting_id",vote_id); params.put("vote_id",user_vote); - WebRequest vote_request = new WebRequest(url+"/vote",true, params); + try { + params.put("voter_id", MainActivity.userData.get("id").toString()); + }catch (JSONException e){ + Log.e("[ERROR]","Cannot get user data"); + } + WebRequest vote_request = new WebRequest(url+"/vote",false, params); vote_request.execute(); }else{ Toast.makeText(cntxt,"Please selet a vote!",Toast.LENGTH_SHORT).show();