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
     compile 'com.jakewharton:butterknife:8.0.1'
30
     compile 'com.jakewharton:butterknife:8.0.1'
31
     apt 'com.jakewharton:butterknife-compiler:8.0.1'
31
     apt 'com.jakewharton:butterknife-compiler:8.0.1'
32
     compile project(path: ':luticateutils')
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
 package com.rthoni.stssaguenay.ui.fragments;
1
 package com.rthoni.stssaguenay.ui.fragments;
2
 
2
 
3
 import android.app.ProgressDialog;
3
 import android.app.ProgressDialog;
4
+import android.graphics.Color;
4
 import android.os.Bundle;
5
 import android.os.Bundle;
5
 import android.support.annotation.Nullable;
6
 import android.support.annotation.Nullable;
6
 import android.support.v4.app.Fragment;
7
 import android.support.v4.app.Fragment;
9
 import android.view.LayoutInflater;
10
 import android.view.LayoutInflater;
10
 import android.view.View;
11
 import android.view.View;
11
 import android.view.ViewGroup;
12
 import android.view.ViewGroup;
13
+import android.widget.ImageView;
12
 import android.widget.TextView;
14
 import android.widget.TextView;
13
 import android.widget.Toast;
15
 import android.widget.Toast;
14
 
16
 
17
+import com.amulyakhare.textdrawable.TextDrawable;
15
 import com.luticate.utils.business.LuPromise;
18
 import com.luticate.utils.business.LuPromise;
16
 import com.rthoni.stssaguenay.R;
19
 import com.rthoni.stssaguenay.R;
17
 import com.rthoni.stssaguenay.business.RoutesBusiness;
20
 import com.rthoni.stssaguenay.business.RoutesBusiness;
41
     private RoutesAdapter _routesAdapter;
44
     private RoutesAdapter _routesAdapter;
42
 
45
 
43
     public static class ViewHolder extends RecyclerView.ViewHolder {
46
     public static class ViewHolder extends RecyclerView.ViewHolder {
47
+        public ImageView _imageView;
44
         public TextView _textView;
48
         public TextView _textView;
45
-        public ViewHolder(TextView v) {
49
+        public ViewHolder(View v) {
46
             super(v);
50
             super(v);
47
-            _textView = v;
48
         }
51
         }
49
     }
52
     }
50
 
53
 
55
         @Override
58
         @Override
56
         public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
59
         public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
57
             View v = LayoutInflater.from(parent.getContext())
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
             return vh;
65
             return vh;
61
         }
66
         }
62
 
67
 
63
         @Override
68
         @Override
64
         public void onBindViewHolder(ViewHolder holder, int position) {
69
         public void onBindViewHolder(ViewHolder holder, int position) {
65
             final RoutesDbo routeDbo = _routes.get(position);
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
             holder._textView.setText(routeDbo.getFullName());
77
             holder._textView.setText(routeDbo.getFullName());
67
             holder._textView.setOnClickListener(new View.OnClickListener() {
78
             holder._textView.setOnClickListener(new View.OnClickListener() {
68
                 @Override
79
                 @Override

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

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

Loading…
Cancel
Save