List of usage examples for android.widget TextView setEllipsize
public void setEllipsize(TextUtils.TruncateAt where)
From source file:fr.cph.chicago.activity.StationActivity.java
/** * Draw line//from w w w .j a va2s. c om * * @param eta * the eta */ private final void drawLine3(final Eta eta) { TrainLine line = eta.getRouteName(); Stop stop = eta.getStop(); int line3Padding = (int) getResources().getDimension(R.dimen.activity_station_stops_line3); Integer viewId = mIds.get(line.toString() + "_" + stop.getDirection().toString()); // viewId might be not there if CTA API provide wrong data if (viewId != null) { LinearLayout line3View = (LinearLayout) findViewById(viewId); Integer id = mIds.get(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName()); if (id == null) { LinearLayout insideLayout = new LinearLayout(this); insideLayout.setOrientation(LinearLayout.HORIZONTAL); insideLayout.setLayoutParams(mParamsStop); int newId = Util.generateViewId(); insideLayout.setId(newId); mIds.put(line.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(), newId); TextView stopName = new TextView(this); stopName.setText(eta.getDestName() + ": "); stopName.setTextColor(getResources().getColor(R.color.grey)); stopName.setPadding(line3Padding, 0, 0, 0); insideLayout.addView(stopName); TextView timing = new TextView(this); timing.setText(eta.getTimeLeftDueDelay() + " "); timing.setTextColor(getResources().getColor(R.color.grey)); timing.setLines(1); timing.setEllipsize(TruncateAt.END); insideLayout.addView(timing); line3View.addView(insideLayout); } else { LinearLayout insideLayout = (LinearLayout) findViewById(id); TextView timing = (TextView) insideLayout.getChildAt(1); timing.setText(timing.getText() + eta.getTimeLeftDueDelay() + " "); } line3View.setVisibility(View.VISIBLE); } }
From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java
private View handleBuses(final int position, @NonNull final ViewGroup parent) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View convertView = vi.inflate(R.layout.list_nearby, parent, false); // Bus/* w w w . j a v a 2s . co m*/ final int index = position - stations.size(); final BusStop busStop = busStops.get(index); final ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); imageView.setImageDrawable( ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_directions_bus_white_24dp)); final TextView routeView = (TextView) convertView.findViewById(R.id.station_name); routeView.setText(busStop.getName()); final LinearLayout resultLayout = (LinearLayout) convertView.findViewById(R.id.nearby_results); final Map<String, List<BusArrival>> arrivalsForStop = busArrivals.get(busStop.getId(), new HashMap<>()); Stream.of(arrivalsForStop.entrySet()).forEach(entry -> { final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final RelativeLayout insideLayout = new RelativeLayout(context); insideLayout.setLayoutParams(leftParam); insideLayout.setPadding(line1PaddingColor * 2, stopsPaddingTop, 0, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { insideLayout.setBackground(ContextCompat.getDrawable(parent.getContext(), R.drawable.any_selector)); } final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams stopParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); stopParam.addRule(RelativeLayout.RIGHT_OF, lineId); stopParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0); final LinearLayout stopLayout = new LinearLayout(context); stopLayout.setOrientation(LinearLayout.VERTICAL); stopLayout.setLayoutParams(stopParam); int stopId = Util.generateViewId(); stopLayout.setId(stopId); final RelativeLayout.LayoutParams boundParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); boundParam.addRule(RelativeLayout.RIGHT_OF, stopId); final LinearLayout boundLayout = new LinearLayout(context); boundLayout.setOrientation(LinearLayout.HORIZONTAL); final String direction = entry.getKey(); final List<BusArrival> busArrivals = entry.getValue(); final String routeId = busArrivals.get(0).getRouteId(); final TextView bound = new TextView(context); final String routeIdText = routeId + " (" + direction + "): "; bound.setText(routeIdText); bound.setTextColor(ContextCompat.getColor(context, R.color.grey_5)); boundLayout.addView(bound); Stream.of(busArrivals).forEach(busArrival -> { final TextView timeView = new TextView(context); final String timeLeftDueDelay = busArrival.getTimeLeftDueDelay() + " "; timeView.setText(timeLeftDueDelay); timeView.setTextColor(ContextCompat.getColor(context, R.color.grey)); timeView.setLines(1); timeView.setEllipsize(TruncateAt.END); boundLayout.addView(timeView); }); stopLayout.addView(boundLayout); insideLayout.addView(lineIndication); insideLayout.addView(stopLayout); resultLayout.addView(insideLayout); }); convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, busStop.getId(), busStop.getPosition().getLatitude(), busStop.getPosition().getLongitude())); return convertView; }
From source file:com.guerinet.materialtabs.TabLayout.java
/** * Creates a default view to be used for tabs. This is called if a custom tab view is not set * via {@link #setCustomTabView(int, int)}. * * @return The default view to use// w w w. j av a2s.c o m */ protected TextView createDefaultTabView() { TextView textView = new TextView(getContext()); prepareTextView(textView); textView.setGravity(Gravity.CENTER); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); //Set the text color if there is one if (this.mDefaultTextColorId != null) { textView.setTextColor(getResources().getColor(mDefaultTextColorId)); } textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setBackgroundResource(getTabBackground()); //Padding int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.nttec.everychan.ui.NewTabFragment.java
private void openLocal() { if (!CompatibilityUtils.hasAccessStorage(activity)) return;/*from ww w . java 2s.com*/ final ListAdapter savedThreadsAdapter = new ArrayAdapter<Object>(activity, 0) { private static final int HEAD_ITEM = 0; private static final int NORMAL_ITEM = 1; private LayoutInflater inflater = LayoutInflater.from(activity); private int drawablePadding = (int) (resources.getDisplayMetrics().density * 5 + 0.5f); { add(new Object()); for (Database.SavedThreadEntry entity : MainApplication.getInstance().database.getSavedThreads()) { File file = new File(entity.filepath); if (file.exists()) add(entity); } } @Override public View getView(int position, View convertView, ViewGroup parent) { View v; if (position == 0) { v = convertView == null ? inflater.inflate(android.R.layout.simple_list_item_1, parent, false) : convertView; TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setText(R.string.newtab_select_local_file); } else { Database.SavedThreadEntry item = (Database.SavedThreadEntry) getItem(position); v = convertView == null ? inflater.inflate(android.R.layout.simple_list_item_2, parent, false) : convertView; TextView t1 = (TextView) v.findViewById(android.R.id.text1); TextView t2 = (TextView) v.findViewById(android.R.id.text2); t1.setSingleLine(); t2.setSingleLine(); t1.setEllipsize(TextUtils.TruncateAt.END); t2.setEllipsize(TextUtils.TruncateAt.START); t1.setText(item.title); t2.setText(item.filepath); ChanModule chan = MainApplication.getInstance().getChanModule(item.chan); if (chan != null) { t1.setCompoundDrawablesWithIntrinsicBounds(chan.getChanFavicon(), null, null, null); t1.setCompoundDrawablePadding(drawablePadding); } } return v; } @Override public int getViewTypeCount() { return 2; } @Override public int getItemViewType(int position) { return position == 0 ? HEAD_ITEM : NORMAL_ITEM; } }; if (savedThreadsAdapter.getCount() == 1) { selectFile(); return; } DialogInterface.OnClickListener listListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { selectFile(); } else { Database.SavedThreadEntry item = (Database.SavedThreadEntry) savedThreadsAdapter.getItem(which); LocalHandler.open(item.filepath, activity); } } }; new AlertDialog.Builder(activity).setTitle(R.string.newtab_saved_threads_title) .setAdapter(savedThreadsAdapter, listListener).setNegativeButton(android.R.string.cancel, null) .show(); }
From source file:com.secbro.qark.filebrowser.FileBrowserFragment.java
private void createFileListAdapter() { adapter = new ArrayAdapter<Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, fileList) {//ww w .j ava 2s. co m @Override public View getView(int position, View convertView, ViewGroup parent) { // creates view View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); // put the image on the text view int drawableID = 0; if (fileList.get(position).icon != -1) { // If icon == -1, then directory is empty drawableID = fileList.get(position).icon; } textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0, 0, 0); textView.setEllipsize(null); // add margin between image and text (support various screen // densities) // int dp5 = (int) (5 * // getResources().getDisplayMetrics().density + 0.5f); int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f); // TODO: change next line for empty directory, so text will be // centered textView.setCompoundDrawablePadding(dp3); textView.setBackgroundColor(Color.LTGRAY); return view; }// public View getView(int position, View convertView, ViewGroup };// adapter = new ArrayAdapter<Item>(this, }
From source file:busradar.madison.StopDialog.java
StopDialog(final Context ctx, final int stopid, final int lat, final int lon) { super(ctx);//w ww . j a v a 2 s . c o m this.stopid = stopid; // getWindow().requestFeature(Window.FEATURE_LEFT_ICON); getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final String name = DB.getStopName(stopid); setTitle(name); routes = get_time_urls(StopDialog.this.stopid); // getWindow().setLayout(LayoutParams.FILL_PARENT, // LayoutParams.FILL_PARENT); setContentView(new RelativeLayout(ctx) { { addView(new TextView(ctx) { { setId(stop_num_id); setText(Html.fromHtml(String.format( "[<a href='http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf'>%04d</a>]", stopid, stopid))); setPadding(0, 0, 5, 0); this.setMovementMethod(LinkMovementMethod.getInstance()); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(ALIGN_PARENT_RIGHT); } }); addView(new ImageView(ctx) { boolean enabled; @Override public void setEnabled(boolean e) { enabled = e; setImageResource(e ? R.drawable.love_enabled : R.drawable.love_disabled); if (e) { G.favorites.add_favorite_stop(stopid, name, lat, lon); Toast.makeText(ctx, "Added stop to Favorites", Toast.LENGTH_SHORT).show(); } else { G.favorites.remove_favorite_stop(stopid); Toast.makeText(ctx, "Removed stop from Favorites", Toast.LENGTH_SHORT).show(); } } { enabled = G.favorites.is_stop_favorite(stopid); setImageResource(enabled ? R.drawable.love_enabled : R.drawable.love_disabled); setPadding(0, 0, 10, 0); setOnClickListener(new OnClickListener() { public void onClick(View v) { setEnabled(!enabled); } }); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(LEFT_OF, stop_num_id); setMargins(0, -3, 0, 0); } }); addView(cur_loading_text = new TextView(ctx) { { setText("Loading..."); setPadding(5, 0, 0, 0); } }); addView(new HorizontalScrollView(ctx) { { setId(route_list_id); setHorizontalScrollBarEnabled(false); addView(new LinearLayout(ctx) { float text_size; Button cur_button; { int last_route = -1; for (int i = 0; i < routes.length; i++) { final RouteURL route = routes[i]; if (route.route == last_route) continue; last_route = route.route; addView(new Button(ctx) { public void setEnabled(boolean e) { if (e) { setBackgroundColor(0xff000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size * 1.5f); } else { setBackgroundColor(0x90000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size); } } { setText(G.route_points[route.route].name); setTextColor(0xffffffff); setTypeface(Typeface.DEFAULT_BOLD); text_size = getTextSize(); if (G.active_route == route.route) { setEnabled(true); cur_button = this; } else setEnabled(false); final Button b = this; setOnClickListener(new OnClickListener() { public void onClick(View v) { if (cur_button != null) { cur_button.setEnabled(false); } if (cur_button == b) { cur_button.setEnabled(false); cur_button = null; selected_route = null; update_time_display(); } else { cur_button = b; cur_button.setEnabled(true); selected_route = route; update_time_display(); } } }); } }); } } }); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, stop_num_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(status_text = new TextView(ctx) { { setText(""); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, route_list_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(list_view = new ListView(ctx) { { setId(time_list_id); setVerticalScrollBarEnabled(false); setAdapter(times_adapter = new BaseAdapter() { public View getView(final int position, View convertView, ViewGroup parent) { CellView v; if (convertView == null) v = new CellView(ctx); else v = (CellView) convertView; RouteTime rt = curr_times.get(position); v.setBackgroundColor(G.route_points[rt.route].color | 0xff000000); v.route_textview.setText(G.route_points[rt.route].name); if (rt.dir != null) v.dir_textview.setText("to " + rt.dir); v.time_textview.setText(rt.time); return v; } public int getCount() { return curr_times.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } }); } }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) { { addRule(RelativeLayout.BELOW, route_list_id); } }); } }); TextView title = (TextView) findViewById(android.R.id.title); title.setEllipsize(TextUtils.TruncateAt.MARQUEE); title.setSelected(true); title.setTextColor(0xffffffff); title.setMarqueeRepeatLimit(-1); // getWindow().set, value) // getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, // android.R.drawable.ic_dialog_info); // title.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); if (G.active_route >= 0) for (int i = 0; i < routes.length; i++) if (routes[i].route == G.active_route) { selected_route = routes[i]; RouteURL[] rnew = new RouteURL[routes.length]; rnew[0] = selected_route; for (int j = 0, k = 1; j < routes.length; j++) if (j != i) rnew[k++] = routes[j]; routes = rnew; break; } update_time_display(); }
From source file:com.example.appdetail_optimization.PagerSlidingTabStrip.java
@SuppressWarnings("deprecation") private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w. jav a2s . c o m*/ tab.setGravity(Gravity.CENTER); tab.setPadding(0, 0, 0, 0); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); tab.setMaxWidth(width / tabCount - tabPadding * 2); tab.setEllipsize(TruncateAt.END); tab.setSingleLine(); addTab(position, tab); }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
/** * Create or recreate the limiter breadcrumbs. *//* www . j av a2 s .co m*/ public void updateLimiterViews() { mLimiterViews.removeAllViews(); Limiter limiterData = mPagerAdapter.getCurrentLimiter(); if (limiterData != null) { String[] limiter = limiterData.names; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; for (int i = 0; i != limiter.length; ++i) { PaintDrawable background = new PaintDrawable(Color.GRAY); background.setCornerRadius(5); TextView view = new TextView(this); view.setSingleLine(); view.setEllipsize(TextUtils.TruncateAt.MARQUEE); view.setText(limiter[i] + " | X"); view.setTextColor(Color.WHITE); view.setBackgroundDrawable(background); view.setLayoutParams(params); view.setPadding(5, 2, 5, 2); view.setTag(i); view.setOnClickListener(this); mLimiterViews.addView(view); } mLimiterScroller.setVisibility(View.VISIBLE); } else { mLimiterScroller.setVisibility(View.GONE); } }
From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java
private void handleStation(@NonNull final FavoritesViewHolder holder, @NonNull final Station station) { final int stationId = station.getId(); final Set<TrainLine> trainLines = station.getLines(); holder.favoriteImage.setImageResource(R.drawable.ic_train_white_24dp); holder.stationNameTextView.setText(station.getName()); holder.detailsButton.setOnClickListener(v -> { if (!Util.isNetworkAvailable(context)) { Util.showNetworkErrorMessage(activity); } else {/*from ww w.j a va 2s . com*/ // Start station activity final Bundle extras = new Bundle(); final Intent intent = new Intent(context, StationActivity.class); extras.putInt(activity.getString(R.string.bundle_train_stationId), stationId); intent.putExtras(extras); activity.startActivity(intent); } }); holder.mapButton.setText(activity.getString(R.string.favorites_view_trains)); holder.mapButton.setOnClickListener(v -> { if (!Util.isNetworkAvailable(context)) { Util.showNetworkErrorMessage(activity); } else { if (trainLines.size() == 1) { startActivity(trainLines.iterator().next()); } else { final List<Integer> colors = new ArrayList<>(); final List<String> values = Stream.of(trainLines).flatMap(line -> { final int color = line != TrainLine.YELLOW ? line.getColor() : ContextCompat.getColor(context, R.color.yellowLine); colors.add(color); return Stream.of(line.toStringWithLine()); }).collect(Collectors.toList()); final PopupFavoritesTrainAdapter ada = new PopupFavoritesTrainAdapter(activity, values, colors); final List<TrainLine> lines = new ArrayList<>(); lines.addAll(trainLines); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setAdapter(ada, (dialog, position) -> startActivity(lines.get(position))); final int[] screenSize = Util.getScreenSize(context); final AlertDialog dialog = builder.create(); dialog.show(); if (dialog.getWindow() != null) { dialog.getWindow().setLayout((int) (screenSize[0] * 0.7), LayoutParams.WRAP_CONTENT); } } } }); Stream.of(trainLines).forEach(trainLine -> { boolean newLine = true; int i = 0; final Map<String, StringBuilder> etas = favoritesData.getTrainArrivalByLine(stationId, trainLine); for (final Entry<String, StringBuilder> entry : etas.entrySet()) { final LinearLayout.LayoutParams containParam = getInsideParams(newLine, i == etas.size() - 1); final LinearLayout container = new LinearLayout(context); container.setOrientation(LinearLayout.HORIZONTAL); container.setLayoutParams(containParam); // Left final RelativeLayout.LayoutParams leftParam = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final RelativeLayout left = new RelativeLayout(context); left.setLayoutParams(leftParam); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, trainLine); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId); destinationParams.setMargins(pixelsHalf, 0, 0, 0); final String destination = entry.getKey(); final TextView destinationTextView = new TextView(context); destinationTextView.setTextColor(grey5); destinationTextView.setText(destination); destinationTextView.setLines(1); destinationTextView.setLayoutParams(destinationParams); left.addView(lineIndication); left.addView(destinationTextView); // Right final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rightParams.setMargins(marginLeftPixel, 0, 0, 0); final LinearLayout right = new LinearLayout(context); right.setOrientation(LinearLayout.VERTICAL); right.setLayoutParams(rightParams); final StringBuilder currentEtas = entry.getValue(); final TextView arrivalText = new TextView(context); arrivalText.setText(currentEtas); arrivalText.setGravity(Gravity.END); arrivalText.setSingleLine(true); arrivalText.setTextColor(grey5); arrivalText.setEllipsize(TextUtils.TruncateAt.END); right.addView(arrivalText); container.addView(left); container.addView(right); holder.mainLayout.addView(container); newLine = false; i++; } }); }
From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java
private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) { holder.stationNameTextView.setText(busRoute.getId()); holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp); final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>(); final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData .getBusArrivalsMapped(busRoute.getId()); for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) { // Build data for button outside of the loop final String stopName = entry.getKey(); final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName); final Map<String, List<BusArrival>> value = entry.getValue(); for (final String key2 : value.keySet()) { final BusArrival busArrival = value.get(key2).get(0); final String boundTitle = busArrival.getRouteDirection(); final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum .fromString(boundTitle); final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId()) .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle) .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName()) .stopName(stopName).build(); busDetailsDTOs.add(busDetails); }/*w w w . j a v a2 s .c om*/ boolean newLine = true; int i = 0; for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) { final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1); final LinearLayout container = new LinearLayout(context); container.setOrientation(LinearLayout.HORIZONTAL); container.setLayoutParams(containParams); // Left final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final RelativeLayout left = new RelativeLayout(context); left.setLayoutParams(leftParams); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId); destinationParams.setMargins(pixelsHalf, 0, 0, 0); final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase(); final String leftString = stopNameTrimmed + " " + bound; final SpannableString destinationSpannable = new SpannableString(leftString); destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(), leftString.length(), 0); // set size destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color final TextView boundCustomTextView = new TextView(context); boundCustomTextView.setText(destinationSpannable); boundCustomTextView.setSingleLine(true); boundCustomTextView.setLayoutParams(destinationParams); left.addView(lineIndication); left.addView(boundCustomTextView); // Right final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rightParams.setMargins(marginLeftPixel, 0, 0, 0); final LinearLayout right = new LinearLayout(context); right.setOrientation(LinearLayout.VERTICAL); right.setLayoutParams(rightParams); final List<BusArrival> buses = entry2.getValue(); final StringBuilder currentEtas = new StringBuilder(); for (final BusArrival arri : buses) { currentEtas.append(" ").append(arri.getTimeLeftDueDelay()); } final TextView arrivalText = new TextView(context); arrivalText.setText(currentEtas); arrivalText.setGravity(Gravity.END); arrivalText.setSingleLine(true); arrivalText.setTextColor(grey5); arrivalText.setEllipsize(TextUtils.TruncateAt.END); right.addView(arrivalText); container.addView(left); container.addView(right); holder.mainLayout.addView(container); newLine = false; i++; } } holder.mapButton.setText(activity.getString(R.string.favorites_view_buses)); holder.detailsButton .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs)); holder.mapButton.setOnClickListener(v -> { if (!Util.isNetworkAvailable(context)) { Util.showNetworkErrorMessage(activity); } else { final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound) .collect(Collectors.toSet()); final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class); final Bundle extras = new Bundle(); extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId()); extras.putStringArray(activity.getString(R.string.bundle_bus_bounds), bounds.toArray(new String[bounds.size()])); intent.putExtras(extras); activity.startActivity(intent); } }); }