Skip to content

Commit

Permalink
* finish dialog show developers
Browse files Browse the repository at this point in the history
* set on long click listener
  • Loading branch information
MustafaHasria committed Jun 24, 2021
1 parent 5741823 commit 0a8f66e
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.example.smoathapplication.models.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smoathapplication.R;
import com.example.smoathapplication.models.addmovie.AddMovieActivity;
import com.example.smoathapplication.models.home.adapter.CategoryAdapter;
import com.example.smoathapplication.models.home.adapter.MovieAdapter;
import com.example.smoathapplication.models.home.adapter.OfferAdapter;
import com.example.smoathapplication.models.home.model.CategoryMovieModel;
import com.example.smoathapplication.models.home.model.MovieModel;
import com.example.smoathapplication.models.home.model.OfferModel;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import java.util.ArrayList;
import java.util.List;

import io.paperdb.Paper;

public class HomeActivity extends AppCompatActivity {
public class HomeActivity extends AppCompatActivity implements OfferAdapter.OfferAdapterClickListeners {

//region Components
RecyclerView homeRecyclerOffer;
Expand All @@ -46,9 +47,9 @@ public class HomeActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();

offerAdapter.updateList(Paper.book().read("MOVIES_LIST", new ArrayList<>()));
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -64,7 +65,17 @@ protected void onCreate(Bundle savedInstanceState) {
homeImageViewInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Dialog dialog = new Dialog(HomeActivity.this);
dialog.setCanceledOnTouchOutside(false);
dialog.setContentView(R.layout.developer_team_info_dialog);
Button developerTeamInfoDialogButtonOk = dialog.findViewById(R.id.developer_team_info_dialog_button_ok);
developerTeamInfoDialogButtonOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});

Expand All @@ -79,18 +90,38 @@ public void onClick(View v) {
}

//region Setup Recyclers
private void setupOfferRecyclerView(){
offerAdapter = new OfferAdapter(offerModelList);
private void setupOfferRecyclerView() {
offerAdapter = new OfferAdapter(offerModelList, this);
layoutManager = new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false);
homeRecyclerOffer.setLayoutManager(layoutManager);
homeRecyclerOffer.setAdapter(offerAdapter);
}

private void setupCategoryRecyclerView(){
private void setupCategoryRecyclerView() {
categoryAdapter = new CategoryAdapter(categoryMovieModelList);
layoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
homeRecyclerCategory.setLayoutManager(layoutManager);
homeRecyclerCategory.setAdapter(offerAdapter);
}


//endregion

//region Adapter listener
@Override
public void onOfferListItemCardMainContainerLongClickListener(MovieModel movieModel, int position) {
Dialog dialog = new Dialog(HomeActivity.this);
dialog.setCanceledOnTouchOutside(false);
dialog.setContentView(R.layout.brief_movie_dialog);
ImageView briefMovieDialogImageClose = dialog.findViewById(R.id.brief_movie_dialog_image_close);
briefMovieDialogImageClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}

//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@

import com.example.smoathapplication.R;
import com.example.smoathapplication.models.home.model.MovieModel;
import com.example.smoathapplication.models.home.model.OfferModel;

import java.util.List;

public class OfferAdapter extends RecyclerView.Adapter<OfferAdapter.OfferAdapterViewHolder> {

//region Variables
List<MovieModel> offerModelList;
OfferAdapterClickListeners offerAdapterClickListeners;
//endregion

//region Constructor

public OfferAdapter(List<MovieModel> offerModelList) {
public OfferAdapter(List<MovieModel> offerModelList, OfferAdapterClickListeners offerAdapterClickListeners) {
this.offerModelList = offerModelList;
this.offerAdapterClickListeners = offerAdapterClickListeners;
}

//endregion
Expand All @@ -46,6 +49,12 @@ public void onBindViewHolder(@NonNull OfferAdapterViewHolder offerAdapterViewHol
offerAdapterViewHolder.offerListItemTextDuration.setText(offerModelList.get(position).getDuration());
offerAdapterViewHolder.offerListItemTextRating.setText(String.valueOf(offerModelList.get(position).getRating()));
offerAdapterViewHolder.offerListItemImageViewImage.setImageBitmap(StringToBitMap(offerModelList.get(position).getImage()));
offerAdapterViewHolder.offerListItemCardMainContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});
}

@Override
Expand All @@ -70,9 +79,15 @@ public Bitmap StringToBitMap(String encodedString) {
}
}

//region Interface
public interface OfferAdapterClickListeners{
void onOfferListItemCardMainContainerLongClickListener(MovieModel movieModel, int position);
}
//endregion


//region View holder
class OfferAdapterViewHolder extends RecyclerView.ViewHolder {
class OfferAdapterViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener{

//region Components
CardView offerListItemCardMainContainer;
Expand All @@ -91,6 +106,14 @@ public OfferAdapterViewHolder(@NonNull View itemView) {
offerListItemTextDuration = itemView.findViewById(R.id.offer_list_item_text_duration);
offerListItemTextRating = itemView.findViewById(R.id.offer_list_item_text_rating);
offerListItemImageViewImage = itemView.findViewById(R.id.offer_list_item_image_view_image);

offerListItemCardMainContainer.setOnLongClickListener(this);
}

@Override
public boolean onLongClick(View v) {
offerAdapterClickListeners.onOfferListItemCardMainContainerLongClickListener(offerModelList.get(getAdapterPosition()), getAdapterPosition());
return false;
}
}
//endregion
Expand Down
95 changes: 95 additions & 0 deletions app/src/main/res/layout/brief_movie_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/brief_movie_dialog_card_main_container"
android:layout_width="match_parent"
android:layout_height="175dp"
android:layout_margin="8dp"
app:cardCornerRadius="16dp"
app:cardElevation="2.5dp">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/brief_movie_dialog_image_view_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/image_poster" />

<ImageView
android:layout_width="match_parent"
android:layout_height="50dp"
android:alpha="0.8"
android:src="@drawable/background_overlay"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent">

<TextView
android:id="@+id/brief_movie_dialog_text_name"
style="@style/text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Avengers end game" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="3">

<TextView
android:id="@+id/brief_movie_dialog_text_category"
style="@style/text_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:text="Action" />

<TextView
android:id="@+id/brief_movie_dialog_text_duration"
style="@style/text_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="duration: 2:15" />

<TextView
android:id="@+id/brief_movie_dialog_text_rating"
style="@style/text_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Rating: 5" />

</LinearLayout>


</LinearLayout>


<ImageView
android:id="@+id/brief_movie_dialog_image_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/ic_baseline_arrow_forward"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />



</androidx.constraintlayout.widget.ConstraintLayout>


</androidx.cardview.widget.CardView>
76 changes: 72 additions & 4 deletions app/src/main/res/layout/developer_team_info_dialog.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@color/background"
android:orientation="vertical">

</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:text="Developers name:"
style="@style/text_style_head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<LinearLayout
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"/>
<TextView
android:layout_gravity="center"
style="@style/text_style"
android:text="the name of developer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

<LinearLayout
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"/>
<TextView
android:layout_gravity="center"
style="@style/text_style"
android:text="the name of developer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

<LinearLayout
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"/>
<TextView
android:layout_gravity="center"
style="@style/text_style"
android:text="the name of developer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

<android.widget.Button
android:id="@+id/developer_team_info_dialog_button_ok"
android:layout_marginTop="20dp"
android:textColor="@color/background"
android:text="Ok"
android:elevation="10dp"
android:textAllCaps="false"
android:background="@drawable/button_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.SMOATHApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.SMOATHApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand All @@ -12,5 +12,6 @@
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:windowFullscreen">true</item>
</style>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.SMOATHApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.SMOATHApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand All @@ -12,6 +12,7 @@
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:windowFullscreen">true</item>
</style>

<style name="text_style_head">
Expand Down

0 comments on commit 0a8f66e

Please sign in to comment.