package com.msa.ui.fragments;

import android.content.Context;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.msa.ui.MainActivity;
import com.msa.ui.R;
import com.msa.ui.adapters.RssItem;

import java.util.Locale;

public class DetailFragment extends Fragment {

    private final int FRAGMENT_WEB_VIEW = 2;
    private Context mContext;
    private TextToSpeech tts;

    public DetailFragment() {}

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

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

        View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
        mContext = getActivity();

        final RssItem rssItem   = ((MainActivity)getActivity()).getRssItem();
        ImageView thumbnail     = (ImageView) rootView.findViewById(R.id.thumbnail);
        final TextView title          = (TextView) rootView.findViewById(R.id.title);
        TextView datetime       = (TextView) rootView.findViewById(R.id.datetime);
        final TextView description    = (TextView) rootView.findViewById(R.id.description);
        TextView txt_open_link  = (TextView) rootView.findViewById(R.id.txt_open_link);
        TextView txt_tts_link   = (TextView) rootView.findViewById(R.id.txt_tts_link);

        Glide.with(getActivity()).load(rssItem.getEnclosure()).into(thumbnail);

        title.setText(rssItem.getTitle());
        datetime.setText(getString(R.string.rss_date_time, rssItem.getStrDate(), rssItem.getStrTime()));
        description.setText(rssItem.getDescription());

        txt_open_link.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity)mContext).setRssItem(rssItem);
                ((MainActivity)mContext).displayView(FRAGMENT_WEB_VIEW);
            }
        });

        tts = new TextToSpeech(mContext, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if(status != TextToSpeech.ERROR) {
                    tts.setLanguage(Locale.FRENCH);
                }
            }
        });

        txt_tts_link.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String message = title.getText() + ". " + description.getText() + ".";
                tts.speak(message, TextToSpeech.QUEUE_FLUSH, null);
            }
        });

        return rootView;
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }
}
@@ -1047,16 +1047,20 @@
 sItem   
+    
 = ((Main
@@ -1129,16 +1129,20 @@
 ail     
+  
+  
 = (Image
@@ -1218,26 +1218,24 @@
 itle        
-  
 = (TextView)
@@ -1298,24 +1298,28 @@
 etime       
+  
+  
 = (TextView)
@@ -1393,18 +1393,16 @@
 iption  
- 
- 
 = (TextV
@@ -1479,16 +1479,20 @@
 n_link  
+    
 = (TextV
@@ -1571,16 +1571,20 @@
 _link   
+    
 = (TextV

Add Text to speech Update Gradle