This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
private val handler = Handler(Looper.getMainLooper()) | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val dynamic = findViewById<DynamicView>(R.id.dynamic1) | |
val button = findViewById<Button>(R.id.button) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DynamicView | |
@JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : View(context, attrs, defStyleAttr) { | |
private var lastUpdateTime: Long = System.currentTimeMillis() | |
// .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DynamicView | |
@JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : View(context, attrs, defStyleAttr) { | |
private var animateToAmplitude = 0f | |
private var amplitude = 0f | |
private var deltaAmplitude = 0f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomView extends View { | |
protected void onDraw(Canvas canvas) { | |
super.onDraw(canvas); | |
// slightly change some value comparing to previous onDraw call | |
// do some actual drawing using canvas | |
invalidate(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean canBlurChat() { | |
return getDevicePerformanceClass() == PERFORMANCE_CLASS_HIGH; | |
} | |
private static int measureMaxParticlesCount() { | |
switch (SharedConfig.getDevicePerformanceClass()) { | |
default: | |
case SharedConfig.PERFORMANCE_CLASS_LOW: | |
case SharedConfig.PERFORMANCE_CLASS_AVERAGE: | |
return 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SharedConfig { | |
private static int devicePerformanceClass; | |
public final static int PERFORMANCE_CLASS_LOW = 0; | |
public final static int PERFORMANCE_CLASS_AVERAGE = 1; | |
public final static int PERFORMANCE_CLASS_HIGH = 2; | |
public static int getDevicePerformanceClass() { | |
if (devicePerformanceClass == -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DateFormatter { | |
private val cache = HashMap<Long, String>() | |
private val months = arrayOf( | |
"января", | |
"февраля", | |
"марта", | |
"апрель", | |
"мая", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserProfileActivity : AppCompatActivity(), View.OnClickListener, UserProfileView { | |
private val presenter: UserProfilePresenter = UserProfilePresenterImpl(this) | |
@Inject | |
lateinit var api: CardInfoApi | |
override fun onCreate(savedInstanceState: Bundle?) { | |
App.component.inject(this) | |
super.onCreate(savedInstanceState) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(val name: String) | |
fun main() { | |
val users = HashSet<User>() | |
for (i in 0 until 100) { | |
users.add(User("Bob)) | |
} | |
} | |
// Сколько объектов будет в сете после выполнения цикла? |