List of usage examples for android.view ViewGroup findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.google.android.apps.iosched.ui.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(/*from w w w. ja v a 2 s. c om*/ new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); mWebView = (WebView) root.findViewById(R.id.webview); mWebView.setWebChromeClient(mWebChromeClient); mWebView.setWebViewClient(mWebViewClient); mWebView.post(new Runnable() { public void run() { // Initialize web view if (CLEAR_CACHE_ON_LOAD) { mWebView.clearCache(true); } mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); mWebView.loadUrl(MAP_URL); mWebView.addJavascriptInterface(mMapJsiImpl, MAP_JSI_NAME); } }); return root; }
From source file:com.mchp.android.PIC32_BTSK.ColorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); // Inflate the layout for this fragment ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_color, container, false); // Get each UI object from the layout mSeekBarR = (SeekBar) rootView.findViewById(R.id.seekR); mSeekBarG = (SeekBar) rootView.findViewById(R.id.seekG); mSeekBarB = (SeekBar) rootView.findViewById(R.id.seekB); mProgressTextR = (TextView) rootView.findViewById(R.id.progressR); mProgressTextG = (TextView) rootView.findViewById(R.id.progressG); mProgressTextB = (TextView) rootView.findViewById(R.id.progressB); mDownR = (Button) rootView.findViewById(R.id.red_down); mUpR = (Button) rootView.findViewById(R.id.red_up); mDownG = (Button) rootView.findViewById(R.id.green_down); mUpG = (Button) rootView.findViewById(R.id.green_up); mDownB = (Button) rootView.findViewById(R.id.blue_down); mUpB = (Button) rootView.findViewById(R.id.blue_up); mColorPicker = (ColorPickerView) rootView.findViewById(R.id.color_picker_view); mNewColor = (ColorPickerPanelView) rootView.findViewById(R.id.new_color_panel); // Set the maximum value for each seekbar mSeekBarR.setMax(seekBarMax);//from ww w . ja v a 2s . co m mSeekBarG.setMax(seekBarMax); mSeekBarB.setMax(seekBarMax); // Initialize the states of the UI objects setSeekBarProgress(); setProgressText(); mDownR.setText("-"); mUpR.setText("+"); mDownG.setText("-"); mUpG.setText("+"); mDownB.setText("-"); mUpB.setText("+"); mColor = Color.rgb(r, g, b); mColorPicker.setColor(mColor); mNewColor.setColor(mColor); // Set listeners for the UI objects mSeekBarR.setOnSeekBarChangeListener(this); mSeekBarG.setOnSeekBarChangeListener(this); mSeekBarB.setOnSeekBarChangeListener(this); mDownR.setOnClickListener(this); mUpR.setOnClickListener(this); mDownG.setOnClickListener(this); mUpG.setOnClickListener(this); mDownB.setOnClickListener(this); mUpB.setOnClickListener(this); mColorPicker.setOnColorChangedListener(this); // Define a touch listener for the color picker. When released, it sends the color // command with the current color. mColorPicker.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); switch (action) { case MotionEvent.ACTION_UP: sendLastColorLedCmd(r, g, b); return true; default: return false; } } }); // Define a touch listener for the color panel. When pressed, its transparency // changes to indicate that it has been pressed. When released, it sends the color // command with the current color. mNewColor.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); switch (action) { case MotionEvent.ACTION_DOWN: try { mNewColor.setAlpha((float) 0.5); } catch (NoSuchMethodError e) { } return true; case MotionEvent.ACTION_UP: try { mNewColor.setAlpha((float) 1.0); } catch (NoSuchMethodError e) { } sendLedCmd(r, g, b); return true; default: return false; } } }); // Return the layout for this fragment return rootView; }
From source file:com.aniruddhc.acemusic.player.NowPlayingActivity.PlaylistPagerFlippedFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_playlist_pager_flipped, container, false);//from w w w . j av a 2 s . com mContext = getActivity().getApplicationContext(); mApp = (Common) mContext; ratingBar = (RatingBar) rootView.findViewById(R.id.playlist_pager_flipped_rating_bar); lyricsRelativeLayout = (RelativeLayout) rootView.findViewById(R.id.lyricsRelativeLayout); lyricsTextView = (TextView) rootView.findViewById(R.id.playlist_pager_flipped_lyrics); headerTextView = (TextView) rootView.findViewById(R.id.playlist_pager_flipped_title); noLyricsFoundText = (TextView) rootView.findViewById(R.id.no_embedded_lyrics_found_text); lyricsTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); lyricsTextView .setPaintFlags(lyricsTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); headerTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); headerTextView .setPaintFlags(headerTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); noLyricsFoundText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); noLyricsFoundText.setPaintFlags( noLyricsFoundText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); lyricsRelativeLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View arg0) { //Fire a broadcast that notifies the PlaylistPager to update flip back to the album art. Intent intent = new Intent(broadcastMessage); intent.putExtra("MESSAGE", broadcastMessage); //Initialize the local broadcast manager. localBroadcastManager = LocalBroadcastManager.getInstance(mContext); localBroadcastManager.sendBroadcast(intent); return true; } }); //Get the file path of the current song. String updatedSongTitle = ""; String updatedSongArtist = ""; String songFilePath = ""; String songId = ""; MediaMetadataRetriever mmdr = new MediaMetadataRetriever(); tempCursor = mApp.getService().getCursor(); tempCursor.moveToPosition( mApp.getService().getPlaybackIndecesList().get(mApp.getService().getCurrentSongIndex())); if (tempCursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH) == -1) { //Retrieve the info from the file's metadata. songFilePath = tempCursor.getString(tempCursor.getColumnIndex(null)); mmdr.setDataSource(songFilePath); updatedSongTitle = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); updatedSongArtist = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); } else { /* Check if the cursor has the SONG_FILE_PATH column. If it does, we're dealing * with the SONGS table. If not, we're dealing with the PLAYLISTS table. We'll * retrieve data from the appropriate columns using this info. */ if (tempCursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH) == -1) { //We're dealing with the Playlists table. songFilePath = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.PLAYLIST_FILE_PATH)); mmdr.setDataSource(songFilePath); updatedSongTitle = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); updatedSongArtist = mmdr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); } else { //We're dealing with the songs table. songFilePath = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH)); updatedSongTitle = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_TITLE)); updatedSongArtist = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)); songId = tempCursor.getString(tempCursor.getColumnIndex(DBAccessHelper.SONG_ID)); } } headerTextView.setText(updatedSongTitle + " - " + updatedSongArtist); ratingBar.setStepSize(1); int rating = mApp.getDBAccessHelper().getSongRating(songId); ratingBar.setRating(rating); //Get the rating value for the song. AudioFile audioFile = null; File file = null; try { audioFile = null; file = new File(songFilePath); try { audioFile = AudioFileIO.read(file); } catch (CannotReadException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (org.jaudiotagger.tag.TagException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ReadOnlyFileException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InvalidAudioFrameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } try { final AudioFile finalizedAudioFile = audioFile; final String finalSongFilePath = songFilePath; final String finalSongId = songId; ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { //Change the rating in the DB and the actual audio file itself. Log.e("DEBUG", ">>>>>RATING: " + rating); try { Tag tag = finalizedAudioFile.getTag(); tag.addField(FieldKey.RATING, "" + ((int) rating)); } catch (KeyNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FieldDataInvalidException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); Log.e("DEBUG", ">>>>>>>RATING FIELD NOT FOUND"); } try { finalizedAudioFile.commit(); } catch (CannotWriteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } mApp.getDBAccessHelper().setSongRating(finalSongId, (int) rating); } }); //Check if the audio file has any embedded lyrics. String lyrics = null; try { Tag tag = audioFile.getTag(); lyrics = tag.getFirst(FieldKey.LYRICS); if (lyrics == null || lyrics.isEmpty()) { lyricsTextView.setVisibility(View.GONE); noLyricsFoundText.setVisibility(View.VISIBLE); return rootView; } //Since the song has embedded lyrics, display them in the layout. lyricsTextView.setVisibility(View.VISIBLE); noLyricsFoundText.setVisibility(View.GONE); lyricsTextView.setText(lyrics); } catch (Exception e) { e.printStackTrace(); lyricsTextView.setVisibility(View.GONE); noLyricsFoundText.setVisibility(View.VISIBLE); return rootView; } } catch (Exception e) { e.printStackTrace(); //Can't do much here. } return rootView; }
From source file:com.grokkingandroid.sampleapp.samples.data.contentprovider.about.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().setTitle(getResources().getString(R.string.cpsample_about)); View view = inflater.inflate(R.layout.fragment_about, container, false); ViewGroup libParent = (ViewGroup) view.findViewById(R.id.about_container); String[] libTitles = getResources().getStringArray(R.array.cpsample_about_titles); String[] libDescriptions = getResources().getStringArray(R.array.cpsample_about_contents); String libraryPlural = getResources().getQuantityString(R.plurals.cpsample_libraries_plural, libTitles.length);/*w w w . j ava2s . c om*/ String aboutText = getResources().getString(R.string.cpsample_about_text, libraryPlural); Spanned spannedAboutText = Html.fromHtml(aboutText); TextView aboutTv = (TextView) libParent.findViewById(R.id.about_text); aboutTv.setText(spannedAboutText); aboutTv.setMovementMethod(LinkMovementMethod.getInstance()); for (int i = 0; i < libTitles.length; i++) { View libContainer = inflater.inflate(R.layout.single_library_layout, libParent, false); TextView currLibTitle = (TextView) libContainer.findViewById(R.id.library_title); currLibTitle.setText(libTitles[i]); TextView currLibDesc = (TextView) libContainer.findViewById(R.id.library_text); Spanned spanned = Html.fromHtml(libDescriptions[i]); currLibDesc.setText(spanned); currLibDesc.setMovementMethod(LinkMovementMethod.getInstance()); libParent.addView(libContainer); } return view; }
From source file:com.ibox_ucsc.design.ui.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(// www . j a va 2 s . c o m new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); // here I can add the bitmap image of the floor plan mWebView = (WebView) root.findViewById(R.id.webview); mWebView.setWebChromeClient(mWebChromeClient); mWebView.setWebViewClient(mWebViewClient); mWebView.post(new Runnable() { public void run() { // Initialize web view if (CLEAR_CACHE_ON_LOAD) { mWebView.clearCache(true); } mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); mWebView.loadUrl(MAP_URL); mWebView.addJavascriptInterface(mMapJsiImpl, MAP_JSI_NAME); } }); return root; }
From source file:no.android.proxime.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);//from w ww. j a v a 2s .c om mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(action); mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:com.buddi.client.dfu.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);//from w ww.j ava2 s .c om mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:com.layer.atlas.cells.GeoCell.java
@Override public View onBind(final ViewGroup cellContainer) { ViewGroup cellRoot = (ViewGroup) Tools.findChildById(cellContainer, R.id.atlas_view_messages_cell_geo); if (cellRoot == null) { cellRoot = (ViewGroup) LayoutInflater.from(cellContainer.getContext()) .inflate(R.layout.atlas_view_messages_cell_geo, cellContainer, false); if (debug) Log.w(TAG, "geo.onBind() inflated geo cell"); }/*from w ww .j a va 2 s . c om*/ ImageView geoImageMy = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_my); ImageView geoImageTheir = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_their); View containerMy = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_my); View containerTheir = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_their); boolean myMessage = messagesList.getLayerClient().getAuthenticatedUserId() .equals(messagePart.getMessage().getSender().getUserId()); if (myMessage) { containerMy.setVisibility(View.VISIBLE); containerTheir.setVisibility(View.GONE); } else { containerMy.setVisibility(View.GONE); containerTheir.setVisibility(View.VISIBLE); } ImageView geoImage = myMessage ? geoImageMy : geoImageTheir; ShapedFrameLayout cellCustom = (ShapedFrameLayout) (myMessage ? containerMy : containerTheir); Object imageId = messagePart.getId(); Bitmap bmp = (Bitmap) Atlas.imageLoader.getImageFromCache(imageId); if (bmp != null) { if (debug) Log.d(TAG, "geo.onBind() bitmap: " + bmp.getWidth() + "x" + bmp.getHeight()); geoImage.setImageBitmap(bmp); } else { if (debug) Log.d(TAG, "geo.onBind() spec: " + spec); geoImage.setImageDrawable(Tools.EMPTY_DRAWABLE); // schedule image File tileFile = getTileFile(cellContainer.getContext()); if (tileFile.exists()) { if (debug) Log.d(TAG, "geo.onBind() decodeImage: " + tileFile); // request decoding spec = Atlas.imageLoader.requestImage(imageId, new Atlas.FileStreamProvider(tileFile), (int) Tools.getPxFromDp(150, cellContainer.getContext()), (int) Tools.getPxFromDp(150, cellContainer.getContext()), false, this); } else { int width = 300; int height = 300; int zoom = 16; final String url = new StringBuilder().append("https://maps.googleapis.com/maps/api/staticmap?") .append("format=png32&").append("center=").append(lat).append(",").append(lon).append("&") .append("zoom=").append(zoom).append("&").append("size=").append(width).append("x") .append(height).append("&").append("maptype=roadmap&").append("markers=color:red%7C") .append(lat).append(",").append(lon).toString(); Atlas.downloadQueue.schedule(url, tileFile, this); if (debug) Log.d(TAG, "geo.onBind() show stub and download image: " + tileFile); } } // clustering cellCustom.setCornerRadiusDp(16, 16, 16, 16); if (AtlasMessagesList.CLUSTERED_BUBBLES) { if (myMessage) { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 2, 16); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(16, 2, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 2, 2, 16); } } else { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 16, 2); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(2, 16, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(2, 16, 16, 2); } } } return cellRoot; }
From source file:gov.wa.wsdot.android.wsdot.ui.MountainPassItemCameraFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_list_with_spinner, null); // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLoadingSpinner = root.findViewById(R.id.loading_spinner); mEmptyView = root.findViewById(R.id.empty_list_view); return root;//from w ww . j a va 2s .co m }
From source file:me.spadival.podmode.PodNotifyService.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { String notifyPackage = (String) event.getPackageName(); if (!event.getClassName().equals(NOTIFICATION_CLASS)) return;//from w w w . ja v a2s. c o m if (notifyPackage.equals(SYSTEMUI_PACKAGE) || notifyPackage.equals(THIS_PACKAGE) || notifyPackage.equals(ANDROID_PACKAGE)) return; PackageManager pm = getPackageManager(); String notifyAppName = null; try { notifyAppName = (String) pm.getApplicationLabel(pm.getApplicationInfo(notifyPackage, 0)); } catch (NameNotFoundException e1) { e1.printStackTrace(); } if (notifyAppName == null) return; if (notifyPackage.equals(GMAPS_PACKAGE)) notifyAppName = getString(R.string.nav_appname); if (notifyPackage.equals(GNOW_PACKAGE)) notifyAppName = "Google Now"; List<CharSequence> textList = event.getText(); String notifyText = ""; if (textList.size() > 0) notifyText = textList.get(0).toString(); if (notifyText.equals("") || notifyPackage.equals(GMAIL_PACKAGE)) { Notification eventNotification = (Notification) event.getParcelableData(); RemoteViews notifyView = eventNotification.contentView; LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup localView = null; try { localView = (ViewGroup) inflater.inflate(notifyView.getLayoutId(), null); } catch (Exception e) { // e.printStackTrace(); return; } try { notifyView.reapply(getApplicationContext(), localView); } catch (NotFoundException e) { // e.printStackTrace(); } View tv = localView.findViewById(android.R.id.title); if (tv != null && tv instanceof TextView) { if (notifyPackage.equals(GNOW_PACKAGE) || notifyPackage.equals(PANDORA_PACKAGE)) notifyText = ((TextView) tv).getText().toString(); else notifyAppName += ": " + ((TextView) tv).getText().toString(); } if (!notifyPackage.equals(GNOW_PACKAGE)) { tv = localView.findViewById(16908358); if (tv != null && tv instanceof TextView) if (notifyPackage.equals(PANDORA_PACKAGE)) notifyAppName += ": " + ((TextView) tv).getText().toString(); else notifyText = (String) ((TextView) tv).getText().toString(); } if (notifyPackage.equals(GMAIL_PACKAGE)) { tv = localView.findViewById(android.R.id.text2); if (tv != null && tv instanceof TextView) notifyText = (String) ((TextView) tv).getText().toString(); } } Intent localIntent = new Intent(PodModeService.NOTIFYACTION); localIntent.putExtra("package", notifyPackage); localIntent.putExtra("appname", notifyAppName); localIntent.putExtra("text", notifyText); LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent); }