To begin with, to improve the readability of the code, I advise you to refer to the document.
Code Conventions for the Java TM Programming Language
There are rules in the convention that should be followed when writing Java libraries, code style rules, Java language rules, etc. These rules should be followed so that your code is concise, understandable and, most importantly, βfamiliarβ to all programmers. Many companies have their own code-writing conventions, but thatβs another story.
There are many translations of Java Code Conventions into Russian, but it is better, if possible, to still read the original. Moreover, it should be done only once.
Specifically, in your example, the following violations of the convention:
operators must be separated by spaces
if (position != 1 && position != 2) {
between the parameters is also necessary space
viewPager.setCurrentItem(position, false);
In Java, it is customary to always use braces, even for "single-line" conditions, each line with a new line
if (strTotalPrice < 500) { Toast.makeText(Home.this, "ΠΠΈΠ½ΠΈΠΌΠ°Π»ΡΠ½Π°Ρ ΡΡΠΌΠΌΠ° Π·Π°ΠΊΠ°Π·Π° 500 ΡΡΠ±.", Toast.LENGTH_SHORT).show(); } else { viewPager.setCurrentItem(position, false); }
I do not pay attention to the structure of the code (enter mutually exclusive if ... else, or go to switch ... case), I made a post about violating the Java convention for writing code, I hope this will be useful