Beispiel #1
0
  public void tabButtonClicked(View v) {
    Button artist = (Button) findViewById(R.id.buttonArtists);
    Button album = (Button) findViewById(R.id.buttonAlbums);
    Button genres = (Button) findViewById(R.id.buttonGeneres);

    if (album == null || artist == null || genres == null) return;

    artist.setPaintFlags(0);
    album.setPaintFlags(0);
    genres.setPaintFlags(0);
    lastClickedButton = v;

    if (databaseTable.equals("lentout")) {
      populateArrayList(
          "SELECT * FROM records INNER JOIN lentout ON  records._id=lentout.album_id ORDER BY album_id",
          false);
    } else if (v.getId() == artist.getId()) {
      artist.setPaintFlags(artist.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
      populateArrayList("SELECT * FROM " + databaseTable + " GROUP BY bandname", true);
    } else if (v.getId() == album.getId()) {
      album.setPaintFlags(album.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
      populateArrayList("SELECT * FROM " + databaseTable + " ORDER BY albumname;", false);
    } else {
      genres.setPaintFlags(genres.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
      populateArrayList("GENRES", false);
    }
  }
  public void setButton(Activity activity) {

    patientBtn.setPaintFlags(patientBtn.getPaintFlags() | Paint.FAKE_BOLD_TEXT_FLAG);
    patientBtn.setText(R.string.patientdata);
    controlBtn.setPaintFlags(controlBtn.getPaintFlags() | Paint.FAKE_BOLD_TEXT_FLAG);
    controlBtn.setText(R.string.controldata);
    snapshotBtn = (Button) activity.findViewById(R.id.snapshotBtn);
  }
Beispiel #3
0
 private void setupDefaultAppearance() {
   Button album = (Button) findViewById(R.id.buttonAlbums);
   if (album != null) {
     album.setPaintFlags(album.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
     lastClickedButton = album;
     tabButtonClicked(lastClickedButton);
     getSupportActionBar().setTitle("My Collection");
   }
 }
Beispiel #4
0
  public void reloadListView() {
    Button artist = (Button) findViewById(R.id.buttonArtists);
    Button album = (Button) findViewById(R.id.buttonAlbums);
    Button genres = (Button) findViewById(R.id.buttonGeneres);
    Button lastClicked = null;

    if (album == null || artist == null || genres == null) return;

    if (artist.getPaintFlags() != 0) lastClicked = artist;
    else if (album.getPaintFlags() != 0) lastClicked = album;
    else if (genres.getPaintFlags() != 0) lastClicked = genres;

    if (lastClicked == null) {
      lastClicked = album;
      album.setPaintFlags(album.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    }
    tabButtonClicked(lastClicked);
  }
Beispiel #5
0
    @Override
    public View getChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      final Entity ent = (Entity) getChild(groupPosition, childPosition);
      // Set an id depending on the table ent belongs to
      int entId;
      if (ent.getTable() == "homework") {
        entId = 1;
      } else if (ent.getTable() == "assignment") {
        entId = 2;
      } else if (ent.getTable() == "exam") {
        entId = 3;
      } else {
        entId = 4;
      }

      // Depending on the id, do something different. For the first three, the only bit that changes
      // is the string in the alertDialog and the activity
      // that's opened when you press the element on the list. I'll comment due homework list, the
      // other are the same.
      switch (entId) {
          // Due homework list
        case 1:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_dueitem, null);
          try {
            Button title = (Button) convertView.findViewById(R.id.title);
            ImageView remove = (ImageView) convertView.findViewById(R.id.dueremove);
            TextView dueclass = (TextView) convertView.findViewById(R.id.dueclass);
            LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.linearLayout1);

            // When editing this element, get the date it was set, not the date you're viewing.
            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(ent.getLong("setDate"));

            // Set text
            title.setText("- " + ent.getString("title"));
            // If the homework is done, strike it through.
            if (ent.getInt("done") == 1) {
              title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              layout.setBackgroundColor(getResources().getColor(R.color.grey));
            }
            title.setOnClickListener(
                new OnClickListener() {

                  // When the element's pressed, open AddHwDialog with all the necessary data to
                  // edit it.
                  public void onClick(View addexam) {
                    Intent i = new Intent(AgendaDay.this, AddHwDialog.class);
                    i.putExtra("homework_id", ent.getId());
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_EDIT);
                  }
                });

            remove.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View removerecord) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                    builder
                        .setMessage(R.string.sureHomework)
                        .setTitle(R.string.sureHomeworkTitle)
                        .setCancelable(true)
                        .setNegativeButton(
                            R.string.cancel,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                dialog.cancel();
                              }
                            })
                        .setPositiveButton(
                            R.string.accept,
                            new DialogInterface.OnClickListener() {
                              // Remove the element.
                              public void onClick(DialogInterface dialog, int arg1) {
                                ent.delete();
                                fillList();
                              }
                            });
                    AlertDialog AD = builder.create();
                    AD.show();
                  }
                });

            // Get the subject this element is associated with...
            Entity classEnt = new Entity("class", ent.getLong("class_id"));
            Entity subject = new Entity("subject", classEnt.getLong("subject_id"));

            // ...to put it as the name that appears.
            dueclass.setText(subject.getString("title"));
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
          // Due assignment list
        case 2:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_dueitem, null);
          try {
            Button title = (Button) convertView.findViewById(R.id.title);
            ImageView remove = (ImageView) convertView.findViewById(R.id.dueremove);
            TextView dueclass = (TextView) convertView.findViewById(R.id.dueclass);
            LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.linearLayout1);

            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(ent.getLong("setDate"));

            title.setText("- " + ent.getString("title"));
            if (ent.getInt("done") == 1) {
              title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              layout.setBackgroundColor(getResources().getColor(R.color.grey));
            }
            title.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View addexam) {
                    Intent i = new Intent(AgendaDay.this, AddAssignDialog.class);
                    i.putExtra("assign_id", ent.getId());
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_EDIT);
                  }
                });

            remove.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View removerecord) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                    builder
                        .setMessage(R.string.sureAssignment)
                        .setTitle(R.string.sureAssignmentTitle)
                        .setCancelable(true)
                        .setNegativeButton(
                            R.string.cancel,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                dialog.cancel();
                              }
                            })
                        .setPositiveButton(
                            R.string.accept,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                ent.delete();
                                fillList();
                              }
                            });
                    AlertDialog AD = builder.create();
                    AD.show();
                  }
                });

            Entity classEnt = new Entity("class", ent.getLong("class_id"));
            Entity subject = new Entity("subject", classEnt.getLong("subject_id"));

            dueclass.setText(subject.getString("title"));
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
          // Due exam list
        case 3:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_dueitem, null);
          try {
            Button title = (Button) convertView.findViewById(R.id.title);
            ImageView remove = (ImageView) convertView.findViewById(R.id.dueremove);
            TextView dueclass = (TextView) convertView.findViewById(R.id.dueclass);

            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(ent.getLong("setDate"));

            title.setText("- " + ent.getString("title"));
            title.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View addexam) {
                    Intent i = new Intent(AgendaDay.this, AddExamDialog.class);
                    i.putExtra("exam_id", ent.getId());
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_EDIT);
                  }
                });

            remove.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View removerecord) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                    builder
                        .setMessage(R.string.sureExam)
                        .setTitle(R.string.sureExamTitle)
                        .setCancelable(true)
                        .setNegativeButton(
                            R.string.cancel,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                dialog.cancel();
                              }
                            })
                        .setPositiveButton(
                            R.string.accept,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                ent.delete();
                                fillList();
                              }
                            });
                    AlertDialog AD = builder.create();
                    AD.show();
                  }
                });

            Entity classEnt = new Entity("class", ent.getLong("class_id"));
            Entity subject = new Entity("subject", classEnt.getLong("subject_id"));

            dueclass.setText(subject.getString("title"));
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
          // Today's classes list
        case 4:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_item, null);
          try {
            Long subjectid = (Long) ent.getValue("subject_id");
            Entity subjectent = new Entity("subject", subjectid);

            // Get when the class starts and when it ends to...
            String starttimehour = ent.getString("starttimehour");
            // Add a 0 if it's lower than 10, Java doesn't do it automatically.
            if (Integer.parseInt(starttimehour) < 10) {
              starttimehour = "0" + starttimehour;
            }
            String starttimeminute = ent.getString("starttimeminute");
            if (Integer.parseInt(starttimeminute) < 10) {
              starttimeminute = "0" + starttimeminute;
            }
            String endtimehour = ent.getString("endtimehour");
            if (Integer.parseInt(endtimehour) < 10) {
              endtimehour = "0" + endtimehour;
            }
            String endtimeminute = ent.getString("endtimeminute");
            if (Integer.parseInt(endtimeminute) < 10) {
              endtimeminute = "0" + endtimeminute;
            }

            // ...display it nicely in a TextView
            String classLength =
                " ("
                    + starttimehour
                    + ":"
                    + starttimeminute
                    + "-"
                    + endtimehour
                    + ":"
                    + endtimeminute
                    + ")";

            TextView subject = (TextView) convertView.findViewById(R.id.subjectname);
            TextView classLengthText = (TextView) convertView.findViewById(R.id.classlength);
            subject.setText(subjectent.getString("title"));
            classLengthText.setText(classLength);

            LinearLayout hwlist =
                (LinearLayout) convertView.findViewById(R.id.homeworkLinearLayout);
            LinearLayout assignlist =
                (LinearLayout) convertView.findViewById(R.id.assignmentLinearLayout);
            LinearLayout examlist = (LinearLayout) convertView.findViewById(R.id.examLinearLayout);

            try {
              // Start my three arraylists.
              entHw = new ArrayList<Entity>();
              entExams = new ArrayList<Entity>();
              entAssignments = new ArrayList<Entity>();
              // Get today's date.
              Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
              c.set(mYear, mMonth, mDay, 0, 0, 0);
              c.set(Calendar.MILLISECOND, 0);

              // Get all homework associated to the class you're viewing.
              List<Entity> entclassHw =
                  db.getEntityList("homework", "class_id = '" + ent.getId() + "'");
              Iterator<Entity> iter = entclassHw.iterator();
              // Put in entHw only those that are set on the day you're viewing
              while (iter.hasNext()) {
                Entity HwEnt = (Entity) iter.next();
                Calendar d = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                d.setTimeInMillis(HwEnt.getLong("setDate"));
                if (d.getTimeInMillis() == c.getTimeInMillis()) {
                  entHw.add(HwEnt);
                }
              }
              List<Entity> entclassAssignments =
                  db.getEntityList("assignment", "class_id = '" + ent.getId() + "'");
              Iterator<Entity> iter2 = entclassAssignments.iterator();
              while (iter2.hasNext()) {
                Entity AssignEnt = (Entity) iter2.next();
                Calendar d = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                d.setTimeInMillis(AssignEnt.getLong("setDate"));
                if (d.get(Calendar.YEAR) == c.get(Calendar.YEAR)
                    && d.get(Calendar.DAY_OF_YEAR) == c.get(Calendar.DAY_OF_YEAR)) {
                  entAssignments.add(AssignEnt);
                }
              }
              List<Entity> entclassExams =
                  db.getEntityList("exam", "class_id = '" + ent.getId() + "'");
              Iterator<Entity> iter3 = entclassExams.iterator();
              while (iter3.hasNext()) {
                Entity ExamEnt = (Entity) iter3.next();
                Calendar d = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                d.setTimeInMillis(ExamEnt.getLong("setDate"));
                if (d.get(Calendar.YEAR) == c.get(Calendar.YEAR)
                    && d.get(Calendar.DAY_OF_YEAR) == c.get(Calendar.DAY_OF_YEAR)) {
                  entExams.add(ExamEnt);
                }
              }
            } catch (Exception e) {
              e.printStackTrace();
            }

            // Get a date for the day you're viewing
            final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
            c.set(mYear, mMonth, mDay, 0, 0, 0);
            c.set(Calendar.MILLISECOND, 0);

            // For every homework you have on the day your viewing and the class element the list is
            // at.
            for (final Entity ent2 : entHw) {
              LinearLayout linear = new LinearLayout(getApplicationContext());
              linear.setOrientation(LinearLayout.HORIZONTAL);
              LayoutParams linearLayoutParams =
                  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
              linear.setLayoutParams(linearLayoutParams);
              linear.setBackgroundResource(R.color.purple);

              Button hwTitle = new Button(getApplicationContext());
              hwTitle.setText("- " + ent2.getString("title"));
              if (ent2.getInt("done") == 1) {
                hwTitle.setPaintFlags(hwTitle.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              }
              hwTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
              hwTitle.setGravity(Gravity.LEFT);
              hwTitle.setPadding(5, 5, 0, 5);
              LayoutParams titleButtonLayoutParams =
                  new LinearLayout.LayoutParams(
                      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
              hwTitle.setLayoutParams(titleButtonLayoutParams);
              hwTitle.setBackgroundColor(android.R.color.transparent);

              hwTitle.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View addexam) {
                      Intent i = new Intent(AgendaDay.this, AddHwDialog.class);
                      i.putExtra("homework_id", ent2.getId());
                      i.putExtra("todayCalendar", c.getTimeInMillis());
                      startActivityForResult(i, ACTIVITY_EDIT);
                    }
                  });

              ImageView remove = new ImageView(getApplicationContext());
              LayoutParams removeButtonLayoutParams =
                  new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              removeButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL;
              remove.setBackgroundDrawable(getResources().getDrawable(R.drawable.remove));
              remove.setLayoutParams(removeButtonLayoutParams);

              remove.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View removerecord) {
                      AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                      builder
                          .setMessage(R.string.sureHomework)
                          .setTitle(R.string.sureHomeworkTitle)
                          .setCancelable(true)
                          .setNegativeButton(
                              R.string.cancel,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  dialog.cancel();
                                }
                              })
                          .setPositiveButton(
                              R.string.accept,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  ent2.delete();
                                  fillList();
                                }
                              });
                      AlertDialog AD = builder.create();
                      AD.show();
                    }
                  });

              linear.addView(hwTitle);
              linear.addView(remove);
              hwlist.addView(linear);
            }

            for (final Entity ent2 : entAssignments) {
              LinearLayout linear = new LinearLayout(getApplicationContext());
              linear.setOrientation(LinearLayout.HORIZONTAL);
              LayoutParams linearLayoutParams =
                  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
              linear.setLayoutParams(linearLayoutParams);
              linear.setBackgroundResource(R.color.light_green);

              Button assignTitle = new Button(getApplicationContext());
              assignTitle.setText("- " + ent2.getString("title"));
              if (ent2.getInt("done") == 1) {
                assignTitle.setPaintFlags(
                    assignTitle.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              }
              assignTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
              assignTitle.setGravity(Gravity.LEFT);
              assignTitle.setPadding(5, 5, 0, 5);
              LayoutParams titleButtonLayoutParams =
                  new LinearLayout.LayoutParams(
                      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
              assignTitle.setLayoutParams(titleButtonLayoutParams);
              assignTitle.setBackgroundColor(android.R.color.transparent);

              assignTitle.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View addexam) {
                      Intent i = new Intent(AgendaDay.this, AddAssignDialog.class);
                      i.putExtra("assign_id", ent2.getId());
                      i.putExtra("todayCalendar", c.getTimeInMillis());
                      startActivityForResult(i, ACTIVITY_EDIT);
                    }
                  });

              ImageView remove = new ImageView(getApplicationContext());
              LayoutParams removeButtonLayoutParams =
                  new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              removeButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL;
              remove.setBackgroundDrawable(getResources().getDrawable(R.drawable.remove));
              remove.setLayoutParams(removeButtonLayoutParams);

              remove.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View removerecord) {
                      AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                      builder
                          .setMessage(R.string.sureAssignment)
                          .setTitle(R.string.sureAssignmentTitle)
                          .setCancelable(true)
                          .setNegativeButton(
                              R.string.cancel,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  dialog.cancel();
                                }
                              })
                          .setPositiveButton(
                              R.string.accept,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  ent2.delete();
                                  fillList();
                                }
                              });
                      AlertDialog AD = builder.create();
                      AD.show();
                    }
                  });

              linear.addView(assignTitle);
              linear.addView(remove);
              assignlist.addView(linear);
            }

            for (final Entity ent2 : entExams) {
              LinearLayout linear = new LinearLayout(getApplicationContext());
              linear.setOrientation(LinearLayout.HORIZONTAL);
              LayoutParams linearLayoutParams =
                  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
              linear.setLayoutParams(linearLayoutParams);
              linear.setBackgroundResource(R.color.light_orange);

              Button examTitle = new Button(getApplicationContext());
              examTitle.setText("- " + ent2.getString("title"));
              examTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
              examTitle.setGravity(Gravity.LEFT);
              examTitle.setPadding(5, 5, 0, 5);
              LayoutParams titleButtonLayoutParams =
                  new LinearLayout.LayoutParams(
                      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
              examTitle.setLayoutParams(titleButtonLayoutParams);
              examTitle.setBackgroundColor(android.R.color.transparent);

              examTitle.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View addexam) {
                      Intent i = new Intent(AgendaDay.this, AddExamDialog.class);
                      i.putExtra("exam_id", ent2.getId());
                      i.putExtra("todayCalendar", c.getTimeInMillis());
                      startActivityForResult(i, ACTIVITY_EDIT);
                    }
                  });

              ImageView remove = new ImageView(getApplicationContext());
              LayoutParams removeButtonLayoutParams =
                  new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              removeButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL;
              remove.setBackgroundDrawable(getResources().getDrawable(R.drawable.remove));
              remove.setLayoutParams(removeButtonLayoutParams);

              remove.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View removerecord) {
                      AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                      builder
                          .setMessage(R.string.sureExam)
                          .setTitle(R.string.sureExamTitle)
                          .setCancelable(true)
                          .setNegativeButton(
                              R.string.cancel,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  dialog.cancel();
                                }
                              })
                          .setPositiveButton(
                              R.string.accept,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  ent2.delete();
                                  fillList();
                                }
                              });
                      AlertDialog AD = builder.create();
                      AD.show();
                    }
                  });

              linear.addView(examTitle);
              linear.addView(remove);
              examlist.addView(linear);
            }

            ImageView add = (ImageView) convertView.findViewById(R.id.add);

            add.setOnClickListener(
                new OnClickListener() {
                  public void onClick(View addsubject) {
                    Intent i = new Intent(AgendaDay.this, AddAssignmentListDialog.class);
                    i.putExtra("class_id", ent.getId());
                    Calendar c = Calendar.getInstance();
                    c.set(mYear, mMonth, mDay, 0, 0, 0);
                    c.set(Calendar.MILLISECOND, 0);
                    c.setTimeZone(TimeZone.getTimeZone("GMT"));
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_CREATE);
                  }
                });
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
      }
      return convertView;
    }