1. Java / Говнокод #18342

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    public String tommorowCalendarCountry(String date, String country){
    		String tommorowCountry = null;
    		if(date.equals(getTommorow())){
    			tommorowCountry =  country;
    		}
    		return tommorowCountry;
    	}
    	
    	public String tommorowCalendarIndicator(String date, String indicator){
    		String tommorowIndicator = null;
    		if(date.equals(getTommorow())){
    			tommorowIndicator =  indicator;
    		}
    		return tommorowIndicator;
    	}
    	
    	public String tommorowCalendarImportance(String date, String importance){
    		String tommorowImportance = null;
    		if(date.equals(getTommorow())){
    			tommorowImportance =  importance;
    		}
    		return tommorowImportance;
    	}
    	
    	public String tommorowCalendarForecast(String date, String forecast){
    		String tommorowForecast = null;
    		if(date.equals(getTommorow())){
    			tommorowForecast =  forecast;
    		}
    		return tommorowForecast;
    	}
    	
    	public String tommorowCalendarPrevious(String date, String previous){
    		String tommorowPrevious = null;
    		if(date.equals(getTommorow())){
    			tommorowPrevious =  previous;
    		}
    		return tommorowPrevious;
    	}
    	
    	public String tommorowCalendarActual(String date, String actual){
    		String tommorowActual = null;
    		if(date.equals(getTommorow())){
    			tommorowActual =  actual;
    		}
    		return tommorowActual;
    	}
    	
    	public String tommorowCalendarDescription(String date, String description){
    		String tommorowDescription = null;
    		if(date.equals(getTommorow())){
    			tommorowDescription =  description;
    		}
    		return tommorowDescription;
    	}
    	
    	public String tommorowCalendarPeriod(String date, String period){
    		String tommorowPeriod = null;
    		if(date.equals(getTommorow())){
    			tommorowPeriod =  period;
    		}
    		return tommorowPeriod;
    	}
    	
    	public String tommorowCalendarLocation(String date, String location){
    		String tommorowLocation = null;
    		if(date.equals(getTommorow())){
    			tommorowLocation =  location;
    		}
    		return tommorowLocation;
    	}

    пришло с аутсорса. Такого в проекте очень много)

    slavik, 15 Июня 2015

    Комментарии (6)
  2. Java / Говнокод #18317

    +143

    1. 1
    2. 2
    3. 3
    if(memberIdList == null || memberIdList.size() < 0) {
    	return setOfThousandMembers;
    }

    Positiveman, 11 Июня 2015

    Комментарии (11)
  3. Java / Говнокод #18314

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    // ====================== БОЛЬШОЕ Спасибо разработчикам архитектуры FzMobile  (GI Center)=====================
            // =============================== Очень удобно трэкать пурчейсы через вьюшку ================================
    
                // Почему бы и не заинитить вьюшку на статическом контексте.
           /*     final FzView fzView = new FzView(sRelatedApplication);
                // Тут мы тупо дадим отдохнуть процесору,
                // и понадеемся, что во время отдыха их сервис все тами, каким то чудом, поднимется.
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        FzController fzController = null;
                        for (int i = 0 ; i < 4; i++){ // Паттерн "настойчивость(с)" был взаимствован непосредственно из их архитектуры.
                            fzController = fzView.getController();
                        }
                        try{ // а тут может и пиздануться.
                            final float fPrice = price/100f;
                            fzController.savePayment(id, "gbp", fPrice, "gbp", fPrice); // даже и не спрашивайте что это за дублирование....
                        }catch (Throwable t){
                            t.printStackTrace();
                        }
                    }
                },555*//*а почему бы и нет*//*);*/ // - слава Аллаху, мы выпилили эту хуету!
            //==============================================================================================

    Egor, 10 Июня 2015

    Комментарии (0)
  4. Java / Говнокод #18310

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    // Насладитесь
            final String[] array_spinner_drinks = new String[20];
            array_spinner_drinks[0] = "1";
            array_spinner_drinks[1] = "2";
            array_spinner_drinks[2] = "3";
            array_spinner_drinks[3] = "4";
            array_spinner_drinks[4] = "5";
            array_spinner_drinks[5] = "6";
            array_spinner_drinks[6] = "7";
            array_spinner_drinks[7] = "8";
            array_spinner_drinks[8] = "9";
            array_spinner_drinks[9] = "10";
            array_spinner_drinks[10] = "11";
            array_spinner_drinks[11] = "12";
            array_spinner_drinks[12] = "13";
            array_spinner_drinks[13] = "14";
            array_spinner_drinks[14] = "15";
            array_spinner_drinks[15] = "16";
            array_spinner_drinks[16] = "17";
            array_spinner_drinks[17] = "18";
            array_spinner_drinks[18] = "19";
            array_spinner_drinks[19] = "20";
            spinner_drinks = (Spinner) findViewById(R.id.spinner_drinks);
            final ArrayAdapter<String> adapter_drinks = new ArrayAdapter<>(this,
                                                                           android.R.layout.simple_spinner_item,
                                                                           array_spinner_drinks);
            spinner_drinks.setAdapter(adapter_drinks);
    
            // load weight spinner with array
            final String[] array_spinner_weight = new String[34];
            array_spinner_weight[0] = "70";
            array_spinner_weight[1] = "80";
            array_spinner_weight[2] = "90";
            array_spinner_weight[3] = "100";
            array_spinner_weight[4] = "110";
            array_spinner_weight[5] = "120";
            array_spinner_weight[6] = "130";
            array_spinner_weight[7] = "140";
            array_spinner_weight[8] = "150";
            array_spinner_weight[9] = "160";
            array_spinner_weight[10] = "170";
            array_spinner_weight[11] = "180";
            array_spinner_weight[12] = "190";
            array_spinner_weight[13] = "200";
            array_spinner_weight[14] = "210";
            array_spinner_weight[15] = "220";
            array_spinner_weight[16] = "230";
            array_spinner_weight[17] = "240";
            array_spinner_weight[18] = "250";
            array_spinner_weight[19] = "260";
            array_spinner_weight[20] = "270";
            array_spinner_weight[21] = "280";
            array_spinner_weight[22] = "290";
            array_spinner_weight[23] = "300";
            array_spinner_weight[24] = "310";
            array_spinner_weight[25] = "320";
            array_spinner_weight[26] = "330";
            array_spinner_weight[27] = "340";
            array_spinner_weight[28] = "350";
            array_spinner_weight[29] = "360";
            array_spinner_weight[30] = "370";
            array_spinner_weight[31] = "380";
            array_spinner_weight[32] = "390";
            array_spinner_weight[33] = "400";
            spinner_weight = (Spinner) findViewById(R.id.spinner_weight);
            final ArrayAdapter<String> adapter_weight = new ArrayAdapter(this,
                                                                         android.R.layout.simple_spinner_item,
                                                                         array_spinner_weight);
            spinner_weight.setAdapter(adapter_weight);

    Я у мамы программист

    ilsy, 10 Июня 2015

    Комментарии (1)
  5. Java / Говнокод #18308

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    private boolean get(CharArrayExt szNum, CountryAreaContainer container) {
            char cCur = 0;
            if(!szNum.isEmpty()) {
                cCur = szNum.charAt(0);
            }
    
            Country lpSettingsCountry = isRemoveNPrefixAfterCC();
    
            if ((cCur != 0) && lpSettingsCountry != null) {
                //Special processing for numbers like +44(0)204445555
    
                int iLen = lpSettingsCountry.getNationalPrefix().length();
    
                if ((iLen > 0) && szNum.startsWith(lpSettingsCountry.getNationalPrefix())) {
                    szNum.cut(iLen);
                    cCur = szNum.charAt(0);
                    container.areaOffset = iLen;
                }
            }
    
            if ((cCur != 0) && isNodeExist(cCur)) {
                if(getNode(cCur).get(szNum.cut(1), container)) {
                    return true;
                }
            }
    
            int iCount = getItemsCount();
    
            if (iCount == 1) { //Normally
                NodeItemBase lpItem = getItems().get(0);
                if (lpItem.isArea()) {
                    container.area = (Area) lpItem;
                }
                container.country = lpItem.getCountry();
                return true;
            } else {
                if (iCount > 1) {
                    for (int i = 0; i < iCount; i++) {
                        NodeItemBase lpItem = getItems().get(i);
    
                        if (lpItem.isCountry()) {
                            Country lpCountry = (Country) lpItem;
    
                            if (lpCountry.getAreas().size() == 0) {
                                container.country = lpCountry;
                                return true;
                            }
                        }
                    }
                }
            }
    
            return false;
        }

    zaebalsya, 09 Июня 2015

    Комментарии (0)
  6. Java / Говнокод #18302

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    File f = new File(Environment.getExternalStorageDirectory().toString());
                    for (File temp : f.listFiles()) {
                        if (temp.getName().equals("temp.jpg")) {
                            f = temp;
                            break;
                        }
                    }

    Мне больно

    ilsy, 09 Июня 2015

    Комментарии (0)
  7. Java / Говнокод #18291

    +78

    1. 1
    2. 2
    if (optional != null && optional.isPresent()) {
        ...

    zazazazazaza, 07 Июня 2015

    Комментарии (250)
  8. Java / Говнокод #18281

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    public int func_175687_A(BlockPos p_175687_1_)
        {
            int var2 = 0;
            EnumFacing[] var3 = EnumFacing.values();
            int var4 = var3.length;
    
            for (int var5 = 0; var5 < var4; ++var5)
            {
                EnumFacing var6 = var3[var5];
                int var7 = this.getRedstonePower(p_175687_1_.offset(var6), var6);
    
                if (var7 >= 15)
                {
                    return 15;
                }
    
                if (var7 > var2)
                {
                    var2 = var7;
                }
            }
    
            return var2;
        }

    Notch видимо не слышал про Math.Max

    GameLoper, 03 Июня 2015

    Комментарии (14)
  9. Java / Говнокод #18280

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    public static Texture loadTextureFromIntBuffer(int[] data, int width,
            int height)
        {
            // Convert:
            int numPixels = width * height;
            byte[] dataBytes = new byte[numPixels * 4];
            
    ...
            
            // Cleans variables
            dataBytes = null;
            data = null;
            
    ...
        }

    Пример из документации Vuforia SDK под android.
    Давайте поможем GC собрать мусор

    chtulhu, 03 Июня 2015

    Комментарии (0)
  10. Java / Говнокод #18271

    +142

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    if (filter != null)
                for (FilterItem item : filter.getItems()) {
                    if (StringUtils.isBlank(item.getProperty()) || StringUtils.isBlank(item.getValue())) {
                        log.warn("Skipping wrong filter: {}", PrintHelper.objectToString(item));
                        continue;
                    }
    
                    String property = item.getProperty().trim();
                    String value = item.getValue().trim();
                    
                    if (property.equals(USER_ACCESS_LEVEL)) {
                        this.accessLevelType = Integer.valueOf(value);
                        paramsMap.put("user_access_level_type.id", ":" + USER_ACCESS_LEVEL);
                        valuesMap.put(USER_ACCESS_LEVEL, this.accessLevelType);
                    } if (property.equals(USER_TYPE)) {
                        this.userType = Integer.valueOf(value);
                        paramsMap.put("user_type.id", ":" + USER_TYPE);
                        valuesMap.put(USER_TYPE, this.userType);
                    } if (property.equals(FEDERAL_DISTRICT_ID)) {
                        this.federalDistrictId = Integer.valueOf(value);
                        paramsMap.put("user_org_detail.federal_district_fkey", ":" + FEDERAL_DISTRICT_ID);
                        valuesMap.put(FEDERAL_DISTRICT_ID, this.federalDistrictId);
                    } if (property.equals(CONSTITUENT_ENTITY_ID)) {
                        this.constituentEntityId = Integer.valueOf(value);
                        paramsMap.put("user_org_detail.constituent_entity_fkey", ":" + CONSTITUENT_ENTITY_ID);
                        valuesMap.put(CONSTITUENT_ENTITY_ID, this.constituentEntityId);
                    } if (property.equals(FORESTRY_ID)) {
                        this.forestryId = value;
                        paramsMap.put("user_org_detail.forestry_fkey", ":" + FORESTRY_ID);
                        valuesMap.put(FORESTRY_ID, this.forestryId);
                    } if (property.equals(USER_ROLE_ID)) {
                        this.userRoleId = value;
                        paramsMap.put("user_role.role_fkey", ":" + USER_ROLE_ID);
                        valuesMap.put(USER_ROLE_ID, this.userRoleId);
                    } if (property.equals(USER_LOGIN)) {
                        this.userLogin = value;
                        paramsMap.put("usr.login", ":" + USER_LOGIN);
                        valuesMap.put(USER_LOGIN, "%" + this.userLogin + "%");
                    } if (property.equals(USER_NAME)) {
                        this.userName = value;
    
                        String[] query = this.userName.split(" ");
                        String[] fnamePlaceholders = {};
                        String[] lnamePlaceholders = {};
                        String[] mnamePlaceholders = {};
    
                        for (int i = 0; i < query.length; i++) {
                            String fname = ":first_name_" + i;
                            fnamePlaceholders = ArrayUtils.add(fnamePlaceholders, fname);
                            String lname = ":last_name_" + i;
                            lnamePlaceholders = ArrayUtils.add(lnamePlaceholders, lname);
                            String mname = ":middle_name_" + i;
                            mnamePlaceholders = ArrayUtils.add(mnamePlaceholders, mname);
    
                            valuesMap.put("first_name_" + i, "%" + query[i] + "%");
                            valuesMap.put("last_name_" + i, "%" + query[i] + "%");
                            valuesMap.put("middle_name_" + i, "%" + query[i] + "%");
                        }
    
                        userParams.put("usr.first_name", fnamePlaceholders);
                        userParams.put("usr.last_name", lnamePlaceholders);
                        userParams.put("usr.middle_name", mnamePlaceholders);
                    } if (property.equals(USER_STATUS)) {
                        this.userStatus = value;
                        paramsMap.put("usr.status", ":" + USER_STATUS);
                        valuesMap.put(USER_STATUS, this.userStatus);
                    } if (property.equals(PARTY_NAME)) {
                        this.partyName = value;
                        String[] query = value.split(" ");
                        String[] fnamePlaceholders = {};
                        String[] lnamePlaceholders = {};
                        String[] mnamePlaceholders = {};
    
                        for (int i = 0; i < query.length; i++) {
                            String fname = ":person_first_name_" + i;
                            fnamePlaceholders = ArrayUtils.add(fnamePlaceholders, fname);
                            String lname = ":person_last_name_" + i;
                            lnamePlaceholders = ArrayUtils.add(lnamePlaceholders, lname);
                            String mname = ":person_mid_name_" + i;
                            mnamePlaceholders = ArrayUtils.add(mnamePlaceholders, mname);
    
                            valuesMap.put("person_first_name_" + i, "%" + query[i] + "%");
                            valuesMap.put("person_last_name_" + i, "%" + query[i] + "%");
                            valuesMap.put("person_mid_name_" + i, "%" + query[i] + "%");
                        }
    
                        partyParams.put("party.person_first_name", fnamePlaceholders);
                        partyParams.put("party.person_last_name", lnamePlaceholders);
                        partyParams.put("party.person_mid_name", mnamePlaceholders);
    
                        partyParams.put("party.party_name", new String[]{":party_name"});
                        valuesMap.put("party_name", "%" + this.partyName + "%");
    
                    } if (property.equals(PARTY_INN)) {
                        this.partyInn = value;
                        paramsMap.put("party.inn", ":" + PARTY_INN);
                        valuesMap.put(PARTY_INN, this.partyInn);
                    } if (property.equals(USER_IS_MASTER)) {
                        this.userIsMaster = Boolean.valueOf(value);
                        paramsMap.put("user_org_detail.organization_master", ":" + USER_IS_MASTER);

    конструктор для named jdbc
    ... если долго смотреть на строки, можно увидеть жирафа...

    floppy, 02 Июня 2015

    Комментарии (1)