Example usage for android.widget ListView setTranscriptMode

List of usage examples for android.widget ListView setTranscriptMode

Introduction

In this page you can find the example usage for android.widget ListView setTranscriptMode.

Prototype

public void setTranscriptMode(int mode) 

Source Link

Document

Puts the list or grid into transcript mode.

Usage

From source file:com.raspi.chatapp.ui.chatting.ChatListFragment.java

/**
 * this function will make sure the ui looks right and reload everything.
 * Yeah, it is inefficient calling it every time a little detail has
 * changed but atm I don't care as this won't be as loaded as the
 * ChatFragment.// w  w  w. ja va2 s . c  om
 */
private void initUI() {
    // create the chatArrayAdapter
    caa = new ChatArrayAdapter(getContext(), R.layout.chat_list_entry);
    ListView lv = (ListView) getView().findViewById(R.id.main_listview);
    lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_NORMAL);
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // on click open the corresponding chat
            ChatEntry chatEntry = caa.getItem(position);
            mListener.onChatOpened(chatEntry.buddyId, chatEntry.name);
        }
    });
    lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
            // on long click rename the chat --> look ChatFragment
            final EditText newName = new EditText(getActivity());
            newName.setText(caa.getItem(position).name);
            String title = getResources().getString(R.string.change_name_title) + " "
                    + caa.getItem(position).name;
            // the dialog with corresponding title and message and with the
            // pre filled editText
            new AlertDialog.Builder(getContext()).setTitle(title).setMessage(R.string.change_name)
                    .setView(newName).setPositiveButton(R.string.rename, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // rename the chat and reinitialize the ui
                            MessageHistory messageHistory = new MessageHistory(getContext());
                            String buddyId = caa.getItem(position).buddyId;
                            String name = newName.getText().toString();
                            messageHistory.renameChat(buddyId, name);
                            initUI();
                        }
                    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // there is a cancel button too...
                        }
                    }).show();
            return true;
        }
    });
    // set the data
    lv.setAdapter(caa);
    MessageHistory messageHistory = new MessageHistory(getContext());
    // retrieve the chats and add them to the listView
    ChatEntry[] entries = messageHistory.getChats();
    for (ChatEntry entry : entries) {
        if (entry != null)
            caa.add(entry);
    }

    // the swipe refresh layout
    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getActivity()
            .findViewById(R.id.swipe_refresh);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // make everything related to refreshing in a background thread
            new Thread(new RefreshRunnable(new Handler(), swipeRefreshLayout)).start();
        }
    });

    // make sure that the no internet text displays the emojicon correctly
    EmojiconTextView textView = (EmojiconTextView) getActivity().findViewById(R.id.no_internet_text);
    textView.setText(
            String.format(getActivity().getResources().getString(R.string.no_internet), "\uD83D\uDE28"));

    // set the title
    actionBar.setTitle("ChatApp");
    // make sure that there is no subtitle
    actionBar.setSubtitle(null);
}

From source file:me.myatminsoe.myansms.MessageListActivity.java

/**
 * {@inheritDoc}/*ww w .  ja  v  a2s. c o m*/
 */
@Override
protected final void onResume() {
    super.onResume();

    final ListView lv = getListView();
    lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    lv.setAdapter(new MessageAdapter(this, uri));
    markedUnread = false;

    final AppCompatImageButton btn = (AppCompatImageButton) findViewById(R.id.send_);
    if (showTextField) {
        Intent i;
        ActivityInfo ai = null;
        final PackageManager pm = getPackageManager();
        try {
            i = buildIntent(false, false);
            if (pm != null && PreferenceManager.getDefaultSharedPreferences(this)
                    .getBoolean(PreferencesActivity.PREFS_SHOWTARGETAPP, true)) {
                ai = i.resolveActivityInfo(pm, 0);
            }
        } catch (NullPointerException e) {
            Log.e(TAG, "unable to build Intent", e);
        }
        etText.setMaxLines(MAX_EDITTEXT_LINES);

        if (ai == null) {
            etText.setMinLines(1);
        } else {
            if (chooserPackage == null) {
                try {
                    final ActivityInfo cai = buildIntent(false, true).resolveActivityInfo(pm, 0);
                    if (cai != null) {
                        chooserPackage = cai.packageName;
                    }
                } catch (NullPointerException e) {
                    Log.e(TAG, "unable to build Intent", e);
                }
            }
            if (ai.packageName.equals(chooserPackage)) {
            } else {

            }
            etText.setMinLines(3);
        }
    } else {
        btn.setImageResource(R.drawable.icn_send_disabled);
    }
}

From source file:de.ub0r.android.smsdroid.MessageListActivity.java

/**
 * {@inheritDoc}//from   w  w w.  j ava2s.co  m
 */
@Override
protected final void onResume() {
    super.onResume();
    boolean noAds = DonationHelper.hideAds(this);
    if (!noAds) {
        Ads.loadAd(this, R.id.ad, ADMOB_PUBID, AD_KEYWORDS);
    }

    final ListView lv = this.getListView();
    lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    lv.setAdapter(new MessageAdapter(this, this.uri));
    this.markedUnread = false;

    final Button btn = (Button) this.findViewById(R.id.send_);
    if (this.showTextField) {
        final Intent i = this.buildIntent(this.enableAutosend, false);
        final PackageManager pm = this.getPackageManager();
        ActivityInfo ai = null;
        if (PreferenceManager.getDefaultSharedPreferences(this)
                .getBoolean(PreferencesActivity.PREFS_SHOWTARGETAPP, true)) {
            ai = i.resolveActivityInfo(pm, 0);
        }
        if (ai == null) {
            btn.setText(null);
            this.etText.setMinLines(1);
        } else {
            if (chooserPackage == null) {
                final ActivityInfo cai = this.buildIntent(this.enableAutosend, true).resolveActivityInfo(pm, 0);
                if (cai != null) {
                    chooserPackage = cai.packageName;
                }
            }
            if (ai.packageName.equals(chooserPackage)) {
                btn.setText(R.string.chooser_);
            } else {
                Log.d(TAG, "ai.pn: " + ai.packageName);
                btn.setText(ai.loadLabel(pm));
            }
            this.etText.setMinLines(3);
        }
    } else {
        btn.setText(null);
    }
}

From source file:org.solovyev.android.messenger.messages.MessagesFragment.java

private void syncOlderMessages() {
    final ListView lv = getListViewById();
    final FragmentActivity activity = getActivity();
    if (lv != null && activity != null) {
        final Integer transcriptMode = lv.getTranscriptMode();
        lv.setTranscriptMode(ListView.TRANSCRIPT_MODE_DISABLED);

        final PublicPullToRefreshListView pullToRefreshListView = getPullToRefreshListView();
        if (pullToRefreshListView != null) {
            pullToRefreshListView.setRefreshingInternal(false);
        }/*from  w  w w .j av  a  2  s .com*/

        new SyncMessagesForChatAsyncTask(this, activity) {
            @Override
            protected void onSuccessPostExecute(@Nonnull Input result) {
                try {
                    super.onSuccessPostExecute(result);
                } finally {
                    setTranscriptMode(lv, transcriptMode);
                }
            }

            @Override
            protected void onFailurePostExecute(@Nonnull Exception e) {
                try {
                    super.onFailurePostExecute(e);
                } finally {
                    setTranscriptMode(lv, transcriptMode);
                }
            }
        }.executeInParallel(
                new SyncMessagesForChatAsyncTask.Input(getUser().getEntity(), chat.getEntity(), true));
    }
}

From source file:com.nnm.smsviet.MessageListActivity.java

/**
 * {@inheritDoc}//from  w  w w.  ja v  a 2  s .c  o m
 */
@Override
protected final void onResume() {
    super.onResume();
    Ads.loadAd(this, R.id.ad, ADMOB_PUBID, null);
    final ListView lv = this.getListView();
    lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    lv.setAdapter(new MessageAdapter(this, this.uri));
    this.markedUnread = false;

    final Button btn = (Button) this.findViewById(R.id.send_);
    // if (this.showTextField) {
    // final Intent i = this.buildIntent(this.enableAutosend, false);
    // final PackageManager pm = this.getPackageManager();
    // ActivityInfo ai = null;
    // if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
    // PreferencesActivity.PREFS_SHOWTARGETAPP, true)) {
    // ai = i.resolveActivityInfo(pm, 0);
    // }
    // if (ai == null) {
    // btn.setText(null);
    // this.etText.setMinLines(1);
    // } else {
    // if (chooserPackage == null) {
    // final ActivityInfo cai = this.buildIntent(this.enableAutosend, true)
    // .resolveActivityInfo(pm, 0);
    // if (cai != null) {
    // chooserPackage = cai.packageName;
    // }
    // }
    // if (ai.packageName.equals(chooserPackage)) {
    // btn.setText(R.string.chooser_);
    // } else {
    // Log.d(TAG, "ai.pn: " + ai.packageName);
    // btn.setText(ai.loadLabel(pm));
    // }
    // this.etText.setMinLines(3);
    // }
    // } else {
    btn.setText(null);
    // }
}

From source file:com.android.calculator2.FloatingCalculatorPageAdapter.java

private void setUpHistory(ListView historyView) {
    FloatingHistoryAdapter.OnHistoryItemClickListener listener = new FloatingHistoryAdapter.OnHistoryItemClickListener() {
        @Override/*from  ww  w.  ja v  a2s. c  o m*/
        public void onHistoryItemClick(HistoryEntry entry) {
            int deleteMode = mLogic.getDeleteMode();
            if (mDisplay.getText().isEmpty()) {
                deleteMode = Logic.DELETE_MODE_CLEAR;
            }

            mDisplay.insert(entry.getEdited());
            mLogic.setDeleteMode(deleteMode);
        }
    };

    FloatingHistoryAdapter historyAdapter = new FloatingHistoryAdapter(mContext, mHistory);
    historyAdapter.setOnHistoryItemClickListener(listener);
    mHistory.setObserver(historyAdapter);
    historyView.setAdapter(historyAdapter);
    historyView.setStackFromBottom(true);
    historyView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
}

From source file:it.ciopper90.gojack2.MessageListActivity.java

/**
 * {@inheritDoc}/*from w ww.ja  va  2  s .c o m*/
 */
@Override
protected final void onResume() {
    super.onResume();
    // boolean noAds = DonationHelper.hideAds(this);
    // if (!noAds) {
    // Ads.loadAd(this, R.id.ad, ADMOB_PUBID, AD_KEYWORDS);
    // }

    final ListView lv = this.getListView();
    lv.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    lv.setAdapter(new MessageAdapter(this, this.uri));
    this.markedUnread = false;

    // final Button btn = (Button) this.findViewById(R.id.send_);
    // if (this.showTextField) {
    // final Intent i = this.buildIntent(this.enableAutosend, false);
    // final PackageManager pm = this.getPackageManager();
    // ActivityInfo ai = null;
    // if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
    // PreferencesActivity.PREFS_SHOWTARGETAPP, true)) {
    // ai = i.resolveActivityInfo(pm, 0);
    // }
    // if (ai == null) {
    // btn.setText(null);
    // this.etText.setMinLines(1);
    // } else {
    // if (chooserPackage == null) {
    // final ActivityInfo cai = this.buildIntent(this.enableAutosend, true)
    // .resolveActivityInfo(pm, 0);
    // if (cai != null) {
    // chooserPackage = cai.packageName;
    // }
    // }
    // if (ai.packageName.equals(chooserPackage)) {
    // btn.setText(R.string.chooser_);
    // } else {
    // Log.d(TAG, "ai.pn: " + ai.packageName);
    // btn.setText(ai.loadLabel(pm));
    // }
    // this.etText.setMinLines(3);
    // }
    // } else {
    // btn.setText(null);
    // }

}

From source file:com.juick.android.ThreadFragment.java

private void onWebSocketMessages(final ArrayList<JuickMessage> messages) {
    getActivity().runOnUiThread(new Runnable() {
        public void run() {
            // don't scroll
            ListView listView = null;
            try {
                listView = getListView();
            } catch (Exception e) {
                // view not yet created
                return;
            }/*ww  w.ja  va  2  s .c  o  m*/
            listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
            listView.setStackFromBottom(false);
            //
            if (sp.getBoolean("current_vibration_enabled", true)) {
                if (!paused) {
                    ((Vibrator) getActivity().getSystemService(Activity.VIBRATOR_SERVICE)).vibrate(250);
                }
            }
            if (listAdapter.getCount() > 0) {
                for (JuickMessage message : messages) {
                    if (message.getReplyTo() != 0 && !message.Text.startsWith("@")) {
                        for (int z = 0; z < listAdapter.getCount(); z++) {
                            JuickMessage item = listAdapter.getItem(z);
                            if (item != null && item.getRID() == message.getReplyTo()) {
                                message.Text = "@" + item.User.UName + " " + message.Text;
                            }
                        }
                    }
                }
                listAdapter.addAllMessages(messages);
                if (getActivity() instanceof ThreadActivity) {
                    ThreadActivity ta = (ThreadActivity) getActivity();
                    Editable text = ta.etMessage.getText();
                    for (JuickMessage message : messages) {
                        if (message.Text.contains(text)) {
                            if (ta.replyInProgress != null) {
                                ta.replyInProgress.preliminarySuccess();
                            }
                        }
                    }
                }
            }
            xmppServiceServiceGetter.getService(new Utils.ServiceGetter.Receiver<XMPPService>() {
                @Override
                public void withService(XMPPService service) {
                    for (JuickMessage message : messages) {
                        service.removeMessages(message.getMID(), false);
                    }
                }
            });
            Utils.ServiceGetter<DatabaseService> databaseGetter = new Utils.ServiceGetter<DatabaseService>(
                    getActivity(), DatabaseService.class);
            databaseGetter.getService(new Utils.ServiceGetter.Receiver<DatabaseService>() {
                @Override
                public void withService(DatabaseService service) {
                    service.maybeSaveMessages(messages);
                    super.withService(service);
                }
            });
            try {
                listAdapter.getItem(1).Text = getResources().getString(R.string.Replies) + " ("
                        + Integer.toString(listAdapter.getCount() - 2) + ")";
            } catch (Throwable ex) {
                // web socket came earlier than body itself!
            }
        }
    });
}

From source file:com.googlecode.networklog.LogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    MyLog.d("[LogFragment] onCreateView");
    LinearLayout layout = new LinearLayout(getActivity().getApplicationContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    ListView listView = new ListView(getActivity().getApplicationContext());
    listView.setAdapter(adapter);//from ww  w  .  j  a va  2 s .  c o  m
    listView.setTextFilterEnabled(true);
    listView.setFastScrollEnabled(true);
    listView.setSmoothScrollbarEnabled(false);
    listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
    listView.setStackFromBottom(true);
    listView.setOnItemClickListener(new CustomOnItemClickListener());
    layout.addView(listView);
    registerForContextMenu(listView);
    startUpdater();
    return layout;
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    // Remove flag button if a single bot app.
    if (MainActivity.launchType == LaunchType.Bot) {
        //findViewById(R.id.flagButton).setVisibility(View.GONE);
    }//w  w  w .jav a 2  s.  c  o m

    //permission required.
    ActivityCompat.requestPermissions(ChatActivity.this, new String[] { Manifest.permission.RECORD_AUDIO }, 1);

    //set/Save the current volume from the device.
    setStreamVolume();
    //Music Volume is Enabled.
    muteMicBeep(false);

    //For "scream" issue
    micLastStat = MainActivity.listenInBackground;

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    this.instance = (InstanceConfig) MainActivity.instance;
    if (this.instance == null) {
        return;
    }
    /*if (MainActivity.showAds) {
         AdView mAdView = (AdView) findViewById(R.id.adView);
         AdRequest adRequest = new AdRequest.Builder().build();
         mAdView.loadAd(adRequest);
    } else {
       AdView mAdView = (AdView) findViewById(R.id.adView);
       mAdView.setVisibility(View.GONE);
    }*/

    setTitle(this.instance.name);
    ((TextView) findViewById(R.id.title)).setText(this.instance.name);
    HttpGetImageAction.fetchImage(this, this.instance.avatar, findViewById(R.id.icon));
    ttsInit = false;
    tts = new TextToSpeech(this, this);

    if (!MainActivity.handsFreeSpeech) {
        setMicIcon(false, false);
    } else if (!MainActivity.listenInBackground) {
        setMicIcon(false, false);
    }

    //Last time will be saved for the MIC.
    if (MainActivity.listenInBackground && MainActivity.handsFreeSpeech) {
        microphoneThread(thread);
    }

    speech = SpeechRecognizer.createSpeechRecognizer(this);
    speech.setRecognitionListener(this);
    //scrollVie added and stuff
    scrollView = findViewById(R.id.chatList);
    menuMLayout = (LinearLayout) findViewById(R.id.menuMLayout);
    chatCLayout = (LinearLayout) findViewById(R.id.chatCLayout);
    responseLayout = (LinearLayout) findViewById(R.id.responseLayout);
    chatToolBar = (LinearLayout) findViewById(R.id.chatToolBar);

    videoView = (VideoView) findViewById(R.id.videoView);
    resetVideoErrorListener();
    videoError = false;

    imageView = (ImageView) findViewById(R.id.imageView);
    videoLayout = findViewById(R.id.videoLayout);

    textView = (EditText) findViewById(R.id.messageText);
    textView.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            submitChat();
            return false;
        }
    });

    if (MainActivity.translate) {
        findViewById(R.id.yandex).setVisibility(View.VISIBLE);
    } else {
        findViewById(R.id.yandex).setVisibility(View.GONE);
    }

    Spinner emoteSpin = (Spinner) findViewById(R.id.emoteSpin);
    emoteSpin.setAdapter(
            new EmoteSpinAdapter(this, R.layout.emote_list, Arrays.asList(EmotionalState.values())));

    ListView list = (ListView) findViewById(R.id.chatList);
    list.setAdapter(new ChatListAdapter(this, R.layout.chat_list, this.messages));
    list.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

    ImageButton button = (ImageButton) findViewById(R.id.speakButton);
    button.setOnClickListener(new View.OnClickListener() {
        @TargetApi(23)
        @Override
        public void onClick(View v) {
            if (MainActivity.handsFreeSpeech) {
                //set the current volume to the setting.
                setStreamVolume();
                //if its ON Or OFF - Switching back and forth 
                MainActivity.listenInBackground = !MainActivity.listenInBackground;

                //saving the boolean data of MainActivity.listeningInBackground
                SharedPreferences.Editor cookies = MainActivity.current.getPreferences(Context.MODE_PRIVATE)
                        .edit();
                cookies.putBoolean("listenInBackground", MainActivity.listenInBackground);
                cookies.commit();
                if (MainActivity.listenInBackground) {
                    micLastStat = true;
                    try {
                        microphoneThread(thread);
                    } catch (Exception ignore) {
                    }
                    beginListening();
                } else {
                    micLastStat = false;
                    microphoneThread(thread);
                    stopListening();
                }
            } else {
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, MainActivity.voice.language);
                try {
                    startActivityForResult(intent, RESULT_SPEECH);
                    textView.setText("");
                } catch (ActivityNotFoundException a) {
                    Toast t = Toast.makeText(getApplicationContext(),
                            "Your device doesn't support Speech to Text", Toast.LENGTH_SHORT);
                    t.show();
                }
            }
        }
    });

    //adding functionality on clicking the image  
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (stateLayouts == 4) {
                stateLayouts = 0;
            }
            switch (stateLayouts) {
            case 0:
                scrollView.setVisibility(View.VISIBLE);
                chatCLayout.setVisibility(View.VISIBLE);
                menuMLayout.setVisibility(View.VISIBLE);
                responseLayout.setVisibility(View.VISIBLE);
                chatToolBar.setVisibility(View.VISIBLE);
                break;
            case 1:
                scrollView.setVisibility(View.GONE);
                break;
            case 2:
                responseLayout.setVisibility(View.GONE);
                chatToolBar.setVisibility(View.GONE);
                break;
            case 3:
                menuMLayout.setVisibility(View.GONE);
                chatCLayout.setVisibility(View.GONE);
                break;
            }
            stateLayouts++;
        }
    });

    //adding functionality on clicking the image 
    videoLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (stateLayouts == 4) {
                stateLayouts = 0;
            }
            switch (stateLayouts) {
            case 0:
                scrollView.setVisibility(View.VISIBLE);
                chatCLayout.setVisibility(View.VISIBLE);
                menuMLayout.setVisibility(View.VISIBLE);
                responseLayout.setVisibility(View.VISIBLE);
                chatToolBar.setVisibility(View.VISIBLE);
                break;
            case 1:
                scrollView.setVisibility(View.GONE);
                break;
            case 2:
                responseLayout.setVisibility(View.GONE);
                chatToolBar.setVisibility(View.GONE);
                break;
            case 3:
                menuMLayout.setVisibility(View.GONE);
                chatCLayout.setVisibility(View.GONE);
                break;
            }
            stateLayouts++;
        }
    });

    GestureDetector.SimpleOnGestureListener listener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTapEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                boolean isVideo = !MainActivity.disableVideo && !videoError && response != null
                        && response.isVideo();
                View imageView = findViewById(R.id.imageView);
                View videoLayout = findViewById(R.id.videoLayout);
                if (imageView.getVisibility() == View.VISIBLE) {
                    imageView.setVisibility(View.GONE);
                } else if (!isVideo) {
                    imageView.setVisibility(View.VISIBLE);
                }
                if (videoLayout.getVisibility() == View.VISIBLE) {
                    videoLayout.setVisibility(View.GONE);
                } else if (isVideo) {
                    videoLayout.setVisibility(View.VISIBLE);
                }
                return true;
            }
            return false;
        }
    };
    final GestureDetector detector = new GestureDetector(this, listener);
    findViewById(R.id.chatList).setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return detector.onTouchEvent(event);
        }
    });

    listener = new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTapEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                View avatarLayout = findViewById(R.id.avatarLayout);
                if (avatarLayout.getVisibility() == View.VISIBLE) {
                    avatarLayout.setVisibility(View.GONE);
                } else {
                    avatarLayout.setVisibility(View.VISIBLE);
                }
                return true;
            }
            return false;
        }
    };
    final GestureDetector detector2 = new GestureDetector(this, listener);
    /*findViewById(R.id.responseText).setOnTouchListener(new View.OnTouchListener() {         
       @Override
       public boolean onTouch(View v, MotionEvent event) {
    return detector2.onTouchEvent(event);
       }
    });*/
    WebView responseView = (WebView) findViewById(R.id.responseText);
    responseView.getSettings().setJavaScriptEnabled(true);
    responseView.getSettings().setDomStorageEnabled(true);
    responseView.addJavascriptInterface(new WebAppInterface(this), "Android");

    findViewById(R.id.responseImageView).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            View avatarLayout = findViewById(R.id.avatarLayout);
            if (avatarLayout.getVisibility() == View.VISIBLE) {
                avatarLayout.setVisibility(View.GONE);
            } else {
                avatarLayout.setVisibility(View.VISIBLE);
            }
        }
    });

    HttpGetImageAction.fetchImage(this, instance.avatar, this.imageView);
    HttpGetImageAction.fetchImage(this, instance.avatar, (ImageView) findViewById(R.id.responseImageView));

    final ChatConfig config = new ChatConfig();
    config.instance = instance.id;
    config.avatar = this.avatarId;
    if (MainActivity.translate && MainActivity.voice != null) {
        config.language = MainActivity.voice.language;
    }
    if (MainActivity.disableVideo) {
        config.avatarFormat = "image";
    } else {
        config.avatarFormat = MainActivity.webm ? "webm" : "mp4";
    }
    config.avatarHD = MainActivity.hd;
    config.speak = !MainActivity.deviceVoice;
    // This is required because of a bug in TextToSpeech that prevents onInit being called if an AsynchTask is called...
    Thread thread1 = new Thread() {
        public void run() {
            for (int count = 0; count < 5; count++) {
                if (ttsInit) {
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (Exception exception) {
                }
            }
            HttpAction action = new HttpChatAction(ChatActivity.this, config);
            action.execute();
        }
    };
    thread1.start();
}