List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);/*www . ja v a 2 s. c om*/ Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); //JSONObject j_artist_info = j.getJSONObject("artist"); final String artist_name = j.getString("name"); tArtistName.setText(artist_name); final JSONObject urls = j.optJSONObject("urls"); final JSONArray videos = j.optJSONArray("video"); final JSONArray images = j.optJSONArray("images"); final String msg = artist_name.replaceAll("\\p{Punct}", " ").replaceAll("\\p{Space}", "+"); AsyncHttpClient client = new AsyncHttpClient(); String fmURL = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + msg + "&autocorrect[1]&format=json&api_key=ca4c10f9ae187ebb889b33ba12da7ee9"; Log.i("musicInfo", fmURL); client.get(fmURL, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { String r = new String(responseBody); ArrayList<String> image_urls = new ArrayList<String>(); try { Log.i("musicInfo", "Communicating with LastFM..."); JSONObject json = new JSONObject(r); Log.i("musicInfo", json.toString()); json = json.getJSONObject("artist"); Log.i("musicInfo", json.toString()); JSONArray artist_images = json.optJSONArray("image"); Log.i("musicInfo", artist_images.toString()); for (int i = 0; i < artist_images.length(); i++) { JSONObject j = artist_images.getJSONObject(i); Log.i("musicInfo", j.optString("size")); if (j.optString("size").contains("extralarge")) { image_urls.add(j.optString("#text")); //b.putString("fm_image", j.getString("#text")); //Log.i("musicInfo", j.getString("#text")); break; } } } catch (JSONException e) { e.printStackTrace(); } if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = null; try { image = images.getJSONObject(i); } catch (JSONException e) { e.printStackTrace(); } int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); Log.i("musicInfo", "Total image#=" + image_urls.size() + " Selected image#=" + random + " " + f_url); if (image_urls.size() > 0) { imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } else { ArtistImage.setImageResource(R.drawable.lamb_no_image_available); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { } }); }
From source file:org.sirimangalo.meditationplus.AdapterMed.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;/*from w ww . ja v a2 s . c o m*/ if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.list_item_med, parent, false); } else { rowView = convertView; } JSONObject p = values.get(position); TextView walk = (TextView) rowView.findViewById(R.id.one_walking); TextView sit = (TextView) rowView.findViewById(R.id.one_sitting); ImageView status = (ImageView) rowView.findViewById(R.id.one_status); TextView name = (TextView) rowView.findViewById(R.id.one_med); ImageView flag = (ImageView) rowView.findViewById(R.id.one_flag); View anuView = rowView.findViewById(R.id.anumodana_shell); TextView anuText = (TextView) rowView.findViewById(R.id.anumodana); try { String wo = p.getString("walking"); String so = p.getString("sitting"); int wi = Integer.parseInt(wo); int si = Integer.parseInt(so); int ti = Integer.parseInt(p.getString("start")); int ei = Integer.parseInt(p.getString("end")); long nowL = System.currentTimeMillis() / 1000; int now = (int) nowL; boolean finished = false; String ws = "0"; String ss = "0"; if (ei > now) { float secs = now - ti; if (secs > wi * 60 || wi == 0) { //walking done float ssecs = (int) (secs - (wi * 60)); if (ssecs < si * 60) // still sitting ss = Integer.toString((int) Math.floor(si - ssecs / 60)); status.setImageResource(R.drawable.sitting_icon); } else { // still walking ws = Integer.toString((int) Math.floor(wi - secs / 60)); ss = so; status.setImageResource(R.drawable.walking_icon); } ws += "/" + wo; ss += "/" + so; } else { ws = wo; ss = so; double age = 1 - (now - ei) / MAX_AGE; String ageColor = Integer.toHexString((int) (255 * age)); if (ageColor.length() == 1) ageColor = "0" + ageColor; int alpha = Color.parseColor("#" + ageColor + "000000"); walk.setTextColor(alpha); sit.setTextColor(alpha); name.setTextColor(alpha); status.setAlpha((float) age); flag.setAlpha((float) age); } walk.setText(ws); sit.setText(ss); if (p.has("country")) { int id = context.getResources().getIdentifier("flag_" + p.getString("country").toLowerCase(), "drawable", context.getPackageName()); flag.setImageResource(id); flag.setVisibility(View.VISIBLE); } final String username = p.getString("username"); final String edit = p.getString("can_edit"); name.setText(username); name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { context.showProfile(username); } }); String type = p.getString("type"); if ("love".equals(type)) status.setImageResource(R.drawable.love_icon); String anu = p.getString("anumodana"); if (!anu.equals("0")) anuText.setText(anu); if (p.getString("anu_me").equals("1")) { anuText.setTextColor(0xFF00BB00); anuText.setTypeface(null, Typeface.BOLD); } final String sid = p.getString("sid"); anuView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "anu clicked"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String loggedUsername = prefs.getString("username", ""); String loginToken = prefs.getString("login_token", ""); ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("form_id", "anumed_" + sid)); nvp.add(new BasicNameValuePair("login_token", loginToken)); nvp.add(new BasicNameValuePair("submit", "Refresh")); nvp.add(new BasicNameValuePair("username", loggedUsername)); nvp.add(new BasicNameValuePair("source", "android")); PostTaskRunner postTask = new PostTaskRunner(postHandler, context); postTask.doPostTask(nvp); } }); } catch (Exception e) { e.printStackTrace(); } return rowView; }
From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.poi.PoiDetailsFragment.java
@Override public void onStart() { super.onStart(); if (getPOI() != null) { ImageView certifiedIcon = (ImageView) this.getView().findViewById(R.id.poi_details_icon); ImageView bannerCertifiedIcon = (ImageView) this.getView().findViewById(R.id.banner_certified); Drawable icon = null;/*from ww w.ja v a 2 s . com*/ if (CategoryHelper.CAT_POI_FAMILY_IN_TRENTINO.equals(mPoi.getType())) { icon = POIHelper.getDrawablePoiFamilyTrentinoDetail(getActivity(), mPoi); bannerCertifiedIcon.setVisibility(View.VISIBLE); } else if (CategoryHelper.CAT_POI_FAMILY_AUDIT.equals(mPoi.getType())) { icon = POIHelper.getDrawablePoiFamilyAuditDetail(getActivity(), mPoi); bannerCertifiedIcon.setVisibility(View.VISIBLE); } certifiedIcon.setImageDrawable(icon); // title TextView tv = (TextView) this.getView().findViewById(R.id.poi_details_title); tv.setText(mPoi.getTitle()); /* * BUTTONS */ // map ImageButton mapBtn = (ImageButton) getView().findViewById(R.id.poidetails_map); mapBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ArrayList<BaseDTObject> list = new ArrayList<BaseDTObject>(); list.add(mPoi); MapManager.switchToMapView(list, mFragment); } }); // directions ImageButton directionsBtn = (ImageButton) getView().findViewById(R.id.poidetails_directions); directionsBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Address to = Utils.getPOIasGoogleAddress(mPoi); Address from = null; GeoPoint mylocation = MapManager.requestMyLocation(getActivity()); if (mylocation != null) { from = new Address(Locale.getDefault()); from.setLatitude(mylocation.getLatitudeE6() / 1E6); from.setLongitude(mylocation.getLongitudeE6() / 1E6); } DTHelper.bringmethere(getActivity(), from, to); } }); if (mPoi.getLocation()[0] == 0 && mPoi.getLocation()[1] == 0) { mapBtn.setVisibility(View.INVISIBLE); directionsBtn.setVisibility(View.GONE); } /* * END BUTTONS */ // description, optional tv = (TextView) this.getView().findViewById(R.id.poi_details_descr); String customDesc = POIHelper.customDescription(mPoi, getActivity()); if (customDesc != null && customDesc.length() > 0) { tv.setText(Html.fromHtml(customDesc)); } else { ((LinearLayout) this.getView().findViewById(R.id.poidetails)).removeView(tv); } // // notes // tv = (TextView) this.getView().findViewById(R.id.poi_details_notes); // ((LinearLayout) this.getView().findViewById(R.id.poidetails)).removeView(tv); // location tv = (TextView) this.getView().findViewById(R.id.poi_details_loc); tv.setText(Html.fromHtml("<a href=\"\">" + Utils.getPOIshortAddress(mPoi) + "</a> ")); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ArrayList<BaseDTObject> list = new ArrayList<BaseDTObject>(); list.add(mPoi); MapManager.switchToMapView(list, PoiDetailsFragment.this); } }); commentsHandler = new CommentsHandler(getPOI(), getActivity(), getView()); } }
From source file:com.android.leanlauncher.Workspace.java
private void addAllAppsIcon() { // Add the Apps button LayoutInflater inflater = LayoutInflater.from(getContext()); TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mWorkspace, false); Drawable d = getResources().getDrawable(R.drawable.all_apps_button_icon); Utilities.resizeIconDrawable(d); allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setContentDescription(getResources().getString(R.string.all_apps_button_label)); mLauncher.setAllAppsButton(allAppsButton); allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); allAppsButton.setOnClickListener(mLauncher); CellLayout.LayoutParams lp = new CellLayout.LayoutParams((mWorkspace.getCountX() - 1) / 2, mWorkspace.getCountY() - 1, 1, 1); lp.canReorder = false;/*from ww w . j a v a 2 s .com*/ mWorkspace.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true); }
From source file:com.filemanager.free.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String f = null;//from w ww. ja v a 2 s . com Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); f = fragment.getClass().getName(); } catch (Exception e1) { return true; } if (f.contains("TabFragment")) { setActionBarTitle("File Manager"); if (aBoolean) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; Main ma = ((Main) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception ignored) { } initiatebbar(); if (Build.VERSION.SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.item10).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (f.contains("AppsList") || f.contains("ProcessViewer")) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (f.contains("ProcessViewer")) menu.findItem(R.id.item10).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (f.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.item10).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.igniva.filemanager.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String f = null;//from www . j a va 2 s.c o m Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); f = fragment.getClass().getName(); } catch (Exception e1) { return true; } if (f.contains("TabFragment")) { setActionBarTitle("Filemanager"); if (aBoolean) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; Main ma = ((Main) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception e) { } initiatebbar(); if (Build.VERSION.SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.item10).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (f.contains("AppsList") || f.contains("ProcessViewer") || f.contains(FTPServerFragment.class.getName())) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (f.contains("ProcessViewer")) menu.findItem(R.id.item10).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (f.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.item10).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.amaze.filemanager.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem s = menu.findItem(R.id.view); MenuItem search = menu.findItem(R.id.search); MenuItem paste = menu.findItem(R.id.paste); String f = null;//w ww .j a va2 s . co m Fragment fragment; try { fragment = getSupportFragmentManager().findFragmentById(R.id.content_frame); f = fragment.getClass().getName(); } catch (Exception e1) { return true; } if (f.contains("TabFragment")) { setActionBarTitle("Amaze"); if (aBoolean) { s.setTitle(getResources().getString(R.string.gridview)); } else { s.setTitle(getResources().getString(R.string.listview)); } try { TabFragment tabFragment = (TabFragment) fragment; Main ma = ((Main) tabFragment.getTab()); if (ma.IS_LIST) s.setTitle(R.string.gridview); else s.setTitle(R.string.listview); updatePath(ma.CURRENT_PATH, ma.results, ma.openMode, ma.folder_count, ma.file_count); } catch (Exception e) { } initiatebbar(); if (Build.VERSION.SDK_INT >= 21) toolbar.setElevation(0); invalidatePasteButton(paste); search.setVisible(true); if (indicator_layout != null) indicator_layout.setVisibility(View.VISIBLE); menu.findItem(R.id.search).setVisible(true); menu.findItem(R.id.home).setVisible(true); menu.findItem(R.id.history).setVisible(true); menu.findItem(R.id.sethome).setVisible(true); menu.findItem(R.id.item10).setVisible(true); if (showHidden) menu.findItem(R.id.hiddenitems).setVisible(true); menu.findItem(R.id.view).setVisible(true); menu.findItem(R.id.extract).setVisible(false); invalidatePasteButton(menu.findItem(R.id.paste)); findViewById(R.id.buttonbarframe).setVisibility(View.VISIBLE); } else if (f.contains("AppsList") || f.contains("ProcessViewer")) { appBarLayout.setExpanded(true); menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); findViewById(R.id.buttonbarframe).setVisibility(View.GONE); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.extract).setVisible(false); if (f.contains("ProcessViewer")) menu.findItem(R.id.item10).setVisible(false); else { menu.findItem(R.id.dsort).setVisible(false); menu.findItem(R.id.sortby).setVisible(false); } menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); } else if (f.contains("ZipViewer")) { menu.findItem(R.id.sethome).setVisible(false); if (indicator_layout != null) indicator_layout.setVisibility(View.GONE); TextView textView = (TextView) mainActivity.pathbar.findViewById(R.id.fullpath); pathbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); menu.findItem(R.id.search).setVisible(false); menu.findItem(R.id.home).setVisible(false); menu.findItem(R.id.history).setVisible(false); menu.findItem(R.id.item10).setVisible(false); menu.findItem(R.id.hiddenitems).setVisible(false); menu.findItem(R.id.view).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.extract).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:it.chefacile.app.MainActivity.java
public void checkButtonSave(final TextView tv, boolean checked, final String ingredient) { boolean control = checked; if (control) { listIngredientsPREF = chefacileDb.getDataInListIngredientPREF(); /* if (chefacileDb.findIngredient(ingredient)) chefacileDb.decrementedId(ingredient);*/ if (chefacileDb.getNumberIngredients() > 3) { chefacileDb.deleteDataIngredient(ingredient); mapIngredients = chefacileDb.getDataInMapIngredient(); mapIngredients = sortByValue(mapIngredients); Log.d("MapVerifica:", mapIngredients.toString()); } else if (chefacileDb.getNumberIngredients() == 3) { String n = addRandomIngredient(); if (!n.equals(ingredient)) { chefacileDb.deleteDataIngredient(ingredient); chefacileDb.insertDataIngredient(n); mapIngredients = chefacileDb.getDataInMapIngredient(); mapIngredients = sortByValue(mapIngredients); Log.d("MapVerificaNOWhile:", mapIngredients.toString()); } else { while (n.equals(ingredient) || chefacileDb.findIngredient(n)) { n = addRandomIngredient(); }//from ww w . j a v a 2s . c o m chefacileDb.deleteDataIngredient(ingredient); chefacileDb.insertDataIngredient(n); mapIngredients = chefacileDb.getDataInMapIngredient(); mapIngredients = sortByValue(mapIngredients); Log.d("MapVerificaWhile:", mapIngredients.toString()); } } Log.d("LISTA PREFERITI: ", listIngredientsPREF.toString()); Log.d("DOPO ELIM PER PREF:", mapIngredients.toString()); tv.setText("Unsave"); Toast.makeText(mContext, "Ingredient added to favourites", Toast.LENGTH_LONG).show(); control = false; final boolean finalControl = control; tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { chefacileDb.deleteDataIngredientPREF(ingredient); chefacileDb.insertDataIngredient(ingredient); tv.setText("Save"); checkButtonSave(tv, finalControl, ingredient); } }); } else { tv.setText("Save"); Toast.makeText(mContext, "Ingredient removed from favourites", Toast.LENGTH_LONG).show(); control = true; final boolean finalControl = control; tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { chefacileDb.insertDataIngredientPREF(ingredient); chefacileDb.deleteDataIngredient(ingredient); tv.setText("Unsave"); checkButtonSave(tv, finalControl, ingredient); } }); } }
From source file:it.sasabz.android.sasabus.fragments.OnlineSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.inflater_glob = inflater; result = inflater.inflate(R.layout.online_search_layout, container, false); Date datum = new Date(); SimpleDateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm"); TextView datetime = (TextView) result.findViewById(R.id.time); String datetimestring = ""; datetimestring = simple.format(datum); datetime.setText(datetimestring);/* ww w . j a va2 s .com*/ Button search = (Button) result.findViewById(R.id.search); search.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AutoCompleteTextView from = (AutoCompleteTextView) result.findViewById(R.id.from_text); AutoCompleteTextView to = (AutoCompleteTextView) result.findViewById(R.id.to_text); TextView datetime = (TextView) result.findViewById(R.id.time); String from_txt = getThis().getResources().getString(R.string.from_txt); if ((!from.getText().toString().trim().equals("") || !from.getHint().toString().trim().equals(from_txt)) && !to.getText().toString().trim().equals("")) { //Intent getSelect = new Intent(getThis().getActivity(), OnlineSelectStopActivity.class); String fromtext = ""; if (from.getText().toString().trim().equals("")) fromtext = from.getHint().toString(); else fromtext = from.getText().toString(); String totext = to.getText().toString(); fromtext = "(" + fromtext.replace(" -", ")"); totext = "(" + totext.replace(" -", ")"); Fragment fragment = new OnlineSelectFragment(fromtext, totext, datetime.getText().toString()); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); Fragment old = fragmentManager.findFragmentById(R.id.onlinefragment); if (old != null) { ft.remove(old); } ft.add(R.id.onlinefragment, fragment); ft.addToBackStack(null); ft.commit(); fragmentManager.executePendingTransactions(); } } }); datetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); ImageButton datepicker = (ImageButton) result.findViewById(R.id.datepicker); datepicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create the dialog final Dialog mDateTimeDialog = new Dialog(getThis().getActivity()); // Inflate the root layout final RelativeLayout mDateTimeDialogView = (RelativeLayout) inflater_glob .inflate(R.layout.date_time_dialog, null); // Grab widget instance final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView .findViewById(R.id.DateTimePicker); TextView dt = (TextView) result.findViewById(R.id.time); String datetimestring = dt.getText().toString(); SimpleDateFormat datetimeformat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date datetime = null; try { datetime = datetimeformat.parse(datetimestring); } catch (Exception e) { ; } mDateTimePicker.updateTime(datetime.getHours(), datetime.getMinutes()); mDateTimePicker.updateDate(datetime.getYear() + 1900, datetime.getMonth(), datetime.getDate()); // Check is system is set to use 24h time (this doesn't seem to // work as expected though) final String timeS = android.provider.Settings.System.getString( getThis().getActivity().getContentResolver(), android.provider.Settings.System.TIME_12_24); final boolean is24h = !(timeS == null || timeS.equals("12")); // Update demo TextViews when the "OK" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mDateTimePicker.clearFocus(); String datetimestring = ""; int day = mDateTimePicker.get(Calendar.DAY_OF_MONTH); int month = mDateTimePicker.get(Calendar.MONTH) + 1; int year = mDateTimePicker.get(Calendar.YEAR); int hour = 0; int min = 0; int append = 0; if (mDateTimePicker.is24HourView()) { hour = mDateTimePicker.get(Calendar.HOUR_OF_DAY); min = mDateTimePicker.get(Calendar.MINUTE); } else { hour = mDateTimePicker.get(Calendar.HOUR); min = mDateTimePicker.get(Calendar.MINUTE); if (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM) { append = 1; } else { append = 2; } } if (day < 10) { datetimestring += "0"; } datetimestring += (day + "."); if (month < 10) { datetimestring += "0"; } datetimestring += (month + "." + year + " "); if (hour < 10) { datetimestring += "0"; } datetimestring += (hour + ":"); if (min < 10) { datetimestring += "0"; } datetimestring += min; switch (append) { case 1: datetimestring += " AM"; break; case 2: datetimestring += " PM"; break; } TextView time = (TextView) result.findViewById(R.id.time); time.setText(datetimestring); mDateTimeDialog.dismiss(); } }); // Cancel the dialog when the "Cancel" button is clicked ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimeDialog.cancel(); } }); // Reset Date and Time pickers when the "Reset" button is // clicked ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime)) .setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mDateTimePicker.reset(); } }); // Setup TimePicker mDateTimePicker.setIs24HourView(is24h); // No title on the dialog window mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the dialog content view mDateTimeDialog.setContentView(mDateTimeDialogView); // Display the dialog mDateTimeDialog.show(); } }); from = (AutoCompleteTextView) result.findViewById(R.id.from_text); to = (AutoCompleteTextView) result.findViewById(R.id.to_text); from.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); } }); to.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } }); LocationManager locman = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE); Location lastloc = locman.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (MySQLiteDBAdapter.exists(this.getActivity())) { if (lastloc == null) { lastloc = locman.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } if (lastloc != null) { try { Palina palina = PalinaList.getPalinaGPS(lastloc); if (palina != null) { from.setHint(palina.toString()); } } catch (Exception e) { Log.e("HomeActivity", "Fehler bei der Location", e); } } else { Log.v("HomeActivity", "No location found!!"); } Vector<DBObject> palinalist = PalinaList.getNameList(); MyAutocompleteAdapter adapterfrom = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); MyAutocompleteAdapter adapterto = new MyAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, palinalist); from.setAdapter(adapterfrom); to.setAdapter(adapterto); InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(from.getWindowToken(), 0); mgr.hideSoftInputFromWindow(to.getWindowToken(), 0); } Button favorites = (Button) result.findViewById(R.id.favorites); favorites.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SelectFavoritenDialog dialog = new SelectFavoritenDialog(getThis()); dialog.show(); } }); Button mappicker = (Button) result.findViewById(R.id.map); mappicker.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MapSelectActivity.class); startActivityForResult(intent, REQUESTCODE_ACTIVITY); } }); return result; }
From source file:de.blinkt.openvpn.ActivityServerList.java
private void makeAvaiableServer() { linearAvailableServers.removeAllViews(); for (int i = 0; i < mServerList.size(); i++) { final String server = mServerList.get(i); View viewItem = LayoutInflater.from(this).inflate(R.layout.itemserver, linearSelectedServer, false); ImageView imgViewFlag = (ImageView) viewItem.findViewById(R.id.imgViewFlag); TextView txtCountry = (TextView) viewItem.findViewById(R.id.txtViewCountryName); final ImageView imgFavorite = (ImageView) viewItem.findViewById(R.id.imgFavorite); if (!spGlobal.getBoolean(server, false)) { imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_unfavorite", null, getPackageName())); imgFavorite.setOnClickListener(new View.OnClickListener() { @Override//from w w w . j a v a 2 s. com public void onClick(View v) { edGlobal.putBoolean(server, true); edGlobal.commit(); imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_favorite", null, getPackageName())); makeFavoriteServer(); } }); } else { imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_favorite", null, getPackageName())); imgFavorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { edGlobal.putBoolean(server, false); edGlobal.commit(); imgFavorite.setImageResource( getResources().getIdentifier("drawable/icon_unfavorite", null, getPackageName())); makeFavoriteServer(); } }); } imgViewFlag.setVisibility(View.GONE); for (int j = 0; j < countryList.length; j++) { String country = countryList[j]; if (server.toLowerCase().contains(country.toLowerCase())) { String resourceName = country.toLowerCase().replace(" ", "_"); int checkExistence = getResources().getIdentifier(resourceName, "drawable", getPackageName()); if (checkExistence != 0) { // the resouce exists... imgViewFlag.setVisibility(View.VISIBLE); imgViewFlag.setImageResource( getResources().getIdentifier("drawable/" + resourceName, null, getPackageName())); } break; } } txtCountry.setText(server); txtCountry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connected) || (ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) { if (ActivityDashboard.lolstring.equals(server)) { } else { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: dialog.dismiss(); ActivityDashboard.lolstring = server; if (VpnStatus.isVPNActive()) { if (ActivityDashboard.mService != null) { try { ActivityDashboard.mService.stopVPN(false); } catch (RemoteException e) { VpnStatus.logException(e); } } } ActivityDashboard.DISCONNECT_VPN_SERVERLIST = 1; finish(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this); if ((ActivityDashboard.m_status == ActivityDashboard.Status.Connecting)) { builder.setMessage( "Currently connecting to another VPN server. Are you sure you want to change the server?") .setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } else { builder.setMessage( "Currently connected to another VPN server. Are you sure you want to change the server?") .setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } } } else { ActivityDashboard.lolstring = server; finish(); } /*if(VpnStatus.isVPNActive() && ActivityDashboard.m_status.equals(Status.Connected) ) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: dialog.dismiss(); ActivityDashboard.lolstring = server; finish(); break; case DialogInterface.BUTTON_NEGATIVE: dialog.dismiss(); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ActivityServerList.this); builder.setMessage("Currently connected to another VPN server. Are you sure you want to change the server?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); }else{ ActivityDashboard.lolstring = server; finish(); }*/ } }); linearAvailableServers.addView(viewItem); } }