android.support.v4.content.ContextCompat Java Examples
The following examples show how to use
android.support.v4.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: RegisterActivity.java From tysq-android with GNU General Public License v3.0 | 6 votes |
/** * 显示邮箱验证验证 * * @param registerResp */ private void showEmailVerifyDialog(RegisterResp registerResp) { String content = String.format(getString(R.string.email_verify_tip_content), registerResp.getActivateEmailScore()); new MaterialDialog.Builder(this) .title(getString(R.string.email_verify_tip_title)) .content(content) .negativeColor(ContextCompat.getColor(this, R.color.et_tip_text_color)) .negativeText(getString(R.string.email_verify_skip)) .onNegative((dialog, which) -> { // 发送登录成功事件,会关闭 "登录"、"注册"、"忘记密码" 页 EventBus.getDefault().post(new LoginSucEvent()); }) .positiveColor(ContextCompat.getColor(this, R.color.main_blue_color)) .positiveText(getString(R.string.email_verify_verify)) .onPositive((dialog, which) -> { EmailVerifyActivity .startActivity(this, UserCache.getDefault().getEmail()); // 发送登录成功事件,会关闭 "登录"、"注册"、"忘记密码" 页 EventBus.getDefault().post(new LoginSucEvent()); }) .show(); }
Example #2
Source File: MatchProgressActivity.java From android with Apache License 2.0 | 6 votes |
private void appendEvent(@DrawableRes int icon, String text, int gravity) { FrameLayout view = (FrameLayout) LayoutInflater.from(this) .inflate(R.layout.match_event, eventsLayout, false); TextView textView = view.findViewById(R.id.txt_match_events); textView.setText(text); Drawable drawable = ContextCompat.getDrawable(this, icon); drawable.setBounds(0, 0, iconSize, iconSize); textView.setCompoundDrawablePadding(iconPadding); if (gravity == GravityCompat.START) { textView.setCompoundDrawables(null, null, drawable, null); } else { textView.setCompoundDrawables(drawable, null, null, null); } LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams(); layoutParams.gravity = gravity; view.setLayoutParams(layoutParams); textView.setGravity(gravity); eventsLayout.addView(view, 0); eventsTimeline.setVisibility(View.VISIBLE); eventsScrollView.smoothScrollTo(0, 0); }
Example #3
Source File: MainActivity.java From TextThing with BSD 2-Clause "Simplified" License | 6 votes |
void themeDay() { themeNr = 1; mainView.setBackgroundColor( ContextCompat.getColor(getApplicationContext(), R.color.MiddleDay) ); btn.setTextColor(Color.WHITE); contentView.setBackgroundColor( ContextCompat.getColor(getApplicationContext(), R.color.DarkDay) ); contentView.setTextColor( ContextCompat.getColor(getApplicationContext(), R.color.LightDay) ); if (Build.VERSION.SDK_INT >= 21) { getWindow().setStatusBarColor( ContextCompat.getColor(getApplicationContext(), R.color.LightDay) ); } if (isMono) { contentView.setTypeface(Typeface.MONOSPACE); btn.setTypeface(Typeface.MONOSPACE); } else { contentView.setTypeface(Typeface.SANS_SERIF); btn.setTypeface(Typeface.SANS_SERIF); } }
Example #4
Source File: MainActivity.java From MOAAP with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_main); if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { Log.i("permission", "request READ_EXTERNAL_STORAGE"); ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA); }else { Log.i("permission", "READ_EXTERNAL_STORAGE already granted"); camera_granted = true; } mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.java_surface_view); mOpenCvCameraView.setCvCameraViewListener(this); }
Example #5
Source File: MainActivity.java From OpenWeatherPlus-Android with Apache License 2.0 | 6 votes |
@Override public void onLocationChanged(AMapLocation aMapLocation) { if (aMapLocation.getErrorCode() == 0) { ContentUtil.NOW_LON = aMapLocation.getLongitude(); ContentUtil.NOW_LAT = aMapLocation.getLatitude(); getNowCity(true); mLocationClient.onDestroy(); } else { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // 没有权限 View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.pop_loc_list, null); LocListWindow locListWindow = new LocListWindow(view, MATCH_PARENT, MATCH_PARENT, MainActivity.this); locListWindow.show(); locListWindow.showAtLocation(tvLocation, Gravity.CENTER, 0, 0); if (ContentUtil.FIRST_OPEN) { ContentUtil.FIRST_OPEN = false; SpUtils.putBoolean(MainActivity.this, "first_open", false); } } getNowCity(true); mLocationClient.onDestroy(); } }
Example #6
Source File: TintableImageView.java From ImageLetterIcon with Apache License 2.0 | 6 votes |
@Override protected void drawableStateChanged() { super.drawableStateChanged(); if (mTint != null) { if (mTint.isStateful()) setColorFilter(mTint.getColorForState(getDrawableState(), 0)); else setColorFilter(mTint); } Drawable drawable = getBackground(); if (mBackgroundTint != null && drawable != null) { Drawable wrap = DrawableCompat.wrap(drawable); wrap = wrap.mutate(); if (mBackgroundTint.isStateful()) DrawableCompat.setTint(wrap, ContextCompat.getColor(getContext(), mBackgroundTint.getColorForState(getDrawableState(), 0))); else DrawableCompat.setTintList(wrap, mBackgroundTint); DrawableCompat.setTintMode(wrap, PorterDuff.Mode.SRC_IN); } }
Example #7
Source File: MainActivity.java From SoftwarePilot with MIT License | 6 votes |
/** * Checks if there is any missing permissions, and * requests runtime permission if needed. */ private void checkAndRequestPermissions() { // Check for permissions for (String eachPermission : REQUIRED_PERMISSION_LIST) { if (ContextCompat.checkSelfPermission(this, eachPermission) != PackageManager.PERMISSION_GRANTED) { missingPermission.add(eachPermission); } } // Request for missing permissions if (missingPermission.isEmpty()) { startSDKRegistration(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { showToast("Need to grant the permissions!"); ActivityCompat.requestPermissions(this, missingPermission.toArray(new String[missingPermission.size()]), REQUEST_PERMISSION_CODE); } }
Example #8
Source File: MainActivity.java From renrenpay-android with Apache License 2.0 | 6 votes |
/** * 获取权限。。有些手机很坑,明明是READ_PHONE_STATE权限,却问用户是否允许拨打电话,汗。 */ private void getPermissions() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return; } List<String> sa = new ArrayList<>(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { //申请READ_PHONE_STATE权限。。。。 sa.add(Manifest.permission.READ_PHONE_STATE); } if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { sa.add(Manifest.permission.READ_EXTERNAL_STORAGE); } if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { sa.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); } if (sa.size() < 1) { return; } ActivityCompat.requestPermissions(this, sa.toArray(new String[]{}), 1); }
Example #9
Source File: LogoutActivity.java From KUAS-AP-Material with MIT License | 6 votes |
@Override public void onClick(View v) { if (v.getId() == R.id.button_openUrl) { mTracker.send(new HitBuilders.EventBuilder().setCategory("open url").setAction("click") .build()); String shareData = mTitle + "\n" + mURL + "\n\n" + getString(R.string.send_from); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_share_white_24dp); builder.setActionButton(icon, getString(R.string.share), Utils.createSharePendingIntent(this, shareData)); builder.setToolbarColor(ContextCompat.getColor(this, R.color.main_theme)); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(this, Uri.parse(mURL)); } else if (v.getId() == R.id.button_logout) { mTracker.send(new HitBuilders.EventBuilder().setCategory("logout").setAction("click") .build()); clearUserData(); startActivity(new Intent(this, LoginActivity.class)); finish(); } }
Example #10
Source File: PBaseLoaderFragment.java From YImagePicker with Apache License 2.0 | 6 votes |
/** * 加载媒体文件夹 */ protected void loadMediaSets() { if (getActivity() == null) { return; } if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQ_STORAGE); } else { //从媒体库拿到文件夹列表 ImagePicker.provideMediaSets(getActivity(), getSelectConfig().getMimeTypes(), new MediaSetsDataSource.MediaSetProvider() { @Override public void providerMediaSets(ArrayList<ImageSet> imageSets) { loadMediaSetsComplete(imageSets); } }); } }
Example #11
Source File: MainActivity.java From android-base-mvp with Apache License 2.0 | 6 votes |
@Override public void showWeather(WeatherPojo weatherPojo) { Timber.d("show Weather %s", weatherPojo.toString()); textview_main_city.setText(weatherPojo.getName()); textView_main_current_temperature.setText(String.format("%.1f°", weatherPojo.getMain().getTemp())); textView_main_min_max.setText(String.format("%.1f° %.1f°", weatherPojo.getMain().getTempMin(), weatherPojo.getMain().getTempMax())); textView_main_conditions.setText(weatherPojo.getWeather().get(0).getDescription()); textView_main_humidity.setText(getString(R.string.humidity) + " " + weatherPojo.getMain().getHumidity() + "%"); String wind_suffix = getResources().getString(R.string.wind_suffix_metric); if (UnitLocale.getDefault().equals(UnitLocale.Imperial)) wind_suffix = getResources().getString(R.string.wind_suffix_imperial); textView_main_wind.setText(getString(R.string.wind) + " " + String.valueOf(weatherPojo.getWind().getSpeed()) + wind_suffix); textView_main_pressure.setText(getString(R.string.pressure) + " " + weatherPojo.getMain().getPressure() + "hPa"); imageView_main_icon.setImageDrawable(ContextCompat.getDrawable(getContext(), getIcon(weatherPojo.getWeather().get(0).getId()))); }
Example #12
Source File: PDFViewActivity.java From AndroidPdfViewerV1 with Apache License 2.0 | 6 votes |
@OptionsItem(R.id.pickFile) void pickFile() { int permissionCheck = ContextCompat.checkSelfPermission(this, READ_EXTERNAL_STORAGE); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions( this, new String[]{READ_EXTERNAL_STORAGE}, PERMISSION_CODE ); return; } launchPicker(); }
Example #13
Source File: MainActivity.java From Android-Example with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvLatitude = (TextView)findViewById(R.id.latitude); tvLongitude = (TextView)findViewById(R.id.longitude); try { if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED ) { ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 101); } } catch (Exception e){ e.printStackTrace(); } }
Example #14
Source File: AuthenticatorActivity.java From Capstone-Project with MIT License | 6 votes |
private void manageBackgroundColor() { switch (PredatorSharedPreferences.getCurrentTheme(getApplicationContext())) { case LIGHT: relativeLayoutAuthenticator.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.background_color)); break; case DARK: relativeLayoutAuthenticator.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.background_color_inverse)); break; case AMOLED: relativeLayoutAuthenticator.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.background_color_amoled)); break; } }
Example #15
Source File: QueueActivity.java From PainlessMusicPlayer with Apache License 2.0 | 6 votes |
private void prepareViewsAndExit(@NonNull final Runnable exitAction) { if (!TransitionUtils.supportsActivityTransitions() || (fab.getScaleX() == 0f && albumArtDim.getAlpha() == 0f)) { exitAction.run(); } else { final boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // Landscape Now Playing has a dim, so dim the ImageView and send it if (isLandscape) { albumArtDim.setAlpha(0f); albumArt.setColorFilter( ContextCompat.getColor(this, R.color.translucentBackground), PorterDuff.Mode.SRC_ATOP); } else { // Portrait NowPlaying does not have a dim. Fade out the dim before animating. albumArtDim.animate().alpha(0f).setDuration(mShortAnimTime).start(); } fab.animate().scaleX(0f).scaleY(0f).setDuration(mShortAnimTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { exitAction.run(); } }).start(); } }
Example #16
Source File: DownloadManagerResolver.java From FaceSlim with GNU General Public License v2.0 | 6 votes |
private static AlertDialog createDialog(final Context context) { AppCompatTextView messageTextView = new AppCompatTextView(context); messageTextView.setTextSize(16f); messageTextView.setText(context.getString(R.string.download_manager_disabled)); messageTextView.setPadding(50, 50, 50, 0); messageTextView.setTextColor(ContextCompat.getColor(context, R.color.black)); return new AlertDialog.Builder(context) .setView(messageTextView) .setPositiveButton("ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { enableDownloadManager(context); } }) .setCancelable(false) .create(); }
Example #17
Source File: WearActivity.java From pocketsphinx-android-demo with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void onCreate(Bundle state) { super.onCreate(state); // Prepare the data for UI captions = new HashMap<String, Integer>(); captions.put(KWS_SEARCH, R.string.kws_caption); captions.put(MENU_SEARCH, R.string.menu_caption); captions.put(DIGITS_SEARCH, R.string.digits_caption); captions.put(PHONE_SEARCH, R.string.phone_caption); captions.put(FORECAST_SEARCH, R.string.forecast_caption); setContentView(R.layout.activity_main); ((TextView) findViewById(edu.cmu.pocketsphinx.demo.wear.R.id.caption_text)) .setText("Preparing the recognizer"); // Check if user has given permission to record audio int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.RECORD_AUDIO); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSIONS_REQUEST_RECORD_AUDIO); return; } runRecognizerSetup(); }
Example #18
Source File: MainActivity.java From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 | 5 votes |
public void changeBackgroundColor(final View view, int from, int to) { int colorFrom = ContextCompat.getColor(this, from); int colorTo = ContextCompat.getColor(this, to); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(250); // milliseconds colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); }
Example #19
Source File: StepperLayout.java From android-material-stepper with Apache License 2.0 | 5 votes |
private void initDefaultValues() { mBackButtonColor = mNextButtonColor = mCompleteButtonColor = ContextCompat.getColorStateList(getContext(), R.color.ms_bottomNavigationButtonTextColor); mSelectedColor = ContextCompat.getColor(getContext(), R.color.ms_selectedColor); mUnselectedColor = ContextCompat.getColor(getContext(), R.color.ms_unselectedColor); mErrorColor = ContextCompat.getColor(getContext(), R.color.ms_errorColor); mBackButtonText = getContext().getString(R.string.ms_back); mNextButtonText = getContext().getString(R.string.ms_next); mCompleteButtonText = getContext().getString(R.string.ms_complete); }
Example #20
Source File: ExploreFragment.java From C9MJ with Apache License 2.0 | 5 votes |
@Override public void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive) { if (!isCurrentlyActive) { BaseViewHolder holder = (BaseViewHolder) viewHolder; CardView cardView = holder.getView(R.id.cardview); cardView.setCardBackgroundColor(ContextCompat.getColor(context, R.color.color_primary)); } }
Example #21
Source File: FriendZomatoActivity.java From Expert-Android-Programming with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_friends_search); toolbar = (Toolbar) findViewById(R.id.toolbar1); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("Find friends on Zomato"); toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white)); recyclerView = (RecyclerView) findViewById(R.id.recyclerView); allList = new ArrayList<>(); allAdapter = new FriendAdapter(context, allList); /*allAdapter.setClickListener(new FriendAdapter.ClickListener() { @Override public void onItemClickListener(View v, int pos) { } @Override public void onFriendListener(int pos, boolean isFollowing) { } });*/ recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.setNestedScrollingEnabled(false); recyclerView.setAdapter(allAdapter); setList(); }
Example #22
Source File: AbsWeexActivity.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public void runWithPermissionsCheck(int requestCode, String permission, Runnable runnable) { if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) { Toast.makeText(this, "please give me the permission", Toast.LENGTH_SHORT).show(); } else { ActivityCompat.requestPermissions(this, new String[]{permission}, requestCode); } } else { if (runnable != null) { runnable.run(); } } }
Example #23
Source File: LikeButton.java From MangoBloggerAndroidApp with Mozilla Public License 2.0 | 5 votes |
/** * This drawable is shown when the button is a liked state. * * @param resId */ public void setLikeDrawableRes(@DrawableRes int resId) { likeDrawable = ContextCompat.getDrawable(getContext(), resId); if (iconSize != 0) { likeDrawable = Utils.resizeDrawable(getContext(), likeDrawable, iconSize, iconSize); } if (isChecked) { icon.setImageDrawable(likeDrawable); } }
Example #24
Source File: CaptureActivity.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 获得运行时权限 */ private void getRuntimeRight() { if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1); } else { openAlbum(); } }
Example #25
Source File: ChartSettings.java From BrainPhaser with GNU General Public License v3.0 | 5 votes |
/** * Formats the text which will be shown when no challenges exist * * @param chart the chart whose no data text will be formatted */ public void applyNoDataSettings(Chart chart) { chart.setNoDataText(mApplication.getString(R.string.chart_no_data_text)); Paint p = chart.getPaint(Chart.PAINT_INFO); p.setTextSize(NO_DATA_TEXT_SIZE); Context appContext = mApplication.getApplicationContext(); p.setColor(ContextCompat.getColor(appContext, android.R.color.tertiary_text_light)); }
Example #26
Source File: VRListActivity.java From VRPlayer with Apache License 2.0 | 5 votes |
private void checkPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, permissions, REQUEST_PERMISSIONS); }else { scanVideo(); } }
Example #27
Source File: ProductDetailActivity.java From FaceT with Mozilla Public License 2.0 | 5 votes |
private void setUpEmojiPopup() { emojiPopup = EmojiPopup.Builder.fromRootView(activity_product_detail_layout) .setOnEmojiBackspaceClickListener(new OnEmojiBackspaceClickListener() { @Override public void onEmojiBackspaceClick(final View v) { Log.d(TAG, "Clicked on Backspace"); } }) .setOnEmojiClickListener(new OnEmojiClickListener() { @Override public void onEmojiClick(@NonNull final EmojiImageView imageView, @NonNull final Emoji emoji) { Log.d(TAG, "Clicked on emoji"); } }) .setOnEmojiPopupShownListener(new OnEmojiPopupShownListener() { @Override public void onEmojiPopupShown() { emojiButton.setBackground(ContextCompat.getDrawable(ProductDetailActivity.this, R.drawable.ic_keyboard)); } }) .setOnSoftKeyboardOpenListener(new OnSoftKeyboardOpenListener() { @Override public void onKeyboardOpen(final int keyBoardHeight) { Log.d(TAG, "Opened soft keyboard"); } }) .setOnEmojiPopupDismissListener(new OnEmojiPopupDismissListener() { @Override public void onEmojiPopupDismiss() { emojiButton.setBackground(ContextCompat.getDrawable(ProductDetailActivity.this, R.drawable.emoji_one_category_people)); } }) .setOnSoftKeyboardCloseListener(new OnSoftKeyboardCloseListener() { @Override public void onKeyboardClose() { emojiPopup.dismiss(); Log.d(TAG, "Closed soft keyboard"); } }) .build(commentEmojiconEditText); }
Example #28
Source File: RichEditorFunctionBar.java From RichEditor with MIT License | 5 votes |
private void initButton(Context context) { Drawable normal = ContextCompat.getDrawable(context, R.drawable.bg_normal_shape); Drawable select = ContextCompat.getDrawable(context, R.drawable.bg_select_shape); Drawable highlight = ContextCompat.getDrawable(context, R.drawable.bg_highlight_shap); for (int type : typeSet) { final StateListImageButton stateListImageButton = stateListImageButtonSparseArray.get(type); stateListImageButton.addState(StyleTypeStateSpec.StyleTypeState.STATE_NONE, normal); stateListImageButton.addState(StyleTypeStateSpec.StyleTypeState.STATE_EXIST, select); stateListImageButton.addState(StyleTypeStateSpec.StyleTypeState.STATE_ACTIVE, highlight); stateListImageButton.setOnClickListener(new StateListImageButtonOnClickListener(type)); } }
Example #29
Source File: CustomScrollerViewProvider.java From recycler-fast-scroll with Apache License 2.0 | 5 votes |
@Override public View provideHandleView(ViewGroup container) { handle = new View(getContext()); int dimen = getContext().getResources().getDimensionPixelSize(R.dimen.custom_handle_size); handle.setLayoutParams(new ViewGroup.LayoutParams(dimen, dimen)); Utils.setBackground(handle, drawCircle(dimen, dimen, ContextCompat.getColor(getContext(), R.color.custom_handle_color))); handle.setVisibility(View.INVISIBLE); return handle; }
Example #30
Source File: PermissionsUtils.java From PhotoPicker with Apache License 2.0 | 5 votes |
public static boolean checkCameraPermission(Fragment fragment) { int cameraPermissionState = ContextCompat.checkSelfPermission(fragment.getContext(), CAMERA); boolean cameraPermissionGranted = cameraPermissionState == PackageManager.PERMISSION_GRANTED; if (!cameraPermissionGranted) { fragment.requestPermissions(PermissionsConstant.PERMISSIONS_CAMERA, PermissionsConstant.REQUEST_CAMERA); } return cameraPermissionGranted; }