androidx.core.content.ContextCompat Java Examples
The following examples show how to use
androidx.core.content.ContextCompat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotiHelper.java From hipda with GNU General Public License v2.0 | 6 votes |
public static void initNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Context context = HiApplication.getAppContext(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager.getNotificationChannel(CHANNEL_ID) == null) { int color = ContextCompat.getColor(context, R.color.icon_blue); NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); notificationChannel.enableLights(true); notificationChannel.setLightColor(color); notificationChannel.enableVibration(false); notificationChannel.setBypassDnd(false); notificationManager.createNotificationChannel(notificationChannel); } } }
Example #2
Source File: SkinManager.java From NewFastFrame with Apache License 2.0 | 6 votes |
public ColorStateList getColorStateList(int resId) { if (isLocal) { CommonLogger.e("放回本地"); return ContextCompat.getColorStateList(context, resId); } int id = resources.getIdentifier(context.getResources().getResourceEntryName(resId), "color", packageName); if (id == 0) { // 如果找不到资源,返回本地资源 return ContextCompat.getColorStateList(context, resId); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return resources.getColorStateList(id, null); } else { return resources.getColorStateList(id); } } }
Example #3
Source File: LiveDataRowsActivity.java From tv-samples with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { AndroidInjection.inject(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_livedata_rows); if (ContextCompat.checkSelfPermission(LiveDataRowsActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { // If the permission is not authorized in the first time. A new permission access // request will be created. if (ActivityCompat.shouldShowRequestPermissionRationale(LiveDataRowsActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { ActivityCompat.requestPermissions(LiveDataRowsActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_PERMISSION); } else { ActivityCompat.requestPermissions(LiveDataRowsActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_PERMISSION); } } }
Example #4
Source File: PreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 6 votes |
/** * Obtains the background of the button bar from the activity's current theme. */ private void obtainButtonBarBackground() { try { int color = ThemeUtil.getColor(getActivity(), R.attr.restoreDefaultsButtonBarBackground); setButtonBarBackgroundColor(color); } catch (NotFoundException e) { int resourceId = ThemeUtil .getResId(getActivity(), R.attr.restoreDefaultsButtonBarBackground, -1); if (resourceId != -1) { setButtonBarBackground(resourceId); } else { setButtonBarBackgroundColor( ContextCompat.getColor(getActivity(), R.color.button_bar_background_light)); } } }
Example #5
Source File: SplashActivity.java From shinny-futures-android with GNU General Public License v3.0 | 6 votes |
private void changeStatusBarColor(boolean isFirm) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); int statusBarHeight = getStatusBarHeight(BaseApplication.getContext()); View view = new View(this); view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); view.getLayoutParams().height = statusBarHeight; ((ViewGroup) w.getDecorView()).addView(view); if (isFirm) view.setBackground(getResources().getDrawable(R.color.colorPrimaryDark)); else view.setBackground(getResources().getDrawable(R.color.login_simulation_hint)); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (isFirm) window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)); else window.setStatusBarColor(ContextCompat.getColor(this, R.color.login_simulation_hint)); } }
Example #6
Source File: AirQuality.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@ColorInt public int getCOColor(Context context) { if (co == null) { return Color.TRANSPARENT; } else if (co <= 5) { return ContextCompat.getColor(context, R.color.colorLevel_1); } else if (co <= 10) { return ContextCompat.getColor(context, R.color.colorLevel_2); } else if (co <= 35) { return ContextCompat.getColor(context, R.color.colorLevel_3); } else if (co <= 60) { return ContextCompat.getColor(context, R.color.colorLevel_4); } else if (co <= 90) { return ContextCompat.getColor(context, R.color.colorLevel_5); } else { return ContextCompat.getColor(context, R.color.colorLevel_6); } }
Example #7
Source File: TintHelper.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) { ColorStateList sl = new ColorStateList(new int[][]{ new int[]{-android.R.attr.state_enabled}, new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked}, new int[]{android.R.attr.state_enabled, android.R.attr.state_checked} }, new int[]{ // Radio button includes own alpha for disabled state ColorUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)), ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light), color }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.setButtonTintList(sl); } else { Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl); radioButton.setButtonDrawable(d); } }
Example #8
Source File: MainActivity.java From wear-os-samples with Apache License 2.0 | 6 votes |
/** Restores the UI to active (non-ambient) mode. */ @Override public void onExitAmbient() { super.onExitAmbient(); Log.d(TAG, "onExitAmbient()"); // Changes views to color. Context context = getApplicationContext(); Resources resources = context.getResources(); mOuterCircle.setBackgroundColor( ContextCompat.getColor(context, R.color.background_color)); mInnerCircle.setBackground( ContextCompat.getDrawable(context, R.drawable.color_circle)); mProgressBar.setProgressTintList( resources.getColorStateList(R.color.progressbar_tint, context.getTheme())); mProgressBar.setProgressBackgroundTintList( resources.getColorStateList( R.color.progressbar_background_tint, context.getTheme())); }
Example #9
Source File: CurrentPlaceTestActivity.java From android-places-demos with Apache License 2.0 | 6 votes |
/** * Fetches a list of {@link PlaceLikelihood} instances that represent the Places the user is * most * likely to be at currently. */ private void findCurrentPlace() { if (ContextCompat.checkSelfPermission(this, permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Toast.makeText( this, "Both ACCESS_WIFI_STATE & ACCESS_FINE_LOCATION permissions are required", Toast.LENGTH_SHORT) .show(); } // Note that it is not possible to request a normal (non-dangerous) permission from // ActivityCompat.requestPermissions(), which is why the checkPermission() only checks if // ACCESS_FINE_LOCATION is granted. It is still possible to check whether a normal permission // is granted or not using ContextCompat.checkSelfPermission(). if (checkPermission(ACCESS_FINE_LOCATION)) { findCurrentPlaceWithPermissions(); } }
Example #10
Source File: RainImplementor.java From GeometricWeather with GNU Lesser General Public License v3.0 | 6 votes |
@ColorInt public static int getThemeColor(Context context, @TypeRule int type) { switch (type) { case TYPE_RAIN_DAY: return Color.rgb(64, 151, 231); case TYPE_RAIN_NIGHT: return Color.rgb(38, 78, 143); case TYPE_SLEET_DAY: return Color.rgb(104, 186, 255); case TYPE_SLEET_NIGHT: return Color.rgb(26, 91, 146); case TYPE_THUNDERSTORM: return Color.rgb(43, 29, 69); } return ContextCompat.getColor(context, R.color.colorPrimary); }
Example #11
Source File: UiSettingsDemoActivity.java From android-samples with Apache License 2.0 | 6 votes |
public void setMyLocationButtonEnabled(View v) { if (!checkReady()) { return; } // Enables/disables the my location button (this DOES NOT enable/disable the my location // dot/chevron on the map). The my location button will never appear if the my location // layer is not enabled. // First verify that the location permission has been granted. if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mUiSettings.setMyLocationButtonEnabled(mMyLocationButtonCheckbox.isChecked()); } else { // Uncheck the box and request missing location permission. mMyLocationButtonCheckbox.setChecked(false); requestLocationPermission(MY_LOCATION_PERMISSION_REQUEST_CODE); } }
Example #12
Source File: ChoiceBookActivity.java From HaoReader with GNU General Public License v3.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.inflate(context, R.layout.item_choice_book_category, null); } TextView tvText = convertView.findViewById(R.id.tv_text); tvText.setText(getItem(position).getKindName()); GradientDrawable drawable = (GradientDrawable) tvText.getBackground(); if (lastPosition == position) { int selectedColor = ContextCompat.getColor(context, R.color.colorAccent); tvText.setTextColor(selectedColor); drawable.setStroke(DensityUtil.dp2px(context, 2), selectedColor); } else { int normalColor = ContextCompat.getColor(context, R.color.colorBarText); tvText.setTextColor(normalColor); drawable.setStroke(DensityUtil.dp2px(context, 2), normalColor); } return convertView; }
Example #13
Source File: NotepadBaseActivity.java From Notepad with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { SharedPreferences pref = getSharedPreferences(getPackageName() + "_preferences", MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); int navbarColorId = -1; int navbarDividerColorId = -1; int sysUiVisibility = -1; if(theme.contains("light")) { navbarColorId = R.color.navbar_color_light; navbarDividerColorId = R.color.navbar_divider_color_light; sysUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; } if(theme.contains("dark")) { navbarColorId = R.color.navbar_color_dark; navbarDividerColorId = R.color.navbar_divider_color_dark; sysUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; } getWindow().setNavigationBarColor(ContextCompat.getColor(this, navbarColorId)); findViewById(Window.ID_ANDROID_CONTENT).setSystemUiVisibility(sysUiVisibility); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) getWindow().setNavigationBarDividerColor(ContextCompat.getColor(this, navbarDividerColorId)); } }
Example #14
Source File: GeoPointMapActivity.java From commcare-android with Apache License 2.0 | 5 votes |
@Override protected void onResume() { mapView.onResume(); super.onResume(); if (isGPSOn && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); } if (isNetworkOn && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); } // TODO PLM: warn user and ask for permissions if the user has disabled them }
Example #15
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Obtains the background color of the card view, which contains the currently shown preference * fragment, when using the split screen layout, from the activity's theme. */ private void obtainCardViewBackgroundColor() { int color; try { color = ThemeUtil.getColor(this, R.attr.cardViewBackgroundColor); } catch (NotFoundException e) { color = ContextCompat.getColor(this, R.color.card_view_background_light); } setCardViewBackgroundColor(color); }
Example #16
Source File: WebViewActivity.java From FastLib with Apache License 2.0 | 5 votes |
@Override public boolean setNavigationBar(Dialog dialog, NavigationViewHelper helper, View bottomView) { Drawable drawableTop = ContextCompat.getDrawable(mContext, R.color.colorLineGray); DrawableUtil.setDrawableWidthHeight(drawableTop, SizeUtil.getScreenWidth(), SizeUtil.dp2px(0.5f)); helper.setPlusNavigationViewEnable(true) .setNavigationViewColor(Color.argb(isTrans() ? 0 : 60, 0, 0, 0)) .setNavigationViewDrawableTop(drawableTop) .setNavigationLayoutColor(Color.WHITE); //导航栏在底部控制才有意义,不然会很丑;开发者自己决定;这里仅供参考 return NavigationBarUtil.isNavigationAtBottom(dialog.getWindow()); }
Example #17
Source File: Util.java From FridaLoader with MIT License | 5 votes |
public static String getRootDirPath(Context context) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0]; return file.getAbsolutePath(); } else { return context.getApplicationContext().getFilesDir().getAbsolutePath(); } }
Example #18
Source File: UCropActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.ucrop_menu_activity, menu); // Change crop & loader menu icons color to match the rest of the UI colors MenuItem menuItemLoader = menu.findItem(R.id.menu_loader); Drawable menuItemLoaderIcon = menuItemLoader.getIcon(); if (menuItemLoaderIcon != null) { try { menuItemLoaderIcon.mutate(); menuItemLoaderIcon.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); menuItemLoader.setIcon(menuItemLoaderIcon); } catch (IllegalStateException e) { Log.i(TAG, String.format("%s - %s", e.getMessage(), getString(R.string.ucrop_mutate_exception_hint))); } ((Animatable) menuItemLoader.getIcon()).start(); } MenuItem menuItemCrop = menu.findItem(R.id.menu_crop); Drawable menuItemCropIcon = ContextCompat.getDrawable(this, mToolbarCropDrawable); if (menuItemCropIcon != null) { menuItemCropIcon.mutate(); menuItemCropIcon.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); menuItemCrop.setIcon(menuItemCropIcon); } return true; }
Example #19
Source File: NotificationReceiver.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 5 votes |
private Notification createStreamNotification(StreamInfo stream, @Nullable Bitmap image, boolean showViewers, Context context) { Intent resultIntent = LiveStreamActivity.createLiveStreamIntent(stream, false, context); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MyStreamsActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent clickIntent = stackBuilder.getPendingIntent( stream.getChannelInfo().getDisplayName().hashCode(), PendingIntent.FLAG_UPDATE_CURRENT ); NotificationTextData textData = constructStreamNotificationText(stream, context); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, context.getString(R.string.live_streamer_notification_id)) .setAutoCancel(false) .setContentTitle(textData.getTitle()) .setContentText(textData.getContent()) .setGroup(GROUP_KEY) .setWhen(stream.getStartedAt()) .setShowWhen(true) .setSmallIcon(R.drawable.ic_notification_icon_refresh) .setColor(ContextCompat.getColor(context, R.color.primary)) .setContentIntent(clickIntent) .setSound(null); if (image != null) { mBuilder.setLargeIcon(image); } if (showViewers) { mBuilder.setSubText(textData.getSubtext()); } return mBuilder.build(); }
Example #20
Source File: AndroidPermissions.java From CrossMobile with GNU Lesser General Public License v3.0 | 5 votes |
public void requestPermissions(VoidBlock1<Collection<String>> notGrantedPermissions, String... permissions) { Collection<String> reqPermissions = new LinkedHashSet<>(); if (permissions != null && permissions.length > 0) { for (String permission : permissions) if (permission != null) { permission = permission.trim(); if (!permission.isEmpty()) { if (ContextCompat.checkSelfPermission(MainActivity.current(), permission) != PackageManager.PERMISSION_GRANTED) reqPermissions.add(permission); } else Native.system().error("Requesting an empty Android permission", null); } else Native.system().error("Requesting a null Android permission", null); } else Native.system().error("Requested Android permissions are empty", null); Collection<String> alreadyAsked = BaseUtils.removeCommon(reqPermissions, alreadyAskedForPermission); alreadyAskedForPermission.addAll(reqPermissions); if (reqPermissions.isEmpty()) { if (notGrantedPermissions != null) notGrantedPermissions.invoke(alreadyAsked); } else { MainActivity.current.getStateListener().request((givenPermissions, grantResults) -> { if (givenPermissions == null || grantResults == null || notGrantedPermissions == null) return; for (int i = 0; i < givenPermissions.length && i < grantResults.length; i++) if (grantResults[i] == PackageManager.PERMISSION_GRANTED) reqPermissions.remove(givenPermissions[i]); notGrantedPermissions.invoke(reqPermissions); }, reqPermissions); } }
Example #21
Source File: QiscusCarouselViewHolder.java From qiscus-sdk-android with Apache License 2.0 | 5 votes |
@Override protected void loadChatConfig() { super.loadChatConfig(); titleTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getCardTitleColor()); descriptionTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getCardDescriptionColor()); buttonsTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getCardButtonTextColor()); buttonsBackgroundColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getCardButtonBackground()); }
Example #22
Source File: UIUtil.java From natrium-android-wallet with BSD 2-Clause "Simplified" License | 5 votes |
/** * Colorize a string in the following manner: * Characters 12-57 are white * * @param s Spannable * @param context Context */ public static void whitenMiddleSpannable(Spannable s, Context context) { if (context == null) { return; } if (s.length() > 58) { s.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.white_90)), 11, 58, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }
Example #23
Source File: ProfileActivity.java From mage-android with Apache License 2.0 | 5 votes |
private void updateAvatarFromGallery() { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(ProfileActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_STORAGE); } else { launchGalleryIntent(); } avatarActionsDialog.cancel(); }
Example #24
Source File: TagSpanGenerator.java From intra42 with Apache License 2.0 | 5 votes |
public void addTag(Achievements achievement) { String str = null; @ColorRes int colorBackground = 0; int colorText = 0; switch (achievement.tier) { case "easy": str = context.getString(R.string.user_achievement_bronze); colorBackground = R.color.user_achievements_bronze; colorText = android.R.color.white; break; case "medium": str = context.getString(R.string.user_achievement_silver); colorBackground = R.color.user_achievements_silver; colorText = android.R.color.black; break; case "hard": str = context.getString(R.string.user_achievement_gold); colorBackground = R.color.user_achievements_gold; colorText = android.R.color.black; break; case "challenge": str = context.getString(R.string.user_achievements_platinum); colorBackground = R.color.user_achievements_platinum; colorText = android.R.color.black; break; } if (str != null) { addTag(str, ContextCompat.getColor(context, colorBackground), ContextCompat.getColor(context, colorText)); } }
Example #25
Source File: FABWrapper.java From Taskbar with Apache License 2.0 | 5 votes |
public FABWrapper(Context context) { view = context.getPackageName().equals(BuildConfig.ANDROIDX86_APPLICATION_ID) ? new ImageView(context) : new FloatingActionButton(context); if(view instanceof ImageView) { view.setBackground(ContextCompat.getDrawable(context, R.drawable.tb_circle)); int padding = context.getResources().getDimensionPixelSize(R.dimen.tb_fake_fab_padding); view.setPadding(padding, padding, padding, padding); } }
Example #26
Source File: OpenChannelViewHolder.java From zap-android with MIT License | 5 votes |
void setState(boolean isActive) { if (isActive) { mStatus.setText(R.string.channel_state_open); mStatusDot.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.superGreen))); mRootView.setAlpha(1f); } else { mStatus.setText(R.string.channel_state_offline); mStatusDot.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.gray))); mRootView.setAlpha(0.65f); } }
Example #27
Source File: KcaEquipListViewAdpater.java From kcanotify with GNU General Public License v3.0 | 5 votes |
private LinearLayout getEquipmentShipDetailView(Context context, LayoutInflater inflater, LinearLayout root, int lv, int alv, String key, boolean is_aircraft) { LinearLayout ship_equip_item = (LinearLayout)inflater.inflate(R.layout.listview_equipment_count, root, false); TextView ship_equip_item_lv = ship_equip_item.findViewById(R.id.equipment_lv); TextView ship_equip_item_alv = ship_equip_item.findViewById(R.id.equipment_alv); TextView ship_equip_item_ships = ship_equip_item.findViewById(R.id.equipment_ships); TextView ship_equip_item_cnt_sum = ship_equip_item.findViewById(R.id.equipment_cnt_sum); JsonObject ship_equip_detail = getEquipmentShipDetail(key); ship_equip_item_lv.setText(getLvText(lv)); if (lv == 0) ship_equip_item_lv.setTextColor(ContextCompat.getColor(context, R.color.grey)); else ship_equip_item_lv.setTextColor(ContextCompat.getColor(context, R.color.itemlevel)); if (is_aircraft) { ship_equip_item_alv.setVisibility(View.VISIBLE); ship_equip_item_alv.setText(getAlvText(alv)); if (alv < 0) ship_equip_item_alv.setTextColor(ContextCompat.getColor(context, R.color.grey)); else if (alv < 4) ship_equip_item_alv.setTextColor(ContextCompat.getColor(context, R.color.itemalv1)); else ship_equip_item_alv.setTextColor(ContextCompat.getColor(context, R.color.itemalv2)); } else { ship_equip_item_alv.setVisibility(View.GONE); ship_equip_item_alv.setText(""); } int item_count = countInfo.get(key).get(); int item_equip_count = ship_equip_detail.get("count").getAsInt(); ship_equip_item_cnt_sum.setText(KcaUtils.format(summary_format, item_count, item_equip_count, item_count - item_equip_count)); ship_equip_item_ships.setText(ship_equip_detail.get("ship").getAsString()); return ship_equip_item; }
Example #28
Source File: OverviewFragment.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onDestroyActionMode(ActionMode mode) { mAdapter.clearSelection(); mActionMode = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.getWindow().setStatusBarColor(ContextCompat.getColor(getContext(), R.color.theme_default_primary_dark)); activity.getWindow().setNavigationBarColor(ContextCompat.getColor(getContext(), R.color.md_black_1000)); } isInActionMode = false; }
Example #29
Source File: SubmitConfirmationCodeFragment.java From FirebaseUI-Android with Apache License 2.0 | 5 votes |
@Override public void onResume() { super.onResume(); if (!mHasResumed) { // Don't check for codes before we've even had the chance to send one. mHasResumed = true; return; } ClipData clip = ContextCompat.getSystemService(requireContext(), ClipboardManager.class) .getPrimaryClip(); if (clip != null && clip.getItemCount() == 1) { CharSequence candidate = clip.getItemAt(0).getText(); if (candidate != null && candidate.length() == VERIFICATION_CODE_LENGTH) { try { Integer.parseInt(candidate.toString()); // We have a number! Try to submit it. mConfirmationCodeEditText.setText(candidate); } catch (NumberFormatException ignored) { // Turns out it wasn't a number } } } mLooper.removeCallbacks(mCountdown); mLooper.postDelayed(mCountdown, TICK_INTERVAL_MILLIS); }
Example #30
Source File: ObservationEditActivity.java From mage-android with Apache License 2.0 | 5 votes |
public void onCameraClick(View v) { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(ObservationEditActivity.this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_CAMERA); } else { launchCameraIntent(); } }