Proyectos de Subversion Android Microlearning - Nuevo Interface

Rev

Rev 62 | Rev 64 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
58 gabriel 1
package com.cesams.twogetskills.fragment;
2
 
3
import android.app.AlertDialog;
4
import android.content.DialogInterface;
5
import android.os.Bundle;
6
 
7
import androidx.cardview.widget.CardView;
8
import androidx.fragment.app.Fragment;
9
import androidx.recyclerview.widget.GridLayoutManager;
10
import androidx.recyclerview.widget.RecyclerView;
11
 
63 gabriel 12
import android.os.Handler;
58 gabriel 13
import android.text.Html;
14
import android.util.Log;
15
import android.view.LayoutInflater;
16
import android.view.View;
17
import android.view.ViewGroup;
18
import android.widget.Button;
19
import android.widget.EditText;
20
import android.widget.ImageView;
21
import android.widget.ProgressBar;
22
import android.widget.RatingBar;
23
import android.widget.TextView;
24
import android.widget.Toast;
25
 
26
import com.bumptech.glide.Glide;
27
import com.bumptech.glide.load.engine.DiskCacheStrategy;
28
import com.bumptech.glide.load.model.GlideUrl;
29
import com.bumptech.glide.load.model.LazyHeaders;
30
import com.bumptech.glide.request.RequestOptions;
31
import com.cesams.twogetskills.Configuration;
32
import com.cesams.twogetskills.Constants;
33
import com.cesams.twogetskills.R;
34
import com.cesams.twogetskills.activity.MainActivity;
35
import com.cesams.twogetskills.adapter.CommentListViewAdapter;
36
import com.cesams.twogetskills.dao.CapsuleDao;
37
import com.cesams.twogetskills.dao.ProgressDao;
38
import com.cesams.twogetskills.entity.Capsule;
39
import com.cesams.twogetskills.entity.Progress;
40
import com.cesams.twogetskills.library.Http;
41
import com.cesams.twogetskills.library.MD5;
42
import com.cesams.twogetskills.skeleton.IReloadData;
43
import com.cesams.twogetskills.skeleton.ITwoGetSkills;
44
import com.google.android.material.tabs.TabLayout;
45
 
46
import org.json.JSONArray;
47
import org.json.JSONException;
48
import org.json.JSONObject;
49
 
50
import java.io.IOException;
51
import java.text.DecimalFormat;
52
import java.util.ArrayList;
53
import java.util.Calendar;
54
import java.util.HashMap;
55
import java.util.Random;
56
import java.util.TimeZone;
63 gabriel 57
import java.util.concurrent.TimeUnit;
58 gabriel 58
 
59
import okhttp3.Call;
60
import okhttp3.FormBody;
63 gabriel 61
import okhttp3.Interceptor;
58 gabriel 62
import okhttp3.OkHttpClient;
63
import okhttp3.Request;
64
import okhttp3.RequestBody;
65
import okhttp3.Response;
66
 
67
 
68
public class CapsuleDetail extends Fragment implements CommentListViewAdapter.ClickListener {
69
 
59 gabriel 70
    private ITwoGetSkills iTwoGetSkills;  Capsule capsula;  Progress progreso;
58 gabriel 71
    TextView nombrecapsula, descripcion, puntuacion, comentarios, porcentaje,docomments;
72
    ImageView capsuleImage; ProgressBar mProgressbar;     private DecimalFormat mDecimalFormat; CardView tarjeta;
73
    TabLayout tabscapsule; RecyclerView listadecomentarios; EditText comentar; Button comentarBoton, continuar; RatingBar ratinglevel;
74
    CommentListViewAdapter adapter;     ArrayList<HashMap<String, String>> commentList;
75
 
76
 
77
    public CapsuleDetail() {
78
        // Required empty public constructor
79
    }
80
 
81
    @Override
82
    public void onCreate(Bundle savedInstanceState) {
83
        super.onCreate(savedInstanceState);
84
    }
85
 
86
    @Override
87
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
88
                             Bundle savedInstanceState) {
89
        View view = inflater.inflate(R.layout.fragment_capsule_detail, container, false);
90
 
91
        iTwoGetSkills = (ITwoGetSkills) getActivity();
92
        ratinglevel = view.findViewById(R.id.ratingBar); continuar= view.findViewById(R.id.continuarbutton); tarjeta= view.findViewById(R.id.cardView3);
93
        capsuleImage = view.findViewById(R.id.imageView4); mProgressbar= view.findViewById(R.id.progressBar3);
94
        nombrecapsula = view.findViewById(R.id.textView19); descripcion = view.findViewById(R.id.textView20);
95
        comentarios = view.findViewById(R.id.textView21); puntuacion = view.findViewById(R.id.textView22);
96
        porcentaje = view.findViewById(R.id.textView17); mDecimalFormat = new DecimalFormat("#.##");
97
        tabscapsule = view.findViewById(R.id.tabLayout2); listadecomentarios = view.findViewById(R.id.recyclerView);
98
        comentar = view.findViewById(R.id.editTextComentar); comentarBoton = view.findViewById(R.id.button4); docomments=view.findViewById(R.id.textView23);
99
 
100
        commentList = new ArrayList<>();
101
        adapter = new CommentListViewAdapter(getContext(),commentList);
102
 
103
        GridLayoutManager layoutcomments = new GridLayoutManager(getContext(),1,GridLayoutManager.VERTICAL, false);
104
        listadecomentarios.setLayoutManager(layoutcomments);
105
        listadecomentarios.setAdapter(adapter);
106
 
107
        adapter.setClickListener(this);
108
 
109
        loaddata();
110
 
63 gabriel 111
 
58 gabriel 112
        comentar.setOnFocusChangeListener((v, hasFocus) -> {
113
 
114
            if(hasFocus){
115
 
116
                tarjeta.setVisibility(View.GONE);
117
            }
118
            else
119
            {
120
                tarjeta.setVisibility(View.VISIBLE);
121
                iTwoGetSkills.hideKeyboard(v);
122
            }
123
        });
124
 
125
        continuar.setOnClickListener(v -> iTwoGetSkills.invokeFragment(Constants.IDX_FRAGMENT_SLIDES));
126
 
127
        tabscapsule.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
128
            @Override
129
            public void onTabSelected(TabLayout.Tab tab) {
130
                int position = tab.getPosition();
131
 
132
                if (position == 0) {
133
                    descripcion.setVisibility(View.VISIBLE);
134
                    descripcion.setText(Html.fromHtml(capsula.getDescription(), Html.FROM_HTML_MODE_COMPACT));
135
                    listadecomentarios.setVisibility(View.GONE);
136
                    comentar.setVisibility(View.GONE);
137
                    comentarBoton.setVisibility(View.GONE);  ratinglevel.setVisibility(View.VISIBLE);
138
                    ratinglevel.setEnabled(false);
139
                    docomments.setVisibility(View.GONE);
140
 
141
 
142
                } else if (position == 1) {
143
                    descripcion.setVisibility(View.GONE);
144
                    listadecomentarios.setVisibility(View.VISIBLE);
145
                    comentar.setVisibility(View.GONE);
146
                    ratinglevel.setVisibility(View.GONE);
147
                    if(capsula.getTotal_comments()==0)
148
                    {
149
                        descripcion.setVisibility(View.VISIBLE);
150
                        descripcion.setText(R.string.no_comments);
151
                    }
152
 
153
                    comentarBoton.setVisibility(View.GONE);
154
                    docomments.setVisibility(View.GONE);
155
 
156
                    loadComments();
157
 
158
                } else if (position == 2) {
159
                    descripcion.setVisibility(View.GONE);
160
                    listadecomentarios.setVisibility(View.GONE);
161
                    comentar.setVisibility(View.VISIBLE);
162
                    comentarBoton.setVisibility(View.VISIBLE); ratinglevel.setVisibility(View.VISIBLE);
163
                    ratinglevel.setEnabled(true);
164
                    docomments.setVisibility(View.VISIBLE);
165
 
166
                }
167
            }
168
 
169
            @Override
170
            public void onTabUnselected(TabLayout.Tab tab) {
171
 
172
            }
173
 
174
            @Override
175
            public void onTabReselected(TabLayout.Tab tab) {
176
 
177
            }
178
        });
179
 
180
        comentarBoton.setOnClickListener(v -> {
181
 
59 gabriel 182
            if(progreso != null) {
183
            if(progreso.getProgress() >0)
184
            {
185
                Toast.makeText(getActivity().getApplicationContext(), "Enviando tu comentario..", Toast.LENGTH_SHORT).show();
58 gabriel 186
 
59 gabriel 187
                String bodyComment = comentar.getText().toString();
188
                String rating = String.valueOf(ratinglevel.getRating());
58 gabriel 189
 
59 gabriel 190
                //Enviamos el comentario de la capsula
191
                addComment(capsula.getUuid(),
192
                        bodyComment,rating);
193
            }
58 gabriel 194
 
59 gabriel 195
            }
196
            else{
197
                Toast.makeText(getActivity().getApplicationContext(), "Toma tiempo para ver esta cápsula antes de comentar", Toast.LENGTH_SHORT).show();
198
            }
58 gabriel 199
        });
200
 
201
        return view;
202
}
203
 
63 gabriel 204
    private final Handler taskHandler = new android.os.Handler();
205
 
206
    private final Runnable repeatativeTaskRunnable = new Runnable() {
207
        public void run() {
208
                    loadComments();
209
                    Log.e("Ando","cargando comentarios");
210
        }
211
    };
212
 
213
    void startHandler() {
214
        taskHandler.postDelayed(repeatativeTaskRunnable, 5 * 1000);
215
    }
216
 
217
    void stopHandler() {
218
        taskHandler.removeCallbacks(repeatativeTaskRunnable);
219
    }
220
 
58 gabriel 221
    public void loadComments(){
222
 
223
        commentList.clear();
224
 
60 gabriel 225
        if(iTwoGetSkills.isConnectedInternet()) {
226
            try {
227
                TimeZone timeZone = TimeZone.getTimeZone("UTC");
228
                Calendar calendar = Calendar.getInstance(timeZone);
229
                int created = (int) (calendar.getTimeInMillis() / 1000);
58 gabriel 230
 
60 gabriel 231
                Random random = new Random(created);
232
                int rand = 1000 + random.nextInt(8999);
58 gabriel 233
 
60 gabriel 234
                String secret = MD5.generar(iTwoGetSkills.getPreference().getPassword() + ':' + created + ':' + rand);
58 gabriel 235
 
60 gabriel 236
                Http http = new Http(getActivity().getCacheDir(), iTwoGetSkills.getPreference().getDeviceUuid(), secret, created, rand);
237
                OkHttpClient client = http.getHttpClient(false);
58 gabriel 238
 
60 gabriel 239
                Request request = new Request.Builder()
240
                        .url(Configuration.URL_COMMENTS + capsula.getUuid())
241
                        .build();
58 gabriel 242
 
243
 
60 gabriel 244
                Call call = client.newCall(request);
245
                call.enqueue(new okhttp3.Callback() {
246
                    public void onResponse(Call call, Response response)
247
                            throws IOException {
248
                        Log.d("TAG", "Response :  " + response.body().toString());
58 gabriel 249
 
60 gabriel 250
                        processResponseSyncToServer(response.body().string());
63 gabriel 251
                        stopHandler();
60 gabriel 252
                    }
58 gabriel 253
 
60 gabriel 254
                    public void onFailure(Call call, IOException e) {
255
                        Log.d("Tag", "Error :  " + e.getMessage());
63 gabriel 256
                        startHandler();
60 gabriel 257
                    }
258
                });
259
            } catch (Exception e) {
63 gabriel 260
                Log.e("Exception load"," comentarios"+e);
60 gabriel 261
            }
58 gabriel 262
        }
60 gabriel 263
        else
264
        {
265
            descripcion.setVisibility(View.VISIBLE);
266
            descripcion.setText("No tienes conexión en este momento");
63 gabriel 267
            startHandler();
60 gabriel 268
        }
58 gabriel 269
 
270
 
271
    }
272
 
273
 
274
    public void addComment(String capsuleUuid, String bodycomment, String rating)
275
    {
276
        //Preparo el numero
277
        rating= rating.substring(0,1);
278
 
60 gabriel 279
        if(iTwoGetSkills.isConnectedInternet()) {
280
            try {
281
                TimeZone timeZone = TimeZone.getTimeZone("UTC");
282
                Calendar calendar = Calendar.getInstance(timeZone);
283
                int created = (int) (calendar.getTimeInMillis() / 1000);
58 gabriel 284
 
60 gabriel 285
                Random random = new Random(created);
286
                int rand = 1000 + random.nextInt(8999);
58 gabriel 287
 
60 gabriel 288
                String secret = MD5.generar(iTwoGetSkills.getPreference().getPassword() + ':' + created + ':' + rand);
58 gabriel 289
 
60 gabriel 290
                Http http = new Http(getActivity().getCacheDir(), iTwoGetSkills.getPreference().getDeviceUuid(), secret, created, rand);
291
                OkHttpClient client = http.getHttpClient(false);
58 gabriel 292
 
60 gabriel 293
                RequestBody formBody = new FormBody.Builder()
294
                        .add("comment", bodycomment)
295
                        .add("rating", rating)
296
                        .build();
58 gabriel 297
 
60 gabriel 298
                Request request = new Request.Builder()
299
                        .url(Configuration.URL_COMMENTS + capsuleUuid + "/add")
300
                        .post(formBody)
301
                        .build();
58 gabriel 302
 
303
 
60 gabriel 304
                Call call = client.newCall(request);
305
                call.enqueue(new okhttp3.Callback() {
306
                    public void onResponse(Call call, Response response)
307
                            throws IOException {
308
                        Log.d("TAG", "Response :  " + response.body().toString());
58 gabriel 309
 
60 gabriel 310
                        processResponseSyncToServer(response.body().string());
311
                    }
58 gabriel 312
 
60 gabriel 313
                    public void onFailure(Call call, IOException e) {
314
                        Log.d("Tag", "Error :  " + e.getMessage());
63 gabriel 315
 
60 gabriel 316
                    }
317
                });
318
            } catch (Exception e) {
319
            }
320
        }else
321
        {
322
            Toast.makeText(getActivity().getApplicationContext(), "En este momento no tienes conexión para enviar el comentario", Toast.LENGTH_SHORT).show();
58 gabriel 323
        }
324
    }
325
 
326
 
327
    private void processResponseSyncToServer(String dataString)
328
    {
329
        boolean success = false;
330
        long sync_id = 0;
331
        JSONArray comentariosarray;
332
 
333
        try {
334
            JSONObject objJSON = new JSONObject(dataString);
335
            success = objJSON.has("success") ? objJSON.getBoolean("success")  : false;
336
            if(success  && objJSON.has("data")) {
337
                JSONObject jsonObjectData = objJSON.getJSONObject("data");
338
 
339
               // Log.e("Respuesta server:", jsonObjectData.toString());
340
 
341
 
342
                if(jsonObjectData.has("message"))
343
                {
344
 
59 gabriel 345
                    if(jsonObjectData.getString("message").equals("El comentario ha sido borrado con éxito"))
58 gabriel 346
                    {
63 gabriel 347
                        requireActivity().runOnUiThread(() -> Toast.makeText(requireActivity().getApplicationContext(), "¡Comentario eliminado, cargando comentarios..!", Toast.LENGTH_SHORT).show());
58 gabriel 348
                        loadComments();
349
                    }
350
                    else {
63 gabriel 351
                        requireActivity().runOnUiThread(() -> Toast.makeText(requireActivity().getApplicationContext(), "¡Comentario enviado, cargando comentarios..!", Toast.LENGTH_SHORT).show());
352
                        requireActivity().runOnUiThread(this::loaddata);
353
                        requireActivity().runOnUiThread(() -> tabscapsule.selectTab(tabscapsule.getTabAt(1), true));
354
                        requireActivity().runOnUiThread(() -> comentar.setText(""));
355
 
58 gabriel 356
                    }
357
                }
358
 
359
                if(jsonObjectData.has("comments"))
360
                {
361
                    //getActivity().runOnUiThread(() -> Toast.makeText(getActivity().getApplicationContext(), "Hay comentarios nuevos", Toast.LENGTH_SHORT).show());
362
 
363
 
364
                    comentariosarray = jsonObjectData.getJSONArray("comments");
365
                    Log.e("Comentarios",""+comentariosarray);
366
 
367
                    for(int i = 0; i < comentariosarray.length(); i++)
368
                    {
369
                        JSONObject objects = comentariosarray.getJSONObject(i);
370
                        HashMap<String, String> m_li;
371
                        m_li = new HashMap<>();
372
                        m_li.put("user", objects.getString("fullname"));
373
                        m_li.put("body", objects.getString("comment"));
374
                        m_li.put("fecha", objects.getString("date"));
375
                        m_li.put("rating", objects.getString("rating"));
376
                        m_li.put("image", objects.getString("image"));
377
                        m_li.put("urldelete", objects.getString("link_delete"));
378
 
379
                        commentList.add(m_li);
380
 
381
 
382
                    }
383
 
384
                    Log.e("Lista de comentarios"," "+commentList.toString());
385
                  getActivity().runOnUiThread(new Runnable() {
386
                      @Override
387
                      public void run() {
388
                          adapter.notifyDataSetChanged();
63 gabriel 389
                          descripcion.setVisibility(View.GONE);
58 gabriel 390
                      }
391
                  });
392
 
393
                }
394
 
395
 
396
                JSONObject capsule_update= jsonObjectData.getJSONObject("capsule");
397
 
398
                CapsuleDao updatecapsule = iTwoGetSkills.getDatabase().getCapsuleDao();
399
                updatecapsule.updateByUuid(capsula.getUuid(),capsule_update.getString("total_comments"),capsule_update.getString("total_rating"));
400
 
401
 
402
            }
403
            else
404
            {
405
                Log.e("Ocurrio un problema",objJSON.toString());
406
            }
407
 
408
        } catch (JSONException e) {
409
            e.printStackTrace();
410
        }
411
    }
412
 
413
    @Override
414
    public void onHiddenChanged(boolean hidden) {
415
        super.onHiddenChanged(hidden);
416
 
417
        if(!hidden) {
418
 
63 gabriel 419
            requireActivity().runOnUiThread(() -> {
58 gabriel 420
 
421
                loaddata();
63 gabriel 422
                tabscapsule.selectTab(tabscapsule.getTabAt(0), true);
58 gabriel 423
 
424
 
425
            });
426
 
427
 
428
        }
429
    }
430
 
431
    public void loaddata(){
432
 
433
    CapsuleDao capsuleDao = iTwoGetSkills.getDatabase().getCapsuleDao();
434
    ProgressDao progressDao = iTwoGetSkills.getDatabase().getProgressDao();
435
 
59 gabriel 436
    progreso = progressDao.selectByCapsuleUuid(iTwoGetSkills.getCapsuleUuidActive());
58 gabriel 437
 
438
 
439
    capsula = capsuleDao.selectByUuid(iTwoGetSkills.getCapsuleUuidActive());
440
 
441
    nombrecapsula.setText(capsula.getName()); descripcion.setText(Html.fromHtml(capsula.getDescription(), Html.FROM_HTML_MODE_COMPACT));
442
    comentarios.setText("Comentarios: "+capsula.getTotal_comments()); puntuacion.setText("Puntuación: "+capsula.getTotal_rating());
443
    ratinglevel.setMax(5); ratinglevel.setRating(capsula.getTotal_rating());
444
    ratinglevel.setEnabled(false);
59 gabriel 445
    if(progreso != null) {
446
        mProgressbar.setMax(progreso.getTotalSlides());
447
        mProgressbar.setProgress(progreso.getViewSlides());
448
        porcentaje.setText(mDecimalFormat.format(progreso.getProgress()) + " %");
449
    }
62 gabriel 450
    else
451
    {
452
        mProgressbar.setMax(100);
453
        mProgressbar.setProgress(0);
454
        porcentaje.setText("0%");
455
    }
58 gabriel 456
    iTwoGetSkills.setTitleActionBar(capsula.getName());
457
 
458
    TimeZone timeZone = TimeZone.getTimeZone("UTC");
459
    Calendar calendar = Calendar.getInstance(timeZone);
460
    TimeZone tz = calendar.getTimeZone();
461
    int created =  (int) (calendar.getTimeInMillis() / 1000);
462
 
463
    Random random = new Random(created);
464
    int rand = 1000 + random.nextInt(8999);
465
 
466
 
467
    String deviceUuid = iTwoGetSkills.getPreference().getDeviceUuid();
468
    String password =  iTwoGetSkills.getPreference().getPassword();
469
 
470
 
471
    String secret = MD5.generar(password + ':' +  created + ':' + rand);
472
 
473
    GlideUrl url = new GlideUrl(capsula.getImage(), new LazyHeaders.Builder()
474
            .addHeader(Constants.HTTP_HEADER_ACCEPT, Constants.HTTP_HEADER_ACCEPT_VALUE)
475
            .addHeader(Constants.HTTP_HEADER_SECURITY_TOKEN, deviceUuid)
476
            .addHeader(Constants.HTTP_HEADER_SECURITY_SECRET, secret)
477
            .addHeader(Constants.HTTP_HEADER_SECURITY_CREATED, String.valueOf(created))
478
            .addHeader(Constants.HTTP_HEADER_SECURITY_RAND, String.valueOf(rand))
479
            .build());
480
 
481
    RequestOptions options = new RequestOptions()
482
            .diskCacheStrategy(DiskCacheStrategy.ALL);
483
 
484
    Glide.with(getContext()).load(url)
485
            .thumbnail()
486
            .apply(options)
487
            .into(capsuleImage);
488
 
489
}
490
 
491
    @Override
492
    public void onResume() {
493
        super.onResume();
494
        loaddata();
495
    }
496
 
497
    @Override
498
    public void onItemClick(int position, View v) {
499
 
60 gabriel 500
        Log.e("On", "click");
501
        if (iTwoGetSkills.isConnectedInternet()) {
58 gabriel 502
 
60 gabriel 503
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
504
            alertDialogBuilder.setMessage("¿Deseas eliminar este comentario?");
505
            alertDialogBuilder.setPositiveButton("Si, eliminarlo",
506
                    new DialogInterface.OnClickListener() {
507
                        @Override
508
                        public void onClick(DialogInterface arg0, int arg1) {
58 gabriel 509
 
60 gabriel 510
                            String urldelete = commentList.get(position).get("urldelete");
511
                            String user = commentList.get(position).get("user");
58 gabriel 512
 
60 gabriel 513
                            if (user.equals(iTwoGetSkills.getPreference().getFirstName() + " " + iTwoGetSkills.getPreference().getLastName())) {
514
                                try {
515
                                    TimeZone timeZone = TimeZone.getTimeZone("UTC");
516
                                    Calendar calendar = Calendar.getInstance(timeZone);
517
                                    int created = (int) (calendar.getTimeInMillis() / 1000);
58 gabriel 518
 
60 gabriel 519
                                    Random random = new Random(created);
520
                                    int rand = 1000 + random.nextInt(8999);
58 gabriel 521
 
60 gabriel 522
                                    String secret = MD5.generar(iTwoGetSkills.getPreference().getPassword() + ':' + created + ':' + rand);
58 gabriel 523
 
60 gabriel 524
                                    Http http = new Http(getActivity().getCacheDir(), iTwoGetSkills.getPreference().getDeviceUuid(), secret, created, rand);
525
                                    OkHttpClient client = http.getHttpClient(false);
58 gabriel 526
 
63 gabriel 527
 
60 gabriel 528
                                    RequestBody formBody = new FormBody.Builder()
529
                                            .add("", "")
530
                                            .build();
531
                                    assert urldelete != null;
532
                                    Request request = new Request.Builder()
533
                                            .url(urldelete).post(formBody)
534
                                            .build();
58 gabriel 535
 
536
 
60 gabriel 537
                                    Call call = client.newCall(request);
538
                                    call.enqueue(new okhttp3.Callback() {
539
                                        public void onResponse(Call call, Response response)
540
                                                throws IOException {
541
                                            Log.d("TAG", "Response :  " + response.body().toString());
58 gabriel 542
 
60 gabriel 543
                                            processResponseSyncToServer(response.body().string());
544
                                        }
59 gabriel 545
 
60 gabriel 546
                                        public void onFailure(Call call, IOException e) {
547
                                            Log.d("Tag", "Error :  " + e.getMessage());
548
                                        }
549
                                    });
550
                                } catch (Exception e) {
551
                                }
552
                            } else {
553
                                Log.e("No es mi ", " comentario");
554
                            }
59 gabriel 555
 
58 gabriel 556
 
60 gabriel 557
                        }
558
                    });
58 gabriel 559
 
560
 
60 gabriel 561
            alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
562
                @Override
563
                public void onClick(DialogInterface dialog, int which) {
58 gabriel 564
 
60 gabriel 565
                }
566
            });
567
            AlertDialog alertDialog = alertDialogBuilder.create();
568
            alertDialog.show();
569
            alertDialog.getButton(alertDialog.BUTTON_POSITIVE).setTextColor(getResources().getColor(R.color.design_default_color_error, null));
570
            alertDialog.getButton(alertDialog.BUTTON_NEGATIVE).setTextColor(getResources().getColor(R.color.colorTextColor, null));
58 gabriel 571
 
60 gabriel 572
            alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
573
                @Override
574
                public void onDismiss(DialogInterface dialogInterface) {
58 gabriel 575
 
576
 
60 gabriel 577
                }
578
            });
58 gabriel 579
 
60 gabriel 580
        }
581
        else
582
        {
63 gabriel 583
            Toast.makeText(requireActivity().getApplicationContext(), "No tienes conexión en este momento para ver los detalles.", Toast.LENGTH_SHORT).show();
60 gabriel 584
        }
58 gabriel 585
    }
586
}