android.support.v4.content.res.ResourcesCompat Java Examples

The following examples show how to use android.support.v4.content.res.ResourcesCompat. 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 Project: android-vertical-stepper-view   Author: liefery   File: VerticalStepperItemView.java    License: MIT License 6 votes vote down vote up
private void setStateComplete() {
    setMarginBottom( false );
    circle.setBackgroundActive();

    if ( isEditable() )
        circle.setIconEdit();
    else
        circle.setIconCheck();

    title.setTextColor( ResourcesCompat.getColor(
        getResources(),
        R.color.vertical_stepper_view_black_87,
        null ) );
    title.setTypeface( title.getTypeface(), Typeface.BOLD );
    summary.setVisibility( TextUtils.isEmpty( summary.getText() ) ? View.GONE
                    : View.VISIBLE );
    contentWrapper.setVisibility( View.GONE );
}
 
Example #2
Source Project: vk_music_android   Author: Mavamaarten   File: VkAudioAdapter.java    License: GNU General Public License v3.0 6 votes vote down vote up
void bind(VKApiAudio audio) {
    binding.getRoot().setOnClickListener(v -> listener.onAudioClicked(audio, getAdapterPosition()));
    binding.audioOptions.setOnClickListener(v -> showPopupMenu(v, audio));
    binding.dragHandle.setOnTouchListener((v, event) -> {
        if (startDragListener == null) {
            return false;
        }
        startDragListener.startDrag(this);
        return true;
    });
    binding.setAudio(audio);
    binding.executePendingBindings();

    if (currentAudio == null || audio.id != currentAudio.id) {
        binding.audioTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null);
    } else {
        binding.audioTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
                ResourcesCompat.getDrawable(resources, R.drawable.ic_now_playing_indicator, null),
                null,
                null,
                null
        );
    }
}
 
Example #3
Source Project: homeassist   Author: axzae   File: ConnectActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showError(String message) {
    Drawable warningIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_warning_white_18dp, null);
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(message);
    mSnackbar = Snackbar.make(findViewById(android.R.id.content), builder, Snackbar.LENGTH_LONG)
            .setAction(getString(R.string.action_retry), new OnClickListener() {
                @Override
                public void onClick(View view) {
                    attemptLogin();
                }
            });
    TextView textView = mSnackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
    textView.setCompoundDrawablesWithIntrinsicBounds(warningIcon, null, null, null);
    textView.setCompoundDrawablePadding(getResources().getDimensionPixelOffset(R.dimen.icon_8dp));
    mSnackbar.getView().setBackgroundColor(ResourcesCompat.getColor(getResources(), R.color.md_red_A200, null));
    mSnackbar.show();
}
 
Example #4
Source Project: android-material-stepper   Author: stepstone-tech   File: StepperLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void setCompoundDrawablesForNavigationButtons(@DrawableRes int backDrawableResId, @DrawableRes int nextDrawableResId) {
    Drawable chevronStartDrawable = backDrawableResId != StepViewModel.NULL_DRAWABLE
            ? ResourcesCompat.getDrawable(getContext().getResources(), backDrawableResId, null)
            : null;
    Drawable chevronEndDrawable = nextDrawableResId != StepViewModel.NULL_DRAWABLE
            ? ResourcesCompat.getDrawable(getContext().getResources(), nextDrawableResId, null)
            : null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mBackNavigationButton.setCompoundDrawablesRelativeWithIntrinsicBounds(chevronStartDrawable, null, null, null);
    } else {
        mBackNavigationButton.setCompoundDrawablesWithIntrinsicBounds(chevronStartDrawable, null, null, null);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mNextNavigationButton.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, chevronEndDrawable, null);
    } else {
        mNextNavigationButton.setCompoundDrawablesWithIntrinsicBounds(null, null, chevronEndDrawable, null);
    }

    TintUtil.tintTextView(mBackNavigationButton, mBackButtonColor);
    TintUtil.tintTextView(mNextNavigationButton, mNextButtonColor);
    TintUtil.tintTextView(mCompleteNavigationButton, mCompleteButtonColor);
}
 
Example #5
Source Project: android-map-sdk   Author: navermaps   File: PolygonOverlayActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(@NonNull NaverMap naverMap) {
    int color = ResourcesCompat.getColor(getResources(), R.color.primary, getTheme());

    PolygonOverlay polygon = new PolygonOverlay();
    polygon.setCoords(COORDS_1);
    polygon.setColor(ColorUtils.setAlphaComponent(color, 31));
    polygon.setOutlineColor(color);
    polygon.setOutlineWidth(getResources().getDimensionPixelSize(R.dimen.overlay_line_width));
    polygon.setMap(naverMap);

    PolygonOverlay polygonWithHole = new PolygonOverlay();
    polygonWithHole.setCoords(COORDS_2);
    polygonWithHole.setHoles(HOLES);
    polygonWithHole.setColor(
        ColorUtils.setAlphaComponent(ResourcesCompat.getColor(getResources(), R.color.gray, getTheme()), 127));
    polygonWithHole.setMap(naverMap);
}
 
Example #6
Source Project: android-docs-samples   Author: GoogleCloudPlatform   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Resources resources = getResources();
    final Resources.Theme theme = getTheme();
    mColorHearing = ResourcesCompat.getColor(resources, R.color.status_hearing, theme);
    mColorNotHearing = ResourcesCompat.getColor(resources, R.color.status_not_hearing, theme);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    mStatus = (TextView) findViewById(R.id.status);
    mText = (TextView) findViewById(R.id.text);

    mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    final ArrayList<String> results = savedInstanceState == null ? null :
            savedInstanceState.getStringArrayList(STATE_RESULTS);
    mAdapter = new ResultAdapter(results);
    mRecyclerView.setAdapter(mAdapter);
}
 
Example #7
Source Project: android-map-sdk   Author: navermaps   File: GlobalZIndexActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(@NonNull NaverMap naverMap) {
    PathOverlay pathOverlay = new PathOverlay();
    pathOverlay.setCoords(PATH_COORDS);
    pathOverlay.setWidth(getResources().getDimensionPixelSize(R.dimen.path_overlay_width));
    pathOverlay.setColor(ResourcesCompat.getColor(getResources(), R.color.primary, getTheme()));
    pathOverlay.setOutlineWidth(getResources().getDimensionPixelSize(R.dimen.path_overlay_outline_width));
    pathOverlay.setOutlineColor(Color.WHITE);
    pathOverlay.setMap(naverMap);

    Marker marker1 = new Marker();
    marker1.setPosition(new LatLng(37.5701761, 126.9799315));
    marker1.setCaptionText(getString(R.string.marker_over_path));
    marker1.setMap(naverMap);

    Marker marker2 = new Marker();
    marker2.setPosition(new LatLng(37.5664663, 126.9772952));
    marker2.setIcon(MarkerIcons.BLUE);
    marker2.setCaptionText(getString(R.string.marker_under_path));
    marker2.setGlobalZIndex(PathOverlay.DEFAULT_GLOBAL_Z_INDEX - 1);
    marker2.setMap(naverMap);
}
 
Example #8
Source Project: SocialMentionAutoComplete   Author: ameenmaheen   File: SocialMentionAutoComplete.java    License: Apache License 2.0 6 votes vote down vote up
public CharSequence terminateToken(CharSequence text) {

            int i = text.length();

            while (i > 0 && text.charAt(i - 1) == ' ') {
                i--;
            }

            if (i > 0 && text.charAt(i - 1) == ' ') {
                return text;
            } else {
                // Returns colored text for selected token
                SpannableString sp = new SpannableString(String.format(formattedOfString, text));
                int textColor = ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null);
                sp.setSpan(new ForegroundColorSpan(textColor), 0, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                return sp;
            }
        }
 
Example #9
Source Project: candybar-library   Author: danimahardhika   File: DrawableHelper.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
public static Drawable getHighQualityIcon(@NonNull Context context, String packageName) {
    try {
        PackageManager packageManager = context.getPackageManager();
        ApplicationInfo info = packageManager.getApplicationInfo(
                packageName, PackageManager.GET_META_DATA);

        Resources resources = packageManager.getResourcesForApplication(packageName);
        int density = DisplayMetrics.DENSITY_XXHIGH;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            density = DisplayMetrics.DENSITY_XXXHIGH;
        }

        Drawable drawable = ResourcesCompat.getDrawableForDensity(
                resources, info.icon, density, null);
        if (drawable != null) return drawable;
        return info.loadIcon(packageManager);
    } catch (Exception | OutOfMemoryError e) {
        LogUtil.e(Log.getStackTraceString(e));
    }
    return null;
}
 
Example #10
Source Project: Kandroid   Author: andresth   File: TaskEditActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void setButtonColor() {
    if (kanboardColors == null || defaultColor == null)
        return;

    btnColor.setEnabled(true);

    Drawable dot = ResourcesCompat.getDrawable(getResources(), R.drawable.shape_circle, null);
    if (colorId != null && kanboardColors.get(colorId) != null) {  //FIXME: it seems that colorId can have a value that is not in the list. Fallback to defaultColor for now.
        dot.setColorFilter(kanboardColors.get(colorId).getBackground(), PorterDuff.Mode.MULTIPLY);
        btnColor.setText(Utils.fromHtml(getString(R.string.taskedit_color, kanboardColors.get(colorId).getName())));
    } else {
        dot.setColorFilter(kanboardColors.get(defaultColor).getBackground(), PorterDuff.Mode.MULTIPLY);
        btnColor.setText(Utils.fromHtml(getString(R.string.taskedit_color, kanboardColors.get(defaultColor).getName())));
    }
    btnColor.setCompoundDrawablesRelativeWithIntrinsicBounds(dot, null, null, null);
}
 
Example #11
Source Project: Camera-Roll-Android-App   Author: kollerlukas   File: Util.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("inlineValue")
public static TextView setToolbarTypeface(Toolbar toolbar) {
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        View view = toolbar.getChildAt(i);
        if (view instanceof TextView) {
            TextView textView = (TextView) view;
            if (textView.getText().equals(toolbar.getTitle())) {
                Typeface typeface = ResourcesCompat
                        .getFont(toolbar.getContext(), R.font.roboto_mono_medium);
                textView.setTypeface(typeface);
                return textView;
            }
        }
    }
    return null;
}
 
Example #12
Source Project: MapsSDK-Native   Author: microsoft   File: MainActivity.java    License: MIT License 5 votes vote down vote up
private MapImage getPinImage() {
    Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_pin, null);

    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return new MapImage(bitmap);
}
 
Example #13
Source Project: MapsSDK-Native   Author: microsoft   File: MainActivity.java    License: MIT License 5 votes vote down vote up
private MapImage getPinImage() {
    Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_pin, null);

    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return new MapImage(bitmap);
}
 
Example #14
Source Project: GNSS_Compare   Author: TheGalfins   File: MapFragment.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Demonstrates converting a {@link Drawable} to a {@link BitmapDescriptor},
 * for use as a marker icon.
 */
private BitmapDescriptor vectorToBitmap(@DrawableRes int id, @ColorInt int color) {
    Drawable vectorDrawable = ResourcesCompat.getDrawable(getResources(), id, null);
    Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
            vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    DrawableCompat.setTint(vectorDrawable, color);
    vectorDrawable.draw(canvas);
    return BitmapDescriptorFactory.fromBitmap(bitmap);
}
 
Example #15
Source Project: MagicPrint-ECommerce-App-Android   Author: singhkshitij   File: SplashActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    session =new UserSession(SplashActivity.this);

  Typeface typeface = ResourcesCompat.getFont(this, R.font.blacklist);

  TextView appname= findViewById(R.id.appname);
  appname.setTypeface(typeface);

    YoYo.with(Techniques.Bounce)
            .duration(7000)
            .playOn(findViewById(R.id.logo));

    YoYo.with(Techniques.FadeInUp)
            .duration(5000)
            .playOn(findViewById(R.id.appname));

        new Handler().postDelayed(new Runnable() {

        /*
         * Showing splash screen with a timer. This will be useful when you
         * want to show case your app logo / company
         */

            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity
                startActivity(new Intent(SplashActivity.this,WelcomeActivity.class));
                finish();
            }
        }, SPLASH_TIME_OUT);
    }
 
Example #16
Source Project: MagicPrint-ECommerce-App-Android   Author: singhkshitij   File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Typeface typeface = ResourcesCompat.getFont(this, R.font.blacklist);
    TextView appname = findViewById(R.id.appname);
    appname.setTypeface(typeface);

    //check Internet Connection
    new CheckInternetConnection(this).checkConnection();

    //retrieve session values and display on listviews
    getValues();

    //Navigation Drawer with toolbar
    inflateNavDrawer();

    //ImageSLider
    inflateImageSlider();

    if (session.getFirstTime()) {
        //tap target view
        tapview();
        session.setFirstTime(false);
    }
}
 
Example #17
Source Project: oversec   Author: oversecio   File: OverlayButtonUpgradeView.java    License: GNU General Public License v3.0 5 votes vote down vote up
public OverlayButtonUpgradeView(Core core, String packageName) {
    super(core, packageName);

    int myWH = isSmall() ? WH_SMALL_PX : WH_PX;

    mPortraitX = mDisplayWidth / 2 - myWH / 2;
    mPortraitY = mDisplayHeight / 2 - myWH / 2;

    //noinspection SuspiciousNameCombination
    mLandscapeX = mPortraitY;
    //noinspection SuspiciousNameCombination
    mLandscapeY = mPortraitX;


    mView.setImageDrawable(null);
    mView.setBackground(null);

    mView.postDelayed(new Runnable() {
        @Override
        public void run() {
            try {
                mView.setImageResource(R.drawable.ic_shop_black_24dp);
                mView.setBackground(
                        ResourcesCompat.getDrawable(getResources(), R.drawable.fab_bg, getContext().getTheme()));
            } catch (Exception ex) {

            }
        }
    }, IabUtil.getInstance(getContext()).getUpgradeButtonDelay(mView.getContext()));
}
 
Example #18
Source Project: android-vertical-stepper-view   Author: liefery   File: ConnectorLineDrawer.java    License: MIT License 5 votes vote down vote up
ConnectorLineDrawer( Context context ) {
    int grey = ResourcesCompat.getColor(
        context.getResources(),
        R.color.vertical_stepper_view_grey_100,
        null );
    paint.setColor( grey );
}
 
Example #19
Source Project: SublimeNavigationView   Author: vikramkakkar   File: SublimeThemer.java    License: Apache License 2.0 5 votes vote down vote up
public Drawable getGroupCollapseDrawable() {
    if (mGroupCollapseDrawable == null) {
        mGroupCollapseDrawable = ResourcesCompat.getDrawable(mContext.getResources(),
                R.drawable.snv_collapse, mContext.getTheme());
    }

    // Return a new drawable since this method will be
    // called multiple times
    return mGroupCollapseDrawable.getConstantState().newDrawable();
}
 
Example #20
Source Project: AlbumCameraRecorder   Author: zhongjhATC   File: CheckRadioView.java    License: MIT License 5 votes vote down vote up
private void init() {
    mSelectedColor = ResourcesCompat.getColor(
            getResources(), R.color.blue_item_checkCircle_backgroundColor,
            getContext().getTheme());
    mUnSelectUdColor = ResourcesCompat.getColor(
            getResources(), R.color.blue_check_original_radio_disable,
            getContext().getTheme());
    setChecked(false);
}
 
Example #21
Source Project: leanback-showcase   Author: googlearchive   File: SearchFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    AndroidSupportInjection.inject(this);
    super.onCreate(savedInstanceState);
    setBadgeDrawable(ResourcesCompat.getDrawable(getActivity().getResources(),
            R.drawable.ic_add_row_circle_black_24dp, getActivity().getTheme()));

    setTitle("Search Using Live Data");
    setSearchResultProvider(this);
    setOnItemViewClickedListener(viewOnClickListenerMap.get(this.getClass()));
}
 
Example #22
Source Project: homeassist   Author: axzae   File: LibraryFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final LibraryViewHolder viewHolder, final int position) {
    final Library library = libraries.get(position);

    viewHolder.mNameView.setText(library.name);

    String subText = library.author;
    if (library.license != null) {
        subText += ", " + library.license;
    }
    viewHolder.mCodeView.setText(subText);

    if (library.website != null) {
        viewHolder.mItemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d("YouQi", "clicked");
                String url = library.website;
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
                //builder.setStartAnimations(this, R.anim.right_in, R.anim.left_out);
                //builder.setExitAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
                builder.setToolbarColor(ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null));
                CustomTabsIntent customTabsIntent = builder.build();
                customTabsIntent.launchUrl(getActivity(), Uri.parse(url));
                getActivity().overridePendingTransition(R.anim.stay_still, R.anim.fade_out);
            }
        });
    }
}
 
Example #23
Source Project: homeassist   Author: axzae   File: EditActivity.java    License: Apache License 2.0 5 votes vote down vote up
private Paint getDividerPaint() {
    Paint paint = new Paint();
    paint.setStrokeWidth(1);
    paint.setColor(ResourcesCompat.getColor(getResources(), R.color.colorDivider, null));
    paint.setAntiAlias(true);
    paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
    return paint;
}
 
Example #24
Source Project: android-docs-samples   Author: GoogleCloudPlatform   File: SentimentFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Resources resources = getResources();
    final Resources.Theme theme = getActivity().getTheme();
    mColorPositive = ResourcesCompat.getColor(resources, R.color.score_positive, theme);
    mColorNeutral = ResourcesCompat.getColor(resources, R.color.score_neutral, theme);
    mColorNegative = ResourcesCompat.getColor(resources, R.color.score_negative, theme);
}
 
Example #25
Source Project: homeassist   Author: axzae   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = View.inflate(getContext(), android.R.layout.simple_list_item_1, null);
    }

    ((TextView) convertView.findViewById(android.R.id.text1)).setText(items.get(position).getLine(getContext()));
    ((TextView) convertView.findViewById(android.R.id.text1)).setTextColor(ResourcesCompat.getColor(getResources(), R.color.md_white_1000, null));
    return convertView;
}
 
Example #26
Source Project: badgebutton   Author: czy1121   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
Drawable wrap(int icon) {
    Drawable drawable = ResourcesCompat.getDrawable(getResources(),icon, getTheme());
    if (mTint == null) {
        mTint = ResourcesCompat.getColorStateList(getResources(), R.color.tab, getTheme());
    }
    if (drawable != null) {
        drawable = DrawableCompat.wrap(drawable.mutate());
        DrawableCompat.setTintList(drawable, mTint);
    }
    return drawable;
}
 
Example #27
Source Project: android-map-sdk   Author: navermaps   File: ArrowheadPathOverlayActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(@NonNull NaverMap naverMap) {
    ArrowheadPathOverlay arrowheadPathOverlay = new ArrowheadPathOverlay();
    arrowheadPathOverlay.setCoords(COORDS);
    arrowheadPathOverlay.setWidth(getResources().getDimensionPixelSize(R.dimen.arrowhead_path_overlay_width));
    arrowheadPathOverlay.setColor(Color.WHITE);
    arrowheadPathOverlay.setOutlineWidth(
        getResources().getDimensionPixelSize(R.dimen.arrowhead_path_overlay_outline_width));
    arrowheadPathOverlay.setOutlineColor(ResourcesCompat.getColor(getResources(), R.color.primary, getTheme()));
    arrowheadPathOverlay.setMap(naverMap);
}
 
Example #28
Source Project: android-map-sdk   Author: navermaps   File: CircleOverlayActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(@NonNull NaverMap naverMap) {
    int color = ResourcesCompat.getColor(getResources(), R.color.primary, getTheme());

    CircleOverlay circleOverlay = new CircleOverlay();
    circleOverlay.setCenter(new LatLng(37.5666102, 126.9783881));
    circleOverlay.setRadius(500);
    circleOverlay.setColor(ColorUtils.setAlphaComponent(color, 31));
    circleOverlay.setOutlineColor(color);
    circleOverlay.setOutlineWidth(getResources().getDimensionPixelSize(R.dimen.overlay_line_width));
    circleOverlay.setMap(naverMap);
}
 
Example #29
Source Project: SocialMentionAutoComplete   Author: ameenmaheen   File: SocialMentionAutoComplete.java    License: Apache License 2.0 5 votes vote down vote up
/**
*This function will process the incoming text into mention format
* You have to implement the processing logic
* */
public void setMentioningText(String text) {

    map.clear();

    Pattern p = Pattern.compile("\\[([^]]+)]\\(([^ )]+)\\)");
    Matcher m = p.matcher(text);

    String finalDesc = text;

    while (m.find()) {
        MentionPerson mentionPerson = new MentionPerson();
        String name = m.group(1);
        String id = m.group(2);
        //Processing Logic
        finalDesc = finalDesc.replace("@[" + name + "](" + id + ")", "@" + name);

        mentionPerson.name = name;
        mentionPerson.id = id;
        map.put("@" + name, mentionPerson);
    }
    int textColor = ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null);
    Spannable spannable = new SpannableString(finalDesc);
    for (Map.Entry<String, MentionPerson> stringMentionPersonEntry : map.entrySet()) {
        int startIndex = finalDesc.indexOf(stringMentionPersonEntry.getKey());
        int endIndex = startIndex + stringMentionPersonEntry.getKey().length();
                   spannable.setSpan(new ForegroundColorSpan(textColor), startIndex, endIndex , Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    setText(spannable);
}
 
Example #30
Source Project: SocialMentionAutoComplete   Author: ameenmaheen   File: SocialMentionTextView.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {

        int textColor = ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null);
        setLinkTextColor(textColor);
        setLinksClickable(true);
        setMovementMethod(LinkMovementMethod.getInstance());
        setFocusable(false);
    }