void setContent(final ListItem li, final UidPolicy up) {
    if (getActivity() instanceof FragmentActivity) {
      LogFragment l = new LogFragment();
      l.getInternal().setUidPolicy(up);
      l.getInternal().setListContentId(getFragment().getId());
      mContent = l;
    } else {
      mContent = setContentNative(li, up);
    }

    setContent(mContent, up == null, up == null ? getString(R.string.logs) : up.getName());
  }
Example #2
0
  /** legt ein neues Log-File an */
  private static void newLogFile() {
    android.util.Log.d(TAG, "newLogFile()");
    DateFormat df = new DateFormat();
    String strDate = (String) df.format("_yyyy_MM_dd-hh_mm_ss.txt", new Date());

    String strFileName = "Log_"; // + strDate;
    android.util.Log.d(TAG, "newLogFile(): " + strFileName);
    textFile = new TextFile(Environment.DIRECTORY_DOWNLOADS, strFileName, false);

    if (mLogFrag.isVisible()) {
      mLogFrag.setTextView("LOGGER: new logging file: " + strFileName + "\n");
    }
  }
Example #3
0
  private static void log(String tag, String outStr) {
    // seqNumber++;        // nur für Testzwecke

    // aktuelle Zeit
    long timeS = (System.currentTimeMillis() - startTimeMs) / 1000;
    String strTimeS = Long.toString(timeS);

    // Ausgabestrings formatieren
    // String strDebTag = String.format("%d %s %s %s\n", seqNumber, strTimeS, tag, outStr);
    // String strDeb = String.format("%d %s %s\n", seqNumber, strTimeS, outStr);
    String strDebTag = String.format("%s %s %s\n", strTimeS, tag, outStr);
    String strDeb = String.format("%s %s\n", strTimeS, outStr);
    String strView;

    // Tag anzeigen ?
    if (mLogFrag.isShowingTag) {
      strView = strDebTag;
    } else {
      strView = strDeb;
    }

    // abspeichern
    if (mLogFrag.isSaving2File) {
      if (textFile == null) {
        newLogFile();
      }
      textFile.appendText(strView);
    } else {
      textFile = null;
    }

    // buffern
    mStringBuilder.append(strView);

    // ausgeben falls Fragment sichtbar
    if (mLogFrag.isVisible()) {
      mLogFrag.setTextView(mStringBuilder.toString());
      mStringBuilder.delete(0, mStringBuilder.length());
    }
  }
Example #4
0
 public static void init(Boolean showTimeStamp, Boolean showTag) { // !!a LOG2 !
   mLogFrag = LogFragment.newInstance(showTimeStamp, showTag);
 }
Example #5
0
  public void saveImage(byte[] img) {
    try {
      Image image = new Image(img);
      System.out.println(
          "SenderName: "
              + image.senderName
              + " Filename: "
              + image.filename
              + " Message: "
              + image.message
              + " Location: "
              + image.location);

      if (image.senderName.equals(TabActivity.senderName)) {
        return;
      }

      // checking image is exist in database?
      mCursor =
          sqLiteDatabase.rawQuery(
              "SELECT * FROM "
                  + MyDatabase.TABLE_NAME_PICTURE
                  + " WHERE "
                  + MyDatabase.COL_SENDER_NAME
                  + " = '"
                  + image.senderName
                  + "' AND "
                  + MyDatabase.COL_FILE_NAME
                  + " = '"
                  + image.filename
                  + "' AND "
                  + MyDatabase.COL_MESSAGE
                  + " = '"
                  + image.message
                  + "' AND "
                  + MyDatabase.COL_LOCATION
                  + " = '"
                  + image.location
                  + "'",
              null);

      if (mCursor.getCount() == 0) {
        if (image.imageBytes != null) {
          String filename = image.filename.substring(0, image.filename.length() - 4);
          File file = ManageImage.setUpPhotoFile(mAlbumStorageDirFactory, filename);
          System.out.println("filename :====" + file.getName());
          FileOutputStream fileOutputStream = new FileOutputStream(file);
          fileOutputStream.write(image.getImageBytes());
          ManageImage.galleryAddPic(file.getAbsolutePath(), activity);
        }
        myDatabase.addToTablePicture(
            sqLiteDatabase, image.senderName, image.filename, image.message, image.location);

        Log.d(TAG, "Finished...");

        LogFragment.print(
            "Time recieve: "
                + getCurrentTimeStamp()
                + " | From: "
                + image.senderName
                + " | Message:  "
                + image.message);

        //                LogFragment.print("Time recieve: " + System.currentTimeMillis() + " |
        // From: " + image.senderName + " | Message:  " + image.message);

        System.out.println("TestRecieveData: " + System.currentTimeMillis());

        final String sentMsg = "Received";
        activity.runOnUiThread(
            new Runnable() {
              @Override
              public void run() {
                NewFeedFragment.updateTable();
                Toast.makeText(activity, sentMsg, Toast.LENGTH_LONG).show();
              }
            });

        // Sent to other node
        if (getIPAddressItSelf().equals("0.0.0.0")) {
          Broadcaster.broadcast(image.getBytes(), ListenerPacket.PORT_PACKET);
        }
      }
      ;
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (ImageChunkIncorrectLengthException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }