Example usage for android.widget TextView setMovementMethod

List of usage examples for android.widget TextView setMovementMethod

Introduction

In this page you can find the example usage for android.widget TextView setMovementMethod.

Prototype

public final void setMovementMethod(MovementMethod movement) 

Source Link

Document

Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.

Usage

From source file:pro.dbro.bart.TheActivity.java

public void displayRouteResponse(routeResponse routeResponse) {
    // Log.d("displayRouteResponse","Is this real?: "+routeResponse.toString());
    // Previously, if the device's locale wasn't in Pacific Standard Time
    // Responses with all expired routes could present, causing a looping refresh cycle
    // This is now remedied by coercing response dates into PST
    boolean expiredResponse = false;
    if (routeResponse.routes.size() == 0) {
        Log.d("displayRouteResponse", "no routes to display");
        expiredResponse = true;/*from w  w w  . j av  a2  s.co  m*/
    }

    if (timer != null)
        timer.cancel(); // cancel previous timer
    timerViews = new ArrayList(); // release old ETA text views
    maxTimer = 0;
    try {
        tableLayout.removeAllViews();
        //Log.v("DATE",new Date().toString());
        long now = new Date().getTime();

        if (!expiredResponse) {
            fareTv.setVisibility(0);
            fareTv.setText("$" + routeResponse.routes.get(0).fare);
            for (int x = 0; x < routeResponse.routes.size(); x++) {
                route thisRoute = routeResponse.routes.get(x);

                TableRow tr = (TableRow) View.inflate(c, R.layout.tablerow, null);
                tr.setPadding(0, 20, 0, 0);
                LinearLayout legLayout = (LinearLayout) View.inflate(c, R.layout.routelinearlayout, null);

                for (int y = 0; y < thisRoute.legs.size(); y++) {
                    TextView trainTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                    trainTv.setPadding(0, 0, 0, 0);
                    trainTv.setTextSize(20);
                    trainTv.setGravity(3); // set left gravity
                    // If route has multiple legs, generate "Transfer At [station name]" and "To [train name] " rows for each leg after the first
                    if (y > 0) {
                        trainTv.setText("transfer at " + BART.REVERSE_STATION_MAP
                                .get(((leg) thisRoute.legs.get(y - 1)).disembarkStation.toLowerCase()));
                        trainTv.setPadding(0, 0, 0, 0);
                        legLayout.addView(trainTv);
                        trainTv.setTextSize(14);
                        trainTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                        trainTv.setPadding(0, 0, 0, 0);
                        trainTv.setTextSize(20);
                        trainTv.setGravity(3); // set left gravity
                        trainTv.setText("to " + BART.REVERSE_STATION_MAP
                                .get(((leg) thisRoute.legs.get(y)).trainHeadStation.toLowerCase()));
                    } else {
                        // For first route leg, display "Take [train name]" row
                        trainTv.setText("take "
                                + BART.REVERSE_STATION_MAP.get(((leg) thisRoute.legs.get(y)).trainHeadStation));
                    }

                    legLayout.addView(trainTv);

                }

                if (thisRoute.legs.size() == 1) {
                    legLayout.setPadding(0, 10, 0, 0); // Address detination train and ETA not aligning 
                }

                tr.addView(legLayout);

                // Prepare ETA TextView
                TextView arrivalTimeTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                arrivalTimeTv.setPadding(10, 0, 0, 0);

                //Log.v("DEPART_DATE",thisRoute.departureDate.toString());

                // Don't report a train that may JUST be leaving with a negative ETA
                long eta;
                if (thisRoute.departureDate.getTime() - now <= 0) {
                    eta = 0;
                } else {
                    eta = thisRoute.departureDate.getTime() - now;
                }

                if (eta > maxTimer) {
                    maxTimer = eta;
                }
                // Set timeTv Tag to departure date for interpretation by ViewCountDownTimer
                arrivalTimeTv.setTag(thisRoute.departureDate.getTime());

                // Print arrival as time, not eta if greater than BART.ETA_THRESHOLD_MS
                if (thisRoute.departureDate.getTime() - now > BART.ETA_IN_MINUTES_THRESHOLD_MS) {
                    SimpleDateFormat sdf = new SimpleDateFormat("h:mm a");
                    arrivalTimeTv.setText(sdf.format(thisRoute.departureDate));
                    arrivalTimeTv.setTextSize(20);
                }
                // Display ETA as minutes until arrival
                else {
                    arrivalTimeTv.setTextSize(36);
                    // Display eta less than 1m as "<1"
                    if (eta < 60 * 1000)
                        arrivalTimeTv.setText("<1"); // TODO - remove this? Does countdown tick on start
                    else
                        arrivalTimeTv.setText(String.valueOf(eta / (1000 * 60))); // TODO - remove this? Does countdown tick on start
                    // Add the timerView to the list of views to be passed to the ViewCountDownTimer
                    timerViews.add(arrivalTimeTv);
                }

                //new ViewCountDownTimer(arrivalTimeTv, eta, 60*1000).start();
                tr.addView(arrivalTimeTv);
                // Set the Row View (containing train names and times) Tag to the route it represents
                tr.setTag(thisRoute);
                tableLayout.addView(tr);
                tr.setOnLongClickListener(new OnLongClickListener() {

                    @Override
                    public boolean onLongClick(View arg0) {
                        Log.d("RouteViewTag", ((route) arg0.getTag()).toString());
                        usherRoute = (route) arg0.getTag();
                        TextView guidanceTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                        guidanceTv.setText(Html.fromHtml(getString(R.string.service_prompt)));
                        guidanceTv.setTextSize(18);
                        guidanceTv.setPadding(0, 0, 0, 0);
                        new AlertDialog.Builder(c).setTitle("Route Guidance").setIcon(R.drawable.ic_launcher)
                                .setView(guidanceTv).setPositiveButton(R.string.service_start_button,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int which) {
                                                Intent i = new Intent(c, UsherService.class);
                                                //i.putExtra("departure", ((leg)usherRoute.legs.get(0)).boardStation);
                                                //Log.v("SERVICE","Starting");
                                                if (usherServiceIsRunning()) {
                                                    stopService(i);
                                                }
                                                startService(i);
                                            }

                                        })
                                .setNeutralButton("Cancel", null).show();
                        return true; // consumed the long click
                    }

                });
                tr.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        int index = tableLayout.indexOfChild(arg0); // index of clicked view. Expanded view will always be +1
                        route thisRoute = (route) arg0.getTag();
                        if (!thisRoute.isExpanded) { // if route not expanded
                            thisRoute.isExpanded = true;
                            LinearLayout routeDetail = (LinearLayout) View.inflate(c, R.layout.routedetail,
                                    null);
                            TextView arrivalTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                            SimpleDateFormat curFormater = new SimpleDateFormat("h:mm a");
                            //arrivalTv.setTextColor(0xFFC9C7C8);
                            arrivalTv.setText("arrives " + curFormater.format(thisRoute.arrivalDate));
                            arrivalTv.setTextSize(20);
                            routeDetail.addView(arrivalTv);
                            ImageView bikeIv = (ImageView) View.inflate(c, R.layout.bikeimage, null);

                            if (!thisRoute.bikes) {
                                bikeIv.setImageResource(R.drawable.no_bicycle);
                            }
                            routeDetail.addView(bikeIv);
                            tableLayout.addView(routeDetail, index + 1);
                        } else {
                            thisRoute.isExpanded = false;
                            tableLayout.removeViewAt(index + 1);
                        }

                    }
                });
            } // end route iteration
        } // end expiredResponse check
          // expiredResponse == True
          // If a late-night routeResponse includes the next morning's routes, they will be
          // presented with HH:MM ETAs, instead of minutes
          // Else if a late-night routeResponse includes routes from earlier in the evening
          // We will display "This route has stopped for tonight"
        else {
            String message = "This route has stopped for tonight";
            TextView specialScheduleTextView = (TextView) View.inflate(c, R.layout.tabletext, null);
            specialScheduleTextView.setText(message);
            specialScheduleTextView.setPadding(0, 0, 0, 0);
            tableLayout.addView(specialScheduleTextView);
        }
        if (routeResponse.specialSchedule != null) {
            ImageView specialSchedule = (ImageView) View.inflate(c, R.layout.specialschedulelayout, null);
            specialSchedule.setTag(routeResponse.specialSchedule);
            specialSchedule.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    TextView specialScheduleTv = (TextView) View.inflate(c, R.layout.tabletext, null);
                    specialScheduleTv.setPadding(0, 0, 0, 0);
                    specialScheduleTv.setText(Html.fromHtml(arg0.getTag().toString()));
                    specialScheduleTv.setTextSize(16);
                    specialScheduleTv.setMovementMethod(LinkMovementMethod.getInstance());
                    new AlertDialog.Builder(c).setTitle("Route Alerts").setIcon(R.drawable.warning)
                            .setView(specialScheduleTv).setPositiveButton("Okay!", null).show();

                }

            });
            tableLayout.addView(specialSchedule);
        }
        // Don't set timer if response is expired
        if (!expiredResponse) {
            timer = new ViewCountDownTimer(timerViews, "route", maxTimer, 30 * 1000);
            timer.start();
        }
    } catch (Throwable t) {
        Log.d("displayRouteResponseError", t.getStackTrace().toString());
    }
}

From source file:pro.dbro.bart.TheActivity.java

/** Called when the activity is first created. */
@Override/*from  w w w.  j av  a2  s.c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //TESTING: enable crittercism
    Crittercism.init(getApplicationContext(), SECRETS.CRITTERCISM_SECRET);

    if (Build.VERSION.SDK_INT < 11) {
        //If API 14+, The ActionBar will be hidden with this call
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    setContentView(R.layout.main);
    tableLayout = (TableLayout) findViewById(R.id.tableLayout);
    tableContainerLayout = (LinearLayout) findViewById(R.id.tableContainerLayout);
    c = this;
    res = getResources();
    prefs = getSharedPreferences("PREFS", 0);
    editor = prefs.edit();

    if (prefs.getBoolean("first_timer", true)) {
        TextView greetingTv = (TextView) View.inflate(c, R.layout.tabletext, null);
        greetingTv.setText(Html.fromHtml(getString(R.string.greeting)));
        greetingTv.setTextSize(18);
        greetingTv.setPadding(0, 0, 0, 0);
        greetingTv.setMovementMethod(LinkMovementMethod.getInstance());
        new AlertDialog.Builder(c).setTitle("Welcome to Open BART").setIcon(R.drawable.ic_launcher)
                .setView(greetingTv).setPositiveButton("Okay!", null).show();

        editor.putBoolean("first_timer", false);
        editor.commit();
    }
    // LocalBroadCast Stuff
    LocalBroadcastManager.getInstance(this).registerReceiver(serviceStateMessageReceiver,
            new IntentFilter("service_status_change"));

    // infoLayout is at the bottom of the screen
    // currently contains the stop service label 
    infoLayout = (LinearLayout) findViewById(R.id.infoLayout);

    // Assign the stationSuggestions Set
    stationSuggestions = new ArrayList();

    // Assign the bart station list to the autocompletetextviews 
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            BART.STATIONS);
    originTextView = (AutoCompleteTextView) findViewById(R.id.originTv);
    // Set tag for array adapter switch
    originTextView.setTag(R.id.TextInputShowingSuggestions, "false");

    fareTv = (TextView) findViewById(R.id.fareTv);
    stopServiceTv = (TextView) findViewById(R.id.stopServiceTv);

    destinationTextView = (AutoCompleteTextView) findViewById(R.id.destinationTv);
    destinationTextView.setTag(R.id.TextInputShowingSuggestions, "false");
    destinationTextView.setAdapter(adapter);
    originTextView.setAdapter(adapter);

    // Retrieve TextView inputs from saved preferences
    if (prefs.contains("origin") && prefs.contains("destination")) {
        //state= originTextView,destinationTextView
        String origin = prefs.getString("origin", "");
        String destination = prefs.getString("destination", "");
        if (origin.compareTo("") != 0)
            originTextView.setThreshold(200); // disable auto-complete until new text entered
        if (destination.compareTo("") != 0)
            destinationTextView.setThreshold(200); // disable auto-complete until new text entered

        originTextView.setText(origin);
        destinationTextView.setText(destination);
        validateInputAndDoRequest();
    }

    // Retrieve station suggestions from file storage
    try {
        ArrayList<StationSuggestion> storedSuggestions = (ArrayList<StationSuggestion>) LocalPersistence
                .readObjectFromFile(c, res.getResourceEntryName(R.string.StationSuggestionFileName));
        // If stored StationSuggestions are found, apply them
        if (storedSuggestions != null) {
            stationSuggestions = storedSuggestions;
            Log.d("stationSuggestions", "Loaded");
        } else
            Log.d("stationSuggestions", "Not Found");

    } catch (Throwable t) {
        // don't sweat it
    }

    ImageButton map = (ImageButton) findViewById(R.id.map);
    map.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(c, MapActivity.class);
            startActivity(intent);
        }

    });

    ImageButton reverse = (ImageButton) findViewById(R.id.reverse);
    reverse.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Editable originTempText = originTextView.getText();
            originTextView.setText(destinationTextView.getText());
            destinationTextView.setText(originTempText);

            validateInputAndDoRequest();
        }
    });

    // Handles restoring TextView input when focus lost, if no new input entered
    // previous input is stored in the target View Tag attribute
    // Assumes the target view is a TextView
    // TODO:This works but starts autocomplete when the view loses focus after clicking outside the autocomplete listview
    OnFocusChangeListener inputOnFocusChangeListener = new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View inputTextView, boolean hasFocus) {
            if (inputTextView.getTag(R.id.TextInputMemory) != null && !hasFocus
                    && ((TextView) inputTextView).getText().toString().compareTo("") == 0) {
                //Log.v("InputTextViewTagGet","orig: "+ inputTextView.getTag());
                ((TextView) inputTextView).setText(inputTextView.getTag(R.id.TextInputMemory).toString());
            }
        }
    };

    originTextView.setOnFocusChangeListener(inputOnFocusChangeListener);
    destinationTextView.setOnFocusChangeListener(inputOnFocusChangeListener);

    // When the TextView is clicked, store current text in TextView's Tag property, clear displayed text 
    // and enable Auto-Completing after first character entered
    OnTouchListener inputOnTouchListener = new OnTouchListener() {
        @Override
        public boolean onTouch(View inputTextView, MotionEvent me) {
            // Only perform this logic on finger-down
            if (me.getAction() == me.ACTION_DOWN) {
                inputTextView.setTag(R.id.TextInputMemory, ((TextView) inputTextView).getText().toString());
                Log.d("adapterSwitch", "suggestions");
                ((AutoCompleteTextView) inputTextView).setThreshold(1);
                ((TextView) inputTextView).setText("");

                // TESTING 
                // set tag to be retrieved on input entered to set adapter back to station list
                // The key of a tag must be a unique ID resource
                inputTextView.setTag(R.id.TextInputShowingSuggestions, "true");
                ArrayList<StationSuggestion> prunedSuggestions = new ArrayList<StationSuggestion>();
                // copy suggestions

                for (int x = 0; x < stationSuggestions.size(); x++) {
                    prunedSuggestions.add(stationSuggestions.get(x));
                }

                // Check for and remove other text input's value from stationSuggestions
                if (inputTextView.equals(findViewById(R.id.originTv))) {
                    // If the originTv is clicked, remove the destinationTv's value from prunedSuggestions
                    if (prunedSuggestions.contains(new StationSuggestion(
                            ((TextView) findViewById(R.id.destinationTv)).getText().toString(), "recent"))) {
                        prunedSuggestions.remove(new StationSuggestion(
                                ((TextView) findViewById(R.id.destinationTv)).getText().toString(), "recent"));
                    }
                } else if (inputTextView.equals(findViewById(R.id.destinationTv))) {
                    // If the originTv is clicked, remove the destinationTv's value from prunedSuggestions
                    if (prunedSuggestions.contains(new StationSuggestion(
                            ((TextView) findViewById(R.id.originTv)).getText().toString(), "recent"))) {
                        prunedSuggestions.remove(new StationSuggestion(
                                ((TextView) findViewById(R.id.originTv)).getText().toString(), "recent"));
                    }
                }

                //if(stationSuggestions.contains(new StationSuggestion(((TextView)inputTextView).getText().toString(),"recent")))

                // if available, add localStation to prunedSuggestions
                if (localStation.compareTo("") != 0) {
                    if (BART.REVERSE_STATION_MAP.get(localStation) != null) {
                        // If a valid localStation (based on DeviceLocation) is available: 
                        // remove localStations from recent suggestions (if it exists there)
                        // and add as nearby station
                        prunedSuggestions.remove(
                                new StationSuggestion(BART.REVERSE_STATION_MAP.get(localStation), "recent"));
                        prunedSuggestions.add(
                                new StationSuggestion(BART.REVERSE_STATION_MAP.get(localStation), "nearby"));
                    }
                }

                // TESTING: Set Custom ArrayAdapter to hold recent/nearby stations
                TextPlusIconArrayAdapter adapter = new TextPlusIconArrayAdapter(c, prunedSuggestions);
                ((AutoCompleteTextView) inputTextView).setAdapter(adapter);
                // force drop-down to appear, overriding requirement that at least one char is entered
                ((AutoCompleteTextView) inputTextView).showDropDown();

                // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                // android.R.layout.simple_dropdown_item_1line, BART.STATIONS);
            }
            // Allow Android to handle additional actions - i.e: TextView takes focus
            return false;
        }
    };

    originTextView.setOnTouchListener(inputOnTouchListener);
    destinationTextView.setOnTouchListener(inputOnTouchListener);

    // Autocomplete ListView item select listener

    originTextView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View arg1, int position, long arg3) {
            Log.d("OriginTextView", "item clicked");
            AutoCompleteTextView originTextView = (AutoCompleteTextView) findViewById(R.id.originTv);
            originTextView.setThreshold(200);
            //hideSoftKeyboard(arg1);
            // calling hideSoftKeyboard with arg1 doesn't work with stationSuggestion adapter
            hideSoftKeyboard(findViewById(R.id.inputLinearLayout));

            // Add selected station to stationSuggestions ArrayList if it doesn't exist
            if (!stationSuggestions
                    .contains((new StationSuggestion(originTextView.getText().toString(), "recent")))) {
                stationSuggestions.add(0, new StationSuggestion(originTextView.getText().toString(), "recent"));
                // if the stationSuggestion arraylist is over the max size, remove the last item
                if (stationSuggestions.size() > STATION_SUGGESTION_SIZE) {
                    stationSuggestions.remove(stationSuggestions.size() - 1);
                }
            }
            // Else, increment click count for that recent
            else {
                stationSuggestions
                        .get(stationSuggestions.indexOf(
                                (new StationSuggestion(originTextView.getText().toString(), "recent"))))
                        .addHit();
            }
            validateInputAndDoRequest();

        }
    });

    destinationTextView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View arg1, int position, long arg3) {
            Log.d("DestinationTextView", "item clicked");

            // Actv not available as arg1
            AutoCompleteTextView destinationTextView = (AutoCompleteTextView) findViewById(R.id.destinationTv);
            destinationTextView.setThreshold(200);
            //hideSoftKeyboard(arg1);
            hideSoftKeyboard(findViewById(R.id.inputLinearLayout));

            // Add selected station to stationSuggestions set
            if (!stationSuggestions
                    .contains((new StationSuggestion(destinationTextView.getText().toString(), "recent")))) {
                Log.d("DestinationTextView", "adding station");
                stationSuggestions.add(0,
                        new StationSuggestion(destinationTextView.getText().toString(), "recent"));
                if (stationSuggestions.size() > STATION_SUGGESTION_SIZE) {
                    stationSuggestions.remove(stationSuggestions.size() - 1);
                }
            }
            // If station exists in StationSuggestions, increment hit
            else {
                stationSuggestions
                        .get(stationSuggestions.indexOf(
                                (new StationSuggestion(destinationTextView.getText().toString(), "recent"))))
                        .addHit();
                //Log.d("DestinationTextView",String.valueOf(stationSuggestions.get(stationSuggestions.indexOf((new StationSuggestion(destinationTextView.getText().toString(),"recent")))).hits));
            }

            //If a valid origin station is not entered, return
            if (BART.STATION_MAP.get(originTextView.getText().toString()) == null)
                return;
            validateInputAndDoRequest();
            //lastRequest = "etd";
            //String url = "http://api.bart.gov/api/etd.aspx?cmd=etd&orig="+originStation+"&key=MW9S-E7SL-26DU-VV8V";
            // TEMP: For testing route function
            //lastRequest = "route";
            //bartApiRequest();
        }
    });

    //OnKeyListener only gets physical device keyboard events (except the softkeyboard delete key. hmmm)
    originTextView.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            //Log.d("seachScreen", "afterTextChanged"); 
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //Log.d("seachScreen", "beforeTextChanged"); 
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(c,
                    android.R.layout.simple_dropdown_item_1line, BART.STATIONS);
            if (((String) ((TextView) findViewById(R.id.originTv)).getTag(R.id.TextInputShowingSuggestions))
                    .compareTo("true") == 0) {
                ((TextView) findViewById(R.id.originTv)).setTag(R.id.TextInputShowingSuggestions, "false");
                ((AutoCompleteTextView) findViewById(R.id.originTv)).setAdapter(adapter);
            }

            Log.d("seachScreen", s.toString());
        }

    });
    destinationTextView.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            //Log.d("seachScreen", "afterTextChanged"); 
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //Log.d("seachScreen", "beforeTextChanged"); 
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(c,
                    android.R.layout.simple_dropdown_item_1line, BART.STATIONS);
            if (((String) ((TextView) findViewById(R.id.destinationTv))
                    .getTag(R.id.TextInputShowingSuggestions)).compareTo("true") == 0) {
                ((TextView) findViewById(R.id.destinationTv)).setTag(R.id.TextInputShowingSuggestions, "false");
                ((AutoCompleteTextView) findViewById(R.id.destinationTv)).setAdapter(adapter);
            }
            Log.d("seachScreen", s.toString());
        }

    });

}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Update the GUI with the specified rating */
private void setUserRatingTextView(int rating) {

    try {/*from   w w  w . j  av  a  2 s. co m*/
        TextView ratingTextView = (TextView) findViewById(R.id.rating);
        String communityRating = (seriesInfo == null) ? "?" : seriesInfo.getRating();
        String communityRatingText = communityRating + " / 10";

        String ratingTextA = communityRatingText + "  (";
        String ratingTextB = (rating == 0) ? "rate" : String.valueOf(rating);
        String ratingTextC = ")";

        int start = ratingTextA.length();
        int end = ratingTextA.length() + ratingTextB.length();

        SpannableStringBuilder ssb = new SpannableStringBuilder(ratingTextA + ratingTextB + ratingTextC);

        ssb.setSpan(new NonUnderlinedClickableSpan() {
            @Override
            public void onClick(View v) {
                showRatingDialog();
            }
        }, start, end, 0);

        ssb.setSpan(new TextAppearanceSpan(getApplicationContext(), R.style.episode_link), start, end, 0); // Set the style of the text
        ratingTextView.setText(ssb, BufferType.SPANNABLE);
        ratingTextView.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (Exception e) {
        Log.e("SeriesOverview", "Failed to setUserRatingTextView: " + e.getMessage());
    }
}

From source file:net.phase.wallet.Currency.java

protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder;/*from   w  w w.j ava  2  s  .co m*/
    AlertDialog alertDialog;
    builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = null;
    final WalletActivity parentActivity = this;

    switch (id) {
    case DIALOG_URL:
        layout = inflater.inflate(R.layout.urlfetch_dialog, null);

        TextView tv = (TextView) layout.findViewById(R.id.pasteBinHelpText);
        tv.setMovementMethod(LinkMovementMethod.getInstance());

        final EditText hashEditText = (EditText) layout.findViewById(R.id.hashEditText);
        final EditText nameEditText = (EditText) layout.findViewById(R.id.nameEditText);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                String hash = hashEditText.getText().toString();
                String name = nameEditText.getText().toString();

                if (!hash.startsWith("http")) {
                    hash = "http://pastebin.com/raw.php?i=" + hash;
                }

                try {
                    Wallet w = new Wallet(name, new URI(hash), parentActivity);
                    addWallet(w);
                } catch (Exception e) {
                    toastMessage(e.getMessage());
                }
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        break;
    case DIALOG_FILE:
        layout = inflater.inflate(R.layout.file_dialog, null);

        TextView tvhelp = (TextView) layout.findViewById(R.id.helpText);
        tvhelp.setMovementMethod(LinkMovementMethod.getInstance());

        final Spinner fileSpinner = (Spinner) layout.findViewById(R.id.fileInput);
        final EditText nameEditText2 = (EditText) layout.findViewById(R.id.nameEditText);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                File filename = (File) fileSpinner.getSelectedItem();
                String name = nameEditText2.getText().toString();
                boolean alreadyexists = false;

                if (name.length() > 0) {
                    if (wallets != null && wallets.length > 0) {
                        for (Wallet w : wallets) {
                            if (w.name.equals(name)) {
                                alreadyexists = true;
                            }
                        }
                    }

                    if (!alreadyexists) {
                        try {
                            Wallet w = new Wallet(name, filename, parentActivity);
                            addWallet(w);
                        } catch (Exception e) {
                            toastMessage(e.getMessage());
                        }
                    } else {
                        toastMessage("Wallet already exists");
                    }
                } else {
                    toastMessage("Invalid Name");
                }
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            }
        });
        break;
    case DIALOG_PASTE:
        layout = inflater.inflate(R.layout.paste_dialog, null);

        final EditText keysText = (EditText) layout.findViewById(R.id.keysText);
        final EditText nameEditText3 = (EditText) layout.findViewById(R.id.walletNameText);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                String keys = keysText.getText().toString();
                String name = nameEditText3.getText().toString();
                boolean alreadyexists = false;

                if (name.length() > 0) {
                    if (wallets != null && wallets.length > 0) {
                        for (Wallet w : wallets) {
                            if (w.name.equals(name)) {
                                alreadyexists = true;
                            }
                        }
                    }

                    if (!alreadyexists) {
                        try {
                            Wallet w = new Wallet(name, keys, parentActivity);
                            addWallet(w);
                        } catch (Exception e) {
                            toastMessage(e.getMessage());
                        }
                    } else {
                        toastMessage("Wallet already exists");
                    }
                } else {
                    toastMessage("Invalid Name");
                }
            }
        });

        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            }
        });
        break;
    case DIALOG_OPTIONS:
        layout = inflater.inflate(R.layout.options_dialog, null);

        final Spinner currencySpinner = (Spinner) layout.findViewById(R.id.currencySpinner);
        final EditText reqText = (EditText) layout.findViewById(R.id.reqText);
        final Spinner decpointSpinner = (Spinner) layout.findViewById(R.id.decpointSpinner);

        builder.setView(layout);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                String currency = (String) currencySpinner.getSelectedItem();
                decimalpoints = ((Integer) decpointSpinner.getSelectedItem()).intValue();
                setActiveCurrency(currency);
                try {
                    maxlength = Integer.parseInt(reqText.getText().toString());
                } catch (RuntimeException e) {
                    toastMessage("Invalid number");
                }
                savePreferences();
            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        break;

    }

    alertDialog = builder.create();

    return alertDialog;
}

From source file:com.yeldi.yeldibazaar.AppDetails.java

private void startViews() {

    // Populate the list...
    ApkListAdapter la = (ApkListAdapter) getListAdapter();
    for (DB.Apk apk : app.apks)
        la.addItem(apk);/*  www.  j a v  a 2s.  c o m*/
    la.notifyDataSetChanged();

    // Insert the 'infoView' (which contains the summary, various odds and
    // ends, and the description) into the appropriate place, if we're in
    // landscape mode. In portrait mode, we put it in the listview's
    // header..
    infoView = View.inflate(this, R.layout.appinfo, null);
    LinearLayout landparent = (LinearLayout) findViewById(R.id.landleft);
    headerView.removeAllViews();
    if (landparent != null) {
        landparent.addView(infoView);
        Log.d("FDroid", "Setting landparent infoview");
    } else {
        headerView.addView(infoView);
        Log.d("FDroid", "Setting header infoview");
    }

    // Set the icon...
    ImageView iv = (ImageView) findViewById(R.id.icon);
    File icon = new File(DB.getIconsPath(this), app.icon);
    if (icon.exists()) {
        iv.setImageDrawable(new BitmapDrawable(icon.getPath()));
    } else {
        iv.setImageResource(android.R.drawable.sym_def_app_icon);
    }

    // Set the title and other header details...
    TextView tv = (TextView) findViewById(R.id.title);
    tv.setText(app.name);
    tv = (TextView) findViewById(R.id.license);
    tv.setText(app.license);
    tv = (TextView) findViewById(R.id.status);

    tv = (TextView) infoView.findViewById(R.id.description);

    /*
     * The following is a quick solution to enable both text selection and
     * links. Causes glitches and crashes:
     * java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts
     * before 0
     * 
     * class CustomMovementMethod extends LinkMovementMethod {
     * 
     * @Override public boolean canSelectArbitrarily () { return true; } }
     * 
     * if (Utils.hasApi(11)) { tv.setTextIsSelectable(true);
     * tv.setMovementMethod(new CustomMovementMethod()); } else {
     * tv.setMovementMethod(LinkMovementMethod.getInstance()); }
     */

    tv.setMovementMethod(LinkMovementMethod.getInstance());

    // Need this to add the unimplemented support for ordered and unordered
    // lists to Html.fromHtml().
    class HtmlTagHandler implements TagHandler {
        int listNum;

        @Override
        public void handleTag(boolean opening, String tag, Editable output, XMLReader reader) {
            if (opening && tag.equals("ul")) {
                listNum = -1;
            } else if (opening && tag.equals("ol")) {
                listNum = 1;
            } else if (tag.equals("li")) {
                if (opening) {
                    if (listNum == -1) {
                        output.append("\t");
                    } else {
                        output.append("\t" + Integer.toString(listNum) + ". ");
                        listNum++;
                    }
                } else {
                    output.append('\n');
                }
            }
        }
    }
    tv.setText(Html.fromHtml(app.detail_description, null, new HtmlTagHandler()));

    tv = (TextView) infoView.findViewById(R.id.appid);
    tv.setText(app.id);

    tv = (TextView) infoView.findViewById(R.id.summary);
    tv.setText(app.summary);

    if (!app.apks.isEmpty()) {
        tv = (TextView) infoView.findViewById(R.id.permissions_list);

        CommaSeparatedList permsList = app.apks.get(0).detail_permissions;
        if (permsList == null) {
            tv.setText(getString(R.string.no_permissions) + '\n');
        } else {
            Iterator<String> permissions = permsList.iterator();
            StringBuilder sb = new StringBuilder();
            while (permissions.hasNext()) {
                String permissionName = permissions.next();
                try {
                    Permission permission = new Permission(this, permissionName);
                    sb.append("\t " + permission.getName() + '\n');
                } catch (NameNotFoundException e) {
                    Log.d("FDroid", "Can't find permission '" + permissionName + "'");
                }
            }
            tv.setText(sb.toString());
        }
        tv = (TextView) infoView.findViewById(R.id.permissions);
        tv.setText(getString(R.string.permissions_for_long, app.apks.get(0).version));
    }
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

private void createTokenLinkSpans(final TextView textView, final Spannable spannable, final String text) {
    // Saw from the source code that LinkMovementMethod sets the selection!
    // http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.1_r1/android/text/method/LinkMovementMethod.java#LinkMovementMethod
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    final Matcher matcher = CHAR_DASH.matcher(text);
    while (matcher.find()) {
        spannable.setSpan(new NonLinkClickableSpan(textColorFg), matcher.start(), matcher.end(),
                Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }/*from w  ww  .j  a va2 s  .c o  m*/
}

From source file:de.azapps.mirakel.main_activity.MainActivity.java

private void handleIntent(final Intent intent) {
    if ((intent == null) || (intent.getAction() == null)) {
        Log.d(MainActivity.TAG, "action null");
    } else if (DefinitionsHelper.SHOW_TASK.equals(intent.getAction())
            || DefinitionsHelper.SHOW_TASK_REMINDER.equals(intent.getAction())
            || DefinitionsHelper.SHOW_TASK_FROM_WIDGET.equals(intent.getAction())) {
        final Optional<Task> task = TaskHelper.getTaskFromIntent(intent);
        if (task.isPresent()) {
            this.currentList = task.get().getList();
            if (this.mDrawerLayout != null) {
                this.mDrawerLayout.postDelayed(new Runnable() {
                    @Override/*from w  w w .  jav  a 2  s .  co m*/
                    public void run() {
                        setCurrentTask(task.get(), true);
                    }
                }, 10L);
            }
        } else {
            Log.d(MainActivity.TAG, "task null");
        }
        if (intent.getAction().equals(DefinitionsHelper.SHOW_TASK_FROM_WIDGET)) {
            this.closeOnBack = true;
        }
    } else if (intent.getAction().equals(Intent.ACTION_SEND)
            || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
        this.closeOnBack = true;
        this.newTaskContent = intent.getStringExtra(Intent.EXTRA_TEXT);
        this.newTaskSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        // If from google now, the content is the subject
        if ((intent.getCategories() != null)
                && intent.getCategories().contains("com.google.android.voicesearch.SELF_NOTE")
                && !this.newTaskContent.isEmpty()) {
            this.newTaskSubject = this.newTaskContent;
            this.newTaskContent = "";
        }
        if (!"text/plain".equals(intent.getType()) && (this.newTaskSubject == null)) {
            this.newTaskSubject = MirakelCommonPreferences.getImportFileTitle();
        }
        final Optional<ListMirakel> listFromSharing = MirakelModelPreferences.getImportDefaultList();
        if (listFromSharing.isPresent()) {
            addTaskFromSharing(listFromSharing.get(), intent);
        } else {
            final AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.import_to);
            final List<CharSequence> items = new ArrayList<>();
            final List<Long> list_ids = new ArrayList<>();
            final int currentItem = 0;
            for (final ListMirakel list : ListMirakel.all()) {
                if (list.getId() > 0) {
                    items.add(list.getName());
                    list_ids.add(list.getId());
                }
            }
            builder.setSingleChoiceItems(items.toArray(new CharSequence[items.size()]), currentItem,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            final Optional<ListMirakel> listMirakelOptional = ListMirakel
                                    .get(list_ids.get(which));
                            withOptional(listMirakelOptional, new OptionalUtils.Procedure<ListMirakel>() {
                                @Override
                                public void apply(final ListMirakel input) {
                                    addTaskFromSharing(input, intent);
                                    dialog.dismiss();
                                }
                            });
                        }
                    });
            builder.create().show();
        }
    } else if (intent.getAction().equals(DefinitionsHelper.SHOW_LIST)
            || intent.getAction().contains(DefinitionsHelper.SHOW_LIST_FROM_WIDGET)) {
        final Optional<ListMirakel> listMirakelOptional = ListHelper.getListMirakelFromIntent(intent);
        if (listMirakelOptional.isPresent()) {
            final ListMirakel list = listMirakelOptional.get();
            setCurrentList(list);
            final Optional<Task> taskOptional = list.getFirstTask();
            if (taskOptional.isPresent()) {
                this.currentTask = taskOptional.get();
            }
            if (getTaskFragment() != null) {
                getTaskFragment().update(this.currentTask);
            }
        } else {
            Log.d(TAG, "show_list does not pass list, so ignore this");
        }
    } else if (intent.getAction().equals(DefinitionsHelper.SHOW_LISTS)) {
        this.mDrawerLayout.openDrawer(DefinitionsHelper.GRAVITY_LEFT);
    } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
        final String query = intent.getStringExtra(SearchManager.QUERY);
        search(query);
    } else if (intent.getAction().contains(DefinitionsHelper.ADD_TASK_FROM_WIDGET)) {
        final int listId = Integer
                .parseInt(intent.getAction().replace(DefinitionsHelper.ADD_TASK_FROM_WIDGET, ""));
        final Optional<ListMirakel> listMirakelOptional = ListMirakel.get(listId);
        if (listMirakelOptional.isPresent()) {
            setCurrentList(listMirakelOptional.get());
        } else {
            setCurrentList(ListMirakel.safeFirst());
        }
        this.mDrawerLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                if ((getTasksFragment() != null) && getTasksFragment().isReady()) {
                    getTasksFragment().focusNew(true);
                } else if (!MirakelCommonPreferences.isTablet()) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (getTasksFragment() != null) {
                                getTasksFragment().focusNew(true);
                            } else {
                                Log.wtf(MainActivity.TAG, "Tasksfragment null");
                            }
                        }
                    });
                }
            }
        }, 10);
    } else if (intent.getAction().equals(DefinitionsHelper.SHOW_MESSAGE)) {
        final String message = intent.getStringExtra(Intent.EXTRA_TEXT);
        String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        if (message != null) {
            if (subject == null) {
                subject = getString(R.string.message_notification);
            }
            final TextView msg = (TextView) getLayoutInflater().inflate(R.layout.alertdialog_textview, null);
            msg.setText(Html.fromHtml(message));
            msg.setMovementMethod(LinkMovementMethod.getInstance());
            msg.setClickable(true);
            new AlertDialog.Builder(this).setTitle(subject).setView(msg).show();
        }
    } else {
        setCurrentItem(getTaskFragmentPosition());
    }
    if (((intent == null) || (intent.getAction() == null)
            || !intent.getAction().contains(DefinitionsHelper.ADD_TASK_FROM_WIDGET))
            && (getTasksFragment() != null)) {
        getTasksFragment().clearFocus();
    }
    setIntent(null);
    if (this.currentList == null) {
        setCurrentList(SpecialList.firstSpecialSafe());
    }
}

From source file:com.example.xyzreader.ui.articledetail.ArticleDetailFragment.java

private void bindViews() {
    if (mRootView == null || mCursor == null) {
        return;//  w  w w.  j a  v  a  2  s  .  c o  m
    }
    final ImageView detailImageView = (ImageView) mRootView.findViewById(R.id.detail_image);
    final TextView articleTitle = (TextView) mRootView.findViewById(R.id.article_detail_title);
    final TextView articleByLine = (TextView) mRootView.findViewById(R.id.article_detail_byline);
    final TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        long itemId = mCursor.getLong(ArticleLoader.Query._ID);
        String imageTransitionName = mContext.getString(R.string.image_transition_name) + itemId;
        detailImageView.setTransitionName(imageTransitionName);
        //            Log.d(LOG_TAG, "detail image transition name = '" + imageTransitionName + "'");
    }

    Picasso.with(mContext).load(mCursor.getString(ArticleLoader.Query.PHOTO_URL)).into(detailImageView,
            new Callback() {
                @Override
                public void onSuccess() {
                    //                        Log.d(LOG_TAG, "successful image load");
                    mPalette = generatePalette(detailImageView);
                    if (getUserVisibleHint() && isResumed()) {
                        setAppBarColor();
                    }
                }

                @Override
                public void onError() {
                    //                        Log.d(LOG_TAG, "image load FAIL");
                }
            });

    articleTitle.setText(mCursor.getString(ArticleLoader.Query.TITLE));

    String byLine = DateUtils
            .getRelativeTimeSpanString(mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
            .toString() + " by " + mCursor.getString(ArticleLoader.Query.AUTHOR);
    articleByLine.setText(byLine);

    // Light up the embedded links in the body of the article
    bodyView.setMovementMethod(LinkMovementMethod.getInstance());

    //        bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
    bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));
}

From source file:com.keylesspalace.tusky.util.LinkHelper.java

/**
 * Finds links, mentions, and hashtags in a piece of text and makes them clickable, associating
 * them with callbacks to notify when they're clicked.
 *
 * @param view the returned text will be put in
 * @param content containing text with mentions, links, or hashtags
 * @param mentions any '@' mentions which are known to be in the content
 * @param listener to notify about particular spans that are clicked
 *///from  w w w .  j av  a2 s . c o m
public static void setClickableText(TextView view, Spanned content, @Nullable Status.Mention[] mentions,
        final LinkListener listener) {

    SpannableStringBuilder builder = new SpannableStringBuilder(content);
    URLSpan[] urlSpans = content.getSpans(0, content.length(), URLSpan.class);
    for (URLSpan span : urlSpans) {
        int start = builder.getSpanStart(span);
        int end = builder.getSpanEnd(span);
        int flags = builder.getSpanFlags(span);
        CharSequence text = builder.subSequence(start, end);
        if (text.charAt(0) == '#') {
            final String tag = text.subSequence(1, text.length()).toString();
            ClickableSpan newSpan = new ClickableSpan() {
                @Override
                public void onClick(View widget) {
                    listener.onViewTag(tag);
                }

                @Override
                public void updateDrawState(TextPaint ds) {
                    super.updateDrawState(ds);
                    ds.setUnderlineText(false);
                }
            };
            builder.removeSpan(span);
            builder.setSpan(newSpan, start, end, flags);
        } else if (text.charAt(0) == '@' && mentions != null && mentions.length > 0) {
            String accountUsername = text.subSequence(1, text.length()).toString();
            /* There may be multiple matches for users on different instances with the same
             * username. If a match has the same domain we know it's for sure the same, but if
             * that can't be found then just go with whichever one matched last. */
            String id = null;
            for (Status.Mention mention : mentions) {
                if (mention.localUsername.equalsIgnoreCase(accountUsername)) {
                    id = mention.id;
                    if (mention.url.contains(getDomain(span.getURL()))) {
                        break;
                    }
                }
            }
            if (id != null) {
                final String accountId = id;
                ClickableSpan newSpan = new ClickableSpan() {
                    @Override
                    public void onClick(View widget) {
                        listener.onViewAccount(accountId);
                    }

                    @Override
                    public void updateDrawState(TextPaint ds) {
                        super.updateDrawState(ds);
                        ds.setUnderlineText(false);
                    }
                };
                builder.removeSpan(span);
                builder.setSpan(newSpan, start, end, flags);
            }
        } else {
            ClickableSpan newSpan = new CustomURLSpan(span.getURL());
            builder.removeSpan(span);
            builder.setSpan(newSpan, start, end, flags);
        }
    }
    view.setText(builder);
    view.setLinksClickable(true);
    view.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.pemikir.youtubeplus.VideoItemDetailFragment.java

public void updateInfo(VideoInfo info) {
    Activity a = getActivity();/*from ww w  . java2 s .c  o  m*/
    try {
        ProgressBar progressBar = (ProgressBar) a.findViewById(R.id.detailProgressBar);
        TextView videoTitleView = (TextView) a.findViewById(R.id.detailVideoTitleView);
        TextView uploaderView = (TextView) a.findViewById(R.id.detailUploaderView);
        TextView viewCountView = (TextView) a.findViewById(R.id.detailViewCountView);
        TextView thumbsUpView = (TextView) a.findViewById(R.id.detailThumbsUpCountView);
        TextView thumbsDownView = (TextView) a.findViewById(R.id.detailThumbsDownCountView);
        TextView uploadDateView = (TextView) a.findViewById(R.id.detailUploadDateView);
        TextView descriptionView = (TextView) a.findViewById(R.id.detailDescriptionView);
        ImageView thumbnailView = (ImageView) a.findViewById(R.id.detailThumbnailView);
        ImageView uploaderThumbnailView = (ImageView) a.findViewById(R.id.detailUploaderThumbnailView);
        ImageView thumbsUpPic = (ImageView) a.findViewById(R.id.detailThumbsUpImgView);
        ImageView thumbsDownPic = (ImageView) a.findViewById(R.id.detailThumbsDownImgView);
        View textSeperationLine = a.findViewById(R.id.textSeperationLine);

        if (textSeperationLine != null) {
            textSeperationLine.setVisibility(View.VISIBLE);
        }
        progressBar.setVisibility(View.GONE);
        videoTitleView.setVisibility(View.VISIBLE);
        uploaderView.setVisibility(View.VISIBLE);
        uploadDateView.setVisibility(View.VISIBLE);
        viewCountView.setVisibility(View.VISIBLE);
        thumbsUpView.setVisibility(View.VISIBLE);
        thumbsDownView.setVisibility(View.VISIBLE);
        uploadDateView.setVisibility(View.VISIBLE);
        descriptionView.setVisibility(View.VISIBLE);
        thumbnailView.setVisibility(View.VISIBLE);
        uploaderThumbnailView.setVisibility(View.VISIBLE);
        thumbsUpPic.setVisibility(View.VISIBLE);
        thumbsDownPic.setVisibility(View.VISIBLE);

        switch (info.videoAvailableStatus) {
        case VideoInfo.VIDEO_AVAILABLE: {
            videoTitleView.setText(info.title);
            uploaderView.setText(info.uploader);
            viewCountView.setText(info.view_count + " " + a.getString(R.string.viewSufix));
            thumbsUpView.setText(info.like_count);
            thumbsDownView.setText(info.dislike_count);
            uploadDateView.setText(a.getString(R.string.uploadDatePrefix) + " " + info.upload_date);
            descriptionView.setText(Html.fromHtml(info.description));
            descriptionView.setMovementMethod(LinkMovementMethod.getInstance());

            ActionBarHandler.getHandler().setVideoInfo(info.webpage_url, info.title);

            // parse streams
            Vector<VideoInfo.VideoStream> streamsToUse = new Vector<>();
            for (VideoInfo.VideoStream i : info.videoStreams) {
                if (useStream(i, streamsToUse)) {
                    streamsToUse.add(i);
                }
            }
            VideoInfo.VideoStream[] streamList = new VideoInfo.VideoStream[streamsToUse.size()];
            for (int i = 0; i < streamList.length; i++) {
                streamList[i] = streamsToUse.get(i);
            }
            ActionBarHandler.getHandler().setStreams(streamList, info.audioStreams);
        }
            break;
        case VideoInfo.VIDEO_UNAVAILABLE_GEMA:
            thumbnailView.setImageBitmap(
                    BitmapFactory.decodeResource(getResources(), R.drawable.gruese_die_gema_unangebracht));
            break;
        case VideoInfo.VIDEO_UNAVAILABLE:
            thumbnailView.setImageBitmap(
                    BitmapFactory.decodeResource(getResources(), R.drawable.not_available_monkey));
            break;
        default:
            Log.e(TAG, "Video Availeble Status not known.");
        }

        if (autoPlayEnabled) {
            ActionBarHandler.getHandler().playVideo();
        }
    } catch (java.lang.NullPointerException e) {
        Log.w(TAG, "updateInfo(): Fragment closed before thread ended work... or else");
        e.printStackTrace();
    }
}