Skip to content

Commit

Permalink
3 Final Commit "Inshallah"
Browse files Browse the repository at this point in the history
  • Loading branch information
AdelEwaida committed Oct 9, 2020
1 parent f7d0e7f commit a22997e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
18 changes: 8 additions & 10 deletions app/src/main/java/com/example/assignment/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
public class MainActivity extends AppCompatActivity {
private EditText editText;
private Spinner spinner1;
// MovieFactory factory = new MovieFactory();

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -34,23 +33,20 @@ protected void onCreate(Bundle savedInstanceState) {
MovieFactory factory = new MovieFactory();
factory.getModel();
List<String> arr = new ArrayList<>();
// MovieData data = new MovieData();
arr = MovieData.getGenre();
spinner1 = findViewById(id.spineer);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, arr);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(arrayAdapter);
//
//
editText = findViewById(id.edit_Text);

editText = findViewById(id.edit_text);
}



public void bsearchOnClick(View view) {
ArrayList<Movie> result = new ArrayList<>();
EditText myText = (EditText) this.findViewById(id.edit_text);
EditText myText = (EditText) this.findViewById(id.edit_Text);
EditText res = this.findViewById(id.result);
Editable word =myText.getText();
String spin = spinner1.getSelectedItem().toString();
Expand Down Expand Up @@ -81,15 +77,17 @@ public void bsearchOnClick(View view) {

}

// Toast.makeText(this, "hii", Toast.LENGTH_SHORT).show();

}

private String print(ArrayList<Movie> result) {
String ress = null;
String ress = "";

if(result.isEmpty())
ress= "Movie is not exist in this Library";
else{
for (int i =0 ; i<result.size();i++){
ress+= result.get(i).toString() +"\n";
}
}}
return ress;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.assignment.controller;

import com.example.assignment.model.IMovieData;
import com.example.assignment.interFaces.IMovieData;
import com.example.assignment.model.MovieData;
public class MovieFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.assignment.model;
package com.example.assignment.interFaces;
import java.util.*;
public interface IMovieData {
ArrayList<String> getMovies();
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/java/com/example/assignment/model/MovieData.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.example.assignment.model;


import java.lang.reflect.Array;
import com.example.assignment.interFaces.IMovieData;

import java.util.ArrayList;
import java.util.Objects;

public class MovieData implements IMovieData {
private static ArrayList<Movie> movies = new ArrayList<>();
Expand All @@ -27,15 +27,19 @@ public MovieData() {

public static ArrayList<Movie> searchNum(int num2, String spin) {
ArrayList<Movie> movies2 = new ArrayList<>();
if (spin.equals("ALL")) {
searchSpin("All");
if (spin.toLowerCase().equals("all")) {
for (int i = 0; i < movies.size(); i++) {
if (movies.get(i).getYear() == num2 ) {
movies2.add(movies.get(i));
}
}

} else {
for (int i = 0; i < movies.size(); i++) {
if (movies.get(i).getYear() == num2 && movies.get(i).getGenre().equals(spin)) {
movies2.add(movies.get(i));
}


}

}
Expand Down
Binary file removed app/src/main/res/drawable-v24/movie.jpg
Binary file not shown.
Binary file added app/src/main/res/drawable/backgound1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ic_launcher2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 22 additions & 24 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,37 @@
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical"

android:background="@drawable/backgound1"
tools:context=".MainActivity">

<TextView

android:layout_width="361dp"
android:layout_height="57dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="vertical"
android:text="Enter the tittle or year or Genere of the movie you want to search"
tools:layout_editor_absoluteX="4dp"
android:textColor="@android:color/white"

android:text="Enter the tittle or year of the movie you want to search then you can choose the genre from the spinner if you want"
android:textSize="20dp"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="39dp" />

<EditText
android:id="@+id/edit_text"

android:layout_width="358dp"
android:layout_height="20dp"
android:layout_gravity="left"
android:id="@+id/edit_Text"
android:layout_width="328dp"
android:layout_height="49dp"
android:layout_gravity="center"
android:layout_margin="8dp"
tools:layout_editor_absoluteY="89dp" />
android:background="@android:color/white"
android:orientation="vertical" />

<Spinner
android:id="@+id/spineer"

android:layout_width="132dp"
android:layout_height="67dp"
android:layout_gravity="right"
android:layout_width="157dp"
android:layout_height="65dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:background="@android:color/white"
android:orientation="horizontal"
android:prompt="@string/app_name"></Spinner>

Expand All @@ -48,20 +49,17 @@
android:layout_gravity="center"
android:layout_margin="8dp"
android:onClick="bsearchOnClick"
android:text="@string/bsearch"

tools:layout_editor_absoluteX="175dp"
tools:layout_editor_absoluteY="168dp" />
android:text="@string/bsearch" />

<EditText
android:id="@+id/result"
android:layout_width="328dp"
android:layout_height="438dp"
android:layout_height="280dp"
android:layout_gravity="center"
android:layout_margin="8dp"
android:orientation="vertical">


</EditText>
android:textStyle="bold"
android:orientation="vertical"
android:textColor="@android:color/white"
android:textSize="14dp"></EditText>

</LinearLayout>

0 comments on commit a22997e

Please sign in to comment.