Browse Source

added routes icons

tags/v1.0.0
Robin Thoni 7 years ago
parent
commit
8a70a39cdb

+ 1
- 0
app/build.gradle View File

@@ -30,4 +30,5 @@ dependencies {
30 30
     compile 'com.jakewharton:butterknife:8.0.1'
31 31
     apt 'com.jakewharton:butterknife-compiler:8.0.1'
32 32
     compile project(path: ':luticateutils')
33
+    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
33 34
 }

+ 15
- 4
app/src/main/java/com/rthoni/stssaguenay/ui/fragments/StopRoutesPickerFragment.java View File

@@ -1,6 +1,7 @@
1 1
 package com.rthoni.stssaguenay.ui.fragments;
2 2
 
3 3
 import android.app.ProgressDialog;
4
+import android.graphics.Color;
4 5
 import android.os.Bundle;
5 6
 import android.support.annotation.Nullable;
6 7
 import android.support.v4.app.Fragment;
@@ -9,9 +10,11 @@ import android.support.v7.widget.RecyclerView;
9 10
 import android.view.LayoutInflater;
10 11
 import android.view.View;
11 12
 import android.view.ViewGroup;
13
+import android.widget.ImageView;
12 14
 import android.widget.TextView;
13 15
 import android.widget.Toast;
14 16
 
17
+import com.amulyakhare.textdrawable.TextDrawable;
15 18
 import com.luticate.utils.business.LuPromise;
16 19
 import com.rthoni.stssaguenay.R;
17 20
 import com.rthoni.stssaguenay.business.RoutesBusiness;
@@ -41,10 +44,10 @@ public class StopRoutesPickerFragment extends Fragment {
41 44
     private RoutesAdapter _routesAdapter;
42 45
 
43 46
     public static class ViewHolder extends RecyclerView.ViewHolder {
47
+        public ImageView _imageView;
44 48
         public TextView _textView;
45
-        public ViewHolder(TextView v) {
49
+        public ViewHolder(View v) {
46 50
             super(v);
47
-            _textView = v;
48 51
         }
49 52
     }
50 53
 
@@ -55,14 +58,22 @@ public class StopRoutesPickerFragment extends Fragment {
55 58
         @Override
56 59
         public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
57 60
             View v = LayoutInflater.from(parent.getContext())
58
-                    .inflate(R.layout.simple_recycler_view_item, parent, false);
59
-            ViewHolder vh = new ViewHolder((TextView)v);
61
+                    .inflate(R.layout.route_recycler_view_item, parent, false);
62
+            ViewHolder vh = new ViewHolder(v);
63
+            vh._textView = (TextView) v.findViewById(R.id.textView);
64
+            vh._imageView = (ImageView) v.findViewById(R.id.imageView);
60 65
             return vh;
61 66
         }
62 67
 
63 68
         @Override
64 69
         public void onBindViewHolder(ViewHolder holder, int position) {
65 70
             final RoutesDbo routeDbo = _routes.get(position);
71
+            TextDrawable drawable = TextDrawable.builder()
72
+                    .beginConfig()
73
+                    .textColor(Color.parseColor("#" + routeDbo.getFgColor()))
74
+                    .endConfig()
75
+                    .buildRound(routeDbo.getId(), Color.parseColor("#" + routeDbo.getBgColor()));
76
+            holder._imageView.setImageDrawable(drawable);
66 77
             holder._textView.setText(routeDbo.getFullName());
67 78
             holder._textView.setOnClickListener(new View.OnClickListener() {
68 79
                 @Override

+ 22
- 0
app/src/main/res/layout/route_recycler_view_item.xml View File

@@ -0,0 +1,22 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+              android:orientation="horizontal"
4
+              android:layout_width="match_parent"
5
+              android:layout_height="wrap_content">
6
+
7
+    <ImageView
8
+        android:layout_width="50dp"
9
+        android:layout_height="50dp"
10
+        android:src="@drawable/ic_add_black_24dp"
11
+        android:id="@+id/imageView"
12
+        android:paddingBottom="2.5dp"
13
+        android:paddingRight="5dp"
14
+        android:paddingTop="2.5dp"/>
15
+
16
+    <TextView
17
+        android:text="TextView"
18
+        android:layout_width="match_parent"
19
+        android:layout_height="match_parent"
20
+        android:id="@+id/textView"
21
+        android:gravity="center_vertical"/>
22
+</LinearLayout>

+ 3
- 0
build.gradle View File

@@ -4,6 +4,9 @@ buildscript {
4 4
     repositories {
5 5
         jcenter()
6 6
         mavenCentral()
7
+        maven {
8
+            url 'http://dl.bintray.com/amulyakhare/maven'
9
+        }
7 10
     }
8 11
     dependencies {
9 12
         classpath 'com.android.tools.build:gradle:2.2.0'

Loading…
Cancel
Save