This repository has been archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update build version * Fixes (#14) - Añadido cacheo de imágenes - Muchos cambios visuales en la lista - Cambiada la lista por RecyclerView, con sus correspondientes animaciones al buscar - Solucionado un fallo al filtrar - Refactor de código * update settings screen * update exoplayer and gson * revert settings xml * update app version
- Loading branch information
Showing
17 changed files
with
397 additions
and
357 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
81 changes: 81 additions & 0 deletions
81
mobile/src/main/java/laquay/com/canalestdt/ChannelListAdapter.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,81 @@ | ||
package laquay.com.canalestdt; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.DiffUtil; | ||
import androidx.recyclerview.widget.ListAdapter; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.bumptech.glide.Glide; | ||
|
||
import laquay.com.canalestdt.component.ChannelList; | ||
|
||
public class ChannelListAdapter extends ListAdapter<ChannelList, ChannelListAdapter.ViewHolder> { | ||
|
||
private Context context; | ||
private OnItemClickListener listener; | ||
|
||
public ChannelListAdapter(Context context, OnItemClickListener listener) { | ||
super(new DiffUtil.ItemCallback<ChannelList>() { | ||
@Override | ||
public boolean areItemsTheSame(@NonNull ChannelList oldItem, @NonNull ChannelList newItem) { | ||
return oldItem.getChannel().getName().equals(newItem.getChannel().getName()); | ||
} | ||
|
||
@Override | ||
public boolean areContentsTheSame(@NonNull ChannelList oldItem, @NonNull ChannelList newItem) { | ||
return true; | ||
} | ||
}); | ||
this.context = context; | ||
this.listener = listener; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_channels, parent, false)); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) { | ||
final ChannelList channel = getItem(position); | ||
|
||
holder.titleView.setText(channel.getChannel().getName()); | ||
holder.subtitleView.setText(String.format("%s - %s", channel.getCountryName(), channel.getCommunityName())); | ||
|
||
// Temporary fix | ||
String imageUrl = channel.getChannel().getLogo().replace("http://graph.facebook.com", "https://graph.facebook.com"); | ||
Glide.with(context).load(imageUrl).placeholder(R.mipmap.ic_launcher).fallback(R.mipmap.ic_launcher).into(holder.imageView); | ||
|
||
holder.itemView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
listener.onItemClickListener(channel); | ||
} | ||
}); | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder { | ||
ImageView imageView; | ||
TextView titleView; | ||
TextView subtitleView; | ||
|
||
public ViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
this.imageView = itemView.findViewById(R.id.channel_icon); | ||
this.titleView = itemView.findViewById(R.id.channel_title); | ||
this.subtitleView = itemView.findViewById(R.id.channel_description); | ||
} | ||
} | ||
|
||
interface OnItemClickListener { | ||
void onItemClickListener(ChannelList channelList); | ||
} | ||
} |
Oops, something went wrong.