Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void interpretMessage(String readMessage) throws IOException, JSONException{
- JSONObject jsonObject = new JSONObject(readMessage);
- String type = jsonObject.getString("type");
- if(type.equals("register")){
- String id = jsonObject.getString("id");
- String group = jsonObject.getString("group");
- MyActivity.activity.setUserGroup(group);
- MyActivity.activity.setUserId(id);
- //pagerAdapter.setText();
- }
- else if(type.equals("locations")){
- Log.d("Type: ", type);
- }
- else if (type.equals("groups")){
- Log.d("HEJHEJHEJ", "HEJHEJ");
- ArrayList<String> groupItems = new ArrayList<String>();
- JSONArray jsonArray;
- jsonArray = jsonObject.getJSONArray("groups");
- try{
- for(int i = 0;i < jsonArray.length();i++){
- JSONObject group = jsonArray.getJSONObject(i);
- String groupName = group.getString("group");
- groupItems.add(groupName);
- }
- MyActivity.activity.setList(groupItems);
- Log.d("Grupper: ", groupItems.toString());
- //MyActivity.activity.pagerAdapter.setList(groupItems);
- }
- catch (JSONException e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement