Example usage for android.text SpannableString length

List of usage examples for android.text SpannableString length

Introduction

In this page you can find the example usage for android.text SpannableString length.

Prototype

int length();

Source Link

Document

Returns the length of this character sequence.

Usage

From source file:it.gulch.linuxday.android.services.AlarmIntentService.java

private void notifyEvent(Intent intent) {
    long eventId = Long.parseLong(intent.getDataString());
    Event event = eventManager.get(eventId);
    if (event == null) {
        return;/*from   ww  w . ja  v  a 2s  . co  m*/
    }

    //      NotificationManager notificationManager = (NotificationManager) getSystemService(Context
    // .NOTIFICATION_SERVICE);

    //      PendingIntent eventPendingIntent =
    //            TaskStackBuilder.create(this).addNextIntent(new Intent(this,
    // MainActivity.class)).addNextIntent(
    //                  new Intent(this, EventDetailsActivity.class).setData(Uri.parse(String.valueOf(event
    // .getId()))))
    //                  .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    PendingIntent eventPendingIntent = TaskStackBuilder.create(this)
            .addNextIntent(new Intent(this, MainActivity.class))
            .addNextIntent(new Intent(this, EventDetailsActivity.class)
                    .setData(Uri.parse(String.valueOf(event.getId()))))
            .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    int defaultFlags = Notification.DEFAULT_SOUND;
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (sharedPreferences.getBoolean(SettingsFragment.KEY_PREF_NOTIFICATIONS_VIBRATE, false)) {
        defaultFlags |= Notification.DEFAULT_VIBRATE;
    }

    String trackName = event.getTrack().getTitle();
    CharSequence bigText;
    String contentText;
    if (CollectionUtils.isEmpty(event.getPeople())) {
        contentText = trackName;
        bigText = event.getSubtitle();
    } else {
        String personsSummary = StringUtils.join(event.getPeople(), ", ");
        contentText = String.format("%1$s - %2$s", trackName, personsSummary);
        String subTitle = event.getSubtitle();

        SpannableString spannableBigText;
        if (TextUtils.isEmpty(subTitle)) {
            spannableBigText = new SpannableString(personsSummary);
        } else {
            spannableBigText = new SpannableString(String.format("%1$s\n%2$s", subTitle, personsSummary));
        }

        // Set the persons summary in italic
        spannableBigText.setSpan(new StyleSpan(Typeface.ITALIC),
                +spannableBigText.length() - personsSummary.length(), spannableBigText.length(),
                +Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        bigText = spannableBigText;
    }

    String roomName = event.getTrack().getRoom().getName();
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher).setWhen(event.getStartDate().getTime())
            .setContentTitle(event.getTitle()).setContentText(contentText)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(bigText).setSummaryText(trackName))
            .setContentInfo(roomName).setContentIntent(eventPendingIntent).setAutoCancel(true)
            .setDefaults(defaultFlags).setPriority(NotificationCompat.PRIORITY_HIGH);

    // Blink the LED with FOSDEM color if enabled in the options
    if (sharedPreferences.getBoolean(SettingsFragment.KEY_PREF_NOTIFICATIONS_LED, false)) {
        notificationBuilder.setLights(getResources().getColor(R.color.maincolor), 1000, 5000);
    }

    /*// Android Wear extensions
    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
            
    // Add an optional action button to show the room map image
    int roomImageResId = getResources()
    .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", getPackageName());
    if(roomImageResId != 0) {
       // The room name is the unique Id of a RoomImageDialogActivity
       Intent mapIntent = new Intent(this, RoomImageDialogActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
       .setData(Uri.parse(roomName));
       mapIntent.putExtra(RoomImageDialogActivity.EXTRA_ROOM_NAME, roomName);
       mapIntent.putExtra(RoomImageDialogActivity.EXTRA_ROOM_IMAGE_RESOURCE_ID, roomImageResId);
       PendingIntent mapPendingIntent =
       PendingIntent.getActivity(this, 0, mapIntent, PendingIntent.FLAG_UPDATE_CURRENT);
       CharSequence mapTitle = getString(R.string.room_map);
       notificationBuilder
       .addAction(new NotificationCompat.Action(R.drawable.ic_action_place, mapTitle, mapPendingIntent));
       // Use bigger action icon for wearable notification
       wearableExtender.addAction(
       new NotificationCompat.Action(R.drawable.ic_place_white_wear, mapTitle, mapPendingIntent));
    }
            
    notificationBuilder.extend(wearableExtender);*/

    NotificationManagerCompat.from(this).notify((int) eventId, notificationBuilder.build());
}

From source file:io.github.hidroh.materialistic.data.HackerNewsItem.java

@NonNull
private SpannableString createAuthorSpannable(boolean authorLink) {
    SpannableString bySpannable = new SpannableString(AUTHOR_SEPARATOR + by);
    if (!authorLink) {
        return bySpannable;
    }/* w  w w. j  a va2s.c om*/
    bySpannable.setSpan(new StyleSpan(Typeface.BOLD), AUTHOR_SEPARATOR.length(), bySpannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View view) {
            view.getContext()
                    .startActivity(new Intent(Intent.ACTION_VIEW).setData(AppUtils.createUserUri(getBy())));
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            super.updateDrawState(ds);
            ds.setUnderlineText(false);
        }
    };
    bySpannable.setSpan(clickableSpan, AUTHOR_SEPARATOR.length(), bySpannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    return bySpannable;
}

From source file:org.bobstuff.bobball.ActivityStateEnum.java

private void updateStatus(final GameState currGameState) {

    SpannableStringBuilder timeLeftStr = SpannableStringBuilder
            .valueOf(getString(R.string.timeLeftLabel, gameManager.timeLeft() / 10));

    SpannableStringBuilder livesStr = formatPerPlayer(getString(R.string.livesLabel), new playstat() {
        @Override//  w  w  w .j  av  a 2 s . co  m
        public int call(Player p) {
            return p.getLives();
        }
    });
    SpannableStringBuilder scoreStr = formatPerPlayer(getString(R.string.scoreLabel), new playstat() {
        @Override
        public int call(Player p) {
            return p.getScore();
        }
    });

    SpannableStringBuilder clearedStr = formatPerPlayer(getString(R.string.areaClearedLabel), new playstat() {
        @Override
        public int call(Player p) {
            Grid grid = currGameState.getGrid();
            if (grid != null)
                return currGameState.getGrid().getPercentComplete(p.getPlayerId());
            else
                return 0;
        }
    });

    //display fps
    if (secretHandshake >= 3) {

        float fps = displayLoop.getFPS();
        int color = (fps < NUMBER_OF_FRAMES_PER_SECOND * 0.98f ? Color.RED : Color.GREEN);
        SpannableString s = new SpannableString(String.format(" FPS: %2.1f", fps));

        s.setSpan(new ForegroundColorSpan(color), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        timeLeftStr.append(s);

        color = (gameManager.getUPS() < gameManager.NUMBER_OF_UPDATES_PER_SECOND * 0.98f ? Color.RED
                : Color.GREEN);
        s = new SpannableString(String.format(" UPS: %3.1f", gameManager.getUPS()));

        s.setSpan(new ForegroundColorSpan(color), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        timeLeftStr.append(s);
    }

    statusTopleft.setText(timeLeftStr);
    statusTopright.setText(livesStr);
    statusBotleft.setText(scoreStr);
    statusBotright.setText(clearedStr);
}

From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.I405TollRatesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_dynamic_toll_rates, null);

    mRecyclerView = root.findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new I405TollRatesItemAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);//from  w ww  .  jav  a 2 s  .  c o  m

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));

    mRecyclerView.setPadding(0, 0, 0, 120);

    addDisclaimerView(root);

    directionRadioGroup = root.findViewById(R.id.segment_control);

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
    radioGroupDirectionIndex = sharedPref.getInt(getString(R.string.toll_rates_405_travel_direction_key), 0);

    if (radioGroupDirectionIndex == 0) {
        RadioButton leftSegment = root.findViewById(R.id.radio_left);
        leftSegment.setChecked(true);
    } else {
        RadioButton rightSegment = root.findViewById(R.id.radio_right);
        rightSegment.setChecked(true);
    }

    directionRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {

        RadioButton selectedDirection = directionRadioGroup.findViewById(checkedId);

        mAdapter.setData(filterTollsForDirection(String.valueOf(selectedDirection.getText().charAt(0))));

        mLayoutManager.scrollToPositionWithOffset(0, 0);
        SharedPreferences sharedPref1 = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences.Editor editor = sharedPref1.edit();

        radioGroupDirectionIndex = directionRadioGroup.indexOfChild(selectedDirection);

        TextView travelTimeView = root.findViewById(R.id.travel_time_text);
        travelTimeView.setText(getTravelTimeStringForDirection(radioGroupDirectionIndex == 0 ? "N" : "S"));

        editor.putInt(getString(R.string.toll_rates_405_travel_direction_key), radioGroupDirectionIndex);

        editor.apply();

    });

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    swipeRefreshLayout = root.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.holo_blue_bright, R.color.holo_green_light,
            R.color.holo_orange_light, R.color.holo_red_light);

    mEmptyView = root.findViewById(R.id.empty_list_view);

    TextView header_link = root.findViewById(R.id.header_text);

    // create spannable string for underline
    SpannableString content = new SpannableString(
            getActivity().getResources().getString(R.string.i405_info_link));
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    header_link.setText(content);

    header_link.setTextColor(getResources().getColor(R.color.primary_default));
    header_link.setOnClickListener(v -> {
        Intent intent = new Intent();
        // GA tracker
        mTracker = ((WsdotApplication) getActivity().getApplication()).getDefaultTracker();
        mTracker.setScreenName("/Toll Rates/Learn about I-405");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://www.wsdot.wa.gov/Tolling/405/rates.htm"));
        startActivity(intent);
    });

    viewModel = ViewModelProviders.of(this, viewModelFactory).get(TollRatesViewModel.class);

    viewModel.getResourceStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                swipeRefreshLayout.setRefreshing(true);
                break;
            case SUCCESS:
                swipeRefreshLayout.setRefreshing(false);
                break;
            case ERROR:
                swipeRefreshLayout.setRefreshing(false);
                Toast.makeText(this.getContext(), "connection error", Toast.LENGTH_LONG).show();
            }
        }
    });

    viewModel.getTravelTimesStatus().observe(this, resourceStatus -> {
        if (resourceStatus != null) {
            switch (resourceStatus.status) {
            case LOADING:
                break;
            case SUCCESS:
                root.findViewById(R.id.travel_time_text).setVisibility(View.VISIBLE);
                break;
            case ERROR:
                root.findViewById(R.id.travel_time_text).setVisibility(View.GONE);
            }
        }
    });

    viewModel.getI405TollRateItems().observe(this, tollRateGroups -> {
        if (tollRateGroups != null) {

            mEmptyView.setVisibility(View.GONE);

            Collections.sort(tollRateGroups, new SortTollGroupByLocation());
            Collections.sort(tollRateGroups, new SortTollGroupByDirection());

            tollGroups = new ArrayList<>(tollRateGroups);

            directionRadioGroup.getCheckedRadioButtonId();
            RadioButton selectedDirection = directionRadioGroup
                    .findViewById(directionRadioGroup.getCheckedRadioButtonId());

            mAdapter.setData(filterTollsForDirection(String.valueOf(selectedDirection.getText().charAt(0))));
        }
    });

    viewModel.getTravelTimesForETLFor("405").observe(this, travelTimes -> {

        TextView travelTimeView = root.findViewById(R.id.travel_time_text);

        if (travelTimes.size() > 0) {
            travelTimeView.setVisibility(View.VISIBLE);

            this.travelTimes = new ArrayList<>(travelTimes);

            travelTimeView.setText(getTravelTimeStringForDirection(radioGroupDirectionIndex == 0 ? "N" : "S"));
        } else {
            travelTimeView.setVisibility(View.GONE);
        }
    });

    timer = new Timer();
    timer.schedule(new RatesTimerTask(), 0, 60000); // Schedule rates to update every 60 seconds

    return root;
}

From source file:com.evandroid.musica.fragment.LyricsViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRetainInstance(true);/*ww  w .  j  a v  a  2  s  . com*/
    setHasOptionsMenu(true);
    View layout = inflater.inflate(R.layout.lyrics_view, container, false);
    if (savedInstanceState != null)
        try {
            Lyrics l = Lyrics.fromBytes(savedInstanceState.getByteArray("lyrics"));
            if (l != null)
                this.mLyrics = l;
            mSearchQuery = savedInstanceState.getString("searchQuery");
            mSearchFocused = savedInstanceState.getBoolean("searchFocused");
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    else {
        Bundle args = getArguments();
        if (args != null)
            try {
                Lyrics lyrics = Lyrics.fromBytes(args.getByteArray("lyrics"));
                this.mLyrics = lyrics;
                if (lyrics != null && lyrics.getText() == null && lyrics.getArtist() != null) {
                    String artist = lyrics.getArtist();
                    String track = lyrics.getTrack();
                    String url = lyrics.getURL();
                    fetchLyrics(artist, track, url);
                    mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout);
                    startRefreshAnimation();
                }
            } catch (IOException | ClassNotFoundException e) {
                e.printStackTrace();
            }
    }
    if (layout != null) {
        Bundle args = savedInstanceState != null ? savedInstanceState : getArguments();

        boolean screenOn = PreferenceManager.getDefaultSharedPreferences(getActivity())
                .getBoolean("pref_force_screen_on", false);

        TextSwitcher textSwitcher = (TextSwitcher) layout.findViewById(R.id.switcher);
        textSwitcher.setFactory(new LyricsTextFactory(layout.getContext()));
        ActionMode.Callback callback = new CustomSelectionCallback(getActivity());
        ((TextView) textSwitcher.getChildAt(0)).setCustomSelectionActionModeCallback(callback);
        ((TextView) textSwitcher.getChildAt(1)).setCustomSelectionActionModeCallback(callback);
        textSwitcher.setKeepScreenOn(screenOn);
        layout.findViewById(R.id.lrc_view).setKeepScreenOn(screenOn);

        TextView id3TV = (TextView) layout.findViewById(R.id.id3_tv);
        SpannableString text = new SpannableString(id3TV.getText());
        text.setSpan(new UnderlineSpan(), 1, text.length() - 1, 0);
        id3TV.setText(text);

        final RefreshIcon refreshFab = (RefreshIcon) getActivity().findViewById(R.id.refresh_fab);
        refreshFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!mRefreshLayout.isRefreshing())
                    fetchCurrentLyrics(true);
            }
        });

        FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class);
                startActivity(settingsIntent);
            }
        });

        if (args != null)
            refreshFab.setEnabled(args.getBoolean("refreshFabEnabled", true));

        mScrollView = (NestedScrollView) layout.findViewById(R.id.scrollview);
        mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout);
        TypedValue primaryColor = new TypedValue();
        getActivity().getTheme().resolveAttribute(R.attr.colorPrimary, primaryColor, true);
        mRefreshLayout.setColorSchemeResources(primaryColor.resourceId, R.color.accent);
        float offset = getResources().getDisplayMetrics().density * 64;
        mRefreshLayout.setProgressViewEndTarget(true, (int) offset);
        mRefreshLayout.setOnRefreshListener(this);

        if (mLyrics == null) {
            if (!startEmtpy)
                fetchCurrentLyrics(false);
        } else if (mLyrics.getFlag() == Lyrics.SEARCH_ITEM) {
            mRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.refresh_layout);
            startRefreshAnimation();
            if (mLyrics.getArtist() != null)
                fetchLyrics(mLyrics.getArtist(), mLyrics.getTrack());
        } else //Rotation, resume
            update(mLyrics, layout, false);
    }
    if (broadcastReceiver == null)
        broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                searchResultLock = false;
                String artist = intent.getStringExtra("artist");
                String track = intent.getStringExtra("track");
                if (artist != null && track != null && mRefreshLayout.isEnabled()) {
                    startRefreshAnimation();
                    new ParseTask(LyricsViewFragment.this, false, true).execute(mLyrics);
                }
            }
        };
    return layout;
}

From source file:com.android.mail.browse.ConversationItemView.java

private static SpannableString copyStyles(CharacterStyle[] spans, CharSequence newText) {
    SpannableString s = new SpannableString(newText);
    if (spans != null && spans.length > 0) {
        s.setSpan(spans[0], 0, s.length(), 0);
    }/*www . j av  a  2s. c o  m*/
    return s;
}

From source file:com.barbrdo.app.activities.UserProfileActivity.java

@Override
void bindControls() {
    editTextPhone.addTextChangedListener(new PhoneNumberFormattingTextWatcher(editTextPhone));
    imageViewProfilePicture.setOnClickListener(this);
    textViewSearchRadius.setOnClickListener(this);
    textViewChangePassword.setOnClickListener(this);
    SpannableString content = new SpannableString(getString(R.string.change_password));
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    textViewChangePassword.setText(content);

    getView(R.id.cv_password_change).setVisibility(View.GONE);
    textViewCancel.setOnClickListener(this);
    textViewUpgrade.setOnClickListener(this);
}

From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE,
            getString(R.string.order_call_taxi_page_title));
    SpannableString spanString = new SpannableString(item.getTitle().toString());
    spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white
    item.setTitle(spanString);//w  w  w .j av a  2s. c  o m
    Utility driver = new Utility(getActivity());

    if (isShowOneKey && driver.getAllDriverAccountInfo().isEmpty())
        item.setVisible(true);
    else
        item.setVisible(false);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.techno.jay.codingcontests.Home.java

private void applyFontToMenuItem(MenuItem mi) {
    Typeface font = Typeface.createFromAsset(getAssets(), "ProductSans-Regular.ttf");
    SpannableString mNewTitle = new SpannableString(mi.getTitle());
    mNewTitle.setSpan(new CustomTypefaceSpan("", font), 0, mNewTitle.length(),
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    mi.setTitle(mNewTitle);/* w  ww .j  av  a 2 s .  co m*/
}

From source file:se.anyro.tagtider.TransferActivity.java

private void setupTransferData(final Bundle extras) {
    TextView trainView = (TextView) findViewById(R.id.train);

    ViewGroup originGroup = (ViewGroup) findViewById(R.id.origin_group);
    TextView originView = (TextView) findViewById(R.id.origin);
    TextView arrivalView = (TextView) findViewById(R.id.arrival);

    TextView stationTrackView = (TextView) findViewById(R.id.station_track);

    ViewGroup destinationGroup = (ViewGroup) findViewById(R.id.destination_group);
    TextView destinationView = (TextView) findViewById(R.id.destination);
    TextView departureView = (TextView) findViewById(R.id.departure);

    TextView commentView = (TextView) findViewById(R.id.comment);
    mEmptyView = (TextView) findViewById(android.R.id.empty);

    trainView.setText("Tg " + extras.getString("train") + " (" + extras.getString("type") + ")");

    String origin = extras.getString("origin");
    if (origin != null && origin.length() > 0) {
        originView.setText("Frn " + origin);
        originGroup.setVisibility(View.VISIBLE);
    } else {/*w w  w .ja  va2 s.  c  om*/
        originGroup.setVisibility(View.GONE);
    }

    String track = extras.getString("track");
    if (track == null || track.equalsIgnoreCase("x") || track.equalsIgnoreCase("null"))
        track = "";

    String arrival = extras.getString("arrival");
    if (arrival != null && !arrival.startsWith("0000")) {
        arrivalView.setText("Ankommer " + StringUtils.extractTime(arrival));
        String newArrival = extras.getString("newArrival");
        if (newArrival != null) {
            newArrival = StringUtils.extractTime(newArrival);
            SpannableString strike = new SpannableString(arrivalView.getText() + " " + newArrival);
            strike.setSpan(new StrikethroughSpan(), strike.length() - 11, strike.length() - 6, 0);
            arrivalView.setText(strike, TextView.BufferType.SPANNABLE);
        }
        if (track.length() == 0) {
            SpannableString strike = new SpannableString(arrivalView.getText());
            strike.setSpan(new StrikethroughSpan(), strike.length() - 5, strike.length(), 0);
            arrivalView.setText(strike, TextView.BufferType.SPANNABLE);
        }
    }

    if (extras.getString("stationName") != null) {
        mStationName = extras.getString("stationName");
    }

    if (track.length() > 0 && mStationName != null)
        stationTrackView.setText(mStationName + ", spr " + track);
    else if (mStationName != null)
        stationTrackView.setText(mStationName);
    else if (track.length() > 0)
        stationTrackView.setText("Spr " + track);
    else
        stationTrackView.setText("");

    String destination = extras.getString("destination");
    if (destination != null && destination.length() > 0) {
        destinationView.setText("Till " + destination);
        destinationGroup.setVisibility(View.VISIBLE);
    } else {
        destinationGroup.setVisibility(View.GONE);
    }

    String departure = extras.getString("departure");
    if (departure != null && !departure.startsWith("0000")) {
        departureView.setText("Avgr " + StringUtils.extractTime(departure));
        String newDeparture = extras.getString("newDeparture");
        if (newDeparture != null) {
            newDeparture = StringUtils.extractTime(newDeparture);
            SpannableString strike = new SpannableString(departureView.getText() + " " + newDeparture);
            strike.setSpan(new StrikethroughSpan(), strike.length() - 11, strike.length() - 6, 0);
            departureView.setText(strike, TextView.BufferType.SPANNABLE);
        }
        if (track.length() == 0) {
            SpannableString strike = new SpannableString(departureView.getText());
            strike.setSpan(new StrikethroughSpan(), strike.length() - 5, strike.length(), 0);
            departureView.setText(strike, TextView.BufferType.SPANNABLE);
        }
    }

    String comment = extras.getString("comment");
    if ((comment == null || comment.length() == 0) && track.length() == 0)
        comment = "Instllt";
    if (comment != null && comment.length() > 0) {
        commentView.setText(comment);
        commentView.setVisibility(View.VISIBLE);
    } else {
        commentView.setVisibility(View.GONE);
    }

    mTrain = extras.getString("train");
    mStationId = extras.getString("stationId");

    mTransferId = extras.getString("id");
}