Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.naabi.listeserie;
- import android.app.AlertDialog;
- import android.content.DialogInterface;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.util.Log;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.BaseAdapter;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.LinearLayout;
- import android.widget.ListView;
- import android.widget.TextView;
- import java.util.ArrayList;
- import java.util.Arrays;
- import com.example.naabi.listeserie.dao.SerialisationSerieDAO;
- import com.example.naabi.listeserie.modele.Acteur;
- import com.example.naabi.listeserie.modele.Episode;
- import com.example.naabi.listeserie.modele.Saison;
- import com.example.naabi.listeserie.modele.Serie;
- public class descriptionMrRobot extends AppCompatActivity implements AdapterView.OnItemClickListener{
- private TextView descSerie;
- private TextView nomSerie;
- private ListView lView1;
- private ListView lView2;
- private Button bSend;
- private ArrayList listeAct = new ArrayList();
- private ArrayList listeEpiSai1 = new ArrayList();
- private ArrayList listeEpiSai2 = new ArrayList();
- private String[] listeSai = {" 1", " 2"};
- private String description = new String();
- private String nom = new String();
- SerialisationSerieDAO dao = SerialisationSerieDAO.getInstance();
- //########1ere saison##########
- Episode ep1 = new Episode("1", "eps1.0_hellofriend.mov");
- Episode ep2 = new Episode("2", "eps1.1_ones-and-zer0es.mpeg");
- Episode ep3 = new Episode("3", "eps1.2_d3bug.mkv");
- Episode ep4 = new Episode("4", "eps1.3_da3m0ns.mp4");
- Episode ep5 = new Episode("5", "eps1.4_3xpl0its.wmv");
- Episode ep6 = new Episode("6", "eps1.5_br4ve-trave1er.asf");
- Episode ep7 = new Episode("7", "eps1.6_v1ew-s0urce.flv");
- Episode ep8 = new Episode("8", "eps1.7_wh1ter0se.m4v");
- Episode ep9 = new Episode("9", "eps1.8_m1rr0r1ng.qt");
- Episode ep10 = new Episode("10", "eps1.9_zer0-day.avi");
- ArrayList<Episode> EpS1= new ArrayList();
- //#############################
- //########acteurs##############
- Acteur ac1 = new Acteur("1", "Rami Malek");
- Acteur ac2 = new Acteur("2", "Carly Chaikins");
- Acteur ac3 = new Acteur("3", "Cristian Slater");
- Acteur ac4 = new Acteur("4", "Portia DoubleDay");
- ArrayList<Acteur> LAct = new ArrayList();
- //#############################
- //########Série################
- ArrayList<Saison> listeSais1 = new ArrayList();
- ArrayList<Serie> listeAllSerie = new ArrayList();
- //#############################
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.i("Passage","Passage dans le onCreate");
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_description_mr_robot);
- description = getResources().getString(R.string.descSerie);
- nom = getResources().getString(R.string.nomSerie);
- restoreMe(savedInstanceState);
- listeAct.addAll(Arrays.asList(getResources().getStringArray(R.array.acteur)));
- listeEpiSai1.addAll(Arrays.asList(getResources().getStringArray(R.array.epiSaison1)));
- listeEpiSai2.addAll(Arrays.asList(getResources().getStringArray(R.array.epiSaison2)));
- for (int i=0; i < listeSai.length; i++) {
- listeSai[i]= this.getResources().getString(R.string.saison) + listeSai[i];
- }
- EpS1.add(ep1);
- EpS1.add(ep2);
- EpS1.add(ep3);
- EpS1.add(ep4);
- EpS1.add(ep5);
- EpS1.add(ep6);
- EpS1.add(ep7);
- EpS1.add(ep8);
- EpS1.add(ep9);
- EpS1.add(ep10);
- LAct.add(ac1);
- LAct.add(ac2);
- LAct.add(ac3);
- LAct.add(ac4);
- Saison s1 = new Saison("1",EpS1);
- listeSais1.add(s1);
- Serie ser1 = new Serie(listeSais1, LAct, "1", "mrrobot", "Ceci est une courte description", "Mr Robot");
- listeAllSerie.add(ser1);
- }
- @Override
- public void onStart() {
- Log.i("Passage","Passage dans le onStart");
- super.onStart();
- final ArrayAdapter<String> adapteracteur = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1, listeAct);
- final ArrayAdapter<String> adaptersaison = new ArrayAdapter<>(this,android.R.layout.simple_list_item_single_choice, listeSai);
- //#############FINDBYID################
- this.lView1 = (ListView) findViewById(R.id.listeSaison);
- this.lView2 = (ListView) findViewById(R.id.acteurSerie);
- this.nomSerie = (TextView) findViewById(R.id.nomSerie);
- this.descSerie = (TextView) findViewById(R.id.descSerie);
- this.bSend = (Button) findViewById(R.id.bEnv);
- //#####################################
- //#######RECUPVARIABLE#################
- descSerie.setText(description);
- nomSerie.setText(nom);
- //#####################################
- lView1.setAdapter(adaptersaison);
- lView1.setItemChecked(0, true);
- lView1.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent ACTION_UP) {
- v.getParent().requestDisallowInterceptTouchEvent(true);
- return false;
- }
- });
- lView2.setAdapter(adapteracteur);
- lView2.setItemChecked(0, true);
- lView2.setOnTouchListener(new View.OnTouchListener() {
- // Setting on Touch Listener for handling the touch inside ScrollView
- @Override
- public boolean onTouch(View v, MotionEvent ACTION_UP) {
- // Disallow the touch request for parent scroll on touch of child view
- v.getParent().requestDisallowInterceptTouchEvent(true);
- return false;
- }
- });
- //#############LISTENER################
- lView1.setOnItemClickListener(this);
- lView2.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- final AlertDialog.Builder fenetreConstruct = new AlertDialog.Builder(descriptionMrRobot.this);
- fenetreConstruct.setTitle("Editeur");
- fenetreConstruct.setMessage("Zone d'édition");
- fenetreConstruct.setCancelable(false);
- final EditText input = new EditText(descriptionMrRobot.this);
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- input.setLayoutParams(lp);
- fenetreConstruct.setView(input);
- fenetreConstruct.setPositiveButton("Ok",new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- lView2.setTag(input.getText());
- ((BaseAdapter) adapteracteur).notifyDataSetChanged();
- }
- });
- fenetreConstruct.setNegativeButton("Annuler",new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- //Rien pour le moment
- }
- });
- final AlertDialog fenetre = fenetreConstruct.create();
- fenetre.show();
- return false;
- } });
- nomSerie.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- final AlertDialog.Builder fenetreConstruct = new AlertDialog.Builder(descriptionMrRobot.this);
- fenetreConstruct.setTitle("Editeur");
- fenetreConstruct.setMessage("Zone d'édition");
- fenetreConstruct.setCancelable(false);
- final EditText input = new EditText(descriptionMrRobot.this);
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- input.setLayoutParams(lp);
- fenetreConstruct.setView(input);
- fenetreConstruct.setPositiveButton("Ok",new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- nomSerie.setText(input.getText());
- }
- });
- fenetreConstruct.setNegativeButton("Annuler",new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- //Rien pour le moment
- }
- });
- final AlertDialog fenetre = fenetreConstruct.create();
- fenetre.show();
- return false;
- } });
- descSerie.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- final AlertDialog.Builder fenetreConstruct = new AlertDialog.Builder(descriptionMrRobot.this);
- fenetreConstruct.setTitle("Editeur");
- fenetreConstruct.setMessage("Zone d'édition");
- fenetreConstruct.setCancelable(false);
- final EditText input = new EditText(descriptionMrRobot.this);
- input.setText(descSerie.getText());
- input.setMaxHeight(450);
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
- input.setLayoutParams(lp);
- fenetreConstruct.setView(input);
- fenetreConstruct.setPositiveButton("Ok",new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- descSerie.setText(input.getText());
- }
- });
- fenetreConstruct.setNegativeButton("Annuler",new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- }
- });
- final AlertDialog fenetre = fenetreConstruct.create();
- fenetre.show();
- return false;
- } });
- }
- //#####################################
- public void onSaveInstanceState(Bundle saveInstanceState){
- Log.i("Passage","Passage dans le onSaveInstanceState");
- dao.writeAll(listeAllSerie);
- super.onSaveInstanceState(saveInstanceState);
- saveInstanceState.putStringArrayList("listeEpi1", listeEpiSai1);
- saveInstanceState.putStringArrayList("listeEpi2", listeEpiSai2);
- saveInstanceState.putStringArrayList("listeAc", listeAct);
- saveInstanceState.putString("descri", descSerie.getText().toString());
- saveInstanceState.putString("tit", nomSerie.getText().toString());
- }
- private void restoreMe(Bundle state) {
- Log.i("Passage","Passage dans le restoreMe");
- if (state!=null) {
- listeAct.addAll(state.getStringArrayList("listeAc"));
- listeEpiSai1.addAll(state.getStringArrayList("listeEpi1"));
- listeEpiSai2.addAll(state.getStringArrayList("listeEpi2"));
- nom = state.getString("tit");
- description = state.getString("descri");
- }
- }
- public void onClickSend(View V) {
- lView1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, listeSai));
- lView1.setItemChecked(0, true);
- lView1.setOnItemClickListener(this);
- bSend.setVisibility(View.GONE);
- }
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- bSend.setVisibility(View.VISIBLE);
- if(position == 0){
- lView1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listeEpiSai1));
- lView1.setOnTouchListener(new View.OnTouchListener() {
- // Setting on Touch Listener for handling the touch inside ScrollView
- @Override
- public boolean onTouch(View v, MotionEvent ACTION_UP) {
- // Disallow the touch request for parent scroll on touch of child view
- v.getParent().requestDisallowInterceptTouchEvent(true);
- return false;
- }
- });
- }
- if(position == 1){
- lView1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listeEpiSai2));
- lView1.setOnTouchListener(new View.OnTouchListener() {
- // Setting on Touch Listener for handling the touch inside ScrollView
- @Override
- public boolean onTouch(View v, MotionEvent ACTION_UP) {
- // Disallow the touch request for parent scroll on touch of child view
- v.getParent().requestDisallowInterceptTouchEvent(true);
- return false;
- }
- });
- }
- }
- }
- /* A bosser
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement