app/src/main/java/com/kevinrei/chronotrack/NewGameActivity.java
// Update the database with the new game
Update the database with the new game
Update the database with the new game
private void updateGameLibrary() {
        gameTitle = mTitle.getText().toString();
        if (imgContent == null) {
            gameImage = "";
        } else {
            gameImage = imgContent;
        }
        gameCategory = mCategory.getSelectedItem().toString();
        if (isEmpty(mUnit)) {
            staminaUnit = "Stamina";
        } else {
            staminaUnit = mUnit.getText().toString();
        }
        recoveryRate = getRateValue(mRecovery);
        if (isEmpty(mStamina)) {
            maxStamina = 0;
        } else {
            maxStamina = Integer.parseInt(mStamina.getText().toString());
        }
        Game game = new Game();
        game.setTitle(gameTitle);
        game.setImage(gameImage);
        game.setCategory(gameCategory);
        game.setUnit(staminaUnit);
        game.setRecoveryRate(recoveryRate);
        game.setMaxStamina(maxStamina);
        if (flag == 2) {
            db.updateGame(game, appId);
        } else {
            db.addGame(game);
        }
        notifyGameAdapter(game);
    }
private void updateGameLibrary ( ) { gameTitle = mTitle . getText ( ) . toString ( ) ; if ( imgContent == null ) { gameImage = "" ; } else { gameImage = imgContent ; } gameCategory = mCategory . getSelectedItem ( ) . toString ( ) ; if ( isEmpty ( mUnit ) ) { staminaUnit = "Stamina" ; } else { staminaUnit = mUnit . getText ( ) . toString ( ) ; } recoveryRate = getRateValue ( mRecovery ) ; if ( isEmpty ( mStamina ) ) { maxStamina = 0 ; } else { maxStamina = Integer . parseInt ( mStamina . getText ( ) . toString ( ) ) ; } Game game = new Game ( ) ; game . setTitle ( gameTitle ) ; game . setImage ( gameImage ) ; game . setCategory ( gameCategory ) ; game . setUnit ( staminaUnit ) ; game . setRecoveryRate ( recoveryRate ) ; game . setMaxStamina ( maxStamina ) ; if ( flag == 2 ) { db . updateGame ( game , appId ) ; } else { db . addGame ( game ) ; } notifyGameAdapter ( game ) ; }
Update the database with the new game
Update the database with the new game
// Title // Image // Category // Unit // Recovery rate // Maximum stamina