Skip to content

Commit

Permalink
feat(gameActivity): WIP animations
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrucesdeveloper committed Aug 15, 2022
1 parent 97c97ec commit 5cdf520
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 26 deletions.
17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package com.jorgecruces.metrometro.activities;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.jorgecruces.metrometro.R;
import com.jorgecruces.metrometro.customViews.StationView;
import com.jorgecruces.metrometro.logic.MetroReaderXML;
import com.jorgecruces.metrometro.logic.PickerStationsAlternative;
import com.jorgecruces.metrometro.model.Line;
Expand Down Expand Up @@ -40,8 +46,37 @@ protected void onCreate(Bundle savedInstanceState) {
this.setLineName();
this.initializeLevelData();
this.initializeLevelViews();

this.setCurrentStationQuestion(this.position);
this.testMethod();
}

private void testMethod() {
LinearLayout linearLayout = findViewById(R.id.gameLayout);
StationView stationView = new StationView(this);
stationView.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
));
linearLayout.addView(stationView);


StationView stationView2 = new StationView(this);
stationView2.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
));
linearLayout.addView(stationView2);

DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;

// ObjectAnimator animation = ObjectAnimator.ofFloat(stationView, "translationX", -(width/2));
// animation.setDuration(3000);
// animation.start();


}

/**
Expand Down Expand Up @@ -165,8 +200,8 @@ private void setCurrentAlternativesViews() {


private void setCurrentStationView() {
TextView currentStationView = findViewById(R.id.textViewCurrentStation);
currentStationView.setText(this.currentStationName);
// TextView currentStationView = findViewById(R.id.textViewCurrentStation);
// currentStationView.setText(this.currentStationName);
}

private void setCurrentStationData(int position) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jorgecruces.metrometro.customViews;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.jorgecruces.metrometro.R;

public class StationView extends LinearLayout{

public StationView(Context context) {
super(context);
this.init();
}

public StationView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.init();
}

public StationView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.init();
}

private void init() {
inflate(getContext(), R.layout.station_layout, this);
}


}
43 changes: 20 additions & 23 deletions app/src/main/res/layout/activity_play_game.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.PlayGameActivity">
Expand All @@ -14,17 +15,18 @@
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="331dp"
android:onClick="goBackToMenu"
android:contentDescription="Button"
android:onClick="goBackToMenu"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_menu_revert" />

<TextView
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="218dp"
android:layout_height="59dp"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-light"
android:text="Lineas Metro"
Expand Down Expand Up @@ -71,16 +73,19 @@
app:layout_constraintBottom_toTopOf="@+id/textViewAlternative3"
app:layout_constraintStart_toStartOf="parent" />


<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="180dp"
android:layout_marginTop="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="181dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewCurrentStation">
app:layout_constraintTop_toBottomOf="@+id/gameLayout">

<TextView
android:id="@+id/textViewCurrentNumberQuestion"
Expand Down Expand Up @@ -119,28 +124,20 @@
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textViewAlternative1" />

<TextView
android:id="@+id/textViewCurrentStation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="240dp"
android:text="CURRENT LINEA"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.48"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="180dp"
android:layout_marginTop="150dp"
android:layout_marginEnd="181dp"
android:id="@+id/gameLayout"
android:layout_width="0dp"
android:layout_height="300dp"
android:layout_marginTop="8dp"
android:background="@android:drawable/edit_text"
android:gravity="clip_horizontal|clip_vertical|center_horizontal|center_vertical"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewCurrentStation">
app:layout_constraintTop_toBottomOf="@+id/textViewTitle"

>

</LinearLayout>

Expand Down
38 changes: 38 additions & 0 deletions app/src/main/res/layout/station_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">

<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_centerInParent="true"
android:backgroundTint="#FF0000"
app:srcCompat="@drawable/metro_svg" />

<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_centerInParent="true"
app:srcCompat="@drawable/ic_baseline_circle_24" />
</RelativeLayout>

<TextView
android:id="@+id/textViewStationName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView"
android:textAlignment="center" />

</LinearLayout>

0 comments on commit 5cdf520

Please sign in to comment.