List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:biz.bokhorst.xprivacy.ActivityApp.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final int userId = Util.getUserId(Process.myUid()); // Check privacy service client if (!PrivacyService.checkClient()) return;/*from w w w.ja v a 2 s . c o m*/ // Set layout setContentView(R.layout.restrictionlist); // Get arguments Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } int uid = extras.getInt(cUid); String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null); String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null); // Get app info mAppInfo = new ApplicationInfoEx(this, uid); if (mAppInfo.getPackageName().size() == 0) { finish(); return; } // Set title setTitle(String.format("%s - %s", getString(R.string.app_name), TextUtils.join(", ", mAppInfo.getApplicationName()))); // Handle info click ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo); imgInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Packages can be selected on the web site Util.viewUri(ActivityApp.this, Uri.parse(String.format(ActivityShare.getBaseURL(ActivityApp.this) + "?package_name=%s", mAppInfo.getPackageName().get(0)))); } }); // Display app name TextView tvAppName = (TextView) findViewById(R.id.tvApp); tvAppName.setText(mAppInfo.toString()); // Background color if (mAppInfo.isSystem()) { LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo); llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous))); } // Display app icon final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon); imgIcon.setImageDrawable(mAppInfo.getIcon(this)); // Handle icon click imgIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openContextMenu(imgIcon); } }); // Display on-demand state final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand); if (PrivacyManager.isApplication(mAppInfo.getUid()) && PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true)) { boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); imgCbOnDemand.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, false); PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand, Boolean.toString(ondemand)); imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox()); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); } }); } else imgCbOnDemand.setVisibility(View.GONE); // Display restriction state swEnabled = (Switch) findViewById(R.id.swEnable); swEnabled.setChecked( PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true)); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, Boolean.toString(isChecked)); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); imgCbOnDemand.setEnabled(isChecked); } }); imgCbOnDemand.setEnabled(swEnabled.isChecked()); // Add context menu to icon registerForContextMenu(imgIcon); // Check if internet access if (!mAppInfo.hasInternet(this)) { ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet); imgInternet.setVisibility(View.INVISIBLE); } // Check if frozen if (!mAppInfo.isFrozen(this)) { ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen); imgFrozen.setVisibility(View.INVISIBLE); } // Display version TextView tvVersion = (TextView) findViewById(R.id.tvVersion); tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this))); // Display package name TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName); tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName())); // Fill privacy list view adapter final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction); lvRestriction.setGroupIndicator(null); mPrivacyListAdapter = new RestrictionAdapter(R.layout.restrictionentry, mAppInfo, restrictionName, methodName); lvRestriction.setAdapter(mPrivacyListAdapter); if (restrictionName != null) { int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values()) .indexOf(restrictionName); lvRestriction.expandGroup(groupPosition); lvRestriction.setSelectedGroup(groupPosition); if (methodName != null) { int childPosition = PrivacyManager.getHooks(restrictionName) .indexOf(new Hook(restrictionName, methodName)); lvRestriction.setSelectedChild(groupPosition, childPosition, true); } } // Listen for package add/remove IntentFilter iff = new IntentFilter(); iff.addAction(Intent.ACTION_PACKAGE_REMOVED); iff.addDataScheme("package"); registerReceiver(mPackageChangeReceiver, iff); mPackageChangeReceiverRegistered = true; // Up navigation getActionBar().setDisplayHomeAsUpEnabled(true); // Tutorial if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) { ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE); ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE); } View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { ViewParent parent = view.getParent(); while (!parent.getClass().equals(ScrollView.class)) parent = parent.getParent(); ((View) parent).setVisibility(View.GONE); PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString()); } }; ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener); ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener); // Process actions if (extras.containsKey(cAction)) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(mAppInfo.getUid()); if (extras.getInt(cAction) == cActionClear) optionClear(); else if (extras.getInt(cAction) == cActionSettings) optionSettings(); } // Annotate Meta.annotate(this); }
From source file:fr.outadev.skinswitch.DetailActivity.java
/** * Creates and displays the skin previews in the containers. */// w ww. j a va 2s .c om private void setupSkinPreviews() { final ImageView img_skin_preview_front = (ImageView) findViewById(R.id.skin_preview_front); final ImageView img_skin_preview_back = (ImageView) findViewById(R.id.skin_preview_back); (new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... voids) { try { return skin.getFrontSkinPreview(DetailActivity.this); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap bmp) { if (bmp != null) { img_skin_preview_front.setImageBitmap(bmp); colorizeInterface(bmp); } (new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... voids) { try { return skin.getBackSkinPreview(DetailActivity.this); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap bmp) { if (bmp != null) { img_skin_preview_back.setImageBitmap(bmp); } } }).execute(); } }).execute(); img_skin_preview_front.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (view.getAlpha() == 1.0) { Utils.crossfade(img_skin_preview_front, img_skin_preview_back, animTime); } } }); img_skin_preview_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (view.getAlpha() == 1.0) { Utils.crossfade(img_skin_preview_back, img_skin_preview_front, animTime); } } }); }
From source file:com.easemob.chatui.adapter.MessageAdapter.java
/** * /*from ww w. j ava 2s .c o m*/ * * @param localThumb * @param iv * @param thumbnailUrl * @param message */ private void showVideoThumbView(String localThumb, ImageView iv, String thumbnailUrl, final EMMessage message) { // first check if the thumbnail image already loaded into cache Bitmap bitmap = ImageCache.getInstance().get(localThumb); if (bitmap != null) { // thumbnail image is already loaded, reuse the drawable iv.setImageBitmap(bitmap); iv.setClickable(true); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { VideoMessageBody videoBody = (VideoMessageBody) message.getBody(); EMLog.d(TAG, "video view is on click"); Intent intent = new Intent(activity, ShowVideoActivity.class); intent.putExtra("localpath", videoBody.getLocalUrl()); intent.putExtra("secret", videoBody.getSecret()); intent.putExtra("remotepath", videoBody.getRemoteUrl()); if (message != null && message.direct == Direct.RECEIVE && !message.isAcked && message.getChatType() != ChatType.GroupChat && message.getChatType() != ChatType.ChatRoom) { message.isAcked = true; try { EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId()); } catch (Exception e) { e.printStackTrace(); } } activity.startActivity(intent); } }); } else { new LoadVideoImageTask().execute(localThumb, thumbnailUrl, iv, activity, message, this); } }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/*from ww w . ja v a2s . c o m*/ final ViewGroup speakersGroup = (ViewGroup) findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getLayoutInflater(); boolean hasSpeakers = false; cursor.moveToPosition(-1); // move to just before first record while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mSpeakersImageLoader != null) { mSpeakersImageLoader.loadImage(speakerImageUrl, speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(CurrentSessionActivity.this, speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); updateEmptyView(); }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** * Constructor//from w w w .ja v a 2 s . co m */ @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); acList = new ArrayList<InitDestFrame>(); r = getResources(); //Calls the initAutoComplete method, adding the autocomplete listeners to acTo and acFrom initAutocomplete(); //Calls the initAddDestButton method, adding the driving through button initAddDestButton(); //Sets hasDrawn to false hasDrawn = false; Bundle extras = getIntent().getExtras(); if (extras != null) { inEditMode = extras.getBoolean("editMode"); positionOfRoute = extras.getInt("routePosition"); } //Hides the checkbox chk_saveRoute = (CheckBox) findViewById(R.id.checkBoxSave); chk_saveRoute.setVisibility(8); //Initialises the draw/next button final Button button = ((Button) findViewById(R.id.btnChooseRoute)); //Adjustments to the gui if in editmode if (inEditMode) { chk_saveRoute.setVisibility(View.GONE); button.setText("Update the route"); button.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); fillFieldsInEdit(); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { createInputDialog("Route", "Insert name of Route", false); } }); } else { button.setText("Show on map"); button.setEnabled(false); } //Initialises the textviews and the clear buttons final AutoCompleteTextView acFrom = (AutoCompleteTextView) findViewById(R.id.etGoingFrom); final AutoCompleteTextView acTo = (AutoCompleteTextView) findViewById(R.id.etGoingTo); ImageView bClearFrom = ((ImageView) findViewById(R.id.etGoingFromClearIcon)); ImageView bClearTo = ((ImageView) findViewById(R.id.etGoingToClearIcon)); //If map is drawn fill the textviews if (selectedRoute.getMapPoints().size() != 0) { fillFieldsOnClick(); } /** * onClickListener on the clearButton on the acFrom field {@link OnClickListener()} */ //Adds onClickListener to the clearbutton on the acFrom field bClearFrom.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { acFrom.setText(""); button.setEnabled(false); button.setText("Show on Map"); } }); /** * onClickListener on the clearButton on the acTo field {@link OnClickListener} */ //Adds onClickListener to the clearbutton on the acTo field bClearTo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { acTo.setText(""); button.setEnabled(false); button.setText("Show on Map"); } }); /** * TextWatcher to the acFrom {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()} */ //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality acFrom.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { hasDrawn = false; if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) { button.setEnabled(true); button.setText("Next"); } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) { button.setEnabled(true); button.setText("Show on Map"); } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { button.setEnabled(true); button.setText("Show on map"); } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { button.setText("Show on map"); button.setEnabled(false); } else if (inEditMode) { } else { button.setText("Show on map"); button.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); /** * TextWatcher to the acTo {@link autoCompleteTextView} autoCompleteTextView {@link TextWatcher()} */ //Adds a TextWatcher to the acFrom field, to update the draw/nextbutton, and its functionality acTo.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { hasDrawn = false; if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == true) { button.setEnabled(true); button.setText("Next"); } else if (checkFields() && selectedRoute.getMapPoints().size() > 2 && hasDrawn == false) { button.setEnabled(true); button.setText("Show on Map"); } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { button.setEnabled(true); button.setText("Show on map"); } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { button.setText("Show on map"); button.setEnabled(false); } else if (inEditMode) { } else { button.setText("Show on map"); button.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); /** * onClickListener on the button(draw/next) {@link OnClickListener} */ //adds the onclickListener to the draw/next button button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == true) { button.setText("Next"); createOneTimeJourney(); } else if (checkFields() && selectedRoute.getMapPoints().size() > 1 && hasDrawn == false) { mapView.getOverlays().clear(); createMap(); button.setText("Next"); } else if (checkFields() && selectedRoute.getMapPoints().size() == 0) { mapView.getOverlays().clear(); createMap(); button.setText("Next"); } else if (checkFields() == false && selectedRoute.getMapPoints().size() == 0) { } else if (inEditMode) { createInputDialog("Route", "Insert name of Route", false); button.setText("Next"); } else { } } }); }
From source file:com.flipzu.flipzu.Player.java
@Override public void onResponseReceived(BroadcastDataSet bcast) { /* unset loading progress */ setProgressBarIndeterminateVisibility(Boolean.FALSE); if (bcast != null) { debug.logV(TAG, "onResponseReceived called with bcast " + bcast.getId()); } else {// w w w . j a v a2s. c om debug.logV(TAG, "onResponseReceived called with bcast NULL"); } boolean newBcast = false; if (bcast != null) { /* start async call to fetch user data */ AsyncFlipInterface.getUser(bcast.getUsername(), user.getToken(), this); if (isNewBcast(bcast)) { debug.logV(TAG, "onResponseReceived, is a new broadcast"); saveBcast(bcast); newBcast = true; } else { debug.logV(TAG, "onResponseReceived, is not a new broadcast"); } } else { // try again with bcast from settings... if (!mSavedBcast) { mSavedBcast = true; AsyncFlipInterface.getBroadcast(getBcastFromSettings(), this); } return; } this.bcast = bcast; mUrl = getCurrentUrl(bcast); if (bcast != null) { mTitle = bcast.getUsername(); if (bcast.getText() != null) mTitle += " - " + bcast.getText(); } debug.logV(TAG, "onResponseReceived, got URL " + mUrl); /* layout */ ImageView bg = (ImageView) findViewById(R.id.user_avatar); final TextView title_tv = (TextView) findViewById(R.id.title); final TextView time_tv = (TextView) findViewById(R.id.time_str); final TextView listeners_tv = (TextView) findViewById(R.id.listeners); final TextView username_tv = (TextView) findViewById(R.id.username); username_tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Player.this, Profile.class); i.putExtra("user", ((TextView) findViewById(R.id.username)).getText()); startActivity(i); } }); bg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Player.this, Profile.class); i.putExtra("user", ((TextView) findViewById(R.id.username)).getText()); startActivity(i); } }); final TextView bottom_title_tv = (TextView) findViewById(R.id.player_title_bottom); // fix padding for player // ScrollingTextView sc_tv = (ScrollingTextView) findViewById(R.id.actionbar_title); // sc_tv.setPadding(35, 0, 0, 0); /* action bar */ // ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar); // actionBar.setHomeLogo(R.drawable.logo2); if (bcast != null) { UrlImageViewHelper.setUrlDrawable(bg, bcast.getImgUrl(), R.drawable.icon_sq); getSupportActionBar().setTitle(bcast.getUsername()); username_tv.setText(bcast.getUsername()); CharSequence title = bcast.getText(); if (title == null) title = getText(R.string.empty_title); title_tv.setText(title); bottom_title_tv.setText(mTitle); bottom_title_tv.setSelected(true); // hack to make text scroll if (bcast.getTimeStr() != null) { time_tv.setText(bcast.getTimeStr()); } if (bcast.getListens() == null) { // maybe erased? Go back... Player.this.finish(); } try { Integer listens = Integer.parseInt(bcast.getListens()) + 1; listeners_tv.setText(listens.toString()); } catch (NumberFormatException e) { Player.this.finish(); } } // EditText comment listener final EditText comment_et = (EditText) findViewById(R.id.post_comment_et); comment_et.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Perform action on key press postComment(); return true; } return false; } }); /* start bcast if it's a new one */ if (newBcast) { debug.logV(TAG, "onResponseReceived, newBcast, sending PLAY"); sendPlay(); } else { if (mState == playerState.STOPPED) sendPlay(); } /* stats thread */ if (bcast != null) { if (bcast.getId() != null) { AsyncFlipInterface.getComments(Integer.parseInt(bcast.getId()), Player.this); } if (bcast.isLive()) { if (mState == playerState.PLAYING) setLiveVisible(true); liveHandler.removeCallbacks(mCheckLiveTask); liveHandler.postDelayed(mCheckLiveTask, 5000); } else { timerHandler.removeCallbacks(mTimerTask); timerHandler.postDelayed(mTimerTask, 1000); } } }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
private View makeView(boolean icon, boolean watcher, boolean closeable, float density) { int size = (int) (48f * density); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER_VERTICAL); ImageView iconView = null;//from w ww. j ava 2 s. co m if (icon) { iconView = new ImageView(context); iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); linearLayout.addView(iconView, (int) (24f * density), size); } TextView textView = makeCommonTextView(false); linearLayout.addView(textView, new LinearLayout.LayoutParams(0, size, 1)); WatcherView watcherView = null; if (watcher) { watcherView = new WatcherView(context); linearLayout.addView(watcherView, size, size); } ImageView closeView = null; if (!watcher && closeable) { closeView = new ImageView(context); closeView.setScaleType(ImageView.ScaleType.CENTER); closeView.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonCancel, 0)); closeView.setBackgroundResource(ResourceUtils.getResourceId(context, android.R.attr.borderlessButtonStyle, android.R.attr.background, 0)); linearLayout.addView(closeView, size, size); closeView.setOnClickListener(closeButtonListener); } ViewHolder holder = new ViewHolder(); holder.icon = iconView; holder.text = textView; holder.extra = watcherView != null ? watcherView : closeView; linearLayout.setTag(holder); int layoutLeftDp = 0; int layoutRightDp = 0; int textLeftDp; int textRightDp; if (C.API_LOLLIPOP) { textLeftDp = 16; textRightDp = 16; if (icon) { layoutLeftDp = 16; textLeftDp = 32; } if (watcher || closeable) { layoutRightDp = 4; textRightDp = 8; } } else { textLeftDp = 8; textRightDp = 8; if (icon) { layoutLeftDp = 8; textLeftDp = 6; textView.setAllCaps(true); } if (watcher || closeable) { layoutRightDp = 0; textRightDp = 0; } } linearLayout.setPadding((int) (layoutLeftDp * density), 0, (int) (layoutRightDp * density), 0); textView.setPadding((int) (textLeftDp * density), 0, (int) (textRightDp * density), 0); return linearLayout; }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/*from w w w . ja v a2 s . co m*/ final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mSpeakersImageLoader != null) { mSpeakersImageLoader.loadImage(speakerImageUrl, speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } }
From source file:com.bofsoft.laio.laiovehiclegps.Fragment.BaiduMapFragment.java
/** * ///*from w w w . j av a 2 s .co m*/ */ private void showLocation(final GPSInfoData gpsInfoData) { int i = 0; if (gpsInfoData == null) { return; } //maker? if (mList != null) { for (i = 0; i < mList.size(); i++) { Marker marker = mList.get(i); if (marker.getExtraInfo().getString("License").equalsIgnoreCase(gpsInfoData.License)) { marker.setToTop(); break; } } } // // InfoWindowview // if (marker == null) { // return; // } // for (i = 0; i < mList.size(); i++) { // if (marker == mList.get(i)) { // currentMarkerNum = i; // break; // } // } // latitude = carListData.InfoList.get(currentMarkerNum).Latitude; // longitude = carListData.InfoList.get(currentMarkerNum).Longitude; // // GPSGPS?????? LatLng tmpLL = new LatLng(gpsInfoData.getLatitude(), gpsInfoData.getLongitude()); // GPSGPS?????? CoordinateConverter converter = new CoordinateConverter(); converter.from(CoordinateConverter.CoordType.GPS); converter.coord(tmpLL); final LatLng pt = converter.convert(); View view = LayoutInflater.from(getActivity()).inflate(R.layout.map_popwindow, null); // ImageView iv_close = (ImageView) view.findViewById(R.id.iv_close); TextView tv_CarLicense = (TextView) view.findViewById(R.id.tv_CarLicense); LinearLayout ll_Navigation = (LinearLayout) view.findViewById(R.id.ll_Navigation); LinearLayout ll_Track = (LinearLayout) view.findViewById(R.id.ll_Track); final ImageView iv_Track = (ImageView) view.findViewById(R.id.iv_Track); final TextView tv_Track = (TextView) view.findViewById(R.id.tv_Track); TextView tv_equipmentTime = (TextView) view.findViewById(R.id.tv_equipmentTime); TextView tv_status = (TextView) view.findViewById(R.id.tv_status); TextView tv_speed = (TextView) view.findViewById(R.id.tv_speed); TextView tv_latlong = (TextView) view.findViewById(R.id.tv_latlong); TextView tv_address = (TextView) view.findViewById(R.id.tv_address); iv_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mBaiduMap.hideInfoWindow();//?? isPopWindowShow = false; iv_normal.setVisibility(View.VISIBLE); iv_satellite.setVisibility(View.VISIBLE); iv_traffic.setVisibility(View.VISIBLE); } }); tv_CarLicense.setText(carListData.InfoList.get(currentMarkerNum).License); ll_Navigation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // isTrack = false; iv_Track.setImageResource(R.mipmap.popwindow_track_on); tv_Track.setText(""); GPS_Monitor(false); ll_distance.setVisibility(View.GONE); mMarkerTemp = null; routeplanToNavi(BNRoutePlanNode.CoordinateType.BD09LL); } }); if (mMarkerTemp != null && mMarkerTemp.getLicense().equalsIgnoreCase(gpsInfoData.getLicense())) { if (ll_distance.getVisibility() == View.VISIBLE) { isTrack = true; iv_Track.setImageResource(R.mipmap.popwindow_track_off); tv_Track.setText(""); } } else { if (ll_distance.getVisibility() == View.VISIBLE) { GPS_Monitor(false); ll_distance.setVisibility(View.GONE); mMarkerTemp = null; } } ll_Track.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // if (isTrack) { isTrack = false; iv_Track.setImageResource(R.mipmap.popwindow_track_on); tv_Track.setText(""); GPS_Monitor(false); ll_distance.setVisibility(View.GONE); mMarkerTemp = null; } else { isTrack = true; iv_Track.setImageResource(R.mipmap.popwindow_track_off); tv_Track.setText(""); GPS_Monitor(true); ll_distance.setVisibility(View.VISIBLE); tv_distance.setText(getDistance(curLocation, pt)); mMarkerTemp = gpsInfoData; } showLocation(gpsInfoData); } }); tv_equipmentTime.setText(carListData.InfoList.get(currentMarkerNum).Datetime); if (carListData.InfoList.get(currentMarkerNum).Status == 0) { tv_status.setText(""); } else { tv_status.setText(carListData.InfoList.get(currentMarkerNum).StatusContent); } tv_speed.setText(carListData.InfoList.get(currentMarkerNum).Speed + "km/h"); tv_latlong.setText(gpsInfoData.getLongitude() + "," + gpsInfoData.getLatitude() + " ?:" + carListData.InfoList.get(currentMarkerNum).getDirectionStr()); hasPopAddress = true; // mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(pt)); if (gpsInfoData.getAddress() == null || gpsInfoData.getAddress().length() == 0) { HomeFragment.LoadAddHelper loadAddHelper = new HomeFragment.LoadAddHelper(gpsInfoData); loadAddHelper.loadReverseGeoCode(); } tv_address.setText( "? " + (carListData.InfoList.get(currentMarkerNum).getAddress() == null ? "" : carListData.InfoList.get(currentMarkerNum).getAddress())); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(pt);//.zoom(18) mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); // InfoWindow mInfoWindow = new InfoWindow(view, pt, -30); iv_normal.setVisibility(View.GONE); iv_satellite.setVisibility(View.GONE); iv_traffic.setVisibility(View.GONE); mBaiduMap.showInfoWindow(mInfoWindow); // isPopWindowShow = true; mShowMarker = gpsInfoData; }
From source file:im.vector.adapters.VectorMediasViewerAdapter.java
/** * Load the video items//from w ww .jav a 2s . c o m * @param view the page view * @param thumbnailUrl the thumbnail URL * @param videoUrl the video Url * @param videoMimeType the video mime type */ private void loadVideo(final int position, final View view, final String thumbnailUrl, final String videoUrl, final String videoMimeType) { final VideoView videoView = (VideoView) view.findViewById(R.id.media_slider_videoview); final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail); final ImageView playView = (ImageView) view.findViewById(R.id.media_slider_video_playView); displayVideoThumbnail(view, !videoView.isPlaying()); videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mPlayingVideoView = null; displayVideoThumbnail(view, true); } }); // the video is renderer in DSA so trap the on click on the video view parent ((View) videoView.getParent()).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopPlayingVideo(); displayVideoThumbnail(view, true); } }); // manage video error cases videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { mPlayingVideoView = null; displayVideoThumbnail(view, true); return false; } }); // init the thumbnail views mMediasCache.loadBitmap(mSession.getHomeserverConfig(), thumbView, thumbnailUrl, 0, 0, null); playView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // init the video view only if there is a valid file // check if the media has been downloaded File srcFile = mMediasCache.mediaCacheFile(videoUrl, videoMimeType); if (null != srcFile) { playVideo(view, videoView, videoUrl, videoMimeType); } else { mAutoPlayItemAt = position; downloadVideo(view, position); } } }); }