Skip to content
Snippets Groups Projects
Commit c95f68dc authored by Paul Cancel's avatar Paul Cancel
Browse files

Q4 : Ajout activités à faire et urgente

parent 99b0a986
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,10 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
viewBinding = true // génération des ViewBindings, Android Studio v4
}
buildTypes {
release {
isMinifyEnabled = false
......
package fr.iutlille.ctp2024;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
import java.util.List;
import fr.iutlille.ctp2024.databinding.ActivityMainBinding;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private ActivityMainBinding ui;
private TacheAdapter adapter;
private TacheApplication context;
private List<Tache> liste;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ui = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(R.layout.super_tache);
setTitle("Super Tâches");
this.context = (TacheApplication) this.getApplication();
this.liste = context.getTaches();
// this.adapter = new TacheAdapter(liste);
TextView tv = findViewById(R.id.textView2);
tv.setText("A faire : " + this.toDo());
tv = findViewById(R.id.textView3);
tv.setText("Urgent : " + this.countUrgent());
Button btn = (Button) findViewById(R.id.button2);
btn.setOnClickListener(this);
RecyclerView.LayoutManager lm = new LinearLayoutManager(this);
}
@Override
......@@ -29,4 +53,20 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
startActivity(intent);
}
}
private int countUrgent(){
int cpt = 0;
for(Tache t : this.liste){
if(t.getPriorite() == Priorite.HAUTE) cpt ++;
}
return cpt;
}
private int toDo(){
int cpt = 0;
for(Tache t : this.liste){
if(t.getStatus() == Status.AFAIRE) cpt ++;
}
return cpt;
}
}
\ No newline at end of file
package fr.iutlille.ctp2024;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import fr.iutlille.ctp2024.databinding.SuperTacheBinding;
import fr.iutlille.ctp2024.databinding.TachesBinding;
public class TacheAdapter extends RecyclerView.Adapter<TacheViewHolder> {
private List<Tache> taches;
public TacheAdapter(List<Tache> liste){
this.taches = liste;
}
@NonNull
@Override
public TacheViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
TachesBinding binding = TachesBinding.inflate(
LayoutInflater.from(parent.getContext()),
parent,
false
);
return new TacheViewHolder(binding);
}
@Override
public void onBindViewHolder(@NonNull TacheViewHolder holder, int position) {
Tache tache = this.taches.get(position);
}
@Override
public int getItemCount() {
return this.taches.size();
}
}
package fr.iutlille.ctp2024;
import androidx.recyclerview.widget.RecyclerView;
import fr.iutlille.ctp2024.databinding.SuperTacheBinding;
import fr.iutlille.ctp2024.databinding.TachesBinding;
public class TacheViewHolder extends RecyclerView.ViewHolder{
private final TachesBinding ui;
public TacheViewHolder(TachesBinding ui){
super(ui.getRoot());
this.ui = ui;
}
public void setTache(Tache tache){
ui.nom.setText(tache.getNom());
}
}
......@@ -37,5 +37,30 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Quitter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="30dp">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A faire : "
android:textAlignment="center"
android:textSize="20sp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Urgent : "
android:textAlignment="center"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="100dp"
android:layout_width="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/nom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="10dp"
android:layout_weight="2" />
</LinearLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment