List of usage examples for android.widget ListView invalidateViews
public void invalidateViews()
From source file:com.rickendirk.rsgwijzigingen.MainFragment.java
private void naZoeken(Wijzigingen wijzigingen) { progressDialog.dismiss();//from w w w . ja v a2 s. com if (wijzigingen.isFoutmelding()) { switch (wijzigingen.getFout()) { case "geenKlas": geenKlasAlert(); break; case "verbindFout": verbindfoutAlert(); break; case "EersteTekenLetter": EersteTekenKlasLetter(); break; case "klasMeerDan4Tekens": klasMeerDan4Tekens(); break; case "geenTabel": geenTabelAlert(); break; case "andereFout": andereFoutAlert(); break; //Onderstaande case kan alleen bij clusterzoeken case "geenClusters": geenClusterAlert(); break; } } else { //Kopieren naar wijzigingenList zodat listView bijgewerkt kan worden, eerst resultaten vorige weghalen wijzigingenList.clear(); //Moet toch iets in lijst worden weergegeven if (!wijzigingen.zijnWijzigingen) wijzigingen.addWijziging("Er zijn geen roosterwijzigingen"); wijzigingenList.addAll(wijzigingen.getWijzigingen()); String standZin = wijzigingen.getStandZin(); String dagEnDatum = wijzigingen.getDagEnDatum(); ListView listView = (ListView) mainView.findViewById(R.id.wijzigingenList); listView.invalidateViews(); TextView textStandView = (TextView) mainView.findViewById(R.id.textStand); textStandView.setText(standZin); //Dag en datum updaten dagEnDatumUpdater(dagEnDatum); //Mag toast met vernieuwd niet bij verbindingsfout etc vernieuwdToast(); setupMessage(wijzigingen); } }
From source file:com.jefftharris.passwdsafe.PasswdSafePolicyListFragment.java
@Override public void onListItemClick(ListView l, View v, int pos, long id) { l.invalidateViews(); }
From source file:com.jefftharris.passwdsafe.sync.SyncLogsFragment.java
@Override public void onListItemClick(ListView l, View v, int pos, long id) { if (l.isItemChecked(pos)) { if (pos == itsSelItemPos) { l.setItemChecked(pos, false); itsSelItemPos = -1;/*from w w w. j ava 2 s . co m*/ } else { itsSelItemPos = pos; } } l.invalidateViews(); }
From source file:com.rickendirk.rsgwijzigingen.MainFragment.java
private void setupListview(ListView listView) { Wijzigingen wijzigingen = new Wijzigingen(true, getActivity()); //Auomatisch uit SP wijzigingenList.clear();// w w w . ja va 2 s . c o m if (wijzigingen.getSize() != 0) { wijzigingenList.addAll(wijzigingen.getWijzigingen()); } else { //Geen roosterwijzigingen wijzigingenList.add("Er zijn geen roosterwijzigingen"); } listView.invalidateViews(); }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public void resetChat(View view) { ChatConfig config = new ChatConfig(); config.instance = instance.id;/*from w ww . j av a 2 s . c om*/ 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; HttpAction action = new HttpChatAction(ChatActivity.this, config); action.execute(); EditText v = (EditText) findViewById(R.id.messageText); v.setText(""); this.messages.clear(); runOnUiThread(new Runnable() { @Override public void run() { ListView list = (ListView) findViewById(R.id.chatList); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); } }); WebView responseView = (WebView) findViewById(R.id.responseText); responseView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null); }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public void submitChat() { ChatConfig config = new ChatConfig(); config.instance = this.instance.id; config.conversation = MainActivity.conversation; config.speak = !MainActivity.deviceVoice; config.avatar = this.avatarId; if (MainActivity.translate && MainActivity.voice != null) { config.language = MainActivity.voice.language; }/*from w w w . ja v a 2s . c o m*/ if (MainActivity.disableVideo) { config.avatarFormat = "image"; } else { config.avatarFormat = MainActivity.webm ? "webm" : "mp4"; } config.avatarHD = MainActivity.hd; EditText v = (EditText) findViewById(R.id.messageText); config.message = v.getText().toString().trim(); if (config.message.equals("")) { return; } this.messages.add(config); runOnUiThread(new Runnable() { @Override public void run() { ListView list = (ListView) findViewById(R.id.chatList); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); } }); Spinner emoteSpin = (Spinner) findViewById(R.id.emoteSpin); config.emote = emoteSpin.getSelectedItem().toString(); HttpChatAction action = new HttpChatAction(ChatActivity.this, config); action.execute(); v.setText(""); emoteSpin.setSelection(0); resetToolbar(); WebView responseView = (WebView) findViewById(R.id.responseText); responseView.loadDataWithBaseURL(null, "thinking...", "text/html", "utf-8", null); //Check the volume AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume <= 3 && volumeChecked) { Toast.makeText(this, "Please check 'Media' volume", Toast.LENGTH_LONG).show(); volumeChecked = false; } //stop letting the mic on. stopListening(); //its Important for "sleep" "scream" ...etc commands. //this will turn off the mic MainActivity.listenInBackground = false; }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public void submitCorrection() { final EditText text = new EditText(this); MainActivity.prompt("Enter correction to the bot's response (what it should have said)", this, text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (instance == null) { return; }/*ww w . j a v a 2s .com*/ ChatConfig config = new ChatConfig(); config.instance = instance.id; config.conversation = MainActivity.conversation; config.speak = !MainActivity.deviceVoice; config.avatar = avatarId; if (MainActivity.disableVideo) { config.avatarFormat = "image"; } else { config.avatarFormat = MainActivity.webm ? "webm" : "mp4"; } config.avatarHD = MainActivity.hd; config.message = text.getText().toString().trim(); if (config.message.equals("")) { return; } messages.add(config); runOnUiThread(new Runnable() { @Override public void run() { ListView list = (ListView) findViewById(R.id.chatList); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); } }); config.correction = true; Spinner emoteSpin = (Spinner) findViewById(R.id.emoteSpin); config.emote = emoteSpin.getSelectedItem().toString(); HttpChatAction action = new HttpChatAction(ChatActivity.this, config); action.execute(); EditText v = (EditText) findViewById(R.id.messageText); v.setText(""); emoteSpin.setSelection(0); resetToolbar(); WebView responseView = (WebView) findViewById(R.id.responseText); responseView.loadDataWithBaseURL(null, "thinking...", "text/html", "utf-8", null); } }); }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public void flagResponse() { if (MainActivity.user == null) { MainActivity.showMessage("You must sign in to flag a response", this); return;/*from w ww.j a v a2s . com*/ } final EditText text = new EditText(this); MainActivity.prompt("Enter reason for flagging response as offensive", this, text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (instance == null) { return; } ChatConfig config = new ChatConfig(); config.instance = instance.id; config.conversation = MainActivity.conversation; config.speak = !MainActivity.deviceVoice; config.avatar = 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.message = text.getText().toString().trim(); if (config.message.equals("")) { return; } messages.add(config); runOnUiThread(new Runnable() { @Override public void run() { ListView list = (ListView) findViewById(R.id.chatList); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); } }); config.offensive = true; Spinner emoteSpin = (Spinner) findViewById(R.id.emoteSpin); config.emote = emoteSpin.getSelectedItem().toString(); HttpChatAction action = new HttpChatAction(ChatActivity.this, config); action.execute(); EditText v = (EditText) findViewById(R.id.messageText); v.setText(""); emoteSpin.setSelection(0); resetToolbar(); WebView responseView = (WebView) findViewById(R.id.responseText); responseView.loadDataWithBaseURL(null, "thinking...", "text/html", "utf-8", null); } }); }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public void debug(final String text) { if (!DEBUG) { return;//ww w.j a va 2s .c om } final ListView list = (ListView) findViewById(R.id.chatList); list.post(new Runnable() { @Override public void run() { ChatResponse ready = new ChatResponse(); ready.message = text; messages.add(ready); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } } }); return; }
From source file:org.botlibre.sdk.activity.ChatActivity.java
public void response(final ChatResponse response) { if (speechPlayer != null || tts != null) { try {// ww w. java 2 s . com tts.stop(); speechPlayer.pause(); } catch (Exception ignore) { Log.e("RESPONSE", "Error: " + ignore.getMessage()); } } //needs when calling "sleep" or the its not going to let the mic off //also to stop the mic until the bot finish the sentence try { stopListening(); this.response = response; String status = ""; if (response.emote != null && !response.emote.equals("NONE")) { status = status + response.emote.toLowerCase(); } if (response.action != null) { if (!status.isEmpty()) { status = status + " "; } status = status + response.action; } if (response.pose != null) { if (!status.isEmpty()) { status = status + " "; } status = status + response.pose; } if (response.command != null) { JSONObject jsonObject = response.getCommand(); Command command = new Command(this, jsonObject); } TextView statusView = (TextView) findViewById(R.id.statusText); statusView.setText(status); final String text = response.message; final ListView list = (ListView) findViewById(R.id.chatList); if (text == null) { list.post(new Runnable() { @Override public void run() { ChatResponse ready = new ChatResponse(); ready.message = "ready"; messages.add(ready); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } beginListening(); } }); return; } list.post(new Runnable() { @Override public void run() { messages.add(response); ((ChatListAdapter) list.getAdapter()).notifyDataSetChanged(); list.invalidateViews(); if (list.getCount() > 2) { list.setSelection(list.getCount() - 2); } } }); WebView responseView = (WebView) findViewById(R.id.responseText); String html = Utils.linkHTML(text); if (html.contains("<") && html.contains(">")) { html = linkPostbacks(html); } responseView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null); boolean talk = (text.trim().length() > 0) && (MainActivity.deviceVoice || (this.response.speech != null && this.response.speech.length() > 0)); if (MainActivity.sound && talk) { if (!MainActivity.disableVideo && !videoError && this.response.isVideo() && this.response.isVideoTalk()) { videoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { try { mp.setLooping(true); if (!MainActivity.deviceVoice) { // Voice audio speechPlayer = playAudio(response.speech, false, false, false); speechPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.release(); videoView.post(new Runnable() { public void run() { cycleVideo(response); } }); runOnUiThread(new Runnable() { public void run() { if (!music) { beginListening(); } } }); } }); speechPlayer.start(); } else { HashMap<String, String> params = new HashMap<String, String>(); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "id"); tts.speak(Utils.stripTags(text), TextToSpeech.QUEUE_FLUSH, params); } } catch (Exception exception) { Log.wtf(exception.getMessage(), exception); } } }); playVideo(this.response.avatarTalk, false); } else if (talk) { if (!MainActivity.deviceVoice) { // Voice audio playAudio(this.response.speech, false, false, true); } else { HashMap<String, String> params = new HashMap<String, String>(); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "id"); this.tts.speak(Utils.stripTags(text), TextToSpeech.QUEUE_FLUSH, params); } } } else if (talk && (!MainActivity.disableVideo && !videoError && this.response.isVideo() && this.response.avatarTalk != null)) { videoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setLooping(false); } }); videoView.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { videoView.setOnCompletionListener(null); cycleVideo(response); } }); playVideo(this.response.avatarTalk, false); runOnUiThread(new Runnable() { public void run() { beginListening(); } }); } else { runOnUiThread(new Runnable() { public void run() { beginListening(); } }); } } catch (Exception exception) { Log.wtf(exception.getMessage(), exception); } if (micLastStat) { MainActivity.listenInBackground = true; } }