List of usage examples for android.graphics.drawable AnimationDrawable start
@Override public void start()
From source file:cn.hbm.superwechat.adapter.MessageAdapter.java
/** * ?/* www . j a va 2 s .c o m*/ * * @param message * @param holder * @param position * @param convertView */ @SuppressWarnings("ResourceType") private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody(); int len = voiceBody.getLength(); if (len > 0) { holder.tv.setText(voiceBody.getLength() + "\""); holder.tv.setVisibility(View.VISIBLE); } else { holder.tv.setVisibility(View.INVISIBLE); } holder.iv.setOnClickListener( new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username)); holder.iv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return true; } }); if (((ChatActivity) activity).playMsgId != null && ((ChatActivity) activity).playMsgId.equals(message.getMsgId()) && VoicePlayClickListener.isPlaying) { AnimationDrawable voiceAnimation; if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(R.anim.voice_from_icon); } else { holder.iv.setImageResource(R.anim.voice_to_icon); } voiceAnimation = (AnimationDrawable) holder.iv.getDrawable(); voiceAnimation.start(); } else { if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(R.drawable.chatfrom_voice_playing); } else { holder.iv.setImageResource(R.drawable.chatto_voice_playing); } } if (message.direct == EMMessage.Direct.RECEIVE) { if (message.isListened()) { // ??? holder.iv_read_status.setVisibility(View.INVISIBLE); } else { holder.iv_read_status.setVisibility(View.VISIBLE); } EMLog.d(TAG, "it is receive msg"); if (message.status == EMMessage.Status.INPROGRESS) { holder.pb.setVisibility(View.VISIBLE); EMLog.d(TAG, "!!!! back receive"); ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() { @Override public void onSuccess() { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); notifyDataSetChanged(); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); } }); } }); } else { holder.pb.setVisibility(View.INVISIBLE); } return; } // until here, deal with send voice msg switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); holder.staus_iv.setVisibility(View.GONE); break; default: sendMsgInBackground(message, holder); } }
From source file:cn.ucai.fulicenter.adapter.MessageAdapter.java
/** * ?//from w w w.j a va 2 s .c o m * * @param message * @param holder * @param position * @param convertView */ private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody(); int len = voiceBody.getLength(); if (len > 0) { holder.tv.setText(voiceBody.getLength() + "\""); holder.tv.setVisibility(View.VISIBLE); } else { holder.tv.setVisibility(View.INVISIBLE); } holder.iv.setOnClickListener( new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username)); holder.iv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return true; } }); if (((ChatActivity) activity).playMsgId != null && ((ChatActivity) activity).playMsgId.equals(message.getMsgId()) && VoicePlayClickListener.isPlaying) { AnimationDrawable voiceAnimation; if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(R.anim.voice_from_icon); } else { holder.iv.setImageResource(R.anim.voice_to_icon); } voiceAnimation = (AnimationDrawable) holder.iv.getDrawable(); voiceAnimation.start(); } else { if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(R.drawable.chatfrom_voice_playing); } else { holder.iv.setImageResource(R.drawable.chatto_voice_playing); } } if (message.direct == EMMessage.Direct.RECEIVE) { if (message.isListened()) { // ??? holder.iv_read_status.setVisibility(View.INVISIBLE); } else { holder.iv_read_status.setVisibility(View.VISIBLE); } EMLog.d(TAG, "it is receive msg"); if (message.status == EMMessage.Status.INPROGRESS) { holder.pb.setVisibility(View.VISIBLE); EMLog.d(TAG, "!!!! back receive"); ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() { @Override public void onSuccess() { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); notifyDataSetChanged(); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); } }); } }); } else { holder.pb.setVisibility(View.INVISIBLE); } return; } // until here, deal with send voice msg switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); holder.staus_iv.setVisibility(View.GONE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.easemob.chatui.adapter.MessageAdapter.java
/** * ?// w w w .j av a 2 s. c o m * * @param message * @param holder * @param position * @param convertView */ private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody(); int len = voiceBody.getLength(); if (len > 0) { holder.tv.setText(voiceBody.getLength() + "\""); holder.tv.setVisibility(View.VISIBLE); } else { holder.tv.setVisibility(View.INVISIBLE); } holder.iv.setOnClickListener(new com.easemob.chatui.adapter.VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username)); holder.iv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return true; } }); if (((ChatActivity) activity).playMsgId != null && ((ChatActivity) activity).playMsgId.equals(message.getMsgId()) && com.easemob.chatui.adapter.VoicePlayClickListener.isPlaying) { AnimationDrawable voiceAnimation; if (message.direct == Direct.RECEIVE) { holder.iv.setImageResource(R.anim.voice_from_icon); } else { holder.iv.setImageResource(R.anim.voice_to_icon); } voiceAnimation = (AnimationDrawable) holder.iv.getDrawable(); voiceAnimation.start(); } else { if (message.direct == Direct.RECEIVE) { holder.iv.setImageResource(R.drawable.chatfrom_voice_playing); } else { holder.iv.setImageResource(R.drawable.chatto_voice_playing); } } if (message.direct == Direct.RECEIVE) { if (message.isListened()) { // ??? holder.iv_read_status.setVisibility(View.INVISIBLE); } else { holder.iv_read_status.setVisibility(View.VISIBLE); } EMLog.d(TAG, "it is receive msg"); if (message.status == EMMessage.Status.INPROGRESS) { holder.pb.setVisibility(View.VISIBLE); EMLog.d(TAG, "!!!! back receive"); ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() { @Override public void onSuccess() { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); notifyDataSetChanged(); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); } }); } }); } else { holder.pb.setVisibility(View.INVISIBLE); } return; } // until here, deal with send voice msg switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); holder.staus_iv.setVisibility(View.GONE); break; default: sendMsgInBackground(message, holder); } }
From source file:cn.ucai.superwechat.adapter.MessageAdapter.java
/** * ?/* www . ja v a 2s.c o m*/ * * @param message * @param holder * @param position * @param convertView */ @SuppressWarnings("ResourceType") private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody(); int len = voiceBody.getLength(); if (len > 0) { holder.tv.setText(voiceBody.getLength() + "\""); holder.tv.setVisibility(View.VISIBLE); } else { holder.tv.setVisibility(View.INVISIBLE); } holder.iv.setOnClickListener( new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username)); holder.iv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return true; } }); if (((ChatActivity) activity).playMsgId != null && ((ChatActivity) activity).playMsgId.equals(message.getMsgId()) && VoicePlayClickListener.isPlaying) { AnimationDrawable voiceAnimation; if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(cn.ucai.superwechat.R.anim.voice_from_icon); } else { holder.iv.setImageResource(cn.ucai.superwechat.R.anim.voice_to_icon); } voiceAnimation = (AnimationDrawable) holder.iv.getDrawable(); voiceAnimation.start(); } else { if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(cn.ucai.superwechat.R.drawable.chatfrom_voice_playing); } else { holder.iv.setImageResource(cn.ucai.superwechat.R.drawable.chatto_voice_playing); } } if (message.direct == EMMessage.Direct.RECEIVE) { if (message.isListened()) { // ??? holder.iv_read_status.setVisibility(View.INVISIBLE); } else { holder.iv_read_status.setVisibility(View.VISIBLE); } EMLog.d(TAG, "it is receive msg"); if (message.status == EMMessage.Status.INPROGRESS) { holder.pb.setVisibility(View.VISIBLE); EMLog.d(TAG, "!!!! back receive"); ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() { @Override public void onSuccess() { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); notifyDataSetChanged(); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); } }); } }); } else { holder.pb.setVisibility(View.INVISIBLE); } return; } // until here, deal with send voice msg switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); holder.staus_iv.setVisibility(View.GONE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.com.easemob.chatuidemo.adapter.MessageAdapter.java
/** * ?/*from w w w . ja va 2 s.c om*/ * * @param message * @param holder * @param position * @param convertView */ private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody(); int len = voiceBody.getLength(); if (len > 0) { holder.tv.setText(voiceBody.getLength() + "\""); holder.tv.setVisibility(View.VISIBLE); } else { holder.tv.setVisibility(View.INVISIBLE); } holder.iv.setOnClickListener( new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username)); holder.iv.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()), ChatMessage.REQUEST_CODE_CONTEXT_MENU); return true; } }); if (((ChatMessage) activity).playMsgId != null && ((ChatMessage) activity).playMsgId.equals(message.getMsgId()) && VoicePlayClickListener.isPlaying) { AnimationDrawable voiceAnimation; if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(R.anim.voice_from_icon); } else { holder.iv.setImageResource(R.anim.voice_to_icon); } voiceAnimation = (AnimationDrawable) holder.iv.getDrawable(); voiceAnimation.start(); } else { if (message.direct == EMMessage.Direct.RECEIVE) { holder.iv.setImageResource(R.drawable.chatfrom_voice_playing); } else { holder.iv.setImageResource(R.drawable.chatto_voice_playing); } } if (message.direct == EMMessage.Direct.RECEIVE) { if (message.isListened()) { // ??? holder.iv_read_status.setVisibility(View.INVISIBLE); } else { holder.iv_read_status.setVisibility(View.VISIBLE); } EMLog.d(TAG, "it is receive msg"); if (message.status == EMMessage.Status.INPROGRESS) { holder.pb.setVisibility(View.VISIBLE); EMLog.d(TAG, "!!!! back receive"); ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() { @Override public void onSuccess() { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); notifyDataSetChanged(); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { activity.runOnUiThread(new Runnable() { @Override public void run() { holder.pb.setVisibility(View.INVISIBLE); } }); } }); } else { holder.pb.setVisibility(View.INVISIBLE); } return; } // until here, deal with send voice msg switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); holder.staus_iv.setVisibility(View.GONE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
public void clickHoldAndTalk(View v) { v.setOnTouchListener(new View.OnTouchListener() { @Override//from ww w.ja v a 2 s.c o m public boolean onTouch(View v, MotionEvent event) { v.setBackgroundResource(R.drawable.spin_animation); // Get the background, which has been compiled to an AnimationDrawable object. AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground(); if (event.getAction() == event.ACTION_DOWN) { onRecord(true); // Start the animation (looped playback by default). frameAnimation.start(); Toast.makeText(getBaseContext(), "Action Down", Toast.LENGTH_SHORT).show(); } else if (event.getAction() == event.ACTION_UP) { calcualteTodayDate(); adapter.add(new StikyChat("", "<img", false, timeSend, "voiceSend", 0, 0, "", "", audiofile.getAbsolutePath(), null, "")); adapter.notifyDataSetChanged(); lv.smoothScrollToPosition(adapter.getCount() - 1); Toast.makeText(getBaseContext(), "Action Up", Toast.LENGTH_SHORT).show(); onRecord(false); frameAnimation.stop(); v.setBackgroundResource(R.drawable.chat_micro); upLoadServerUri = getApplicationContext().getResources().getString(R.string.url) + "/androidstikyhive/voicetransfer.php?fromStikyBee=" + pref.getString("stkid", "") + "&toStikyBee=" + recipientStkid + "&message=voice" + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url=" + URLEncoder.encode(getResources().getString(R.string.url)); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub int serverResponseCode = uploadFile(audiofile); if (serverResponseCode == 200) { Log.i("Success", " is done! "); flagChatting = false; flagTransfer = true; messageServer = "<img"; msg = "Voice Message"; recipientStkidGCM = recipientStkid; new regTask().execute("GCM"); new regTask2().execute("Last Message!"); } } }).start(); } return false; } }); }
From source file:lu.fisch.canze.activities.MainActivity.java
private void setBluetoothState(int btState) { if (bluetoothMenutItem != null) { final ImageView imageView = (ImageView) bluetoothMenutItem.getActionView() .findViewById(R.id.animated_menu_item_action); // stop the animation if there is one running AnimationDrawable frameAnimation; if (imageView.getBackground() instanceof AnimationDrawable) { frameAnimation = (AnimationDrawable) imageView.getBackground(); if (frameAnimation.isRunning()) frameAnimation.stop();// w w w . j a v a 2s.co m } switch (btState) { case BLUETOOTH_DISCONNECTED: imageView.setBackgroundResource(R.mipmap.bluetooth_none); break; case BLUETOOTH_CONNECTED: imageView.setBackgroundResource(R.mipmap.bluetooth_3); break; case BLUETOOTH_SEARCH: runOnUiThread(new Runnable() { @SuppressLint("NewApi") @Override public void run() { AnimationDrawable drawable = (AnimationDrawable) ContextCompat .getDrawable(getApplicationContext(), R.anim.animation_bluetooth); // Use setBackgroundDrawable() for API 14 and 15 and setBackground() for API 16+: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(drawable); } else { //noinspection deprecation imageView.setBackgroundDrawable(drawable); } AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground(); frameAnimation.start(); } }); break; default: break; } } }
From source file:org.telegram.ui.ChatActivity.java
private void setTypingAnimation(boolean start) { TextView subtitle = (TextView) parentActivity.findViewById(R.id.action_bar_subtitle); if (subtitle == null) { final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_subtitle", "id", "android"); subtitle = (TextView) parentActivity.findViewById(subtitleId); }/*from w w w .jav a 2 s. c o m*/ if (subtitle != null) { if (start) { try { if (currentChat != null) { subtitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.typing_dots_chat, 0, 0, 0); } else { subtitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.typing_dots, 0, 0, 0); } subtitle.setCompoundDrawablePadding(Utilities.dp(4)); AnimationDrawable mAnim = (AnimationDrawable) subtitle.getCompoundDrawables()[0]; mAnim.setAlpha(200); mAnim.start(); } catch (Exception e) { FileLog.e("tmessages", e); } } else { subtitle.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); } } }
From source file:com.zoffcc.applications.zanavi.Navit.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); ///*from w w w . jav a 2s. c o m*/ menu.clear(); // load the menu from XML getMenuInflater().inflate(R.menu.actionbaricons, menu); // NavitOverflowMenuItemID = R.id.item_overflow_menu_button; menu.findItem(R.id.share_menu_destination).setTitle(Navit.get_text("Share Destination")); menu.findItem(R.id.share_menu_location).setTitle(Navit.get_text("Share my Location")); menu.findItem(R.id.search_menu_offline).setTitle(get_text("address search (offline)")); menu.findItem(R.id.search_menu_online).setTitle(get_text("address search (online)")); menu.findItem(R.id.item_recentdest_menu_button).setTitle(get_text("Recent destinations")); menu.findItem(R.id.item_settings_menu_button).setTitle(get_text("Settings")); menu.findItem(R.id.item_search_menu_button).setTitle(get_text("Search")); // --- download icon --- menu.findItem(R.id.item_download_menu_button).setTitle(get_text("downloading map")); // --- download icon --- // menu.findItem(R.id.overflow_share_location).setTitle(Navit.get_text("Share my Location")); menu.findItem(R.id.overflow_share_destination).setTitle(Navit.get_text("Share Destination")); menu.findItem(R.id.overflow_settings).setTitle(Navit.get_text("Settings")); menu.findItem(R.id.overflow_zoom_to_route).setTitle(Navit.get_text("Zoom to Route")); if (ZANaviNormalDonateActivity.on_amazon_device) { menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate")); } else { menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate with Google Play")); } menu.findItem(R.id.overflow_donate_bitcoins_item).setTitle(Navit.get_text("Donate with Bitcoin")); //. TRANSLATORS: text to translate is: exit ZANavi menu.findItem(R.id.overflow_exit).setTitle(Navit.get_text("exit navit")); menu.findItem(R.id.overflow_toggle_poi).setTitle(Navit.get_text("toggle POI")); menu.findItem(R.id.overflow_announcer_on).setTitle(Navit.get_text("Announcer On")); menu.findItem(R.id.overflow_announcer_off).setTitle(Navit.get_text("Announcer Off")); menu.findItem(R.id.overflow_download_maps).setTitle(Navit.get_text("download maps")); menu.findItem(R.id.overflow_delete_maps).setTitle(Navit.get_text("delete maps")); menu.findItem(R.id.overflow_maps_age).setTitle(Navit.get_text("show Maps age")); menu.findItem(R.id.overflow_coord_dialog).setTitle(Navit.get_text("Coord Dialog")); menu.findItem(R.id.overflow_add_traffic_block).setTitle(Navit.get_text("add Traffic block")); menu.findItem(R.id.overflow_clear_traffic_block).setTitle(Navit.get_text("clear Traffic blocks")); menu.findItem(R.id.overflow_convert_gpx_file).setTitle(Navit.get_text("convert GPX file")); menu.findItem(R.id.overflow_replay_gps_file).setTitle(Navit.get_text("replay a ZANavi gps file")); menu.findItem(R.id.overflow_yaml_tests).setTitle(Navit.get_text("run YAML tests")); menu.findItem(R.id.overflow_clear_gpx_map).setTitle(Navit.get_text("clear GPX map")); // menu.findItem(R.id.overflow_dummy2) menu.findItem(R.id.overflow_demo_v_normal).setTitle(get_text("Demo Vehicle") + " [normal]"); menu.findItem(R.id.overflow_demo_v_fast).setTitle(get_text("Demo Vehicle") + " [fast]"); menu.findItem(R.id.overflow_speech_texts).setTitle(Navit.get_text("Speech Texts")); menu.findItem(R.id.overflow_nav_commands).setTitle(Navit.get_text("Nav. Commands")); menu.findItem(R.id.overflow_toggle_route_graph).setTitle(Navit.get_text("toggle Routegraph")); //menu.findItem(R.id.overflow_dummy1) menu.findItem(R.id.overflow_export_map_points_to_sdcard).setTitle(Navit.get_text("export Destinations")); menu.findItem(R.id.overflow_import_map_points_from_sdcard).setTitle(Navit.get_text("import Destinations")); menu.findItem(R.id.overflow_send_feedback).setTitle(Navit.get_text("send feedback")); menu.findItem(R.id.overflow_online_help).setTitle(Navit.get_text("online Help")); menu.findItem(R.id.overflow_about).setTitle(Navit.get_text("About")); //. TRANSLATORS: it means: "show current target in google maps" //. TRANSLATORS: please keep this text short, to fit in the android menu! menu.findItem(R.id.overflow_target_in_gmaps).setTitle(Navit.get_text("Target in gmaps")); // // menu.findItem(R.id.item_share_menu_button).setTitle(get_text("Share")); Display display_ = getWindowManager().getDefaultDisplay(); Log.e("Navit", "Navit width in DP -> " + display_.getWidth() / Navit.metrics.density); Log.e("Navit", "Navit width in DP -> density=" + Navit.metrics.density); try { View v4 = findViewById(R.id.item_settings_menu_button); // Log.e("Navit", "Navit width in DP -> v4=" + v4); if ((v4 != null) && (v4.getWidth() > 0)) { Log.e("Navit", "Navit width in DP -> v4.w=" + v4.getWidth()); MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button); // Log.e("Navit", "Navit width in DP -> mi=" + menuItem); // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon()); Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth()); actionbar_item_width = (int) ((v4.getWidth() + (menuItem.getIcon().getIntrinsicWidth() * 1.5f)) / 2); } else { MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button); // Log.e("Navit", "Navit width in DP -> mi=" + menuItem); // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon()); Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth()); actionbar_item_width = (int) ((menuItem.getIcon().getIntrinsicWidth()) * 1.7f); } actionbar_items_will_fit = display_.getWidth() / actionbar_item_width; Log.e("Navit", "Navit width in DP -> number of items that will fit=" + actionbar_items_will_fit); if (actionbar_items_will_fit > 6) // now we need to fit max. 6 items on actionbar { actionbar_all_items_will_fit = true; } else { actionbar_all_items_will_fit = false; } } catch (Exception e) { if ((display_.getWidth() / Navit.metrics.density) < NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR) { actionbar_all_items_will_fit = false; } else { actionbar_all_items_will_fit = true; } } if (actionbar_all_items_will_fit == false) { menu.findItem(R.id.item_share_menu_button).setVisible(false); menu.findItem(R.id.overflow_share_location).setVisible(true); if (NavitGraphics.CallbackDestinationValid2() == 0) { menu.findItem(R.id.overflow_share_destination).setVisible(false); } else { menu.findItem(R.id.overflow_share_destination).setVisible(true); } if (actionbar_items_will_fit < 6) { // also push the settings icons to overflow menu menu.findItem(R.id.item_settings_menu_button).setVisible(false); menu.findItem(R.id.overflow_settings).setVisible(true); } else { menu.findItem(R.id.item_settings_menu_button).setVisible(true); menu.findItem(R.id.overflow_settings).setVisible(false); } } else { menu.findItem(R.id.item_settings_menu_button).setVisible(true); menu.findItem(R.id.overflow_settings).setVisible(false); menu.findItem(R.id.overflow_share_location).setVisible(false); menu.findItem(R.id.overflow_share_destination).setVisible(false); menu.findItem(R.id.item_share_menu_button).setVisible(true); } cur_menu = menu; System.out.println("down_icon:000"); try { MenuItem downloadViewMenuItem = menu.findItem(R.id.item_download_menu_button); System.out.println("down_icon:001"); downloadViewMenuItem.setVisible(true); System.out.println("down_icon:002"); System.out.println("down_icon:003"); android.widget.ImageView v = (android.widget.ImageView) MenuItemCompat .getActionView(menu.findItem(R.id.item_download_menu_button)); System.out.println("down_icon:004"); v.setVisibility(View.VISIBLE); if (v != null) { System.out.println("down_icon:005"); v.setImageBitmap(null); System.out.println("down_icon:006"); v.setBackgroundResource(R.drawable.anim_download_icon_2); final AnimationDrawable anim = (AnimationDrawable) v.getBackground(); // ---------------------------------- // thanks to: http://stackoverflow.com/questions/14686802/animationdrawable-is-not-working-on-2-3-6-android-version // ---------------------------------- v.post(new Runnable() { public void run() { try { anim.start(); System.out.println("down_icon:006a"); } catch (Exception e) { e.printStackTrace(); } } }); System.out.println("down_icon:007"); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent mapdownload_cancel_activity = new Intent(Navit.this, ZANaviDownloadMapCancelActivity.class); mapdownload_cancel_activity .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(mapdownload_cancel_activity); } }); } } catch (Exception e) { e.printStackTrace(); System.out.println("down_icon:099:EE"); } if (actionabar_download_icon_visible) { menu.findItem(R.id.item_download_menu_button).setVisible(true); } else { menu.findItem(R.id.item_download_menu_button).setVisible(false); } if (NavitGraphics.CallbackDestinationValid2() > 0) { menu.findItem(R.id.item_endnavigation_menu_button).setVisible(true); menu.findItem(R.id.item_endnavigation_menu_button).setTitle(get_text("Stop Navigation")); menu.findItem(R.id.overflow_zoom_to_route).setVisible(true); menu.findItem(R.id.overflow_target_in_gmaps).setVisible(true); menu.findItem(R.id.share_menu_destination).setVisible(true); } else { menu.findItem(R.id.item_endnavigation_menu_button).setVisible(false); menu.findItem(R.id.overflow_zoom_to_route).setVisible(false); menu.findItem(R.id.overflow_target_in_gmaps).setVisible(false); menu.findItem(R.id.share_menu_destination).setVisible(false); } if (Navit_Announcer == true) { menu.findItem(R.id.overflow_announcer_off).setVisible(true); menu.findItem(R.id.overflow_announcer_on).setVisible(false); } else { menu.findItem(R.id.overflow_announcer_off).setVisible(false); menu.findItem(R.id.overflow_announcer_on).setVisible(true); } if (p.PREF_enable_debug_functions) { menu.findItem(R.id.overflow_dummy2).setVisible(true); menu.findItem(R.id.overflow_demo_v_normal).setVisible(true); menu.findItem(R.id.overflow_demo_v_fast).setVisible(true); menu.findItem(R.id.overflow_speech_texts).setVisible(true); menu.findItem(R.id.overflow_nav_commands).setVisible(true); menu.findItem(R.id.overflow_toggle_route_graph).setVisible(true); menu.findItem(R.id.overflow_replay_gps_file).setVisible(true); menu.findItem(R.id.overflow_yaml_tests).setVisible(true); } else { menu.findItem(R.id.overflow_dummy2).setVisible(false); menu.findItem(R.id.overflow_demo_v_normal).setVisible(false); menu.findItem(R.id.overflow_demo_v_fast).setVisible(false); menu.findItem(R.id.overflow_speech_texts).setVisible(false); menu.findItem(R.id.overflow_nav_commands).setVisible(false); menu.findItem(R.id.overflow_toggle_route_graph).setVisible(false); menu.findItem(R.id.overflow_replay_gps_file).setVisible(false); menu.findItem(R.id.overflow_yaml_tests).setVisible(false); } return true; }