Example usage for android.content.res Resources getText

List of usage examples for android.content.res Resources getText

Introduction

In this page you can find the example usage for android.content.res Resources getText.

Prototype

@NonNull
public CharSequence getText(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapterTest.java

@Test
public void testBestChannelsGHZ2ErrorMessage() throws Exception {
    // setup/*from  ww w  .  j  av a  2 s . com*/
    Resources resources = mainActivity.getResources();
    String expected = resources.getText(R.string.channel_rating_best_none).toString()
            + resources.getText(R.string.channel_rating_best_alternative) + " "
            + resources.getString(WiFiBand.GHZ5.getTextResource());
    List<WiFiChannel> wiFiChannels = new ArrayList<>();
    List<ChannelAPCount> channelAPCounts = new ArrayList<>();
    when(channelRating.getBestChannels(wiFiChannels)).thenReturn(channelAPCounts);
    // execute
    fixture.bestChannels(WiFiBand.GHZ2, wiFiChannels);
    // validate
    assertEquals(expected, bestChannels.getText());
    verify(channelRating).getBestChannels(wiFiChannels);
}

From source file:com.example.android.wearable.gridviewpager.SampleGridPagerAdapter.java

private Fragment cardFragment(int titleRes, int textRes) {
    Resources res = mContext.getResources();
    CardFragment fragment = CardFragment.create(res.getText(titleRes), res.getText(textRes));
    // Add some extra bottom margin to leave room for the page indicator
    fragment.setCardMarginBottom(res.getDimensionPixelSize(R.dimen.card_margin_bottom));
    return fragment;
}

From source file:com.gammalabs.wifianalyzer.wifi.ChannelRatingAdapter.java

void bestChannels(@NonNull WiFiBand wiFiBand, @NonNull List<WiFiChannel> wiFiChannels) {
    List<ChannelAPCount> channelAPCounts = channelRating.getBestChannels(wiFiChannels);
    int channelCount = 0;
    StringBuilder result = new StringBuilder();
    for (ChannelAPCount channelAPCount : channelAPCounts) {
        if (channelCount > MAX_CHANNELS_TO_DISPLAY) {
            result.append("...");
            break;
        }/*from  w  ww.j  av a  2 s .c o  m*/
        if (result.length() > 0) {
            result.append(", ");
        }
        result.append(channelAPCount.getWiFiChannel().getChannel());
        channelCount++;
    }
    if (result.length() > 0) {
        bestChannels.setText(result.toString());
        bestChannels.setTextColor(ContextCompat.getColor(getContext(), R.color.success_color));
    } else {
        Resources resources = getContext().getResources();
        StringBuilder message = new StringBuilder(resources.getText(R.string.channel_rating_best_none));
        if (WiFiBand.GHZ2.equals(wiFiBand)) {
            message.append(resources.getText(R.string.channel_rating_best_alternative));
            message.append(" ");
            message.append(WiFiBand.GHZ5.getBand());
        }
        bestChannels.setText(message);
        bestChannels.setTextColor(ContextCompat.getColor(getContext(), R.color.error_color));
    }
}

From source file:com.vrem.wifianalyzer.wifi.channelrating.ChannelRatingAdapter.java

void bestChannels(@NonNull WiFiBand wiFiBand, @NonNull List<WiFiChannel> wiFiChannels) {
    List<ChannelAPCount> channelAPCounts = channelRating.getBestChannels(wiFiChannels);
    int channelCount = 0;
    StringBuilder result = new StringBuilder();
    for (ChannelAPCount channelAPCount : channelAPCounts) {
        if (channelCount > MAX_CHANNELS_TO_DISPLAY) {
            result.append("...");
            break;
        }//from   w  ww.  j a  v  a  2  s .  co  m
        if (result.length() > 0) {
            result.append(", ");
        }
        result.append(channelAPCount.getWiFiChannel().getChannel());
        channelCount++;
    }
    if (result.length() > 0) {
        bestChannels.setText(result.toString());
        bestChannels.setTextColor(ContextCompat.getColor(getContext(), R.color.success_color));
    } else {
        Resources resources = getContext().getResources();
        StringBuilder message = new StringBuilder(resources.getText(R.string.channel_rating_best_none));
        if (WiFiBand.GHZ2.equals(wiFiBand)) {
            message.append(resources.getText(R.string.channel_rating_best_alternative));
            message.append(" ");
            message.append(getContext().getResources().getString(WiFiBand.GHZ5.getTextResource()));
        }
        bestChannels.setText(message);
        bestChannels.setTextColor(ContextCompat.getColor(getContext(), R.color.error_color));
    }
}

From source file:kr.co.generic.wifianalyzer.wifi.ChannelRatingAdapter.java

void bestChannels(@NonNull WiFiBand wiFiBand, @NonNull List<WiFiChannel> wiFiChannels) {
    List<ChannelAPCount> channelAPCounts = channelRating.getBestChannels(wiFiChannels);
    int channelCount = 0;
    StringBuilder result = new StringBuilder();
    for (ChannelAPCount channelAPCount : channelAPCounts) {
        if (channelCount > MAX_CHANNELS_TO_DISPLAY) {
            result.append("...");
            break;
        }//from  ww w  . ja v  a2s .c  om
        if (result.length() > 0) {
            result.append(", ");
        }
        result.append(channelAPCount.getWiFiChannel().getChannel());
        channelCount++;
    }
    if (result.length() > 0) {
        bestChannels.setText(result.toString());
        bestChannels.setTextColor(
                ContextCompat.getColor(getContext(), kr.co.generic.wifianalyzer.R.color.success_color));
    } else {
        Resources resources = getContext().getResources();
        StringBuilder message = new StringBuilder(
                resources.getText(kr.co.generic.wifianalyzer.R.string.channel_rating_best_none));
        if (WiFiBand.GHZ2.equals(wiFiBand)) {
            message.append(
                    resources.getText(kr.co.generic.wifianalyzer.R.string.channel_rating_best_alternative));
            message.append(" ");
            message.append(WiFiBand.GHZ5.getBand());
        }
        bestChannels.setText(message);
        bestChannels.setTextColor(
                ContextCompat.getColor(getContext(), kr.co.generic.wifianalyzer.R.color.error_color));
    }
}

From source file:com.vuze.android.remote.adapter.OpenOptionsPagerAdapter.java

@Override
public CharSequence getPageTitle(int position) {
    if (count == 2) {
        position++;/*www  .j a va 2 s .c om*/
    }
    Resources resources = VuzeRemoteApp.getContext().getResources();
    switch (position) {
    case 2:
        return resources.getString(R.string.details_tab_tags);

    case 1:
        return resources.getText(R.string.details_tab_files);

    case 0:
        return resources.getText(R.string.details_tab_general);
    }
    return super.getPageTitle(position);
}

From source file:com.achep.base.dashboard.DashboardCategory.java

/**
 * Return the currently set title. If {@link #titleRes} is set,
 * this resource is loaded from <var>res</var> and stored in {@link #title}.
 *///from   w w  w.  j av  a2 s .c om
public CharSequence getTitle(Resources res) {
    if (titleRes != 0) {
        title = res.getText(titleRes);
        titleRes = 0;
    }

    return title;
}

From source file:xanthanov.droid.funrun.PlaceSearcher.java

public PlaceSearcher(Resources res) {
    //Define a map between category strings (res/strings/strings.xml)) --> google map API URI parameters
    stringToQuery = new HashMap<CharSequence, CharSequence>();
    stringToQuery.put(res.getText(R.string.cafe), "types=cafe");
    stringToQuery.put(res.getText(R.string.school), "types=school|university");
    stringToQuery.put(res.getText(R.string.zoo), "types=zoo&name=zoo");
    stringToQuery.put(res.getText(R.string.point_of_interest), "types=point_of_interest");
    stringToQuery.put(res.getText(R.string.smoothies), "name=smoothie");
    stringToQuery.put(res.getText(R.string.juice_bar), "name=juice");
    stringToQuery.put(res.getText(R.string.park), "types=park&name=park");
    stringToQuery.put(res.getText(R.string.book_store), "types=book_store");
    stringToQuery.put(res.getText(R.string.clothing_store), "types=clothing_store");
    stringToQuery.put(res.getText(R.string.bicycle_store), "types=bicycle_store");
    stringToQuery.put(res.getText(R.string.florist), "types=florist");
    stringToQuery.put(res.getText(R.string.library), "types=library");
    stringToQuery.put(res.getText(R.string.food_cart), "types=food|restaurant&name=food+cart");
    stringToQuery.put(res.getText(R.string.museum), "types=museum");
    stringToQuery.put(res.getText(R.string.art_gallery), "types=art_gallery");
    stringToQuery.put(res.getText(R.string.pet_store), "types=pet_store");
    stringToQuery.put(res.getText(R.string.bar), "types=bar");

    stringToQuery.put(res.getText(R.string.aquarium), "types=aquarium");
    stringToQuery.put(res.getText(R.string.amusement_park), "types=amusement_park");
    stringToQuery.put(res.getText(R.string.movie_theater), "types=movie_theater");
    stringToQuery.put(res.getText(R.string.bowling_alley), "types=bowling_alley");
    stringToQuery.put(res.getText(R.string.shopping_mall), "types=shopping_mall");
    stringToQuery.put(res.getText(R.string.natural_feature), "types=natural_feature");
    stringToQuery.put(res.getText(R.string.pizza),
            "types=food|bar|restaurant|meal_takeaway|meal_delivery&name=pizza");
    stringToQuery.put(res.getText(R.string.brew_pub), "types=bar|food|restaurant&name=brew+pub");
}

From source file:com.vuze.android.remote.activity.DrawerActivity.java

@SuppressLint("NewApi")
public void onCreate_setupDrawer() {
    setupProfileSpinner();// w w w  .  ja v a  2 s .c  o  m

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            DrawerActivity.this.onDrawerClosed(view);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            DrawerActivity.this.onDrawerOpened(view);
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerView = findViewById(R.id.drawer_view);
    ListView mDrawerList = (ListView) findViewById(R.id.drawer_listview);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mDrawerLayout.setElevation(30);
    }

    Resources res = getResources();
    // Set the adapter for the list view
    mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, R.id.title,
            new CharSequence[] { res.getText(R.string.drawer_torrents), res.getText(R.string.drawer_rcm),
                    res.getText(R.string.drawer_logout), }));
    // Set the list's click listener
    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mDrawerLayout.closeDrawer(mDrawerView);
            switch (position) {
            case 0: {
                Intent intent = new Intent(Intent.ACTION_VIEW, null, DrawerActivity.this,
                        TorrentViewActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.putExtra(SessionInfoManager.BUNDLE_KEY, getSessionInfo().getRemoteProfile().getID());
                startActivity(intent);
                break;
            }

            case 1: {
                Intent intent = new Intent(Intent.ACTION_VIEW, null, DrawerActivity.this, RcmActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.putExtra(SessionInfoManager.BUNDLE_KEY, getSessionInfo().getRemoteProfile().getID());
                startActivity(intent);
                break;
            }

            case 2: {
                RemoteUtils.openRemoteList(DrawerActivity.this);
                SessionInfoManager.removeSessionInfo(getSessionInfo().getRemoteProfile().getID());
                finish();
                break;
            }
            }
        }
    });
}

From source file:com.woodblockwithoutco.quickcontroldock.ui.ControlService.java

private void startForeground() {
    Resources res = getResources();
    Intent settingsIntent = new Intent(this, SettingsActivity.class);
    PendingIntent settingsPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, settingsIntent,
            0);/*from  w w  w  .  j  a  v  a2s . c  o  m*/
    NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
    builder.setSmallIcon(R.drawable.ic_notification)
            .setContentTitle(res.getText(R.string.foreground_mode_title))
            .setContentText(res.getText(R.string.foreground_mode_message))
            .setContentIntent(settingsPendingIntent);
    Notification notification = null;
    notification = builder.build();
    startForeground(FOREGROUND_ID, notification);
}