List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.filemanager.free.adapters.DrawerAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (values.get(position).isSection()) { ImageView view = new ImageView(context); if (m.theme1 == 0) view.setImageResource(R.color.divider); else/*from w w w. ja v a 2s . c om*/ view.setImageResource(R.color.divider_dark); view.setClickable(false); view.setFocusable(false); if (m.theme1 == 0) view.setBackgroundColor(Color.WHITE); else view.setBackgroundResource(R.color.background_material_dark); view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17))); view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8)); return view; } else { View view = inflater.inflate(R.layout.drawerrow, parent, false); final TextView txtTitle = (TextView) view.findViewById(R.id.firstline); final ImageView imageView = (ImageView) view.findViewById(R.id.icon); if (m.theme1 == 0) { view.setBackgroundResource(R.drawable.safr_ripple_white); } else { view.setBackgroundResource(R.drawable.safr_ripple_black); } view.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { m.selectItem(position); } // TODO: Implement this method }); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!getItem(position).isSection()) // not to remove the first bookmark (storage) and permanent bookmarks if (position > m.storage_count && position < values.size() - 7) { EntryItem item = (EntryItem) getItem(position); String path = (item).getPath(); if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) { m.renameBookmark((item).getTitle(), path); } else if (path.startsWith("smb:/")) { m.showSMBDialog(item.getTitle(), path, true); } } else if (position < m.storage_count) { String path = ((EntryItem) getItem(position)).getPath(); if (!path.equals("/")) new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m, m.theme1); } // return true to denote no further processing return true; } }); txtTitle.setText(((EntryItem) (values.get(position))).getTitle()); imageView.setImageDrawable(getDrawable(position)); imageView.clearColorFilter(); if (myChecked.get(position)) { if (m.theme1 == 0) view.setBackgroundColor(Color.parseColor("#ffeeeeee")); else view.setBackgroundColor(Color.parseColor("#ff424242")); imageView.setColorFilter(fabskin); txtTitle.setTextColor(Color.parseColor(m.fabskin)); } else { if (m.theme1 == 0) { imageView.setColorFilter(Color.parseColor("#666666")); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black)); } else { imageView.setColorFilter(Color.WHITE); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); } } return view; } }
From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;/*w ww . j a v a 2s. c o m*/ // TODO: remove existing speakers from layout, since this cursor might be from a data change final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); 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)) { mImageFetcher.loadThumbnailImage(speakerImageUrl, speakerImageView, R.drawable.person_image_empty); } 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); UIUtils.safeOpenLink(getActivity(), 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.raspi.chatapp.ui.chatting.SendImageFragment.java
/** * this function will initialize the ui showing the current image and reload * everything to make sure it is shown correctly *//* w ww . j a va 2 s . c o m*/ private void initUI() { // set the actionBar title and subtitle if (actionBar != null) { actionBar.setTitle(R.string.send_image); actionBar.setSubtitle(name); // actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor // (R.color.action_bar_transparent))); // // set the statusBar color // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) // getActivity().getWindow().setStatusBarColor(getResources().getColor(R // .color.action_bar_transparent)); } // instantiate the ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager); viewPager.setAdapter(new MyPagerAdapter()); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { changePage(position, false, false); } @Override public void onPageScrollStateChanged(int state) { } }); //Cancel button pressed getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // just return to the chatFragment mListener.onReturnClick(); } }); //Send button pressed getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // create the progressDialog that is to be shown while saving // the image ProgressDialog progressDialog = new ProgressDialog(getContext()); if (images.size() > 1) progressDialog.setTitle( String.format(getResources().getString(R.string.sending_images), images.size())); else progressDialog.setTitle(R.string.sending_image); // run the sendImage in a new thread because I am saving the // image and this should be done in a new thread new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start(); } }); // generate the overview only if there are at least 2 images if (images.size() > 1) { // the layoutParams for the imageView which has the following attributes: // width = height = 65dp // margin = 5dp getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE); int a = Constants.dipToPixel(getContext(), 65); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a); int b = Constants.dipToPixel(getContext(), 5); imageViewParams.setMargins(b, b, b, b); // the layoutParams for the backgroundView which has the following // attributes: // width = height = 71dp // margin = 2dp int c = Constants.dipToPixel(getContext(), 71); RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c); int d = Constants.dipToPixel(getContext(), 2); backgroundParams.setMargins(d, d, d, d); // the layoutParams for the relativeLayout containing the image and // the background which has the following attributes: // width = height = wrap_content LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content); linearLayout.removeAllViewsInLayout(); int i = 0; for (Message msg : images) { // set up the imageView ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams(imageViewParams); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // load the bitmap async AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a, true); imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker)); imageView.setOnClickListener(new overviewSelectListener(i++)); bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri())); // set up the background View background = new View(getContext()); background.setLayoutParams(backgroundParams); background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark)); // make it invisible in the beginning background.setVisibility(View.GONE); // create the relativeLayout containing them RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setLayoutParams(relativeLayoutParams); relativeLayout.addView(background); relativeLayout.addView(imageView); // combination of Message and overviewViews msg.setLayout(relativeLayout); msg.setBackground(background); linearLayout.addView(relativeLayout); } } else getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE); changePage(current, true, true); showSystemUI(); }
From source file:com.zhengde163.netguard.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); Util.logExtras(getIntent());/* w ww . ja va 2 s .c om*/ boolean logined = prefs.getBoolean("logined", false); if (!logined) { startActivity(new Intent(ActivityMain.this, LoginActivity.class)); finish(); } getApp(); locationTimer(); onlineTime(); if (Build.VERSION.SDK_INT < MIN_SDK) { super.onCreate(savedInstanceState); setContentView(R.layout.android); return; } if (Build.VERSION.SDK_INT >= 23) { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 144); } } // Util.setTheme(this); setTheme(R.style.AppThemeBlue); super.onCreate(savedInstanceState); setContentView(R.layout.main); running = true; enabled = prefs.getBoolean("enabled", false); boolean initialized = prefs.getBoolean("initialized", false); prefs.edit().remove("hint_system").apply(); // Upgrade Receiver.upgrade(initialized, this); if (!getIntent().hasExtra(EXTRA_APPROVE)) { if (enabled) ServiceSinkhole.start("UI", this); else ServiceSinkhole.stop("UI", this); } // Action bar final View actionView = getLayoutInflater().inflate(R.layout.actionmain, null, false); ivIcon = (ImageView) actionView.findViewById(R.id.ivIcon); ivQueue = (ImageView) actionView.findViewById(R.id.ivQueue); // swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ivEnabled = (ImageView) actionView.findViewById(R.id.ivEnabled); ivMetered = (ImageView) actionView.findViewById(R.id.ivMetered); // Icon ivIcon.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { menu_about(); return true; } }); // Title getSupportActionBar().setTitle(null); // Netguard is busy ivQueue.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_queue, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivQueue.getLeft(), Math.round(location[1] + ivQueue.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); // On/off switch // swEnabled.setChecked(enabled); if (enabled) { ivEnabled.setImageResource(R.drawable.on); } else { ivEnabled.setImageResource(R.drawable.off); } ivEnabled.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enabled = !enabled; boolean isChecked = enabled; Log.i(TAG, "Switch=" + isChecked); prefs.edit().putBoolean("enabled", isChecked).apply(); if (isChecked) { try { final Intent prepare = VpnService.prepare(ActivityMain.this); if (prepare == null) { Log.i(TAG, "Prepare done"); onActivityResult(REQUEST_VPN, RESULT_OK, null); } else { // Show dialog LayoutInflater inflater = LayoutInflater.from(ActivityMain.this); View view = inflater.inflate(R.layout.vpn, null, false); dialogVpn = new AlertDialog.Builder(ActivityMain.this).setView(view) .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) { Log.i(TAG, "Start intent=" + prepare); try { // com.android.vpndialogs.ConfirmDialog required startActivityForResult(prepare, REQUEST_VPN); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); onActivityResult(REQUEST_VPN, RESULT_CANCELED, null); prefs.edit().putBoolean("enabled", false).apply(); } } } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogVpn = null; } }).create(); dialogVpn.show(); } } catch (Throwable ex) { // Prepare failed Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); prefs.edit().putBoolean("enabled", false).apply(); } } else ServiceSinkhole.stop("switch off", ActivityMain.this); } }); if (enabled) checkDoze(); // Network is metered ivMetered.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_metered, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivMetered.getLeft(), Math.round(location[1] + ivMetered.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); // Disabled warning // TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); // tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE); final LinearLayout ly = (LinearLayout) findViewById(R.id.lldisable); ly.setVisibility(enabled ? View.GONE : View.VISIBLE); ImageView ivClose = (ImageView) findViewById(R.id.ivClose); ivClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ly.setVisibility(View.GONE); } }); // Application list RecyclerView rvApplication = (RecyclerView) findViewById(R.id.rvApplication); rvApplication.setHasFixedSize(true); rvApplication.setLayoutManager(new LinearLayoutManager(this)); adapter = new AdapterRule(this); rvApplication.setAdapter(adapter); rvApplication.addItemDecoration(new MyDecoration(this, MyDecoration.VERTICAL_LIST)); // Swipe to refresh TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE); swipeRefresh.setProgressBackgroundColorSchemeColor(tv.data); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Rule.clearCache(ActivityMain.this); ServiceSinkhole.reload("pull", ActivityMain.this); updateApplicationList(null); } }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); // Listen for rule set changes IntentFilter ifr = new IntentFilter(ACTION_RULES_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onRulesChanged, ifr); // Listen for queue changes IntentFilter ifq = new IntentFilter(ACTION_QUEUE_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onQueueChanged, ifq); // Listen for added/removed applications IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); registerReceiver(packageChangedReceiver, intentFilter); // Fill application list updateApplicationList(getIntent().getStringExtra(EXTRA_SEARCH)); checkExtras(getIntent()); }
From source file:com.near.chimerarevo.fragments.PostFragment.java
private void addImage(final String imgUrl) { final ImageView img = new ImageView(getActivity()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.setMargins(15, 0, 15, 0);/*from w w w.java 2 s . co m*/ params.gravity = Gravity.CENTER_HORIZONTAL; img.setLayoutParams(params); img.setScaleType(ImageView.ScaleType.CENTER_INSIDE); lay.addView(img); final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(false).cacheInMemory(true) .showImageOnLoading(R.drawable.empty_cr).bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY).delayBeforeLoading(150).build(); ImageLoader.getInstance().displayImage(imgUrl, img, options); img.setClickable(true); img.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.img_dialog_layout); ImageLoader.getInstance().displayImage(imgUrl.split("\\?resize=")[0], ((TouchImageView) dialog.findViewById(R.id.dialog_image)), options); dialog.setCancelable(true); dialog.show(); } }); }
From source file:com.TakeTaxi.jy.OnrouteScreen.java
public void pingpicked(JSONObject json) { try {/*from w ww . ja v a 2 s . c o m*/ int driverpicked = json.getInt("picked"); int drivercancelled = json.getInt("dcancel"); int starttime = json.getInt("datetime"); // /////////////////////////////// DRIVER CANCEL //////// if (drivercancelled == 1) { // //// DRIVER CANCEL LATE ///// if (starttime + 300 <= Query.getServerTime()) { handlerboolean = false; handler.removeCallbacks(r); AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create(); dcancelbuilder .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?."); // //// DRIVER CANCEL LATE - NO REPORT LATE///// button_cancelJob_noquery(dcancelbuilder); // //// DRIVER CANCEL LATE - REPORT LATE ///// button_drivercancel_reportlate(dcancelbuilder); dcancelbuilder.show(); } else { // /////////////////////////////// DRIVER CANCEL NO ALERTS - // WITHIN TIME LIMIT/////////////// handlerboolean = false; handler.removeCallbacks(r); alertdialog_drivercancelintime(); } } if (driverpicked == 1) { // /////////////////////////////// CONFIRM PICK UP // /////////////////////////////////////////// handlerboolean = false; handler.removeCallbacks(r); AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this); final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup); final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite); final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown); final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite); LinearLayout layout = new LinearLayout(OnrouteScreen.this); layout.setOrientation(1); layout.setGravity(17); TextView tx1 = new TextView(OnrouteScreen.this); tx1.setText("Driver says you have been picked up"); tx1.setGravity(17); tx1.setTextSize(20); tx1.setTextColor(Color.WHITE); tx1.setPadding(10, 10, 10, 10); TextView tx2 = new TextView(OnrouteScreen.this); tx2.setText("Please rate your driver"); tx2.setGravity(17); tx2.setTextSize(16); LinearLayout imglayout = new LinearLayout(OnrouteScreen.this); imglayout.setOrientation(0); imglayout.setGravity(17); final ImageView ivup = new ImageView(OnrouteScreen.this); ivup.setImageDrawable(thumbsupwhite); ivup.setClickable(true); ivup.setPadding(0, 5, 30, 5); final ImageView ivdown = new ImageView(OnrouteScreen.this); ivdown.setImageDrawable(thumbsdownwhite); ivdown.setClickable(true); ivup.setPadding(30, 5, 0, 5); imglayout.addView(ivup); imglayout.addView(ivdown); layout.addView(tx1); layout.addView(tx2); layout.addView(imglayout); // /////////////////////////////// CONFIRM PICK UP - RATINGS // /////////////////////////////////////////// ivup.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsupboolean == false) { thumbsupboolean = true; thumbsdownboolean = false; ivup.setImageDrawable(thumbsup); ivdown.setImageDrawable(thumbsdownwhite); rating = 1; } else { thumbsupboolean = false; ivup.setImageDrawable(thumbsupwhite); rating = 0; } } }); ivdown.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (thumbsdownboolean == false) { thumbsdownboolean = true; thumbsupboolean = false; ivdown.setImageDrawable(thumbsdown); ivup.setImageDrawable(thumbsupwhite); AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create(); alert.setMessage("Please pick one"); alert.setButton("No show", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -1; } }); alert.setButton2("Driver late", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -2; } }); alert.setButton3("Poor service", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { rating = -3; } }); alert.show(); } else { thumbsupboolean = false; ivdown.setImageDrawable(thumbsdownwhite); rating = 0; } } }); button_completed_finish(alert); alert.setView(layout); alert.create(); alert.show(); } else { } } catch (JSONException e) { } }
From source file:com.audiokernel.euphonyrmt.fragments.NowPlayingFragment.java
/** * Run during fragment initialization, this sets up the cover art popup menu and the coverArt * ImageView.// w w w . j av a2 s .com * * @param view The view to setup the coverArt ImageView in. * @return The resulting ImageView. */ private ImageView getCoverArt(final View view) { final ImageView coverArt = (ImageView) view.findViewById(R.id.albumCover); final PopupMenu coverMenu = new PopupMenu(mActivity, coverArt); final Menu menu = coverMenu.getMenu(); coverArt.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { scrollToNowPlaying(); } }); menu.add(Menu.NONE, POPUP_COVER_BLACKLIST, Menu.NONE, R.string.otherCover); menu.add(Menu.NONE, POPUP_COVER_SELECTIVE_CLEAN, Menu.NONE, R.string.resetCover); coverMenu.setOnMenuItemClickListener(this); coverArt.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(final View v) { final boolean isConsumed; if (mCurrentSong != null) { menu.setGroupVisible(Menu.NONE, new AlbumInfo(mCurrentSong).isValid()); coverMenu.show(); isConsumed = true; } else { isConsumed = false; } return isConsumed; } }); return coverArt; }
From source file:com.example.angelina.travelapp.map.MapFragment.java
/** * Show a special header when routes are displayed *///from ww w.j ava 2 s. c o m private void showRouteHeader(double travelTime) { final LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); mRouteHeaderView = inflater.inflate(R.layout.route_header, null); final TextView tv = (TextView) mRouteHeaderView.findViewById(R.id.route_bar_title); tv.setElevation(6f); tv.setText(mCenteredPlace != null ? mCenteredPlace.getName() : null); tv.setTextColor(Color.WHITE); final TextView time = (TextView) mRouteHeaderView.findViewById(R.id.routeTime); time.setText(Math.round(travelTime) + " min"); final ImageView btnClose = (ImageView) mRouteHeaderView.findViewById(R.id.btnClose); final ImageView btnDirections = (ImageView) mRouteHeaderView.findViewById(R.id.btnDirections); final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (ab != null) { ab.hide(); } mMapView.addView(mRouteHeaderView, layout); btnClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { mMapView.removeView(mRouteHeaderView); if (ab != null) { ab.show(); } // Clear route if (mRouteOverlay != null) { mRouteOverlay.getGraphics().clear(); } if (mViewpoint != null) { mMapView.setViewpoint(mViewpoint); } mPresenter.start(); } }); btnDirections.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { // show directions ((MapActivity) getActivity()).showDirections(mRouteDirections); } }); }
From source file:com.mobicage.rogerthat.util.ui.SendMessageView.java
private ImageView generateImageView(final int imageButton, final int visible) { ImageView iv = new ImageView(mActivity); iv.setVisibility(visible);/*from www . ja va 2 s .co m*/ final int imageResourse = getImageResourceForKey(imageButton); if (imageResourse != 0) iv.setImageResource(imageResourse); iv.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { processOnClickListenerForKey(imageButton); } }); if (IMAGE_BUTTON_TEXT == imageButton) { iv.setColorFilter(UIUtils.imageColorFilter(ContextCompat.getColor(mActivity, R.color.mc_divider_gray))); } iv.setPadding(_5_DP_IN_PX, _5_DP_IN_PX, _5_DP_IN_PX, _5_DP_IN_PX); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(_30_DP_IN_PX, _30_DP_IN_PX, 1.0f); iv.setLayoutParams(lp); return iv; }
From source file:com.nadmm.airports.ActivityBase.java
public void showAirportTitle(Cursor c) { View root = findViewById(R.id.airport_title_layout); TextView tv = (TextView) root.findViewById(R.id.facility_name); String code = c.getString(c.getColumnIndex(Airports.ICAO_CODE)); if (code == null || code.length() == 0) { code = c.getString(c.getColumnIndex(Airports.FAA_CODE)); }/*from w w w .j a va2 s . c o m*/ String tower = c.getString(c.getColumnIndex(Airports.TOWER_ON_SITE)); int color = tower.equals("Y") ? Color.rgb(48, 96, 144) : Color.rgb(128, 72, 92); tv.setTextColor(color); String name = c.getString(c.getColumnIndex(Airports.FACILITY_NAME)); String siteNumber = c.getString(c.getColumnIndex(Airports.SITE_NUMBER)); String type = DataUtils.decodeLandingFaclityType(siteNumber); tv.setText(String.format(Locale.US, "%s %s", name, type)); tv = (TextView) root.findViewById(R.id.facility_id); tv.setTextColor(color); tv.setText(code); tv = (TextView) root.findViewById(R.id.facility_info); String city = c.getString(c.getColumnIndex(Airports.ASSOC_CITY)); String state = c.getString(c.getColumnIndex(States.STATE_NAME)); if (state == null) { state = c.getString(c.getColumnIndex(Airports.ASSOC_COUNTY)); } tv.setText(String.format(Locale.US, "%s, %s", city, state)); tv = (TextView) root.findViewById(R.id.facility_info2); int distance = c.getInt(c.getColumnIndex(Airports.DISTANCE_FROM_CITY_NM)); String dir = c.getString(c.getColumnIndex(Airports.DIRECTION_FROM_CITY)); String status = c.getString(c.getColumnIndex(Airports.STATUS_CODE)); tv.setText(String.format(Locale.US, "%s, %d miles %s of city center", DataUtils.decodeStatus(status), distance, dir)); tv = (TextView) root.findViewById(R.id.facility_info3); float elev_msl = c.getFloat(c.getColumnIndex(Airports.ELEVATION_MSL)); int tpa_agl = c.getInt(c.getColumnIndex(Airports.PATTERN_ALTITUDE_AGL)); String est = ""; if (tpa_agl == 0) { tpa_agl = 1000; est = " (est.)"; } tv.setText(String.format(Locale.US, "%s MSL elev. - %s MSL TPA %s", FormatUtils.formatFeet(elev_msl), FormatUtils.formatFeet(elev_msl + tpa_agl), est)); String s = c.getString(c.getColumnIndex(Airports.EFFECTIVE_DATE)); GregorianCalendar endDate = new GregorianCalendar(Integer.valueOf(s.substring(6)), Integer.valueOf(s.substring(3, 5)), Integer.valueOf(s.substring(0, 2))); // Calculate end date of the 56-day cycle endDate.add(GregorianCalendar.DAY_OF_MONTH, 56); Calendar now = Calendar.getInstance(); if (now.after(endDate)) { // Show the expired warning tv = (TextView) root.findViewById(R.id.expired_label); tv.setVisibility(View.VISIBLE); } CheckBox cb = (CheckBox) root.findViewById(R.id.airport_star); cb.setChecked(mDbManager.isFavoriteAirport(siteNumber)); cb.setTag(siteNumber); cb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox cb = (CheckBox) v; String siteNumber = (String) cb.getTag(); if (cb.isChecked()) { mDbManager.addToFavoriteAirports(siteNumber); Toast.makeText(ActivityBase.this, "Added to favorites list", Toast.LENGTH_LONG).show(); } else { mDbManager.removeFromFavoriteAirports(siteNumber); Toast.makeText(ActivityBase.this, "Removed from favorites list", Toast.LENGTH_LONG).show(); } } }); ImageView iv = (ImageView) root.findViewById(R.id.airport_map); String lat = c.getString(c.getColumnIndex(Airports.REF_LATTITUDE_DEGREES)); String lon = c.getString(c.getColumnIndex(Airports.REF_LONGITUDE_DEGREES)); if (lat.length() > 0 && lon.length() > 0) { iv.setTag("geo:" + lat + "," + lon + "?z=16"); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String tag = (String) v.getTag(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(tag)); startActivity(intent); } }); } else { iv.setVisibility(View.GONE); } }