Skip to content

Commit

Permalink
Merge pull request #29 from GabrielSirtoriCorrea/ImplementandoClickLi…
Browse files Browse the repository at this point in the history
…stView

ClickListViewImplementadoParcialmente
  • Loading branch information
GabrielSirtoriCorrea authored Jul 2, 2020
2 parents d2c0dbb + 2dcfdbd commit 45f1ae2
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -28,6 +32,7 @@ public class DevicesFragment extends Fragment {
private Button btnAddNewInteraction;
private ListView listDevices;
private ArrayList<JSONArray> arrayList;
private Intent intent;

@Nullable
@Override
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -28,6 +32,7 @@ public class InteractionFragment extends Fragment {
private Button btnAddNewInteraction;
private ListView listInteractions;
private ArrayList<JSONArray> arrayList;
private Intent intent;

@Nullable
@Override
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -29,6 +33,7 @@ public class HomeWorkFragment extends Fragment {
private Button btnAddNewInteraction;
private ListView listHomeWorks;
private ArrayList<JSONArray> arrayList;
private Intent intent;

@Nullable
@Override
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,6 +19,7 @@
import com.gazeboindustries.sextafeiramobile.ServerConnection;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;

Expand All @@ -27,6 +30,7 @@ public class ProjectFragment extends Fragment {
private Button btnAddNewInteraction;
private ListView listProjects;
private ArrayList<JSONArray> arrayList;
private Intent intent;

@Nullable
@Override
Expand All @@ -48,7 +52,7 @@ public void onClick(View view) {
ServerConnection connection = new ServerConnection("getProjects");

try {
sleep(3000);
sleep(4500);
} catch (InterruptedException e) {
e.printStackTrace();
}
Expand All @@ -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;
}
}
Loading

0 comments on commit 45f1ae2

Please sign in to comment.