Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Homework #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Homework #6

wants to merge 5 commits into from

Conversation

Nadenokk
Copy link

No description provided.

Nadya added 2 commits April 7, 2019 19:57
@otopba otopba self-requested a review April 20, 2019 10:23
Copy link

@otopba otopba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Работа выполнена хорошо.
Есть небольшие замечания

ball = findViewById(R.id.activity_main_ball);
hoop = findViewById(R.id.activity_main_hoop);

final ConstraintLayout activityMain = findViewById(R.id.activity_main);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это не активити, название не соответствует

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправила

}

public boolean AnimatorTrack(final float X, final float Y, final float xHoop, final float yHoop, final float targetSize) {
ValueAnimator aniView = ValueAnimator.ofFloat(0, 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aniView?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опечаталась, поправила

ball.setTranslationX((float) ((1 - Math.cos(angle)) * X));
ball.setTranslationY((float) (-Math.sin(angle) * Math.abs(Y)));

if ((Math.abs(xHoop - x) <= targetSize) && (Math.abs(yHoop - y) <= targetSize)) hit = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше всегда ставить фигурные скобки

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поставила

float y = ball.getY();
int rotation = 50 + (int) (Math.random() * 101);

float value = (Float) valueAnimator.getAnimatedValue();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем тут каст к объекту Float ? можно просто float

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправила

switch (hits) {
case 1:
star = findViewById(R.id.imageStar1);
star.setImageDrawable(getResources().getDrawable(R.drawable.ic_grade_red_24dp));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно один раз считать drawable и потом использовать. А не считывать каждый раз

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправила

ImageView star;
switch (hits) {
case 1:
star = findViewById(R.id.imageStar1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну нужно каждый раз делать findViewById. Можно один раз найти вью и сохранить ссылку

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправила

android:id="@+id/activity_main_player"
android:layout_width="76dp"
android:layout_height="131dp"
android:layout_marginLeft="50dp"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стоит добавить layout_marginStart

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавила

android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_grade_black_24dp"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Посмотри ворнинг от андроид студии:

To use VectorDrawableCompat, you need to make two modifications to your project. First, set android.defaultConfig.vectorDrawables.useSupportLibrary = true in your build.gradle file, and second, use app:srcCompat instead of android:src to refer to vector drawables.

app:layout_constraintStart_toStartOf="parent" />

<ImageView
android:id="@+id/imageStar1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Названия должны быть однотипные. В нашем случае, через подчеркивание

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправила

@@ -2,12 +2,152 @@

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стоит сохранять аниматоры и останавливать их при уничтожении активити

@otopba
Copy link

otopba commented Apr 20, 2019

Нет кастомного вью

Nadya added 2 commits May 4, 2019 18:37
@@ -59,27 +60,27 @@ public boolean onTouch(View v, MotionEvent event) {
}

public boolean AnimatorTrack(final float X, final float Y, final float xHoop, final float yHoop, final float targetSize) {
ValueAnimator aniView = ValueAnimator.ofFloat(0, 1);
ValueAnimator anyView = ValueAnimator.ofFloat(0, 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже странно название. Почему стало any?

float angle = value * 3.14f;

ball.setRotation(rotation * value);
ball.setTranslationX((float) ((1 - Math.cos(angle)) * X));
ball.setTranslationY((float) (-Math.sin(angle) * Math.abs(Y)));

if ((Math.abs(xHoop - x) <= targetSize) && (Math.abs(yHoop - y) <= targetSize)) hit = true;
if ((Math.abs(xHoop - x) <= targetSize) && (Math.abs(yHoop - y) <= targetSize)) { hit = true;}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше писать на следующей строчке то, что находится внутри фигурных скобок. Можно использовать автоформатирование

ImageView star;
Drawable redStar = getResources().getDrawable(R.drawable.ic_grade_red_24dp);
Drawable blackStar = getResources().getDrawable(R.drawable.ic_grade_black_24dp);
ImageView star1=findViewById(R.id.image_Star1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Методы должны называться с маленьких букв
  2. Не нужно каждый раз считывать ресурсы, можно счиать родин раз
  3. Нейминг ресурсов должен включать только маленькие буквы (image_Star2 и тп)

break;
case 5:
star = findViewById(R.id.imageStar5);
star.setImageDrawable(getResources().getDrawable(R.drawable.ic_grade_red_24dp));
star5.setImageDrawable(redStar);
hits = 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hits не используется

@Nadenokk
Copy link
Author

Nadenokk commented Jun 4, 2019

Изначально ani было от animator. Затем я забыла что это было так и подумала, что опечаталась в слове any, не вникая в код. И вот вспомнила и назвала полностью AnimatorValue. Всё остальное исправила

@otopba
Copy link

otopba commented Jun 13, 2019

До сих пор нет кастомного вью

@otopba
Copy link

otopba commented Jun 13, 2019

Работа принята
7 балов

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants