Skip to content
Snippets Groups Projects
Commit c5ec801e authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

Partie 6 tj pas finie mais un peu + avancée

parent 0573d261
Branches
No related tags found
No related merge requests found
......@@ -4,14 +4,11 @@
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Git/application-android-iut/app/src/main/res/layout-land/activity_main.xml" value="0.19635416666666666" />
<entry key="..\:/Git/application-android-iut/app/src/main/res/layout-land/fragment_frag_horizontal_layout.xml" value="0.11197916666666667" />
<entry key="..\:/Git/application-android-iut/app/src/main/res/layout/activity_main.xml" value="0.176" />
<entry key="..\:/Git/application-android-iut/app/src/main/res/layout/activity_num_table.xml" value="0.264" />
<entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout-land/activity_main.xml" value="0.21516754850088182" />
<entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout-land/fragment_frag_horizontal_layout.xml" value="0.1" />
<entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/activity_main.xml" value="0.11302083333333333" />
<entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/activity_num_table.xml" value="0.24547101449275363" />
<entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/fragment_frag_horizontal_layout.xml" value="0.1" />
<entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/fragment_frag_vertical_layout.xml" value="0.1" />
<entry key="..\:/Git/application-android-iut/app/src/main/res/layout/fragment_frag_vertical_layout.xml" value="0.1" />
<entry key="..\:/Git/application-android-iut/app/src/main/res/layout/fragment_pizza_custom_vertical.xml" value="0.176" />
<entry key="..\:/Z IUT Orsay/AndroidStudioProjects/Pizzeria/app/src/main/res/layout-land/activity_main.xml" value="0.1" />
<entry key="..\:/Z IUT Orsay/AndroidStudioProjects/Pizzeria/app/src/main/res/layout/activity_main.xml" value="0.2" />
</map>
......
package com.slprojects.pizzeria;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragCustomPizza extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_pizza_custom_vertical, container, false);
return view;
}
}
......@@ -11,6 +11,7 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import java.util.ArrayList;
......@@ -66,6 +67,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
boutons.add(frag.getView().findViewById(R.id.hawaii));
boutons.add(frag.getView().findViewById(R.id.pannaCotta));
boutons.add(frag.getView().findViewById(R.id.tiramisu));
boutons.add(frag.getView().findViewById(R.id.pizzaperso));
// On ajoute un listener sur chaque bouton
boutons.forEach((btn) -> btn.setOnClickListener(this));
......@@ -96,15 +98,35 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public void onClick(View v) {
try{
if(v.getId() == R.id.pizzaperso){
// On vide la vue du fragment
FrameLayout fl= findViewById(R.id.fragment_vertical_layout);
fl.removeAllViews();
// On va afficher le fragment de la piza perso
FragCustomPizza customPizzaFrag = new FragCustomPizza();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.add(R.id.fragment_vertical_layout, customPizzaFrag);
transaction.commit();
}else if(v.getId() == R.id.btnValiderPizzaCustom) {
// On vide la vue du fragment
FrameLayout fl= findViewById(R.id.fragment_vertical_layout);
fl.removeAllViews();
// On affiche le fragment principal
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.add(R.id.fragment_vertical_layout, frag);
transaction.commit();
} else {
Button bouton = boutons.get(idIndexes.indexOf(v.getId()));
numCommands.set(idIndexes.indexOf(v.getId()), numCommands.get(idIndexes.indexOf(v.getId()))+1);
setButtonText(bouton);
String message = numTable+nomBoutons.get(idIndexes.indexOf(v.getId()));
// Envoie de la commande
tacheDeFond = new backTasks();
tacheDeFond.execute(message);
// Envoie de la commande
//tacheDeFond.registerCommand(numTable+nomBoutons.get(idIndexes.indexOf(v.getId())));
}
}catch ( Exception e ){
Log.e("Erreur", e.getMessage());
}
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragCustomPizza">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteX="1dp">
<Button
android:id="@+id/mozzarella"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#E53935"
android:text="MOZZARELLA" />
<Button
android:id="@+id/gorgonzola"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#E53935"
android:text="GORGONZOLA" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/linearLayout1"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteX="1dp">
<Button
android:id="@+id/anchois"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#FF6E40"
android:text="ANCHOIS" />
<Button
android:id="@+id/capres"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#FF6E40"
android:text="CÂPRES" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
app:layout_constraintBottom_toTopOf="@+id/linearLayout4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteX="1dp">
<Button
android:id="@+id/olives"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#009688"
android:text="OLIVES" />
<Button
android:id="@+id/artichauts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#009688"
android:text="ARTICHAUTS" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3"
app:layout_constraintBottom_toTopOf="@+id/btnValiderPizzaCustom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteX="1dp">
<Button
android:id="@+id/merguezChipo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#D32F2F"
android:text="MERGUEZ CHIPO" />
<Button
android:id="@+id/merguezPiquante"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#D32F2F"
android:text="MERGUEZ PIQUANTE" />
</LinearLayout>
<Button
android:id="@+id/btnValiderPizzaCustom"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="#4CAF50"
android:text="VALIDER"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment