aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2018-04-26 13:34:40 +0200
committermarcinzelent <zelent.marcin@gmail.com>2018-04-26 13:34:40 +0200
commit9ecffe7854da65b39ae13b18be7da425777f1ee8 (patch)
tree431c18a13684d54c656c935ef4fdfcc93e0e81fc /app/src/main/java/org/marcinzelent/liberavem/AtlasGridAdapter.java
parent4de306375a33b2abd067e65658a46d45cba5e56e (diff)
Riced the app, added Atlas and About views
Diffstat (limited to 'app/src/main/java/org/marcinzelent/liberavem/AtlasGridAdapter.java')
-rw-r--r--app/src/main/java/org/marcinzelent/liberavem/AtlasGridAdapter.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/app/src/main/java/org/marcinzelent/liberavem/AtlasGridAdapter.java b/app/src/main/java/org/marcinzelent/liberavem/AtlasGridAdapter.java
new file mode 100644
index 0000000..0aa1ca5
--- /dev/null
+++ b/app/src/main/java/org/marcinzelent/liberavem/AtlasGridAdapter.java
@@ -0,0 +1,67 @@
+package org.marcinzelent.liberavem;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.squareup.picasso.Picasso;
+
+public class AtlasGridAdapter extends BaseAdapter {
+
+ private Context mContext;
+ private Bird[] birds;
+
+ public AtlasGridAdapter(Context c, Bird[] b) {
+ mContext = c;
+ birds = b;
+ }
+
+ public int getCount() {
+ return birds.length;
+ }
+
+ public Object getItem(int position) {
+ return null;
+ }
+
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ // create a new ImageView for each item referenced by the Adapter
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder;
+ final View result;
+
+ if (convertView == null) {
+
+ viewHolder = new ViewHolder();
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ convertView = inflater.inflate(R.layout.atlas_grid_item, parent, false);
+ viewHolder.photo = convertView.findViewById(R.id.atlas_photo);
+ viewHolder.name = convertView.findViewById(R.id.atlas_name);
+
+ result = convertView;
+
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ result = convertView;
+ }
+
+ Picasso.get().load(birds[position].getPhotoUrl()).into(viewHolder.photo);
+ viewHolder.name.setText(birds[position].getNameEnglish());
+
+ return convertView;
+ }
+
+ private static class ViewHolder {
+ ImageView photo;
+ TextView name;
+ }
+}