List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:im.vector.activity.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (CommonActivityUtils.shouldRestartApp()) { Log.e(LOG_TAG, "Restart the application."); CommonActivityUtils.restartApp(this); }/*from w w w .jav a 2s. c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); mMediasCache = Matrix.getInstance(this).getMediasCache(); // add any known session LinearLayout globalLayout = (LinearLayout) findViewById(R.id.settings_layout); TextView profileHeader = (TextView) findViewById(R.id.settings_profile_information_header); int pos = globalLayout.indexOfChild(profileHeader); for (MXSession session : Matrix.getMXSessions(this)) { final MXSession fSession = session; LinearLayout profileLayout = (LinearLayout) getLayoutInflater() .inflate(R.layout.account_section_settings, null); mLinearLayoutBySession.put(session, profileLayout); pos++; globalLayout.addView(profileLayout, pos); refreshProfileThumbnail(session, profileLayout); ImageView avatarView = (ImageView) profileLayout.findViewById(R.id.imageView_avatar); avatarView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mUpdatingSession = fSession; Intent fileIntent = new Intent(Intent.ACTION_PICK); fileIntent.setType("image/*"); startActivityForResult(fileIntent, REQUEST_IMAGE); } }); MyUser myUser = session.getMyUser(); TextView matrixIdTextView = (TextView) profileLayout.findViewById(R.id.textView_matrix_id); matrixIdTextView.setText(myUser.userId); final Button saveButton = (Button) profileLayout.findViewById(R.id.button_save); EditText displayNameEditText = (EditText) profileLayout.findViewById(R.id.editText_displayName); displayNameEditText.setText(myUser.displayname); displayNameEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateSaveButton(saveButton); } @Override public void afterTextChanged(Editable s) { } }); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveChanges(fSession); } }); } // Config information String versionName = ""; try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); versionName = pInfo.versionName; } catch (Exception e) { } TextView consoleVersionTextView = (TextView) findViewById(R.id.textView_matrixConsoleVersion); consoleVersionTextView.setText(getString(R.string.settings_config_console_version, versionName)); TextView sdkVersionTextView = (TextView) findViewById(R.id.textView_matrixSDKVersion); sdkVersionTextView.setText(getString(R.string.settings_config_sdk_version, versionName)); TextView buildNumberTextView = (TextView) findViewById(R.id.textView_matrixBuildNumber); buildNumberTextView.setText(getString(R.string.settings_config_build_number, "")); TextView userIdTextView = (TextView) findViewById(R.id.textView_configUsers); String config = ""; int sessionIndex = 1; Collection<MXSession> sessions = Matrix.getMXSessions(this); for (MXSession session : sessions) { if (sessions.size() > 1) { config += "\nAccount " + sessionIndex + " : \n"; sessionIndex++; } config += String.format(getString(R.string.settings_config_home_server), session.getCredentials().homeServer); config += "\n"; config += String.format(getString(R.string.settings_config_user_id), session.getMyUser().userId); if (sessions.size() > 1) { config += "\n"; } } userIdTextView.setText(config); // room settings final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); listenBoxUpdate(preferences, R.id.checkbox_useGcm, getString(R.string.settings_key_use_google_cloud_messaging), true); listenBoxUpdate(preferences, R.id.checkbox_displayAllEvents, getString(R.string.settings_key_display_all_events), false); listenBoxUpdate(preferences, R.id.checkbox_hideUnsupportedEvenst, getString(R.string.settings_key_hide_unsupported_events), true); listenBoxUpdate(preferences, R.id.checkbox_sortByLastSeen, getString(R.string.settings_key_sort_by_last_seen), true); listenBoxUpdate(preferences, R.id.checkbox_displayLeftMembers, getString(R.string.settings_key_display_left_members), false); listenBoxUpdate(preferences, R.id.checkbox_displayPublicRooms, getString(R.string.settings_key_display_public_rooms_recents), true); final Button clearCacheButton = (Button) findViewById(R.id.button_clear_cache); clearCacheButton.setText(getString(R.string.clear_cache) + " (" + computeApplicationCacheSize() + ")"); clearCacheButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Matrix.getInstance(SettingsActivity.this).reloadSessions(SettingsActivity.this); } }); final Button notificationsRuleButton = (Button) findViewById(R.id.button_notifications_rule); notificationsRuleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { launchNotificationsActivity(); } }); final GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(this) .getSharedGcmRegistrationManager(); refreshGCMEntries(); final EditText pusherUrlEditText = (EditText) findViewById(R.id.editText_gcm_pusher_url); pusherUrlEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { gcmRegistrationManager.setPusherUrl(pusherUrlEditText.getText().toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final EditText pusherProfileEditText = (EditText) findViewById(R.id.editText_gcm_pusher_profile_tag); pusherProfileEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { gcmRegistrationManager.setPusherFileTag(pusherProfileEditText.getText().toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); managePedingGCMregistration(); }
From source file:jahirfiquitiva.iconshowcase.activities.ViewerActivity.java
@SuppressWarnings("ResourceAsColor") @Override// w w w.j a va 2s . c o m protected void onCreate(Bundle savedInstanceState) { ThemeUtils.onActivityCreateSetTheme(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ThemeUtils.onActivityCreateSetNavBar(this); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } super.onCreate(savedInstanceState); context = this; usePalette = getResources().getBoolean(R.bool.use_palette_api_in_viewer); mPrefs = new Preferences(context); mPrefs.setActivityVisible(true); Intent intent = getIntent(); String transitionName = intent.getStringExtra("transitionName"); item = intent.getParcelableExtra("item"); setContentView(R.layout.wall_viewer_activity); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(""); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } final int iconsColor = ThemeUtils.darkTheme ? ContextCompat.getColor(context, R.color.toolbar_text_dark) : ContextCompat.getColor(context, R.color.toolbar_text_light); ToolbarColorizer.colorizeToolbar(toolbar, iconsColor); toHide1 = (LinearLayout) findViewById(R.id.iconsA); toHide2 = (LinearLayout) findViewById(R.id.iconsB); int tintLightLighter = ContextCompat.getColor(context, R.color.drawable_base_tint); int tintDark = ContextCompat.getColor(context, R.color.drawable_tint_dark); Drawable save = ColorUtils.getTintedIcon(context, R.drawable.ic_save, ThemeUtils.darkTheme ? tintDark : tintLightLighter); Drawable apply = ColorUtils.getTintedIcon(context, R.drawable.ic_apply_wallpaper, ThemeUtils.darkTheme ? tintDark : tintLightLighter); Drawable info = ColorUtils.getTintedIcon(context, R.drawable.ic_info, ThemeUtils.darkTheme ? tintDark : tintLightLighter); ImageView saveIV = (ImageView) findViewById(R.id.download); if (item.isDownloadable()) { saveIV.setImageDrawable(save); saveIV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!PermissionUtils.canAccessStorage(context)) { PermissionUtils.setViewerActivityAction("save"); PermissionUtils.requestStoragePermission(context); } else { showDialogs("save"); } } }); } else { saveIV.setVisibility(View.GONE); } ImageView applyIV = (ImageView) findViewById(R.id.apply); applyIV.setImageDrawable(apply); applyIV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showApplyWallpaperDialog(context, item.getWallURL()); } }); ImageView infoIV = (ImageView) findViewById(R.id.info); infoIV.setImageDrawable(info); infoIV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ISDialogs.showWallpaperDetailsDialog(context, item.getWallName(), item.getWallAuthor(), item.getWallDimensions(), item.getWallCopyright()); } }); TouchImageView mPhoto = (TouchImageView) findViewById(R.id.big_wallpaper); ViewCompat.setTransitionName(mPhoto, transitionName); layout = (RelativeLayout) findViewById(R.id.viewerLayout); TextView wallNameText = (TextView) findViewById(R.id.wallName); wallNameText.setText(item.getWallName()); Bitmap bmp = null; String filename = getIntent().getStringExtra("image"); try { if (filename != null) { FileInputStream is = context.openFileInput(filename); bmp = BitmapFactory.decodeStream(is); is.close(); } else { bmp = null; } } catch (Exception e) { e.printStackTrace(); } int colorFromCachedPic = 0; if (bmp != null) { colorFromCachedPic = ColorExtractor.getFinalGeneratedIconsColorFromPalette(bmp, usePalette); } else { colorFromCachedPic = ThemeUtils.darkTheme ? tintDark : tintLightLighter; } final ProgressBar spinner = (ProgressBar) findViewById(R.id.progress); spinner.getIndeterminateDrawable().setColorFilter(colorFromCachedPic, PorterDuff.Mode.SRC_IN); ToolbarColorizer.colorizeToolbar(toolbar, colorFromCachedPic); Drawable d; if (bmp != null) { d = new GlideBitmapDrawable(getResources(), bmp); } else { d = new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent)); } if (mPrefs.getAnimationsEnabled()) { Glide.with(context).load(item.getWallURL()).placeholder(d).diskCacheStrategy(DiskCacheStrategy.SOURCE) .fitCenter().listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { Bitmap picture = ((GlideBitmapDrawable) resource).getBitmap(); ToolbarColorizer.colorizeToolbar(toolbar, ColorExtractor.getFinalGeneratedIconsColorFromPalette(picture, usePalette)); spinner.setVisibility(View.GONE); return false; } }).into(mPhoto); } else { Glide.with(context).load(item.getWallURL()).placeholder(d).dontAnimate() .diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter() .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { Bitmap picture = ((GlideBitmapDrawable) resource).getBitmap(); ToolbarColorizer.colorizeToolbar(toolbar, ColorExtractor.getFinalGeneratedIconsColorFromPalette(picture, usePalette)); spinner.setVisibility(View.GONE); return false; } }).into(mPhoto); } }
From source file:com.me.resume.MainActivity.java
/** * ?/*from w w w. ja v a 2 s .c o m*/ * @param view */ private void initView8(View view) { mViewList.add(view8); TextView words = (TextView) view8.findViewById(R.id.item2); String wordStr = preferenceUtil.getPreferenceData(Constants.MYWORDS, ""); if (RegexUtil.checkNotNull(wordStr)) { words.setText(Html.fromHtml(" " + wordStr)); } else { words.setText(getResources().getString(R.string.resume_mywords)); } words.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // if (preferenceUtil.getPreferenceData(Constants.EDITMODE)) { goFlag = true; ActivityUtils.startActivity(self, Constants.PACKAGENAMECHILD + Constants.WORDS, false); // } } }); ImageView goHome = (ImageView) view8.findViewById(R.id.gohome); goHome.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { preferenceUtil.setPreferenceData(Constants.SET_STARTVERYTIME, false); ActivityUtils.startActivity(self, Constants.PACKAGENAMECHILD + Constants.HOME, true); } }); }
From source file:com.softminds.matrixcalculator.MatrixAdapter.java
@Override @NonNull/*from w w w . jav a 2 s .com*/ public View getView(int position, View convertView, @NonNull ViewGroup parent) { final MatrixV2 m = getItem(position); if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_layout_fragment, parent, false); //Grab References TextView Row = convertView.findViewById(R.id.MatrixTitleRow); TextView Col = convertView.findViewById(R.id.MatrixTitleCol); TextView Naam = convertView.findViewById(R.id.MatrixTitle); ImageView icon = convertView.findViewById(R.id.ImageForMatrix); CardView cardView = convertView.findViewById(R.id.Matrix_holder); //Set Values @SuppressWarnings({ "ConstantConditions" }) String r = "Row : " + String.valueOf(m.getNumberOfRows()); String c = "Column : " + String.valueOf(m.getNumberOfCols()); if (PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DARK_THEME_KEY", false)) { Row.setTextColor(Color.WHITE); Col.setTextColor(Color.WHITE); Naam.setTextColor(Color.WHITE); cardView.setCardBackgroundColor(ContextCompat.getColor(getContext(), R.color.DarkcolorPrimary)); } Row.setText(r); Col.setText(c); m.setType(); Naam.setText(m.getName()); icon.setImageResource(m.getDrawable(m.getType())); icon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(getContext(), m.getType().toString() + " MatrixV2", Toast.LENGTH_SHORT).show(); } }); //Return the View return convertView; }
From source file:com.zhengde163.netguard.ActivityLog.java
@Override protected void onCreate(Bundle savedInstanceState) { // Util.setTheme(this); setTheme(R.style.AppThemeBlue);/* w ww .j a v a 2 s. c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.logging); running = true; // Action bar View actionView = getLayoutInflater().inflate(R.layout.actionlog, null, false); // SwitchCompat swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ImageView ivEnabled = (ImageView) actionView.findViewById(R.id.ivEnabled); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); getSupportActionBar().setTitle(R.string.menu_log); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get settings final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); resolve = prefs.getBoolean("resolve", false); organization = prefs.getBoolean("organization", false); log = prefs.getBoolean("log", false); // Show disabled message // TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); // tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE); final LinearLayout ly = (LinearLayout) findViewById(R.id.lldisable); ly.setVisibility(log ? 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); } }); // Set enabled switch // swEnabled.setChecked(log); if (ivEnabled != null) { if (log) { ivEnabled.setImageResource(R.drawable.on); } else { ivEnabled.setImageResource(R.drawable.off); } ivEnabled.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { log = !log; boolean isChecked = log; prefs.edit().putBoolean("log", isChecked).apply(); } }); } // swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // prefs.edit().putBoolean("log", isChecked).apply(); // } // }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); lvLog = (ListView) findViewById(R.id.lvLog); boolean udp = prefs.getBoolean("proto_udp", true); boolean tcp = prefs.getBoolean("proto_tcp", true); boolean other = prefs.getBoolean("proto_other", true); boolean allowed = prefs.getBoolean("traffic_allowed", true); boolean blocked = prefs.getBoolean("traffic_blocked", true); adapter = new AdapterLog(this, DatabaseHelper.getInstance(this).getLog(udp, tcp, other, allowed, blocked), resolve, organization); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return DatabaseHelper.getInstance(ActivityLog.this).searchLog(constraint.toString()); } }); lvLog.setAdapter(adapter); try { vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } lvLog.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PackageManager pm = getPackageManager(); Cursor cursor = (Cursor) adapter.getItem(position); long time = cursor.getLong(cursor.getColumnIndex("time")); int version = cursor.getInt(cursor.getColumnIndex("version")); int protocol = cursor.getInt(cursor.getColumnIndex("protocol")); final String saddr = cursor.getString(cursor.getColumnIndex("saddr")); final int sport = (cursor.isNull(cursor.getColumnIndex("sport")) ? -1 : cursor.getInt(cursor.getColumnIndex("sport"))); final String daddr = cursor.getString(cursor.getColumnIndex("daddr")); final int dport = (cursor.isNull(cursor.getColumnIndex("dport")) ? -1 : cursor.getInt(cursor.getColumnIndex("dport"))); final String dname = cursor.getString(cursor.getColumnIndex("dname")); final int uid = (cursor.isNull(cursor.getColumnIndex("uid")) ? -1 : cursor.getInt(cursor.getColumnIndex("uid"))); int allowed = (cursor.isNull(cursor.getColumnIndex("allowed")) ? -1 : cursor.getInt(cursor.getColumnIndex("allowed"))); // Get external address InetAddress addr = null; try { addr = InetAddress.getByName(daddr); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } String ip; int port; if (addr.equals(vpn4) || addr.equals(vpn6)) { ip = saddr; port = sport; } else { ip = daddr; port = dport; } // Build popup menu PopupMenu popup = new PopupMenu(ActivityLog.this, findViewById(R.id.vwPopupAnchor)); popup.inflate(R.menu.log); // Application name if (uid >= 0) popup.getMenu().findItem(R.id.menu_application) .setTitle(TextUtils.join(", ", Util.getApplicationNames(uid, ActivityLog.this))); else popup.getMenu().removeItem(R.id.menu_application); // Destination IP popup.getMenu().findItem(R.id.menu_protocol) .setTitle(Util.getProtocolName(protocol, version, false)); // Whois final Intent lookupIP = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.tcpiputils.com/whois-lookup/" + ip)); if (pm.resolveActivity(lookupIP, 0) == null) popup.getMenu().removeItem(R.id.menu_whois); else popup.getMenu().findItem(R.id.menu_whois).setTitle(getString(R.string.title_log_whois, ip)); // Lookup port final Intent lookupPort = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.speedguide.net/port.php?port=" + port)); if (port <= 0 || pm.resolveActivity(lookupPort, 0) == null) popup.getMenu().removeItem(R.id.menu_port); else popup.getMenu().findItem(R.id.menu_port).setTitle(getString(R.string.title_log_port, port)); if (!prefs.getBoolean("filter", false)) { popup.getMenu().removeItem(R.id.menu_allow); popup.getMenu().removeItem(R.id.menu_block); } final Packet packet = new Packet(); packet.version = version; packet.protocol = protocol; packet.daddr = daddr; packet.dport = dport; packet.time = time; packet.uid = uid; packet.allowed = (allowed > 0); // Time popup.getMenu().findItem(R.id.menu_time) .setTitle(SimpleDateFormat.getDateTimeInstance().format(time)); // Handle click popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_application: { Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); return true; } case R.id.menu_whois: startActivity(lookupIP); return true; case R.id.menu_port: startActivity(lookupPort); return true; case R.id.menu_allow: DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 0); ServiceSinkhole.reload("allow host", ActivityLog.this); Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); return true; case R.id.menu_block: DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 1); ServiceSinkhole.reload("block host", ActivityLog.this); Intent main1 = new Intent(ActivityLog.this, ActivityMain.class); main1.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main1); return true; default: return false; } } }); // Show popup.show(); } }); live = true; }
From source file:com.doomy.decode.ScanActivity.java
private void openAboutDialog() { LayoutInflater mLayoutInflater = LayoutInflater.from(ScanActivity.this); View mView = mLayoutInflater.inflate(R.layout.view_about, null); ImageView mImageViewMrDoomy = (ImageView) mView.findViewById(R.id.imageViewMrDoomy); ImageView mImageViewStudio = (ImageView) mView.findViewById(R.id.imageViewStudio); ImageView mImageViewGitHub = (ImageView) mView.findViewById(R.id.imageViewGitHub); Drawable mMrDoomy = mImageViewMrDoomy.getDrawable(); Drawable mStudio = mImageViewStudio.getDrawable(); Drawable mGitHub = mImageViewGitHub.getDrawable(); mMrDoomy.setColorFilter(getResources().getColor(R.color.greenDark), PorterDuff.Mode.SRC_ATOP); mStudio.setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_ATOP); mGitHub.setColorFilter(getResources().getColor(R.color.greyMaterialDark), PorterDuff.Mode.SRC_ATOP); mImageViewGitHub.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a2 s.c om*/ public void onClick(View v) { Intent mIntent = new Intent(); mIntent.setAction(Intent.ACTION_VIEW); mIntent.addCategory(Intent.CATEGORY_BROWSABLE); mIntent.setData(Uri.parse(getString(R.string.url))); startActivity(mIntent); } }); AlertDialog.Builder mAlertDialog = new AlertDialog.Builder(ScanActivity.this, Utils.setThemeDialog()); mAlertDialog.setTitle(getString(R.string.about)); mAlertDialog.setView(mView); mAlertDialog.setPositiveButton(getString(R.string.okay), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); mAlertDialog.show(); }
From source file:jahirfiquitiva.iconshowcase.activities.WallpaperViewerActivity.java
@SuppressWarnings("ResourceAsColor") @Override//from www.j a v a2 s. com protected void onCreate(Bundle savedInstanceState) { ThemeUtils.onActivityCreateSetTheme(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ThemeUtils.onActivityCreateSetNavBar(this); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } super.onCreate(savedInstanceState); makeStatusBarIconsWhite(); context = this; mPrefs = new Preferences(context); Intent intent = getIntent(); String transitionName = intent.getStringExtra("transitionName"); item = intent.getParcelableExtra("item"); setContentView(R.layout.wallpaper_viewer_activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(""); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back_with_shadow); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } ToolbarColorizer.colorizeToolbar(toolbar, ContextCompat.getColor(context, android.R.color.white)); toHide1 = (LinearLayout) findViewById(R.id.iconsA); toHide2 = (LinearLayout) findViewById(R.id.iconsB); int tintColor = ThemeUtils.darkOrLight(context, R.color.drawable_tint_dark, R.color.drawable_base_tint); Drawable save = IconUtils.getTintedIcon(context, R.drawable.ic_save, tintColor); Drawable apply = IconUtils.getTintedIcon(context, R.drawable.ic_apply_wallpaper, tintColor); Drawable info = IconUtils.getTintedIcon(context, R.drawable.ic_info, tintColor); ImageView saveIV = (ImageView) findViewById(R.id.download); if (item.isDownloadable()) { saveIV.setImageDrawable(save); saveIV.setOnClickListener(new DebouncedClickListener() { @Override public void onDebouncedClick(View v) { if (!PermissionUtils.canAccessStorage(context)) { PermissionUtils.setViewerActivityAction("save"); PermissionUtils.requestStoragePermission(context); } else { showDialogs("save"); } } }); } else { saveIV.setVisibility(View.GONE); } ImageView applyIV = (ImageView) findViewById(R.id.apply); applyIV.setImageDrawable(apply); applyIV.setOnClickListener(new DebouncedClickListener() { @Override public void onDebouncedClick(View v) { showApplyWallpaperDialog(item.getWallURL()); } }); ImageView infoIV = (ImageView) findViewById(R.id.info); infoIV.setImageDrawable(info); infoIV.setOnClickListener(new DebouncedClickListener() { @Override public void onDebouncedClick(View v) { ISDialogs.showWallpaperDetailsDialog(context, item.getWallName(), item.getWallAuthor(), item.getWallDimensions(), item.getWallCopyright(), new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { //Do nothing } }); } }); TouchImageView mPhoto = (TouchImageView) findViewById(R.id.big_wallpaper); ViewCompat.setTransitionName(mPhoto, transitionName); layout = (RelativeLayout) findViewById(R.id.viewerLayout); TextView wallNameText = (TextView) findViewById(R.id.wallName); wallNameText.setText(item.getWallName()); Bitmap bmp = null; String filename = getIntent().getStringExtra("image"); try { if (filename != null) { FileInputStream is = context.openFileInput(filename); bmp = BitmapFactory.decodeStream(is); is.close(); } else { bmp = null; } } catch (Exception e) { e.printStackTrace(); } int colorFromCachedPic; if (bmp != null) { colorFromCachedPic = ColorUtils.getPaletteSwatch(bmp).getTitleTextColor(); } else { colorFromCachedPic = tintColor; } final ProgressBar spinner = (ProgressBar) findViewById(R.id.progress); spinner.getIndeterminateDrawable().setColorFilter(colorFromCachedPic, PorterDuff.Mode.SRC_IN); Drawable d; if (bmp != null) { d = new GlideBitmapDrawable(getResources(), bmp); } else { d = new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent)); } if (mPrefs.getAnimationsEnabled()) { Glide.with(context).load(item.getWallURL()).placeholder(d).diskCacheStrategy(DiskCacheStrategy.SOURCE) .fitCenter().listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { spinner.setVisibility(View.GONE); return false; } }).into(mPhoto); } else { Glide.with(context).load(item.getWallURL()).placeholder(d).dontAnimate() .diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter() .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { spinner.setVisibility(View.GONE); return false; } }).into(mPhoto); } }
From source file:com.zns.comicdroid.activity.Add.java
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_add); super.onCreate(savedInstanceState); mEtISBN = (EditText) findViewById(R.id.etISBN); mSpGroup = (Spinner) findViewById(R.id.add_spGroup); mCbIsRead = (CheckBox) findViewById(R.id.add_cbIsRead); ListView lvComics = (ListView) findViewById(R.id.add_lvComics); ImageView ivGroupAdd = (ImageView) findViewById(R.id.add_ivGroupAdd); mBtnScan = (Button) findViewById(R.id.btnScan); mBtnSearch = (Button) findViewById(R.id.btnSearch); //Spinner groups List<Group> groups = getDBHelper().getGroups(); if (groups == null) groups = new ArrayList<Group>(); groups.add(0, new Group(0, getResources().getString(R.string.common_nogroup), null, 0, 0, 0, 0, 0)); adapterGroups = new ArrayAdapter<Group>(this, android.R.layout.simple_spinner_item, groups); adapterGroups.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpGroup.setAdapter(adapterGroups);/*w ww .ja v a 2 s.c o m*/ //Dialog ivGroupAdd.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogFragment dialogAddGroup = new GroupDialogFragment(); dialogAddGroup.show(getSupportFragmentManager(), "GROUPADD"); } }); ArrayList<Comic> comics = new ArrayList<Comic>(); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_COMICS)) { comics = savedInstanceState.getParcelableArrayList(STATE_COMICS); } mAdapter = new ComicArrayAdapter(this, comics, getImagePath(true)); lvComics.setAdapter(mAdapter); }
From source file:com.nextgis.maplibui.fragment.LayersListAdapter.java
private View getStandardLayerView(final ILayer layer, View view) { LayoutInflater inflater = LayoutInflater.from(mContext); View v = view;/*from w ww .j a v a2 s .c o m*/ if (v == null || v.getId() == R.id.empty_row) v = inflater.inflate(R.layout.row_layer, null); if (layer instanceof NGWLookupTable || layer instanceof NGWTrackLayer) return inflater.inflate(R.layout.row_empty, null); final ILayerUI layerui; if (layer == null) { return v; } else if (layer instanceof ILayerUI) { layerui = (ILayerUI) layer; } else { layerui = null; } ImageView ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(layerui != null ? layerui.getIcon(mContext) : null); TextView tvPaneName = (TextView) v.findViewById(R.id.tvLayerName); tvPaneName.setText(layer.getName()); //final int id = layer.getId(); final ImageButton btMore = (ImageButton) v.findViewById(R.id.btMore); ImageButton btShow = (ImageButton) v.findViewById(R.id.btShow); ImageView ivEdited = (ImageView) v.findViewById(R.id.ivEdited); boolean hide = layerui instanceof VectorLayer && ((VectorLayer) layerui).isLocked(); btMore.setVisibility(hide ? View.GONE : View.VISIBLE); btShow.setVisibility(hide ? View.GONE : View.VISIBLE); ivEdited.setVisibility(hide ? View.VISIBLE : View.GONE); if (mOnPencilClickListener != null) ivEdited.setOnClickListener(mOnPencilClickListener); int[] attrs = new int[] { R.attr.ic_action_visibility_on, R.attr.ic_action_visibility_off }; TypedArray ta = mContext.obtainStyledAttributes(attrs); Drawable visibilityOn = ta.getDrawable(0); Drawable visibilityOff = ta.getDrawable(1); if (layer instanceof Layer) { btShow.setImageDrawable(//setImageResource( ((Layer) layer).isVisible() ? visibilityOn : visibilityOff); //btShow.refreshDrawableState(); btShow.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { //Layer layer = mMap.getLayerById(id); ((Layer) layer).setVisible(!((Layer) layer).isVisible()); layer.save(); } }); } ta.recycle(); btMore.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { PopupMenu popup = new PopupMenu(mContext, btMore); popup.getMenuInflater().inflate(R.menu.layer_popup, popup.getMenu()); if (layerui == null) { popup.getMenu().findItem(R.id.menu_settings).setEnabled(false); popup.getMenu().findItem(R.id.menu_share).setEnabled(false); } if (layer instanceof VectorLayerUI) popup.getMenu().findItem(R.id.menu_send_to_ngw).setVisible(true); if (layerui instanceof TrackLayer) { popup.getMenu().findItem(R.id.menu_delete).setVisible(false); popup.getMenu().findItem(R.id.menu_settings).setTitle(R.string.track_list); List<ILayer> tracks = new ArrayList<>(); LayerGroup.getLayersByType(mMap, LAYERTYPE_NGW_TRACKS, tracks); popup.getMenu().findItem(R.id.menu_share).setVisible(true); mTracksSyncEnabled = tracks.size() > 0; int title = mTracksSyncEnabled ? R.string.sync_disable : R.string.sync; popup.getMenu().findItem(R.id.menu_share).setTitle(title); } else if (layerui instanceof VectorLayer) { popup.getMenu().findItem(R.id.menu_edit).setVisible(true); popup.getMenu().findItem(R.id.menu_share).setVisible(true); popup.getMenu().findItem(R.id.menu_zoom_extent).setVisible(true); popup.getMenu().findItem(R.id.menu_download_tiles).setVisible(true); popup.getMenu().findItem(R.id.menu_download_tiles).setTitle(R.string.attributes); } else if (layerui instanceof LocalTMSLayer) { popup.getMenu().findItem(R.id.menu_zoom_extent).setVisible(true); } else if (layerui instanceof NGWRasterLayer) { popup.getMenu().findItem(R.id.menu_zoom_extent).setVisible(true); popup.getMenu().findItem(R.id.menu_download_tiles).setVisible(true); } else if (layerui instanceof RemoteTMSLayer) { popup.getMenu().findItem(R.id.menu_download_tiles).setVisible(true); } if (layerui instanceof NGWWebMapLayerUI) { popup.getMenu().findItem(R.id.menu_zoom_extent).setVisible(false); popup.getMenu().findItem(R.id.menu_edit).setVisible(true); popup.getMenu().findItem(R.id.menu_edit).setTitle(R.string.sync_layers); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.menu_settings) { assert layerui != null; layerui.changeProperties(mContext); } else if (i == R.id.menu_share) { assert layerui != null; if (layerui instanceof TrackLayerUI) { // handleTrackSync(); Toast.makeText(mContext, R.string.commercial, Toast.LENGTH_SHORT).show(); return true; } else if (layerui instanceof VectorLayer) { VectorLayer vectorLayer = (VectorLayer) layerui; LayerUtil.shareLayerAsGeoJSON(mActivity, vectorLayer); } } else if (i == R.id.menu_edit) { if (layerui instanceof NGWWebMapLayerUI) ((NGWWebMapLayerUI) layerui).showLayersDialog(mMapView, mActivity); else if (mEditListener != null) mEditListener.onLayerEdit(layer); } else if (i == R.id.menu_delete) { return deleteLayer(layer); } else if (i == R.id.menu_zoom_extent) { mMap.zoomToExtent(layer.getExtents()); } else if (i == R.id.menu_download_tiles) { GeoEnvelope env = mMap.getCurrentBounds(); if (layer instanceof RemoteTMSLayerUI) { RemoteTMSLayerUI remoteTMSLayer = (RemoteTMSLayerUI) layer; remoteTMSLayer.downloadTiles(mContext, env); } else if (layer instanceof NGWRasterLayerUI) { NGWRasterLayerUI remoteTMSLayer = (NGWRasterLayerUI) layer; remoteTMSLayer.downloadTiles(mContext, env); } else if (layer instanceof NGWWebMapLayerUI) { NGWWebMapLayerUI remoteTMSLayer = (NGWWebMapLayerUI) layer; remoteTMSLayer.downloadTiles(mContext, env); } else if (layer instanceof IVectorLayerUI) { IVectorLayerUI vectorLayerUI = (IVectorLayerUI) layer; vectorLayerUI.showAttributes(); } } else if (i == R.id.menu_send_to_ngw) { if (layer instanceof VectorLayerUI) ((VectorLayerUI) layer).sendToNGW(mActivity); } if (mDrawer != null) mDrawer.closeDrawers(); return true; } }); popup.show(); } }); return v; }
From source file:com.handpoint.headstart.client.ui.ReceiptActivity.java
/** Called when the activity is first created. */ @Override//from w w w . j a v a 2s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.receipt); long transactionId = getIntent().getLongExtra(EXTRA_TRANSACTION_ID, -1); if (transactionId == -1) { finish(); return; } DaoHelper daoHelper = new DaoHelper(this); daoHelper.open(false); mResult = daoHelper.getFinancialTransaction(transactionId); Basket basket = daoHelper.getBasketByTransaction(transactionId); if (null != basket) { mBasketItem = daoHelper.getBasketItem(basket.getId()); } daoHelper.close(); Button buttonDone = (Button) findViewById(R.id.bottom_button); buttonDone.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); mRevertButton = (Button) findViewById(R.id.revert_button); if ((mResult.getType() == FinancialTransactionResult.FT_TYPE_SALE || mResult.getType() == FinancialTransactionResult.FT_TYPE_REFUND) && null != mResult.getTransactionId() && mResult.getTransactionId().length() > 0 && mResult.getTransactionStatus() == TransactionStatus.EFT_TRANSACTION_APPROVED && 0 == mResult.getVoidedId()) { mRevertButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent startVoidIntent = new Intent(HeadstartService.ACTION_MAIN); startVoidIntent.putExtra(HeadstartService.EXTRA_OPERATION_TYPE, mResult.getType() == FinancialTransactionResult.FT_TYPE_SALE ? FinancialTransactionResult.FT_TYPE_SALE_VOID : FinancialTransactionResult.FT_TYPE_REFUND_VOID); startVoidIntent.putExtra(HeadstartService.EXTRA_PAYMENT_VALUE, mResult.getAuthorizedAmount()); startVoidIntent.putExtra(HeadstartService.EXTRA_PAYMENT_CURRENCY, mResult.getCurrency()); startVoidIntent.putExtra(HeadstartService.EXTRA_PAYMENT_TRANSACTION_ID, mResult.getTransactionId()); startVoidIntent.putExtra("com.handpoint.headstart.client.VOIDED_ID", mResult.getId()); startActivity(startVoidIntent); finish(); } }); } else { mRevertButton.setVisibility(View.GONE); } mDetailsButton = (Button) findViewById(R.id.details_button); if (!TextUtils.isEmpty(mResult.getMerchantReceipt()) || !TextUtils.isEmpty(mResult.getCustomerReceipt())) { mDetailsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ReceiptActivity.this, RawReceiptActivity.class); intent.putExtra("merchantReceipt", mResult.getMerchantReceipt()); intent.putExtra("customerReceipt", mResult.getCustomerReceipt()); intent.putExtra("signatureVerificationText", mResult.getSignatureVerificationText()); intent.putExtra("signatureImage", mResult.getSignaturePath()); startActivity(intent); } }); } else { mDetailsButton.setVisibility(View.GONE); } initReceiptView(); final ImageView sendEmailView = (ImageView) findViewById(R.id.email_send_image); mEmailView = (EditText) findViewById(R.id.email_address); final ImageView sendSmsView = (ImageView) findViewById(R.id.sms_send_image); mSmsView = (EditText) findViewById(R.id.sms_address); sendEmailView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { hideSoftKeyboard(mEmailView); mPdfDlg = new ProgressDialog(v.getContext()); mPdfDlg.setMessage(getString(R.string.pdf_dlg_msg)); mPdfDlg.setTitle(getString(R.string.pdf_dlg_title)); mPdfDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER); mPdfDlg.setCancelable(true); mPdfDlg.show(); new Thread(new Runnable() { public void run() { ArrayList<File> attachments = null; try { Thread.sleep(1000); attachments = getCustomerEmailAttachments(); } catch (InterruptedException e) { e.printStackTrace(); } if (attachments != null) { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } mPdfDlg.dismiss(); SenderHelper.MerchantEmailServerSettings serverSettings = new SenderHelper.MerchantEmailServerSettings( ReceiptActivity.this); SendAsyncTask sendTask = new SendAsyncTask(); sendTask.execute(new EmailDataHolder(ReceiptActivity.this, serverSettings, mEmailView.getText().toString(), new SpannableString(""), attachments, EmailTypes.CUSTOMER)); } } }).start(); } }); sendSmsView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { hideSoftKeyboard(mSmsView); SenderHelper.sendReceiptSms(ReceiptActivity.this, mSmsView.getText().toString(), mResult); //mark customer receipt as "copy" markCustomerReceiptAsCopied(ReceiptActivity.this, mResult); } }); if (getIntent().getBooleanExtra(EXTRA_SEND_MERCHANT_RECEIPT, false) && savedInstanceState == null) { sendMerchantReceipt(); } // repeat image bug fix // View background = findViewById(R.id.rootLayout); // ((BitmapDrawable)background.getBackground()).setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); // getSupportActionBar().setTitle(R.string.abs_title); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); }