List of usage examples for android.content.res Resources getColor
@ColorInt @Deprecated public int getColor(@ColorRes int id) throws NotFoundException
From source file:com.mikecorrigan.trainscorekeeper.FragmentSummary.java
@SuppressLint("NewApi") @Override/*from w w w .j ava 2 s . co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.vc(VERBOSE, TAG, "onCreateView: inflater=" + inflater + ", container=" + container + ", savedInstanceState=" + Utils.bundleToString(savedInstanceState)); View rootView = inflater.inflate(R.layout.fragment_summary, container, false); final MainActivity activity = (MainActivity) getActivity(); final Context context = activity; final Resources resources = context.getResources(); // Get the model and attach a listener. game = activity.getGame(); if (game != null) { game.addListener(mGameListener); } players = activity.getPlayers(); // Get resources. String[] playerNames = resources.getStringArray(R.array.playerNames); TypedArray drawablesArray = resources.obtainTypedArray(R.array.playerDrawables); TypedArray playerTextColorsArray = resources.obtainTypedArray(R.array.playerTextColors); int[] playerTextColorsIds = new int[playerTextColorsArray.length()]; for (int i = 0; i < playerTextColorsArray.length(); i++) { playerTextColorsIds[i] = playerTextColorsArray.getResourceId(i, -1); } // Get root view. ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.scroll_view); // Create table. tableLayout = new TableLayout(context); TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); tableLayout.setLayoutParams(tableLayoutParams); scrollView.addView(tableLayout); // Add header. { TableRow row = new TableRow(context); row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tableLayout.addView(row); TextView tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.player)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.trains)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.contracts)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); tv.setText(resources.getString(R.string.bonuses)); tv.setTypeface(null, Typeface.BOLD); row.addView(tv); } // Add rows. for (int i = 0; i < players.getNum(); i++) { TableRow row = new TableRow(context); row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tableLayout.addView(row); ToggleButton toggleButton = new ToggleButton(context); toggleButton.setGravity(Gravity.CENTER); toggleButton.setPadding(10, 10, 10, 10); toggleButton.setText(playerNames[i]); toggleButton.setClickable(false); Drawable drawable = drawablesArray.getDrawable(i); int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { toggleButton.setBackgroundDrawable(drawable); } else { toggleButton.setBackground(drawable); } toggleButton.setTextColor(resources.getColor(playerTextColorsIds[i])); row.addView(toggleButton); TextView tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); row.addView(tv); tv = new TextView(context); tv.setGravity(Gravity.CENTER); tv.setPadding(10, 10, 10, 10); row.addView(tv); } Bundle args = getArguments(); if (args == null) { Log.e(TAG, "onCreateView: missing arguments"); return rootView; } drawablesArray.recycle(); playerTextColorsArray.recycle(); // final int index = args.getInt(ARG_INDEX); // final String tabSpec = args.getString(ARG_TAB_SPEC); return rootView; }
From source file:com.hichinaschool.flashcards.anki.Reviewer.java
private void invertColors(boolean invert) { Resources res = getResources(); int[] colors = Themes.setNightMode(this, mMainLayout, invert); mForegroundColor = colors[0];// www . ja v a 2 s.c o m mNextTimeTextColor = mForegroundColor; mNextTimeTextRecomColor = colors[1]; mFlipCard.setTextColor(mForegroundColor); mNext4.setTextColor(mNextTimeTextColor); mEase4.setTextColor(mNextTimeTextColor); mCardTimer.setTextColor(mForegroundColor); mTextBarRed.setTextColor(invert ? res.getColor(R.color.night_blue) : res.getColor(R.color.blue)); mTextBarBlack.setTextColor(invert ? res.getColor(R.color.night_red) : res.getColor(R.color.red)); mTextBarBlue.setTextColor(invert ? res.getColor(R.color.night_green) : res.getColor(R.color.green)); mAnswerField.setTextColor(mForegroundColor); if (mSimpleCard != null) { mSimpleCard.setBackgroundColor(mCurrentBackgroundColor); mSimpleCard.setTextColor(mForegroundColor); } if (mCard != null) { mCard.setBackgroundColor(mCurrentBackgroundColor); } int fgColor = R.color.studyoptions_progressbar_frame_light; int bgColor = R.color.studyoptions_progressbar_background_nightmode; findViewById(R.id.progress_bars_border1).setBackgroundResource(fgColor); findViewById(R.id.progress_bars_border2).setBackgroundResource(fgColor); findViewById(R.id.progress_bars_back1).setBackgroundResource(bgColor); findViewById(R.id.progress_bars_back2).setBackgroundResource(bgColor); AnkiDroidApp.getCompat().setActionBarBackground(this, invert ? R.color.white_background_night : R.color.actionbar_background); }
From source file:com.tct.mail.browse.ConversationItemView.java
private static synchronized void getItemViewResources(Context context) { if (sConfigurationChangedReceiver == null) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override/* w w w . jav a2 s .c o m*/ public void onReceive(Context context, Intent intent) { STAR_OFF = null; //[BUGFIX]-Mod-BEGIN by TCTNB.caixia.chen,01/07/2015,PR 893304 getItemViewResources(context.getApplicationContext()); //[BUGFIX]-Mod-END by TCTNB.caixia.chen } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (STAR_OFF == null) { final Resources res = context.getResources(); // Initialize static bitmaps. //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S // star off will not show in list item. //STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp); STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp); ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_20dp); ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double); TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single); IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double_important_unread); IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single_important_unread); IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread); STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light); STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light); STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_forward_holo_light); STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light); VISIBLE_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight); RIGHT_EDGE_TABLET = res.getDrawable(R.drawable.list_edge_tablet); //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398) sHighPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_high_priority); sLowPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_low_priority); sNormalPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal); //[FEATURE]-Add-END by TSCD.chao zhang // Initialize colors. sActivatedTextSpan = CharacterStyle .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color))); sSendersTextColor = res.getColor(R.color.senders_text_color); sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle); sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle); sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle); sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color)); sDateTextColorRead = res.getColor(R.color.date_text_color_read); sDateTextColorUnread = res.getColor(R.color.date_text_color_unread); sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop); sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop); sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration); sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration); // Initialize static color. sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedPaddingToken = res.getString(R.string.elided_padding_token); sScrollSlop = res.getInteger(R.integer.swipeScrollSlop); sFoldersStartPadding = res.getDimensionPixelOffset(R.dimen.folders_start_padding); sFoldersInnerPadding = res.getDimensionPixelOffset(R.dimen.folder_cell_content_padding); sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count); sFoldersOverflowGradientPadding = res.getDimensionPixelOffset(R.dimen.folders_gradient_padding); sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration); sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width); sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius); sFolderRoundedCornerRadius = res.getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius); sDividerColor = res.getColor(R.color.conversation_list_divider_color); sDividerInset = res.getDimensionPixelSize(R.dimen.conv_list_divider_inset); sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height); } }
From source file:com.edgar.banner.BannerPagerView.java
private void init(AttributeSet attrs, int defStyle) { Context context = getContext(); Resources resource = context.getResources(); LayoutInflater.from(getContext()).inflate(R.layout.banner_layout, this, true); mViewPage = (LoopViewPager) findViewById(R.id.carouse_viewpager); setBannerScroller(new BannerScroller(getContext())); mViewPage.setOverScrollMode(View.OVER_SCROLL_NEVER); mViewPage.setOnPageChangeListener(mCarousePageListener); mBannerPageAdapter = new DefaultBannerPageViewAdapter(); mIndicatorParams.gravity = Gravity.BOTTOM; mPointPadding = resource.getDimensionPixelOffset(R.dimen.point_margin); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BannerPagerView, defStyle, 0); int N = a.getIndexCount(); for (int i = 0; i < N; i++) { int attr = a.getIndex(i); if (attr == R.styleable.BannerPagerView_bannerAnimation) { int transformerType = a.getInt(attr, 0); setBannerPageTransformer(true, TransformerType.convert(transformerType)); } else if (attr == R.styleable.BannerPagerView_enableAutoPlayer) { setEnableAutoPlay(a.getBoolean(attr, false)); } else if (attr == R.styleable.BannerPagerView_indicatorStyle) { mIndicatorStyle = a.getInt(attr, IndicatorStyle.CIRCLE_INDICATOR); } else if (attr == R.styleable.BannerPagerView_indicatorLayout) { int resId = a.getResourceId(attr, 0); if (resId != 0) { View indicatorView = LayoutInflater.from(context).inflate(resId, this, false); if (!(indicatorView instanceof BannerIndicator)) { throw new IllegalArgumentException("Your indicator must implements BannerIndicator."); }// www. j av a 2 s . c om mIndicatorView = indicatorView; mBannerIndicator = (BannerIndicator) indicatorView; addView(mIndicatorView); } } else if (attr == R.styleable.BannerPagerView_unSelectDrawable) { mUnSelectedDrawable = a.getDrawable(attr); } else if (attr == R.styleable.BannerPagerView_selectedDrawable) { mSelectedDrawable = a.getDrawable(attr); } else if (attr == R.styleable.BannerPagerView_indicatorGravity) { mIndicatorGravity = a.getInt(attr, Gravity.CENTER); } else if (attr == R.styleable.BannerPagerView_pointPadding) { mPointPadding = a.getDimensionPixelOffset(attr, mPointPadding); } else if (attr == R.styleable.BannerPagerView_indicatorBackground) { mIndicatorBackground = a.getDrawable(attr); } } if (mUnSelectedDrawable == null) { mUnSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_normal_background); } if (mSelectedDrawable == null) { mSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_selected_background); } if (mIndicatorBackground == null) { mIndicatorBackground = new ColorDrawable(resource.getColor(R.color.indicator_background)); } if (mBannerIndicator == null) { setIndicatorStyle(mIndicatorStyle); } a.recycle(); }
From source file:com.androzic.MapFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Resources resources = getResources(); if (getString(R.string.pref_wakelock).equals(key)) { keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock)); map.setKeepScreenOn(keepScreenOn); } else if (getString(R.string.pref_showdistance_int).equals(key)) { showDistance = Integer.parseInt(sharedPreferences.getString(key, getString(R.string.def_showdistance))); } else if (getString(R.string.pref_hidemapinfo).equals(key)) { mapInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_hidesatinfo).equals(key)) { satInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_hidenavinfo).equals(key)) { navInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_maprenderinterval).equals(key)) { updatePeriod = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_maprenderinterval)) * 100;/*from w w w . ja v a2 s . c o m*/ } else if (getString(R.string.pref_mapfollowonloc).equals(key)) { followOnLocation = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapfollowonloc)); } else if (getString(R.string.pref_mapdiminterval).equals(key)) { dimInterval = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdiminterval)) * 1000; } else if (getString(R.string.pref_mapdimvalue).equals(key)) { dimValue = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdimvalue)); } else if (getString(R.string.pref_mapdim).equals(key)) { autoDim = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdim)); dimScreen(); } else if (getString(R.string.pref_unfollowontap).equals(key)) { map.setStrictUnfollow( !sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unfollowontap))); } else if (getString(R.string.pref_lookahead).equals(key)) { map.setLookAhead(sharedPreferences.getInt(key, resources.getInteger(R.integer.def_lookahead))); } else if (getString(R.string.pref_mapbest).equals(key)) { map.setBestMapEnabled(sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapbest))); } else if (getString(R.string.pref_mapbestinterval).equals(key)) { map.setBestMapInterval( sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapbestinterval)) * 1000); } else if (getString(R.string.pref_scalebarbg).equals(key)) { map.setDrawScaleBarBackground( sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_scalebarbg))); } else if (getString(R.string.pref_scalebarcolor).equals(key)) { map.setScaleBarColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebar))); } else if (getString(R.string.pref_scalebarbgcolor).equals(key)) { map.setScaleBarBackgroundColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebarbg))); } else if (getString(R.string.pref_hidemapcross).equals(key)) { int delay = Integer.parseInt(sharedPreferences.getString(key, "5")); map.setCrossCursorHideDelay(delay); } else if (getString(R.string.pref_mapcrosscolor).equals(key)) { map.setCrossColor(sharedPreferences.getInt(key, resources.getColor(R.color.mapcross))); } else if (getString(R.string.pref_cursorvector).equals(key) || getString(R.string.pref_cursorvectormlpr).equals(key)) { map.setCursorVector( Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_cursorvector), getString(R.string.def_cursorvector))), sharedPreferences.getInt(getString(R.string.pref_cursorvectormlpr), resources.getInteger(R.integer.def_cursorvectormlpr))); } else if (getString(R.string.pref_cursorcolor).equals(key)) { map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor))); } else if (getString(R.string.pref_navigation_proximity).equals(key)) { map.setProximity(Integer .parseInt(sharedPreferences.getString(key, getString(R.string.def_navigation_proximity)))); } else if (getString(R.string.pref_unitspeed).equals(key)) { speedUnit.setText(StringFormatter.speedAbbr); } else if (getString(R.string.pref_unitelevation).equals(key)) { elevationUnit.setText(StringFormatter.elevationAbbr); } else if (getString(R.string.pref_unitangle).equals(key)) { trackUnit.setText(StringFormatter.angleAbbr); bearingUnit.setText(StringFormatter.angleAbbr); turnUnit.setText(StringFormatter.angleAbbr); } }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
@Nullable @Override//from ww w . ja v a 2s . c o m public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_gallery_list, container, false); Context context = getContext2(); Assert.assertNotNull(context); Resources resources = context.getResources(); mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mShowActionFab = true; View mainLayout = ViewUtils.$$(view, R.id.main_layout); ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout); mRecyclerView = contentLayout.getRecyclerView(); FastScroller fastScroller = contentLayout.getFastScroller(); RefreshLayout refreshLayout = contentLayout.getRefreshLayout(); mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout); mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar); mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout); mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab); int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar); int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab); mViewTransition = new ViewTransition(contentLayout, mSearchLayout); mHelper = new GalleryListHelper(); mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit)); contentLayout.setHelper(mHelper); contentLayout.getFastScroller().setOnDragHandlerListener(this); mAdapter = new GalleryListAdapter(inflater, resources, mRecyclerView, Settings.getListMode()); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false)); mRecyclerView.setDrawSelectorOnTop(true); mRecyclerView.hasFixedSize(); mRecyclerView.setClipToPadding(false); mRecyclerView.setOnItemClickListener(this); mRecyclerView.setOnItemLongClickListener(this); mRecyclerView.addOnScrollListener(mOnScrollListener); fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB, fastScroller.getPaddingRight(), fastScroller.getPaddingBottom()); refreshLayout.setHeaderTranslationY(paddingTopSB); mLeftDrawable = new DrawerArrowDrawable(context); mRightDrawable = new AddDeleteDrawable(context); mSearchBar.setLeftDrawable(mLeftDrawable); mSearchBar.setRightDrawable(mRightDrawable); mSearchBar.setHelper(this); mSearchBar.setOnStateChangeListener(this); setSearchBarHint(context, mSearchBar); mSearchLayout.setHelper(this); mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB, mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab); mFabLayout.setAutoCancel(true); mFabLayout.setExpanded(false); mFabLayout.setHidePrimaryFab(false); mFabLayout.setOnClickFabListener(this); mFabLayout.setOnExpandListener(this); addAboveSnackView(mFabLayout); mActionFabDrawable = new AddDeleteDrawable(context); mActionFabDrawable.setColor(resources.getColor(R.color.primary_drawable_dark)); mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable); mSearchFab.setOnClickListener(this); mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView, mSearchLayout); // Update list url builder onUpdateUrlBuilder(); // Restore state int newState = mState; mState = STATE_NORMAL; setState(newState, false); // Only refresh for the first time if (!mHasFirstRefresh) { mHasFirstRefresh = true; mHelper.firstRefresh(); } guideQuickSearch(); return view; }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.PlusStreamRowViewBinder.java
public static void bindActivityView(final View rootView, Activity activity, ImageLoader imageLoader, boolean singleSourceMode) { // Prepare view holder. ViewHolder tempViews = (ViewHolder) rootView.getTag(); final ViewHolder views; if (tempViews != null) { views = tempViews;/* w w w .j a va 2 s.c o m*/ } else { views = new ViewHolder(); rootView.setTag(views); // Author and metadata box views.authorContainer = rootView.findViewById(R.id.stream_author_container); views.userImage = (ImageView) rootView.findViewById(R.id.stream_user_image); views.userName = (TextView) rootView.findViewById(R.id.stream_user_name); views.time = (TextView) rootView.findViewById(R.id.stream_time); // Author's content views.content = (TextView) rootView.findViewById(R.id.stream_content); // Original share box views.originalContainer = rootView.findViewById(R.id.stream_original_container); views.originalAuthor = (TextView) rootView.findViewById(R.id.stream_original_author); views.originalContent = (TextView) rootView.findViewById(R.id.stream_original_content); // Media box views.mediaContainer = rootView.findViewById(R.id.stream_media_container); views.mediaBackground = (ImageView) rootView.findViewById(R.id.stream_media_background); views.mediaOverlay = (ImageView) rootView.findViewById(R.id.stream_media_overlay); views.mediaTitle = (TextView) rootView.findViewById(R.id.stream_media_title); views.mediaSubtitle = (TextView) rootView.findViewById(R.id.stream_media_subtitle); // Interactions box views.interactionsContainer = rootView.findViewById(R.id.stream_interactions_container); views.plusOnes = (TextView) rootView.findViewById(R.id.stream_plus_ones); views.shares = (TextView) rootView.findViewById(R.id.stream_shares); views.comments = (TextView) rootView.findViewById(R.id.stream_comments); } final Context context = rootView.getContext(); final Resources res = context.getResources(); // Determine if this is a reshare (affects how activity fields are to be interpreted). Activity.PlusObject.Actor originalAuthor = activity.getObject().getActor(); boolean isReshare = "share".equals(activity.getVerb()) && originalAuthor != null; // Author and metadata box views.authorContainer.setVisibility(singleSourceMode ? View.GONE : View.VISIBLE); views.userName.setText(activity.getActor().getDisplayName()); // Find user profile image url String userImageUrl = null; if (activity.getActor().getImage() != null) { userImageUrl = activity.getActor().getImage().getUrl(); } // Load image from network in background thread using Volley library imageLoader.get(userImageUrl, views.userImage, PLACEHOLDER_USER_IMAGE); long thenUTC = activity.getUpdated().getValue() + activity.getUpdated().getTimeZoneShift() * 60000; views.time.setText(DateUtils.getRelativeTimeSpanString(thenUTC, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_RELATIVE)); // Author's additional content String selfContent = isReshare ? activity.getAnnotation() : activity.getObject().getContent(); views.content.setMaxLines(singleSourceMode ? 1000 : 5); if (!TextUtils.isEmpty(selfContent)) { views.content.setVisibility(View.VISIBLE); views.content.setText(Html.fromHtml(selfContent)); } else { views.content.setVisibility(View.GONE); } // Original share box if (isReshare) { views.originalContainer.setVisibility(View.VISIBLE); // Set original author text, highlight author name final String author = res.getString(R.string.stream_originally_shared, originalAuthor.getDisplayName()); final SpannableStringBuilder spannableAuthor = new SpannableStringBuilder(author); spannableAuthor.setSpan(new StyleSpan(Typeface.BOLD), author.length() - originalAuthor.getDisplayName().length(), author.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); views.originalAuthor.setText(spannableAuthor, TextView.BufferType.SPANNABLE); String originalContent = activity.getObject().getContent(); views.originalContent.setMaxLines(singleSourceMode ? 1000 : 3); if (!TextUtils.isEmpty(originalContent)) { views.originalContent.setVisibility(View.VISIBLE); views.originalContent.setText(Html.fromHtml(originalContent)); } else { views.originalContent.setVisibility(View.GONE); } } else { views.originalContainer.setVisibility(View.GONE); } // Media box // Set media content. List<Activity.PlusObject.Attachments> attachments = activity.getObject().getAttachments(); if (attachments != null && attachments.size() > 0) { Activity.PlusObject.Attachments attachment = attachments.get(0); String objectType = attachment.getObjectType(); String imageUrl = attachment.getImage() != null ? attachment.getImage().getUrl() : null; if (imageUrl == null && attachment.getThumbnails() != null && attachment.getThumbnails().size() > 0) { Thumbnails thumb = attachment.getThumbnails().get(0); imageUrl = thumb.getImage() != null ? thumb.getImage().getUrl() : null; } // Load image from network in background thread using Volley library imageLoader.get(imageUrl, views.mediaBackground, PLACEHOLDER_MEDIA_IMAGE); boolean overlayStyle = false; views.mediaOverlay.setImageDrawable(null); if (("photo".equals(objectType) || "video".equals(objectType) || "album".equals(objectType)) && !TextUtils.isEmpty(imageUrl)) { overlayStyle = true; views.mediaOverlay .setImageResource("video".equals(objectType) ? R.drawable.ic_stream_media_overlay_video : R.drawable.ic_stream_media_overlay_photo); } else if ("article".equals(objectType) || "event".equals(objectType)) { overlayStyle = false; views.mediaTitle.setText(attachment.getDisplayName()); if (!TextUtils.isEmpty(attachment.getUrl())) { Uri uri = Uri.parse(attachment.getUrl()); views.mediaSubtitle.setText(uri.getHost()); } else { views.mediaSubtitle.setText(""); } } views.mediaContainer.setVisibility(View.VISIBLE); views.mediaContainer.setBackgroundResource( overlayStyle ? R.color.plus_stream_media_background : android.R.color.black); if (overlayStyle) { views.mediaBackground.clearColorFilter(); } else { views.mediaBackground.setColorFilter(res.getColor(R.color.plus_media_item_tint)); } views.mediaOverlay.setVisibility(overlayStyle ? View.VISIBLE : View.GONE); views.mediaTitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE); views.mediaSubtitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE); } else { views.mediaContainer.setVisibility(View.GONE); views.mediaBackground.setImageDrawable(null); views.mediaOverlay.setImageDrawable(null); } // Interactions box final int plusOneCount = (activity.getObject().getPlusoners() != null) ? activity.getObject().getPlusoners().getTotalItems().intValue() : 0; if (plusOneCount > 0) { views.plusOnes.setVisibility(View.VISIBLE); views.plusOnes.setText(getPlusOneString(plusOneCount)); } else { views.plusOnes.setVisibility(View.GONE); } final int commentCount = (activity.getObject().getReplies() != null) ? activity.getObject().getReplies().getTotalItems().intValue() : 0; if (commentCount > 0) { views.comments.setVisibility(View.VISIBLE); views.comments.setText(Integer.toString(commentCount)); } else { views.comments.setVisibility(View.GONE); } final int resharerCount = (activity.getObject().getResharers() != null) ? activity.getObject().getResharers().getTotalItems().intValue() : 0; if (resharerCount > 0) { views.shares.setVisibility(View.VISIBLE); views.shares.setText(Integer.toString(resharerCount)); } else { views.shares.setVisibility(View.GONE); } views.interactionsContainer.setVisibility( (plusOneCount > 0 || commentCount > 0 || resharerCount > 0) ? View.VISIBLE : View.GONE); }
From source file:com.androzic.vnspeech.MapFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Resources resources = getResources(); if (getString(R.string.pref_wakelock).equals(key)) { keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock)); map.setKeepScreenOn(keepScreenOn); } else if (getString(R.string.pref_showdistance_int).equals(key)) { showDistance = Integer.parseInt(sharedPreferences.getString(key, getString(R.string.def_showdistance))); } else if (getString(R.string.pref_hidemapinfo).equals(key)) { mapInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_hidesatinfo).equals(key)) { satInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_hidenavinfo).equals(key)) { navInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_maprenderinterval).equals(key)) { updatePeriod = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_maprenderinterval)) * 100;/*from w w w. j ava 2s . co m*/ } else if (getString(R.string.pref_mapfollowonloc).equals(key)) { followOnLocation = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapfollowonloc)); } else if (getString(R.string.pref_mapdiminterval).equals(key)) { dimInterval = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdiminterval)) * 1000; } else if (getString(R.string.pref_mapdimvalue).equals(key)) { dimValue = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdimvalue)); } else if (getString(R.string.pref_mapdim).equals(key)) { autoDim = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdim)); dimScreen(); } else if (getString(R.string.pref_unfollowontap).equals(key)) { map.setStrictUnfollow( !sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unfollowontap))); } else if (getString(R.string.pref_lookahead).equals(key)) { map.setLookAhead(sharedPreferences.getInt(key, resources.getInteger(R.integer.def_lookahead))); } else if (getString(R.string.pref_mapbest).equals(key)) { map.setBestMapEnabled(sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapbest))); } else if (getString(R.string.pref_mapbestinterval).equals(key)) { map.setBestMapInterval( sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapbestinterval)) * 1000); } else if (getString(R.string.pref_mapforcezoom).equals(key)) { forceZoomMap = Integer.parseInt(sharedPreferences.getString(key, "1")); } else if (getString(R.string.pref_maprotation).equals(key)) { int rotation = Integer .parseInt(sharedPreferences.getString(key, resources.getString(R.string.def_maprotation))); map.setMapRotation(rotation); } else if (getString(R.string.pref_scalebarbg).equals(key)) { map.setDrawScaleBarBackground( sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_scalebarbg))); } else if (getString(R.string.pref_scalebarcolor).equals(key)) { map.setScaleBarColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebar))); } else if (getString(R.string.pref_scalebarbgcolor).equals(key)) { map.setScaleBarBackgroundColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebarbg))); } else if (getString(R.string.pref_hidemapcross).equals(key)) { int delay = Integer.parseInt(sharedPreferences.getString(key, "5")); map.setCrossCursorHideDelay(delay); } else if (getString(R.string.pref_mapcrosscolor).equals(key)) { map.setCrossColor(sharedPreferences.getInt(key, resources.getColor(R.color.mapcross))); } else if (getString(R.string.pref_cursorvector).equals(key) || getString(R.string.pref_cursorvectormlpr).equals(key)) { map.setCursorVector( Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_cursorvector), getString(R.string.def_cursorvector))), sharedPreferences.getInt(getString(R.string.pref_cursorvectormlpr), resources.getInteger(R.integer.def_cursorvectormlpr))); } else if (getString(R.string.pref_cursorcolor).equals(key)) { map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor))); } else if (getString(R.string.pref_navigation_proximity).equals(key)) { map.setProximity(Integer .parseInt(sharedPreferences.getString(key, getString(R.string.def_navigation_proximity)))); } else if (getString(R.string.pref_unitspeed).equals(key)) { speedUnit.setText(StringFormatter.speedAbbr); } else if (getString(R.string.pref_unitelevation).equals(key)) { elevationUnit.setText(StringFormatter.elevationAbbr); } else if (getString(R.string.pref_unitangle).equals(key)) { trackUnit.setText(StringFormatter.angleAbbr); bearingUnit.setText(StringFormatter.angleAbbr); turnUnit.setText(StringFormatter.angleAbbr); } }
From source file:com.androzic.MapActivity.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Resources resources = getResources(); // application preferences if (getString(R.string.pref_folder_data).equals(key)) { application.setDataPath(Androzic.PATH_DATA, sharedPreferences.getString(key, resources.getString(R.string.def_folder_data))); } else if (getString(R.string.pref_folder_icon).equals(key)) { application.setDataPath(Androzic.PATH_ICONS, sharedPreferences.getString(key, resources.getString(R.string.def_folder_icon))); } else if (getString(R.string.pref_orientation).equals(key)) { setRequestedOrientation(Integer.parseInt(sharedPreferences.getString(key, "-1"))); } else if (getString(R.string.pref_grid_mapshow).equals(key)) { application.mapGrid = sharedPreferences.getBoolean(key, false); application.initGrids();/* w ww. j av a 2 s . c om*/ } else if (getString(R.string.pref_grid_usershow).equals(key)) { application.userGrid = sharedPreferences.getBoolean(key, false); application.initGrids(); } else if (getString(R.string.pref_grid_preference).equals(key)) { application.gridPrefer = Integer.parseInt(sharedPreferences.getString(key, "0")); application.initGrids(); } else if (getString(R.string.pref_grid_userscale).equals(key) || getString(R.string.pref_grid_userunit).equals(key) || getString(R.string.pref_grid_usermpp).equals(key)) { application.initGrids(); } else if (getString(R.string.pref_useonlinemap).equals(key) && sharedPreferences.getBoolean(key, false)) { application.setOnlineMap(sharedPreferences.getString(getString(R.string.pref_onlinemap), resources.getString(R.string.def_onlinemap))); } else if (getString(R.string.pref_onlinemap).equals(key) || getString(R.string.pref_onlinemapscale).equals(key)) { application.setOnlineMap(sharedPreferences.getString(getString(R.string.pref_onlinemap), resources.getString(R.string.def_onlinemap))); } else if (getString(R.string.pref_mapadjacent).equals(key)) { application.adjacentMaps = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapadjacent)); } else if (getString(R.string.pref_mapcropborder).equals(key)) { application.cropMapBorder = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapcropborder)); } else if (getString(R.string.pref_mapdrawborder).equals(key)) { application.drawMapBorder = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdrawborder)); } // activity preferences else if (getString(R.string.pref_wakelock).equals(key)) { keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock)); android.view.Window wnd = getWindow(); if (wnd != null) { if (keepScreenOn) wnd.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); else wnd.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } } else if (getString(R.string.pref_exit).equals(key)) { exitConfirmation = Integer.parseInt(sharedPreferences.getString(key, "0")); secondBack = false; } else if (getString(R.string.pref_unitprecision).equals(key)) { boolean precision = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unitprecision)); precisionFormat = precision ? "%.1f" : "%.0f"; } // map preferences else if (getString(R.string.pref_cursorcolor).equals(key)) { map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor))); } else if (getString(R.string.pref_panelactions).equals(key)) { String pa = sharedPreferences.getString(key, resources.getString(R.string.def_panelactions)); activeActions = Arrays.asList(pa.split(",")); } }