Advertisement
Guest User

MainActivity

a guest
Mar 9th, 2019
197
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.rafaelrp.melo_birthday;
  2.  
  3. import android.content.Context;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.ImageView;
  8. import android.widget.TextView;
  9. import android.widget.Toast;
  10.  
  11. public class MainActivity extends AppCompatActivity {
  12.  
  13.     ImageView imgView;
  14.  
  15.     private SpeechToText stt;
  16.     public static Context context;
  17.     private boolean firstTime = true;
  18.     private static TextView subtitle;
  19.  
  20.     @Override
  21.     protected void onCreate(Bundle savedInstanceState) {
  22.         super.onCreate(savedInstanceState);
  23.         setContentView(R.layout.activity_main);
  24.  
  25.         subtitle = findViewById(R.id.textView);
  26.  
  27.         imgView = findViewById(R.id.imageView);
  28.         imgView.setOnClickListener(new View.OnClickListener() {
  29.             @Override
  30.             public void onClick(View v) {
  31.                 stt.callBackgroundListener();
  32.             }
  33.         });
  34.  
  35.         context = getApplicationContext();
  36.         if(isFirstTime())
  37.             setSST();
  38.     }
  39.  
  40.     public static Context getContext() {
  41.         return context;
  42.     }
  43.  
  44.     public boolean isFirstTime() {
  45.         return firstTime;
  46.     }
  47.  
  48.     public void setFirstTime(boolean firstTime) {
  49.         this.firstTime = firstTime;
  50.     }
  51.  
  52.     public void setSST(){
  53.         stt = new SpeechToText(this);
  54.         setFirstTime(false);
  55.     }
  56.  
  57.     public static void setsubtitle(String txt){
  58.         subtitle.setText(txt);
  59.     }
  60. }
Advertisement
RAW Paste Data Copied
Advertisement