3434import com .example .fernandon .android_client .TALLER2 .model .ListadoHistoriasFragment ;
3535import com .example .fernandon .android_client .TALLER2 .model .ListadoNotificacionesFragment ;
3636import com .example .fernandon .android_client .TALLER2 .model .Notificacion ;
37+ import com .example .fernandon .android_client .TALLER2 .model .PerfilFragment ;
3738
3839public class MainActivity extends AppCompatActivity implements SearchView .OnQueryTextListener ,
3940 ListadoAmistadesFragment .AmistadesListListener ,
4041 ListadoHistoriasFragment .HistoriasListListener ,
4142 ListadoConversacionesFragment .ConversacionesListListener ,
4243 ListadoNotificacionesFragment .NotificacionesListListener {
4344
44- //private SectionsPagerAdapter mAdapter;
45- //private ActionBar actionBar;
4645 private SectionsPagerAdapter mSectionsPagerAdapter ;
4746 private ViewPager mViewPager ;
4847
@@ -61,29 +60,53 @@ protected void onCreate(Bundle savedInstanceState) {
6160 mViewPager = (ViewPager ) findViewById (R .id .container );
6261 mViewPager .setAdapter (mSectionsPagerAdapter );
6362
63+ ImageButton b_menu = findViewById ( R .id .buttonMenu );
64+ b_menu .setOnClickListener (new View .OnClickListener (){
65+ @ Override
66+ public void onClick (View view ){
67+ goMenu ();
68+ }
69+ });
70+ ImageButton b_chat = findViewById ( R .id .buttonChat );
71+ b_chat .setOnClickListener (new View .OnClickListener (){
72+ @ Override
73+ public void onClick (View view ){
74+ goChat ();
75+ }
76+ });
77+
78+ ImageButton b_amigos = findViewById ( R .id .buttonAmigos );
79+ b_amigos .setOnClickListener (new View .OnClickListener (){
80+ @ Override
81+ public void onClick (View view ){
82+ goAmistades ();
83+ }
84+ });
85+
86+ ImageButton b_notif = findViewById ( R .id .buttonNotificaciones );
87+ b_notif .setOnClickListener (new View .OnClickListener (){
88+ @ Override
89+ public void onClick (View view ){
90+ goNotif ();
91+ }
92+ });
93+
6494 FloatingActionButton fab = (FloatingActionButton ) findViewById (R .id .fab );
6595 fab .setOnClickListener (new View .OnClickListener () {
6696 @ Override
6797 public void onClick (View view ) {
68- Snackbar .make (view , "Replace with your own action" , Snackbar .LENGTH_LONG )
69- .setAction ("Action" , null ).show ();
98+ // Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
99+ // .setAction("Action", null).show();
70100 }
71101 });
72102
73103 }
74104
75- public void goMenu (){
76- Intent intent = new Intent (this , LoginActivity .class );
77- startActivity (intent );
78- }
79- public void goChat (){
80- Intent intent = new Intent (this , LoginActivity .class );
81- startActivity (intent );
82- }
83- public void goNotif (){
84- Intent intent = new Intent (this , LoginActivity .class );
85- startActivity (intent );
86- }
105+ public void goMenu (){ mViewPager .setCurrentItem (0 ); }
106+ public void goAmistades (){ mViewPager .setCurrentItem (1 ); }
107+ public void goNotif (){ mViewPager .setCurrentItem (2 ); }
108+ public void goChat (){ mViewPager .setCurrentItem (3 ); }
109+
87110
88111
89112 @ Override
@@ -99,17 +122,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
99122 // automatically handle clicks on the Home/Up button, so long
100123 // as you specify a parent activity in AndroidManifest.xml.
101124 int id = item .getItemId ();
125+ if (id == R .id .buttonChat ) {goChat (); return true ;}
126+ if (id == R .id .buttonNotificaciones ) {goNotif (); return true ;}
127+ if (id == R .id .buttonAmigos ) {goAmistades (); return true ;}
128+ if (id == R .id .buttonMenu ) {goMenu (); return true ;}
129+ if (id == R .id .action_logout ) {exit (); return true ;}
102130
103- if (id == R .id .action_logout ){
104- exit ();
105- return true ;
106-
107- }
108- /*if (id == R.id.action_perfil) {
109- goPerfil();
110- return true;
111- }*/
112-
131+ //if (id == R.id.action_perfil) {goPerfil(); return true; }
113132 return super .onOptionsItemSelected (item );
114133 }
115134
@@ -134,29 +153,24 @@ public boolean onQueryTextChange(String newText) {
134153
135154 @ Override
136155 public void onAmistadClicked (Amistad amistad ) {
137- Intent intent = new Intent ();
138- intent .setClass (this , MiPerfilActivity .class );
139- startActivity (intent );
140156 }
141157
142158 @ Override
143159 public void onHistoriaClicked (Historia historia ) {
144- Intent intent = new Intent ();
145- intent .setClass (this , MiPerfilActivity .class );
146- startActivity (intent );
147160 }
148161 @ Override
149- public void onAmistadClicked (Conversacion conversacion ){
150- Intent intent = new Intent ();
151- intent .setClass (this , MiPerfilActivity .class );
152- startActivity (intent );
162+ public void onConversacionClickedRechazar (Conversacion conversacion ){
163+ String rechazar = "rechazo" ;
164+ conversacion .notify ();
165+ }
166+ @ Override
167+ public void onConversacionClickedAceptar (Conversacion conversacion ){
153168 }
154-
155169 @ Override
156170 public void onNotificacionClicked (Notificacion notificacion ) {
157- Intent intent = new Intent ();
158- intent .setClass (this , MiPerfilActivity .class );
159- startActivity (intent );
171+ // Intent intent = new Intent();
172+ // intent.setClass(this, MiPerfilActivity.class);
173+ // startActivity(intent);
160174 }
161175
162176 /**
@@ -188,59 +202,13 @@ public static PlaceholderFragment newInstance(int sectionNumber) {
188202 public View onCreateView (LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) {
189203
190204 final View rootView = inflater .inflate (R .layout .fragment_main , container , false );
191-
192205 ImageButton b_menu = (ImageButton ) rootView .findViewById (R .id .buttonMenu );
193206 b_menu .setOnClickListener (new View .OnClickListener () {
194207 @ Override
195208 public void onClick (View v ) {
196- LinearLayout ll = (LinearLayout ) rootView .findViewById (R .id .menu_cambiante );
197- ll .removeAllViews ();
198- ll .addView ( getLayoutInflater ().inflate (R .layout .activity_historias , null ));
209+ v .setVisibility (View .GONE );
199210 }
200211 });
201-
202- ImageButton b_amigos = (ImageButton ) rootView .findViewById (R .id .buttonAmigos );
203- b_amigos .setOnClickListener (new View .OnClickListener () {
204- @ Override
205- public void onClick (View v ) {
206- LinearLayout ll = (LinearLayout ) rootView .findViewById (R .id .menu_cambiante );
207- ll .removeAllViews ();
208- ll .addView ( getLayoutInflater ().inflate (R .layout .activity_amistades_nuevas , null ));
209- }
210- });
211-
212- ImageButton b_notificaciones = (ImageButton ) rootView .findViewById (R .id .buttonNotificaciones );
213- b_notificaciones .setOnClickListener (new View .OnClickListener () {
214- @ Override
215- public void onClick (View v ) {
216- LinearLayout ll = (LinearLayout ) rootView .findViewById (R .id .menu_cambiante );
217- ll .removeAllViews ();
218- ll .addView ( getLayoutInflater ().inflate (R .layout .activity_opciones , null ));
219- }
220- });
221-
222- ImageButton b_chat = (ImageButton ) rootView .findViewById (R .id .buttonChat );
223- b_chat .setOnClickListener (new View .OnClickListener () {
224- @ Override
225- public void onClick (View v ) {
226- LinearLayout ll = (LinearLayout ) rootView .findViewById (R .id .menu_cambiante );
227- ll .removeAllViews ();
228- ll .addView ( getLayoutInflater ().inflate (R .layout .activity_conversaciones , null ));
229-
230- }
231- });
232-
233- // ImageButton b_options = (ImageButton) rootView.findViewById(R.id.buttonOptions);
234- // b_options.setOnClickListener(new View.OnClickListener() {
235- // @Override
236- // public void onClick(View v) {
237- // LinearLayout ll = (LinearLayout) rootView.findViewById(R.id.menu_cambiante);
238- // ll.removeAllViews();
239- // ll.addView( getLayoutInflater().inflate(R.layout.activity_opciones, null));
240- // }
241- // });
242-
243-
244212 return rootView ;
245213
246214 }
@@ -249,10 +217,7 @@ public void pantallaPPAL(){
249217 Intent intent = new Intent (this , MiPerfilActivity .class );
250218 startActivity (intent );
251219 }
252- /**
253- * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
254- * one of the sections/tabs/pages.
255- */
220+
256221 public class SectionsPagerAdapter extends FragmentPagerAdapter {
257222
258223 public SectionsPagerAdapter (FragmentManager fm ) {
0 commit comments