-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jaskirat #7
Open
jaskirat18
wants to merge
3
commits into
master
Choose a base branch
from
jaskirat
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Jaskirat #7
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/src/main/java/com/sdsmdg/hareshkh/lectureassignment/Movie.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.sdsmdg.hareshkh.lectureassignment; | ||
|
||
/** | ||
* Created by Jaskirat on 03-02-2017. | ||
*/ | ||
|
||
public class Movie | ||
{ | ||
private String name; | ||
private String year; | ||
private String genre; | ||
private int img; | ||
|
||
// | ||
|
||
private boolean isSelected; | ||
|
||
public boolean getSelected() | ||
{ | ||
return isSelected; | ||
} | ||
|
||
public void setSelected(boolean x) | ||
{ | ||
isSelected=x; | ||
} | ||
|
||
// | ||
|
||
public Movie() | ||
{ | ||
isSelected=false; | ||
} | ||
|
||
public Movie(String name, String year, String genre, int img) | ||
{ | ||
this.name = name; | ||
this.year = year; | ||
this.genre = genre; | ||
this.img = img; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public void setName(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
public String getYear() | ||
{ | ||
return year; | ||
} | ||
|
||
public void setYear(String year) | ||
{ | ||
this.year = year; | ||
} | ||
|
||
public String getGenre() | ||
{ | ||
return genre; | ||
} | ||
|
||
public void setGenre(String genre) | ||
{ | ||
this.genre = genre; | ||
} | ||
|
||
public void setImg(int img) | ||
{ | ||
this.img = img; | ||
} | ||
|
||
public int getImg() | ||
{ | ||
return img; | ||
} | ||
|
||
} |
174 changes: 174 additions & 0 deletions
174
app/src/main/java/com/sdsmdg/hareshkh/lectureassignment/MovieAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
package com.sdsmdg.hareshkh.lectureassignment; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.v4.content.ContextCompat; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Jaskirat on 03-02-2017. | ||
*/ | ||
|
||
public class MovieAdapter extends RecyclerView.Adapter<MovieAdapter.MyViewHolder> | ||
{ | ||
private Context mContext; | ||
private List<Movie> movieList; | ||
private String line; | ||
|
||
public class MyViewHolder extends RecyclerView.ViewHolder | ||
{ | ||
public TextView genre, name, year; | ||
public ImageView thumbnail; | ||
|
||
public MyViewHolder(View view) | ||
{ | ||
super(view); | ||
name = (TextView) view.findViewById(R.id.title); | ||
year = (TextView) view.findViewById(R.id.yr); | ||
genre= (TextView) view.findViewById(R.id.gen); | ||
thumbnail = (ImageView) view.findViewById(R.id.thumbnail); | ||
} | ||
} | ||
|
||
public MovieAdapter(Context mContext, List<Movie> movieList) { | ||
this.mContext = mContext; | ||
this.movieList = movieList; | ||
} | ||
|
||
@Override | ||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) | ||
{ | ||
View itemView = LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.movie_card, parent, false); | ||
|
||
return new MyViewHolder(itemView); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(final MyViewHolder holder, int position) | ||
{ | ||
final Movie movie = movieList.get(position); | ||
holder.name.setText(movie.getName()); | ||
holder.year.setText(movie.getYear()); | ||
holder.genre.setText(movie.getGenre()); | ||
|
||
|
||
Bitmap bitmap,scaled; | ||
Drawable drawable; | ||
|
||
switch(movie.getImg()) | ||
{ | ||
case ((int) R.drawable.grey): drawable = ContextCompat.getDrawable(mContext, R.drawable.grey); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.shawshank): drawable = ContextCompat.getDrawable(mContext, R.drawable.shawshank); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.joker): drawable = ContextCompat.getDrawable(mContext, R.drawable.joker); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.dictator): drawable = ContextCompat.getDrawable(mContext, R.drawable.dictator); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.wolf): drawable = ContextCompat.getDrawable(mContext, R.drawable.wolf); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.lala): drawable = ContextCompat.getDrawable(mContext, R.drawable.lala); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.titanic): drawable = ContextCompat.getDrawable(mContext, R.drawable.titanic); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.godfather): drawable = ContextCompat.getDrawable(mContext, R.drawable.godfather); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
|
||
case ((int) R.drawable.happyness): drawable = ContextCompat.getDrawable(mContext, R.drawable.happyness); | ||
bitmap = ((BitmapDrawable)drawable).getBitmap(); | ||
scaled=Bitmap.createScaledBitmap(bitmap,180,180,false); | ||
holder.thumbnail.setImageBitmap(scaled); | ||
break; | ||
} | ||
|
||
|
||
// loading album cover using Glide library | ||
//Glide.with(mContext).load(movie.getImg()).into(holder.thumbnail); | ||
|
||
|
||
holder.thumbnail.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
|
||
holder.itemView.performClick(); | ||
} | ||
}); | ||
|
||
holder.itemView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
line= (String) holder.name.getText(); | ||
line+=" was clicked"; | ||
|
||
Toast toast=Toast.makeText(mContext, line, Toast.LENGTH_SHORT); | ||
if(toast!=null) | ||
toast.show(); | ||
} | ||
}); | ||
|
||
|
||
//holder.itemView.setBackgroundColor(context.getResources().getColor(movie.getSelected() ? R.color.delete_gray: R.color.White)); | ||
|
||
holder.itemView.setBackgroundColor(movie.getSelected() ? Color.CYAN : Color.WHITE); | ||
|
||
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { | ||
@Override | ||
public boolean onLongClick(View view) { | ||
|
||
movie.setSelected(!movie.getSelected()); | ||
holder.itemView.setBackgroundColor(movie.getSelected() ? Color.CYAN : Color.WHITE); | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public int getItemCount() | ||
{ | ||
return movieList.size(); | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need a switch case here. You could just write the following replacing the whole switch case code.
drawable = ContextCompat.getDrawable(mContext, movie.getImg());