Exemplo n.º 1
0
  public static void copyDataBase(SharedPreferences sharedPreferences) {

    try {
      logger.debug("Copie de base Magasins debutee");
      InputStream inStream = ctx.getResources().openRawResource(R.raw.poimeuge);
      byte[] buffer = new byte[inStream.available()];
      inStream.read(buffer);
      inStream.close();
      FileOutputStream fos =
          new FileOutputStream(
              ctx.getDir("databases", 0) + "/" + ctx.getString(R.string.database_file_interne),
              false);
      fos.write(buffer);
      fos.close();
      SharedPreferences.Editor editor = sharedPreferences.edit();
      editor.putBoolean(BundleTools.DATABASE_CHARGE, true);
      editor.commit();
      logger.debug("Fin de copie de base Magasins debutee");
    } catch (FileNotFoundException e) {
      logger.error("Fichier base non trouve");
    } catch (IOException e) {
      logger.error(
          String.format(
              "Fichier bizarre : %s non trouve", ctx.getString(R.string.database_file_interne)));
    }
  }
Exemplo n.º 2
0
 public static Logger getLoggerPerso() {
   Logger retour = getLogger();
   if (Boolean.getBoolean(ctx.getString(R.string.log_enable)))
     retour.addAppender(getLogCatAppender);
   retour.addAppender(getFileAppender);
   return retour;
 }
Exemplo n.º 3
0
 /**
  * Sets the context for the logger which will add support for logging to file
  *
  * @param c context of the logger
  */
 public synchronized void setContext(Context c) {
   if (mFileAppender == null) {
     PatternFormatter formatter = new PatternFormatter();
     /*
      * Format date message throwable
      */
     formatter.setPattern("%d{ISO8601} %m %T");
     /*
      * Always write logs to file
      */
     mFileAppender = new FileAppender(c);
     mFileAppender.setFormatter(formatter);
     File logFile = mFileAppender.getLogFile();
     boolean append = true;
     if (logFile != null) {
       if (logFile.length() > 1024 * 1024) {
         /*
          * The log file is > 1MB, start a new one
          */
         append = false;
       }
     }
     mFileAppender.setAppend(append);
     mMicrologLogger.addAppender(mFileAppender);
   }
 }
Exemplo n.º 4
0
 private static void chargeBase(SharedPreferences sharedPreferences) {
   if (!BundleTools.isDBaseLoaded(sharedPreferences)) {
     copyDataBase(sharedPreferences);
     if (!BundleTools.isDBaseLoaded(sharedPreferences)) {
       // ...on affiche un Toast pour le signaler à l'utilisateur
       Toast.makeText(ctx, "Chargement de base Magasins", Toast.LENGTH_SHORT).show();
       logger.debug("Chargement de base Magasins debutee");
       LectureFichierPOI.LectureFichier(
           ctx.getResources().openRawResource(R.raw.magasins),
           "Magasins.asc",
           ctx,
           sharedPreferences);
       logger.debug("Fin de chargement de base Magasins");
       Toast.makeText(ctx, "Chargement de base Magasins finie", Toast.LENGTH_SHORT).show();
       // Magasins_But.Magasins_But(contextCreated);
     }
   }
 }
Exemplo n.º 5
0
  private Log() {
    mMicrologLogger = LoggerFactory.getLogger();

    /*
     * Only write prints to logcat if this is a
     * debug build
     */
    if (WakeMeSki.DEBUG) {
      mMicrologLogger.addAppender(new LogCatAppender());
    }
  }
Exemplo n.º 6
0
  /**
   * @Description
   *
   * @param name
   */
  private void playMusic(String name) {
    try {
      if (mMediaPlayer.isPlaying()) {
        mMediaPlayer.stop();
      }
      mMediaPlayer.reset();
      mMediaPlayer.setDataSource(name);
      mMediaPlayer.prepare();
      mMediaPlayer.start();
      mMediaPlayer.setOnCompletionListener(
          new OnCompletionListener() {
            public void onCompletion(MediaPlayer mp) {}
          });

    } catch (Exception e) {
      LOGGER.error("播放出错", e);
    }
  }