From 2dcfdbd9e572b3bf1d5512f73bac1a21550f06de Mon Sep 17 00:00:00 2001 From: Gazebo Date: Wed, 1 Jul 2020 22:32:23 -0300 Subject: [PATCH] ClickListViewImplementadoParcialmente --- .../DevicesFragments/DevicesFragment.java | 23 +++++++++++ .../DevicesFragments/ViewDevicesFragment.java | 18 +++++++- .../InteractionFragment.java | 36 ++++++++++++++++ .../ViewInteractionFragment.java | 41 ++++++++++++++++++- .../HomeworkFragments/HomeWorkFragment.java | 26 ++++++++++++ .../ViewHomeWorkFragment.java | 27 +++++++++++- .../ProjectsFragments/ProjectFragment.java | 25 ++++++++++- .../ViewProjectsFragment.java | 17 +++++++- .../main/res/layout/fragment_viewdevice.xml | 6 +-- ...eraction.xml => fragment_viewhomework.xml} | 22 +++++----- ...orks.xml => fragment_viewinteractions.xml} | 30 +++++++------- .../main/res/layout/fragment_viewproject.xml | 4 +- App/app/src/main/res/values/strings.xml | 1 + 13 files changed, 239 insertions(+), 37 deletions(-) rename App/app/src/main/res/layout/{fragment_viewinteraction.xml => fragment_viewhomework.xml} (91%) rename App/app/src/main/res/layout/{fragment_viewhomeworks.xml => fragment_viewinteractions.xml} (91%) diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java index 1c98f4c..17a5bf2 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.DevicesFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; @@ -13,11 +15,13 @@ import androidx.fragment.app.Fragment; import com.gazeboindustries.sextafeiramobile.Fragments.InteractionsFragments.AddInteractionFragment; +import com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.ProjectsFragments.ViewProjectsFragment; import com.gazeboindustries.sextafeiramobile.ListItemRow; import com.gazeboindustries.sextafeiramobile.R; import com.gazeboindustries.sextafeiramobile.ServerConnection; import org.json.JSONArray; +import org.json.JSONException; import java.util.ArrayList; @@ -28,6 +32,7 @@ public class DevicesFragment extends Fragment { private Button btnAddNewInteraction; private ListView listDevices; private ArrayList arrayList; + private Intent intent; @Nullable @Override @@ -60,6 +65,24 @@ public void onClick(View view) { listDevices.setAdapter(arrayAdapter); + listDevices.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + try { + intent = getActivity().getIntent(); + intent.putExtra("Device", arrayList.get(i).get(1).toString()); + intent.putExtra("Description", arrayList.get(i).get(2).toString()); + + assert getFragmentManager() != null; + getFragmentManager().beginTransaction().replace(R.id.frame, new ViewDevicesFragment()).commit(); + } catch (JSONException e) { + e.printStackTrace(); + } + + + } + }); + return view; } } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java index 67e72f1..1b062e8 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.DevicesFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -12,9 +14,23 @@ import com.gazeboindustries.sextafeiramobile.R; public class ViewDevicesFragment extends Fragment { + private Intent intent; + private EditText txtDevice; + private EditText txtDescription; + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_viewdevice, container, false); + View view = inflater.inflate(R.layout.fragment_viewdevice, container, false); + + txtDevice = view.findViewById(R.id.txtViewDevice); + txtDescription = view.findViewById(R.id.txtViewDeviceDescription); + + intent = getActivity().getIntent(); + + txtDevice.setText(intent.getSerializableExtra("Device").toString()); + txtDescription.setText(intent.getSerializableExtra("Description").toString()); + + return view; } } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/InteractionFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/InteractionFragment.java index 539c573..c65bdd4 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/InteractionFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/InteractionFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.InteractionsFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; @@ -12,11 +14,13 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; +import com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.HomeworkFragments.ViewHomeWorkFragment; import com.gazeboindustries.sextafeiramobile.ListItemRow; import com.gazeboindustries.sextafeiramobile.R; import com.gazeboindustries.sextafeiramobile.ServerConnection; import org.json.JSONArray; +import org.json.JSONException; import java.util.ArrayList; import java.util.List; @@ -28,6 +32,7 @@ public class InteractionFragment extends Fragment { private Button btnAddNewInteraction; private ListView listInteractions; private ArrayList arrayList; + private Intent intent; @Nullable @Override @@ -60,6 +65,37 @@ public void onClick(View view) { listInteractions.setAdapter(arrayAdapter); + listInteractions.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + try { + System.out.println("RESPOSTA TESTE" + arrayList.get(i).get(6)); + + intent = getActivity().getIntent(); + intent.putExtra("Keyword1", arrayList.get(i).get(1).toString()); + intent.putExtra("Keyword2", arrayList.get(i).get(2).toString()); + intent.putExtra("Keyword3", arrayList.get(i).get(3).toString()); + intent.putExtra("Response1", arrayList.get(i).get(4).toString()); + intent.putExtra("Response2", arrayList.get(i).get(5).toString()); + intent.putExtra("Response3", arrayList.get(i).get(6).toString()); + intent.putExtra("Command", arrayList.get(i).get(7).toString()); + + try { + sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + assert getFragmentManager() != null; + getFragmentManager().beginTransaction().replace(R.id.frame, new ViewInteractionFragment()).commit(); + } catch (JSONException e) { + e.printStackTrace(); + } + + + } + }); + return view; } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/ViewInteractionFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/ViewInteractionFragment.java index c726f68..9e3a76a 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/ViewInteractionFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/InteractionsFragments/ViewInteractionFragment.java @@ -1,10 +1,10 @@ package com.gazeboindustries.sextafeiramobile.Fragments.InteractionsFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import android.widget.EditText; import androidx.annotation.NonNull; @@ -14,10 +14,47 @@ import com.gazeboindustries.sextafeiramobile.R; public class ViewInteractionFragment extends Fragment { + private Intent intent; + private EditText keyWord1; + private EditText keyWord2; + private EditText keyWord3; + private EditText response1; + private EditText response2; + private EditText response3; + private EditText command; + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_viewinteraction, container, false); + View view = inflater.inflate(R.layout.fragment_viewhomework, container, false); + + keyWord1 = view.findViewById(R.id.txtViewInteractionKeyword1); + keyWord2 = view.findViewById(R.id.txtViewInteractionKeyword2); + keyWord3 = view.findViewById(R.id.txtViewInteractionKeyword3); + response1 = view.findViewById(R.id.txtViewInteractionResponse1); + response2 = view.findViewById(R.id.txtViewInteractionResponse2); + response3 = view.findViewById(R.id.txtViewInteractionResponse3); + command = view.findViewById(R.id.txtViewInteractionCommand); + + intent = getActivity().getIntent(); + + System.out.println(intent.getSerializableExtra("Keyword1").toString()); + System.out.println(intent.getSerializableExtra("Keyword2").toString()); + System.out.println(intent.getSerializableExtra("Keyword3").toString()); + System.out.println(intent.getSerializableExtra("Response1").toString()); + System.out.println(intent.getSerializableExtra("Response2").toString()); + System.out.println(intent.getSerializableExtra("Response3").toString()); + System.out.println(intent.getSerializableExtra("Command").toString()); + + + /*keyWord1.setText(intent.getSerializableExtra("Keyword1").toString()); + keyWord2.setText(intent.getSerializableExtra("Keyword2").toString()); + keyWord3.setText(intent.getSerializableExtra("Keyword3").toString()); + response1.setText(intent.getSerializableExtra("Response1").toString()); + response2.setText(intent.getSerializableExtra("Response2").toString()); + response3.setText(intent.getSerializableExtra("Response3").toString()); + command.setText(intent.getSerializableExtra("Command").toString()); + */ return view; } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/HomeWorkFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/HomeWorkFragment.java index d0f76d6..350fe84 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/HomeWorkFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/HomeWorkFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.HomeworkFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; @@ -14,11 +16,13 @@ import com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.ProjectsFragments.AddProjectFragment; import com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.ProjectsFragments.ProjectFragment; +import com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.ProjectsFragments.ViewProjectsFragment; import com.gazeboindustries.sextafeiramobile.ListItemRow; import com.gazeboindustries.sextafeiramobile.R; import com.gazeboindustries.sextafeiramobile.ServerConnection; import org.json.JSONArray; +import org.json.JSONException; import java.util.ArrayList; @@ -29,6 +33,7 @@ public class HomeWorkFragment extends Fragment { private Button btnAddNewInteraction; private ListView listHomeWorks; private ArrayList arrayList; + private Intent intent; @Nullable @Override @@ -61,6 +66,27 @@ public void onClick(View view) { listHomeWorks.setAdapter(arrayAdapter); + listHomeWorks.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + try { + intent = getActivity().getIntent(); + intent.putExtra("Type", arrayList.get(i).get(1).toString()); + intent.putExtra("Subject", arrayList.get(i).get(2).toString()); + intent.putExtra("HomeWork", arrayList.get(i).get(3).toString()); + intent.putExtra("Delivery", arrayList.get(i).get(4).toString()); + intent.putExtra("Description", arrayList.get(i).get(5).toString()); + + assert getFragmentManager() != null; + getFragmentManager().beginTransaction().replace(R.id.frame, new ViewHomeWorkFragment()).commit(); + } catch (JSONException e) { + e.printStackTrace(); + } + + + } + }); + return view; } } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/ViewHomeWorkFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/ViewHomeWorkFragment.java index b9cee3b..d977a3e 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/ViewHomeWorkFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/HomeworkFragments/ViewHomeWorkFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.HomeworkFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -12,9 +14,32 @@ import com.gazeboindustries.sextafeiramobile.R; public class ViewHomeWorkFragment extends Fragment { + Intent intent; + EditText txtType; + EditText txtSubject; + EditText txtHomeWork; + EditText txtDelivery; + EditText txtDescription; + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_viewhomeworks, container, false); + View view = inflater.inflate(R.layout.fragment_viewinteractions, container, false); + + txtType = view.findViewById(R.id.txtViewHomeWorkType); + txtSubject = view.findViewById(R.id.txtViewHomeWorkSubject); + txtHomeWork = view.findViewById(R.id.txtViewHomeWork); + txtDelivery = view.findViewById(R.id.txtViewHomeWorkDelivery); + txtDescription = view.findViewById(R.id.txtViewHomeWorkDescription); + + intent = getActivity().getIntent(); + + txtType.setText(intent.getSerializableExtra("Type").toString()); + txtSubject.setText(intent.getSerializableExtra("Subject").toString()); + txtHomeWork.setText(intent.getSerializableExtra("HomeWork").toString()); + txtDelivery.setText(intent.getSerializableExtra("Delivery").toString()); + txtDescription.setText(intent.getSerializableExtra("Description").toString()); + + return view; } } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java index e113495..0ffb749 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.ProjectsFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; @@ -17,6 +19,7 @@ import com.gazeboindustries.sextafeiramobile.ServerConnection; import org.json.JSONArray; +import org.json.JSONException; import java.util.ArrayList; @@ -27,6 +30,7 @@ public class ProjectFragment extends Fragment { private Button btnAddNewInteraction; private ListView listProjects; private ArrayList arrayList; + private Intent intent; @Nullable @Override @@ -48,7 +52,7 @@ public void onClick(View view) { ServerConnection connection = new ServerConnection("getProjects"); try { - sleep(3000); + sleep(4500); } catch (InterruptedException e) { e.printStackTrace(); } @@ -59,6 +63,25 @@ public void onClick(View view) { listProjects.setAdapter(arrayAdapter); + listProjects.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + try { + intent = getActivity().getIntent(); + intent.putExtra("Project", arrayList.get(i).get(1).toString()); + intent.putExtra("Repository", arrayList.get(i).get(2).toString()); + + assert getFragmentManager() != null; + getFragmentManager().beginTransaction().replace(R.id.frame, new ViewProjectsFragment()).commit(); + } catch (JSONException e) { + e.printStackTrace(); + } + + + } + }); + + return view; } } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java index 378cfbe..df0956f 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java @@ -1,9 +1,11 @@ package com.gazeboindustries.sextafeiramobile.Fragments.SkillsFragments.ProjectsFragments; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -12,9 +14,22 @@ import com.gazeboindustries.sextafeiramobile.R; public class ViewProjectsFragment extends Fragment { + Intent intent; + EditText txtProject; + EditText txtRepository; + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_viewproject, container, false); + View view = inflater.inflate(R.layout.fragment_viewproject , container, false); + + txtProject = view.findViewById(R.id.txtViewProject); + txtRepository = view.findViewById(R.id.txtViewRepository); + + intent = getActivity().getIntent(); + + txtProject.setText(intent.getSerializableExtra("Project").toString()); + txtRepository.setText(intent.getSerializableExtra("Repository").toString()); + return view; } } diff --git a/App/app/src/main/res/layout/fragment_viewdevice.xml b/App/app/src/main/res/layout/fragment_viewdevice.xml index 83d4ef1..dbe1623 100644 --- a/App/app/src/main/res/layout/fragment_viewdevice.xml +++ b/App/app/src/main/res/layout/fragment_viewdevice.xml @@ -35,7 +35,7 @@ diff --git a/App/app/src/main/res/layout/fragment_viewinteraction.xml b/App/app/src/main/res/layout/fragment_viewhomework.xml similarity index 91% rename from App/app/src/main/res/layout/fragment_viewinteraction.xml rename to App/app/src/main/res/layout/fragment_viewhomework.xml index c7650a3..b789b3d 100644 --- a/App/app/src/main/res/layout/fragment_viewinteraction.xml +++ b/App/app/src/main/res/layout/fragment_viewhomework.xml @@ -9,7 +9,7 @@ @@ -64,12 +64,12 @@ @@ -92,12 +92,12 @@ @@ -120,12 +120,12 @@ @@ -148,12 +148,12 @@ diff --git a/App/app/src/main/res/layout/fragment_viewhomeworks.xml b/App/app/src/main/res/layout/fragment_viewinteractions.xml similarity index 91% rename from App/app/src/main/res/layout/fragment_viewhomeworks.xml rename to App/app/src/main/res/layout/fragment_viewinteractions.xml index 42591db..b0bc0a0 100644 --- a/App/app/src/main/res/layout/fragment_viewhomeworks.xml +++ b/App/app/src/main/res/layout/fragment_viewinteractions.xml @@ -9,7 +9,7 @@ @@ -65,12 +65,12 @@ @@ -94,12 +94,12 @@ @@ -123,12 +123,12 @@ @@ -152,12 +152,12 @@ @@ -181,12 +181,12 @@ @@ -210,12 +210,12 @@ diff --git a/App/app/src/main/res/layout/fragment_viewproject.xml b/App/app/src/main/res/layout/fragment_viewproject.xml index 7078eda..8c36bb8 100644 --- a/App/app/src/main/res/layout/fragment_viewproject.xml +++ b/App/app/src/main/res/layout/fragment_viewproject.xml @@ -35,7 +35,7 @@ Salvar Server Address: Server port: + Tarefa