Skip to content

Commit

Permalink
updated ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Alina committed Sep 5, 2018
1 parent 3308e3b commit 7f47c7c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
22 changes: 9 additions & 13 deletions app/src/main/java/com/example/alina/tetris/Controller.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package com.example.alina.tetris;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.example.alina.tetris.R;
import com.example.alina.tetris.listeners.OnControllerListener;
import com.example.alina.tetris.listeners.OnPlayingAreaClick;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

Expand All @@ -21,7 +17,7 @@

public class Controller extends LinearLayout {

private OnControllerListener onControllerListener;
private OnPlayingAreaClick onPlayingAreaClick;

public Controller(Context context) {
super(context);
Expand All @@ -39,25 +35,25 @@ public Controller(Context context, @Nullable AttributeSet attrs, int defStyleAtt
}

private void setLayout() {
View view = inflate(getContext(), R.layout.controller, this);
View view = inflate(getContext(), R.layout.left_right_controls, this);
ButterKnife.bind(this, view);
}

public void setOnControllerListener(OnControllerListener onControllerListener) {
this.onControllerListener = onControllerListener;
public void setOnPlayingAreaClick(OnPlayingAreaClick onPlayingAreaClick) {
this.onPlayingAreaClick = onPlayingAreaClick;
}

@OnClick(R.id.bLeft)
void moveLeft() {
if (onControllerListener != null) {
onControllerListener.onLeftButtonClick();
if (onPlayingAreaClick != null) {
onPlayingAreaClick.onLeftButtonClick();
}
}

@OnClick (R.id.bRight)
void moveRight() {
if (onControllerListener != null) {
onControllerListener.onRightButtonClick();
if (onPlayingAreaClick != null) {
onPlayingAreaClick.onRightButtonClick();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import com.example.alina.tetris.views.PlayingArea;
import com.example.alina.tetris.R;
import com.example.alina.tetris.views.ScoreArea;
import com.example.alina.tetris.listeners.OnControllerListener;
import com.example.alina.tetris.listeners.OnPlayingAreaClick;

import butterknife.BindView;
import butterknife.ButterKnife;


public class MainActivity extends AppCompatActivity implements OnControllerListener {
public class MainActivity extends AppCompatActivity implements OnPlayingAreaClick {

@BindView(R.id.pole)
PlayingArea playingArea;
Expand All @@ -30,7 +30,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
playingArea.setScoreArea(scoreArea);
controller.setOnControllerListener(this);
controller.setOnPlayingAreaClick(this);
playingArea.createFigureWithDelay();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by Alina on 18.03.2017.
*/

public interface OnControllerListener {
public interface OnPlayingAreaClick {

void onRightButtonClick();

Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions app/src/main/res/layout/side_controls.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llSideControls"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/ivRotate"
android:padding="25dp"
android:src="@drawable/ic_rotate"
style="@style/ImageViewStyle"/>

<ImageView
android:id="@+id/ivMoveDown"
android:src="@drawable/ic_down"
android:padding="10dp"
style="@style/ImageViewStyle"/>

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand Down

0 comments on commit 7f47c7c

Please sign in to comment.