List of usage examples for android.view ViewGroup setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
/** * Handle {@link SessionsQuery} {@link Cursor}. */// w w w.ja v a 2 s . c om private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. finish(); return; } mTitleString = cursor.getString(SessionsQuery.TITLE); mSessionColor = cursor.getInt(SessionsQuery.COLOR); if (mSessionColor == 0) { // no color -- use default mSessionColor = getResources().getColor(R.color.default_session_color); } else { // make sure it's opaque mSessionColor = UIUtils.setColorAlpha(mSessionColor, 255); } mHeaderBox.setBackgroundColor(mSessionColor); getLUtils().setStatusBarColor(UIUtils.scaleColor(mSessionColor, 0.8f, false)); mLivestreamUrl = cursor.getString(SessionsQuery.LIVESTREAM_URL); mHasLivestream = !TextUtils.isEmpty(mLivestreamUrl); // Format the time this session occupies mSessionStart = cursor.getLong(SessionsQuery.START); mSessionEnd = cursor.getLong(SessionsQuery.END); mRoomName = cursor.getString(SessionsQuery.ROOM_NAME); mSpeakers = cursor.getString(SessionsQuery.SPEAKER_NAMES); String subtitle = UIUtils.formatSessionSubtitle(mSessionStart, mSessionEnd, mRoomName, mBuffer, this); if (mHasLivestream) { subtitle += " " + UIUtils.getLiveBadgeText(this, mSessionStart, mSessionEnd); } mTitle.setText(mTitleString); mSubtitle.setText(subtitle); for (int resId : SECTION_HEADER_RES_IDS) { ((TextView) findViewById(resId)).setTextColor(mSessionColor); } mPhotoViewContainer.setBackgroundColor(UIUtils.scaleSessionColorToDefaultBG(mSessionColor)); String photo = cursor.getString(SessionsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mHasPhoto = true; mNoPlaceholderImageLoader.loadImage(photo, mPhotoView, new RequestListener<String>() { @Override public void onException(Exception e, String url, Target target) { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } @Override public void onImageReady(String url, Target target, boolean b, boolean b2) { // Trigger image transition recomputePhotoAndScrollingMetrics(); } }); recomputePhotoAndScrollingMetrics(); } else { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashTag = cursor.getString(SessionsQuery.HASHTAG); if (!TextUtils.isEmpty(mHashTag)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); final boolean inMySchedule = cursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; setupShareMenuItemDeferred(); // Handle Keynote as a special case, where the user cannot remove it // from the schedule (it is auto added to schedule on sync) mTagsString = cursor.getString(SessionsQuery.TAGS); mIsKeynote = mTagsString.contains(Config.Tags.SPECIAL_KEYNOTE); mAddScheduleButton.setVisibility( (AccountUtils.hasActiveAccount(this) && !mIsKeynote) ? View.VISIBLE : View.INVISIBLE); tryRenderTags(); if (!mIsKeynote) { showStarredDeferred(mInitStarred = inMySchedule, false); } final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } updatePlusOneButton(); // Build requirements section final View requirementsBlock = findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Build related videos section final ViewGroup relatedVideosBlock = (ViewGroup) findViewById(R.id.related_videos_block); relatedVideosBlock.setVisibility(View.GONE); // Build links section buildLinksSection(cursor); updateEmptyView(); updateTimeBasedUi(); mHandler.post(new Runnable() { @Override public void run() { onScrollChanged(0, 0); // trigger scroll handling mScrollViewChild.setVisibility(View.VISIBLE); //mAbstract.setTextIsSelectable(true); } }); mTimeHintUpdaterRunnable = new Runnable() { @Override public void run() { updateTimeBasedUi(); mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); } }; mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); }
From source file:com.grottworkshop.gwsswipelayout.SwipeLayout.java
/** * prevent bottom view get any touch event. Especially in LayDown mode. *//*w w w.ja v a 2s .com*/ private void safeBottomView() { Status status = getOpenStatus(); ViewGroup bottom = getBottomView(); if (status == Status.Close) { if (bottom.getVisibility() != INVISIBLE) bottom.setVisibility(INVISIBLE); } else { if (bottom.getVisibility() != VISIBLE) bottom.setVisibility(VISIBLE); } }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//*from w ww . j a v a2s . c o m*/ private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mServerId = cursor.getString(SessionsQuery.SESSION_ID); mTitleString = cursor.getString(SessionsQuery.TITLE); mSessionColor = cursor.getInt(SessionsQuery.COLOR); if (mSessionColor == 0) { // no color -- use default mSessionColor = getResources().getColor(R.color.default_session_color); } else { // make sure it's opaque mSessionColor = UIUtils.setColorAlpha(mSessionColor, 255); } mHeaderBackgroundBox.setBackgroundColor(mSessionColor); ((BaseActivity) getActivity()).getLPreviewUtils() .setStatusBarColor(UIUtils.scaleColor(mSessionColor, 0.8f, false)); mLivestreamUrl = cursor.getString(SessionsQuery.LIVESTREAM_URL); mHasLivestream = !TextUtils.isEmpty(mLivestreamUrl); // Format the time this session occupies mSessionStart = cursor.getLong(SessionsQuery.START); mSessionEnd = cursor.getLong(SessionsQuery.END); mRoomName = cursor.getString(SessionsQuery.ROOM_NAME); mSpeakers = cursor.getString(SessionsQuery.SPEAKER_NAMES); String subtitle = UIUtils.formatSessionSubtitle(mSessionStart, mSessionEnd, mRoomName, mBuffer, getActivity()); if (mHasLivestream) { subtitle += " " + UIUtils.getLiveBadgeText(getActivity(), mSessionStart, mSessionEnd); } mTitle.setText(mTitleString); mSubtitle.setText(subtitle); for (int resId : SECTION_HEADER_RES_IDS) { ((TextView) mRootView.findViewById(resId)).setTextColor(mSessionColor); } mPhotoViewContainer.setBackgroundColor(UIUtils.scaleSessionColorToDefaultBG(mSessionColor)); String photo = cursor.getString(SessionsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mHasPhoto = true; mNoPlaceholderImageLoader.loadImage(photo, mPhotoView, new RequestListener<String>() { @Override public void onException(Exception e, String url, Target target) { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } @Override public void onImageReady(String url, Target target, boolean b, boolean b2) { // Trigger image transition recomputePhotoAndScrollingMetrics(); } }); recomputePhotoAndScrollingMetrics(); } else { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashTag = "#droidconnyc #dcnyc" + mServerId;//;cursor.getString(SessionsQuery.HASHTAG); if (!TextUtils.isEmpty(mHashTag)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); final boolean inMySchedule = cursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; setupShareMenuItemDeferred(); // Handle Keynote as a special case, where the user cannot remove it // from the schedule (it is auto added to schedule on sync) mTagsString = cursor.getString(SessionsQuery.TAGS); mIsKeynote = mTagsString.contains(Config.Tags.SPECIAL_KEYNOTE); mAddScheduleButton.setVisibility( (AccountUtils.hasActiveAccount(getActivity()) && !mIsKeynote) ? View.VISIBLE : View.INVISIBLE); tryRenderTags(); if (!mIsKeynote) { showStarredDeferred(mInitStarred = inMySchedule, false); } final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } updatePlusOneButton(); // Build requirements section final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Build related videos section final ViewGroup relatedVideosBlock = (ViewGroup) mRootView.findViewById(R.id.related_videos_block); relatedVideosBlock.setVisibility(View.GONE); // Build links section buildLinksSection(cursor); // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } updateTimeBasedUi(); mHandler.post(new Runnable() { @Override public void run() { onScrollChanged(0, 0); // trigger scroll handling mScrollViewChild.setVisibility(View.VISIBLE); //mAbstract.setTextIsSelectable(true); } }); mTimeHintUpdaterRunnable = new Runnable() { @Override public void run() { if (isAdded()) { updateTimeBasedUi(); mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); } } }; mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); }
From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//* w ww . j a v a 2 s. c om*/ private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. finish(); return; } mTitleString = cursor.getString(SessionsQuery.TITLE); mSessionColor = cursor.getInt(SessionsQuery.COLOR); if (mSessionColor == 0) { // no color -- use default mSessionColor = getResources().getColor(com.saarang.samples.apps.iosched.R.color.default_session_color); } else { // make sure it's opaque mSessionColor = UIUtils.setColorAlpha(mSessionColor, 255); } mHeaderBox.setBackgroundColor(mSessionColor); getLUtils().setStatusBarColor(UIUtils.scaleColor(mSessionColor, 0.8f, false)); mLivestreamUrl = cursor.getString(SessionsQuery.LIVESTREAM_URL); mHasLivestream = !TextUtils.isEmpty(mLivestreamUrl); // Format the time this session occupies mSessionStart = cursor.getLong(SessionsQuery.START); mSessionEnd = cursor.getLong(SessionsQuery.END); mRoomName = cursor.getString(SessionsQuery.ROOM_NAME); mSpeakers = cursor.getString(SessionsQuery.SPEAKER_NAMES); String subtitle = UIUtils.formatSessionSubtitle(mSessionStart, mSessionEnd, mRoomName, mBuffer, this); if (mHasLivestream) { subtitle += " " + UIUtils.getLiveBadgeText(this, mSessionStart, mSessionEnd); } mTitle.setText(mTitleString); mSubtitle.setText(subtitle); for (int resId : SECTION_HEADER_RES_IDS) { ((TextView) findViewById(resId)).setTextColor(mSessionColor); } mPhotoViewContainer.setBackgroundColor(UIUtils.scaleSessionColorToDefaultBG(mSessionColor)); String photo = cursor.getString(SessionsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mHasPhoto = true; mNoPlaceholderImageLoader.loadImage(photo, mPhotoView, new RequestListener<String>() { @Override public void onException(Exception e, String url, Target target) { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } @Override public void onImageReady(String url, Target target, boolean b, boolean b2) { // Trigger image transition recomputePhotoAndScrollingMetrics(); } }); recomputePhotoAndScrollingMetrics(); } else { mHasPhoto = false; recomputePhotoAndScrollingMetrics(); } mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashTag = cursor.getString(SessionsQuery.HASHTAG); if (!TextUtils.isEmpty(mHashTag)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); mCaption = cursor.getString(SessionsQuery.CAPTION); final boolean inMySchedule = cursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; setupShareMenuItemDeferred(); // Handle Keynote as a special case, where the user cannot remove it // from the schedule (it is auto added to schedule on sync) mTagsString = cursor.getString(SessionsQuery.TAGS); mIsKeynote = mTagsString.contains(Config.Tags.SPECIAL_KEYNOTE); mAddScheduleButton.setVisibility( (AccountUtils.hasActiveAccount(this) && !mIsKeynote) ? View.VISIBLE : View.INVISIBLE); tryRenderTags(); if (!mIsKeynote) { showStarredDeferred(mInitStarred = inMySchedule, false); } final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } updatePlusOneButton(); // Build requirements section final View requirementsBlock = findViewById( com.saarang.samples.apps.iosched.R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Build related videos section final ViewGroup relatedVideosBlock = (ViewGroup) findViewById( com.saarang.samples.apps.iosched.R.id.related_videos_block); relatedVideosBlock.setVisibility(View.GONE); // Build links section buildLinksSection(cursor); updateEmptyView(); updateTimeBasedUi(); mHandler.post(new Runnable() { @Override public void run() { onScrollChanged(0, 0); // trigger scroll handling mScrollViewChild.setVisibility(View.VISIBLE); //mAbstract.setTextIsSelectable(true); } }); mTimeHintUpdaterRunnable = new Runnable() { @Override public void run() { updateTimeBasedUi(); mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); } }; mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); }
From source file:com.github.google.beaconfig.BeaconConfigActivity.java
/** * Displays a screen with a message and a "try again" button. Pressing the button will attempt * to connect to the beacon from beginning * * @param message message which we want to be printed on the screen *///www . ja v a2 s . c om private void displayConnectionFailScreen(final String message) { runOnUiThread(new Runnable() { @Override public void run() { enableDisplay(); ViewGroup configContentView = (ViewGroup) findViewById(R.id.beacon_config_page_content); UiUtils.makeChildrenInvisible(configContentView); ViewGroup connectionFailSlot = (ViewGroup) findViewById(R.id.connection_fail); connectionFailSlot.findViewById(R.id.connection_fail_btn) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { accessBeacon(); findViewById(R.id.connection_fail).setVisibility(View.GONE); } }); ((TextView) connectionFailSlot.findViewById(R.id.connection_fail_message)).setText(message); connectionFailSlot.setVisibility(View.VISIBLE); } }); }
From source file:se.anyro.tagtider.TransferActivity.java
private void setupTransferData(final Bundle extras) { TextView trainView = (TextView) findViewById(R.id.train); ViewGroup originGroup = (ViewGroup) findViewById(R.id.origin_group); TextView originView = (TextView) findViewById(R.id.origin); TextView arrivalView = (TextView) findViewById(R.id.arrival); TextView stationTrackView = (TextView) findViewById(R.id.station_track); ViewGroup destinationGroup = (ViewGroup) findViewById(R.id.destination_group); TextView destinationView = (TextView) findViewById(R.id.destination); TextView departureView = (TextView) findViewById(R.id.departure); TextView commentView = (TextView) findViewById(R.id.comment); mEmptyView = (TextView) findViewById(android.R.id.empty); trainView.setText("Tg " + extras.getString("train") + " (" + extras.getString("type") + ")"); String origin = extras.getString("origin"); if (origin != null && origin.length() > 0) { originView.setText("Frn " + origin); originGroup.setVisibility(View.VISIBLE); } else {// ww w .j a va 2 s. c o m originGroup.setVisibility(View.GONE); } String track = extras.getString("track"); if (track == null || track.equalsIgnoreCase("x") || track.equalsIgnoreCase("null")) track = ""; String arrival = extras.getString("arrival"); if (arrival != null && !arrival.startsWith("0000")) { arrivalView.setText("Ankommer " + StringUtils.extractTime(arrival)); String newArrival = extras.getString("newArrival"); if (newArrival != null) { newArrival = StringUtils.extractTime(newArrival); SpannableString strike = new SpannableString(arrivalView.getText() + " " + newArrival); strike.setSpan(new StrikethroughSpan(), strike.length() - 11, strike.length() - 6, 0); arrivalView.setText(strike, TextView.BufferType.SPANNABLE); } if (track.length() == 0) { SpannableString strike = new SpannableString(arrivalView.getText()); strike.setSpan(new StrikethroughSpan(), strike.length() - 5, strike.length(), 0); arrivalView.setText(strike, TextView.BufferType.SPANNABLE); } } if (extras.getString("stationName") != null) { mStationName = extras.getString("stationName"); } if (track.length() > 0 && mStationName != null) stationTrackView.setText(mStationName + ", spr " + track); else if (mStationName != null) stationTrackView.setText(mStationName); else if (track.length() > 0) stationTrackView.setText("Spr " + track); else stationTrackView.setText(""); String destination = extras.getString("destination"); if (destination != null && destination.length() > 0) { destinationView.setText("Till " + destination); destinationGroup.setVisibility(View.VISIBLE); } else { destinationGroup.setVisibility(View.GONE); } String departure = extras.getString("departure"); if (departure != null && !departure.startsWith("0000")) { departureView.setText("Avgr " + StringUtils.extractTime(departure)); String newDeparture = extras.getString("newDeparture"); if (newDeparture != null) { newDeparture = StringUtils.extractTime(newDeparture); SpannableString strike = new SpannableString(departureView.getText() + " " + newDeparture); strike.setSpan(new StrikethroughSpan(), strike.length() - 11, strike.length() - 6, 0); departureView.setText(strike, TextView.BufferType.SPANNABLE); } if (track.length() == 0) { SpannableString strike = new SpannableString(departureView.getText()); strike.setSpan(new StrikethroughSpan(), strike.length() - 5, strike.length(), 0); departureView.setText(strike, TextView.BufferType.SPANNABLE); } } String comment = extras.getString("comment"); if ((comment == null || comment.length() == 0) && track.length() == 0) comment = "Instllt"; if (comment != null && comment.length() > 0) { commentView.setText(comment); commentView.setVisibility(View.VISIBLE); } else { commentView.setVisibility(View.GONE); } mTrain = extras.getString("train"); mStationId = extras.getString("stationId"); mTransferId = extras.getString("id"); }
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final SRThemeAttributes attr = new SRThemeAttributes(context); mPost = post;/*from w ww. j a v a 2 s.c o m*/ isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, SRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:org.onebusaway.android.ui.ArrivalsListAdapterStyleA.java
@Override protected void initView(View view, ArrivalInfo stopInfo) { final Context context = getContext(); final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); TextView route = (TextView) view.findViewById(R.id.route); TextView destination = (TextView) view.findViewById(R.id.destination); TextView time = (TextView) view.findViewById(R.id.time); TextView status = (TextView) view.findViewById(R.id.status); TextView etaView = (TextView) view.findViewById(R.id.eta); TextView minView = (TextView) view.findViewById(R.id.eta_min); ViewGroup realtimeView = (ViewGroup) view.findViewById(R.id.eta_realtime_indicator); ImageView moreView = (ImageView) view.findViewById(R.id.more_horizontal); moreView.setColorFilter(context.getResources().getColor(R.color.switch_thumb_normal_material_dark)); ImageView starView = (ImageView) view.findViewById(R.id.route_favorite); starView.setColorFilter(context.getResources().getColor(R.color.navdrawer_icon_tint)); starView.setImageResource(//w ww. ja va 2s . c o m stopInfo.isRouteAndHeadsignFavorite() ? R.drawable.focus_star_on : R.drawable.focus_star_off); route.setText(arrivalInfo.getShortName()); destination.setText(MyTextUtils.toTitleCase(arrivalInfo.getHeadsign())); status.setText(stopInfo.getStatusText()); long eta = stopInfo.getEta(); if (eta == 0) { etaView.setText(R.string.stop_info_eta_now); minView.setVisibility(View.GONE); } else { etaView.setText(String.valueOf(eta)); minView.setVisibility(View.VISIBLE); } status.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) status.getBackground(); Integer colorCode = stopInfo.getColor(); int color = context.getResources().getColor(colorCode); if (stopInfo.getPredicted()) { // Show real-time indicator UIUtils.setRealtimeIndicatorColorByResourceCode(realtimeView, colorCode, android.R.color.transparent); realtimeView.setVisibility(View.VISIBLE); } else { realtimeView.setVisibility(View.INVISIBLE); } etaView.setTextColor(color); minView.setTextColor(color); d.setColor(color); // Set padding on status view int pSides = UIUtils.dpToPixels(context, 5); int pTopBottom = UIUtils.dpToPixels(context, 2); status.setPadding(pSides, pTopBottom, pSides, pTopBottom); time.setText(DateUtils.formatDateTime(context, stopInfo.getDisplayTime(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); ContentValues values = null; if (mTripsForStop != null) { values = mTripsForStop.getValues(arrivalInfo.getTripId()); } if (values != null) { String reminderName = values.getAsString(ObaContract.Trips.NAME); TextView reminder = (TextView) view.findViewById(R.id.reminder); if (reminderName.length() == 0) { reminderName = context.getString(R.string.trip_info_noname); } reminder.setText(reminderName); Drawable d2 = reminder.getCompoundDrawables()[0]; d2 = DrawableCompat.wrap(d2); DrawableCompat.setTint(d2.mutate(), view.getResources().getColor(R.color.button_material_dark)); reminder.setCompoundDrawables(d2, null, null, null); reminder.setVisibility(View.VISIBLE); } else { // Explicitly set this to invisible because we might be reusing // this view. View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); } }
From source file:org.onebusaway.android.report.ui.SimpleArrivalListFragment.java
private void loadArrivalList(ObaArrivalInfo[] info, final ObaReferences refs, long currentTime) { LinearLayout contentLayout = (LinearLayout) getActivity().findViewById(R.id.simple_arrival_content); contentLayout.removeAllViews();/*w w w .j a va2 s .co m*/ ArrayList<ArrivalInfo> arrivalInfos = ArrivalInfoUtils.convertObaArrivalInfo(getActivity(), info, new ArrayList<String>(), currentTime, false); for (ArrivalInfo stopInfo : arrivalInfos) { final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); LayoutInflater inflater = LayoutInflater.from(getActivity()); LinearLayout view = (LinearLayout) inflater.inflate(R.layout.arrivals_list_item, null, false); view.setBackgroundColor(getResources().getColor(R.color.material_background)); TextView route = (TextView) view.findViewById(R.id.route); TextView destination = (TextView) view.findViewById(R.id.destination); TextView time = (TextView) view.findViewById(R.id.time); TextView status = (TextView) view.findViewById(R.id.status); TextView etaView = (TextView) view.findViewById(R.id.eta); TextView minView = (TextView) view.findViewById(R.id.eta_min); ViewGroup realtimeView = (ViewGroup) view.findViewById(R.id.eta_realtime_indicator); view.findViewById(R.id.more_horizontal).setVisibility(View.INVISIBLE); view.findViewById(R.id.route_favorite).setVisibility(View.INVISIBLE); String routeShortName = arrivalInfo.getShortName(); route.setText(routeShortName); UIUtils.maybeShrinkRouteName(getActivity(), route, routeShortName); destination.setText(UIUtils.formatDisplayText(arrivalInfo.getHeadsign())); status.setText(stopInfo.getStatusText()); long eta = stopInfo.getEta(); if (eta == 0) { etaView.setText(R.string.stop_info_eta_now); minView.setVisibility(View.GONE); } else { etaView.setText(String.valueOf(eta)); minView.setVisibility(View.VISIBLE); } status.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) status.getBackground(); Integer colorCode = stopInfo.getColor(); int color = getActivity().getResources().getColor(colorCode); if (stopInfo.getPredicted()) { // Show real-time indicator UIUtils.setRealtimeIndicatorColorByResourceCode(realtimeView, colorCode, android.R.color.transparent); realtimeView.setVisibility(View.VISIBLE); } else { realtimeView.setVisibility(View.INVISIBLE); } etaView.setTextColor(color); minView.setTextColor(color); d.setColor(color); // Set padding on status view int pSides = UIUtils.dpToPixels(getActivity(), 5); int pTopBottom = UIUtils.dpToPixels(getActivity(), 2); status.setPadding(pSides, pTopBottom, pSides, pTopBottom); time.setText(DateUtils.formatDateTime(getActivity(), stopInfo.getDisplayTime(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); contentLayout.addView(view); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String agencyName = findAgencyNameByRouteId(refs, arrivalInfo.getRouteId()); mCallback.onArrivalItemClicked(arrivalInfo, agencyName); } }); } }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
private void onSpeakersQueryComplete(Cursor cursor) { try {// w w w . ja va 2 s. c o m mSpeakersCursor = true; // TODO: remove any existing speakers from layout, since this cursor // might be from a data change notification. final ViewGroup speakersGroup = (ViewGroup) findViewById(R.id.session_speakers_block); final LayoutInflater inflater = getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); if (TextUtils.isEmpty(speakerName)) continue; final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final String speaker = getString(R.string.speaker_template, speakerName, speakerCompany); ((TextView) speakerView.findViewById(R.id.speaker_header)).setText(speaker); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); final TextView abstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); UIUtils.setTextMaybeHtml(abstractView, speakerAbstract); speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } } finally { cursor.close(); } }