Example usage for android.content.res Resources getString

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

Introduction

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

Prototype

@NonNull
public String getString(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem item;//from  w  ww  . ja  va  2s  .  c  o m
    Resources res = getResources();
    // Lookup.initialize(this, mDeck.getDeckPath());
    // item = menu.add(Menu.NONE, MENU_LOOKUP, Menu.NONE,
    // Lookup.getSearchStringTitle());
    // item.setIcon(R.drawable.ic_menu_search);
    // item.setEnabled(Lookup.isAvailable());
    // item = menu.add(Menu.NONE, MENU_RESET, Menu.NONE,
    // res.getString(R.string.card_editor_reset));
    // item.setIcon(R.drawable.ic_menu_revert);
    if (!mAddNote) {
        item = menu.add(Menu.NONE, MENU_ADD_CARD, Menu.NONE, res.getString(R.string.card_editor_add_card));
        item.setIcon(R.drawable.ic_menu_add);
    }
    item = menu.add(Menu.NONE, MENU_COPY_CARD, Menu.NONE, res.getString(R.string.card_editor_copy_card));
    item.setIcon(R.drawable.ic_menu_upload);
    if (!mAddNote) {
        item = menu.add(Menu.NONE, MENU_RESET_CARD_PROGRESS, Menu.NONE,
                res.getString(R.string.card_editor_reset_card));
        item.setIcon(R.drawable.ic_menu_delete);
    }
    if (mCaller != CALLER_CARDEDITOR_INTENT_ADD) {
        mIntentInformation = MetaDB.getIntentInformation(this);
        item = menu.add(Menu.NONE, MENU_SAVED_INTENT, Menu.NONE,
                res.getString(R.string.intent_add_saved_information));
        item.setIcon(R.drawable.ic_menu_archive);
    }
    return true;
}

From source file:com.example.navigationsearchview.NavigationSearchView.java

/**
 * Create and return an Intent that can launch the voice search activity,
 * perform a specific voice transcription, and forward the results to the
 * searchable activity.//from   w  w  w  .j  a  va 2 s  .c om
 *
 * @param baseIntent
 *            The voice app search intent to start from
 * @return A completely-configured intent ready to send to the voice search
 *         activity
 */
@TargetApi(Build.VERSION_CODES.FROYO)
private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
    ComponentName searchActivity = searchable.getSearchActivity();

    // create the necessary intent to set up a search-and-forward operation
    // in the voice search system. We have to keep the bundle separate,
    // because it becomes immutable once it enters the PendingIntent
    Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
    queryIntent.setComponent(searchActivity);
    PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent,
            PendingIntent.FLAG_ONE_SHOT);

    // Now set up the bundle that will be inserted into the pending intent
    // when it's time to do the search. We always build it here (even if
    // empty)
    // because the voice search activity will always need to insert "QUERY"
    // into
    // it anyway.
    Bundle queryExtras = new Bundle();
    if (mAppSearchData != null) {
        queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData);
    }

    // Now build the intent to launch the voice search. Add all necessary
    // extras to launch the voice recognizer, and then all the necessary
    // extras
    // to forward the results to the searchable activity
    Intent voiceIntent = new Intent(baseIntent);

    // Add all of the configuration options supplied by the searchable's
    // metadata
    String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
    String prompt = null;
    String language = null;
    int maxResults = 1;

    if (Build.VERSION.SDK_INT >= 8) {
        Resources resources = getResources();
        if (searchable.getVoiceLanguageModeId() != 0) {
            languageModel = resources.getString(searchable.getVoiceLanguageModeId());
        }
        if (searchable.getVoicePromptTextId() != 0) {
            prompt = resources.getString(searchable.getVoicePromptTextId());
        }
        if (searchable.getVoiceLanguageId() != 0) {
            language = resources.getString(searchable.getVoiceLanguageId());
        }
        if (searchable.getVoiceMaxResults() != 0) {
            maxResults = searchable.getVoiceMaxResults();
        }
    }
    voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            searchActivity == null ? null : searchActivity.flattenToShortString());

    // Add the values that configure forwarding the results
    voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);

    return voiceIntent;
}

From source file:com.google.android.apps.santatracker.launch.StartupActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu
    getMenuInflater().inflate(R.menu.menu_startup, menu);

    // Add cast button
    if (mCastManager != null) {
        mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
    }//from   w  w w.j  a  v a  2 s.  c  o m

    mMenuItemLegal = menu.findItem(R.id.legal);
    mMenuItemLegal.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            final Resources resources = getResources();
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(StartupActivity.this);
            dialogBuilder.setItems(resources.getStringArray(R.array.legal_privacy),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            String url;
                            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(StartupActivity.this);
                            switch (which) {
                            case 1:
                                // Privacy
                                url = resources.getString(R.string.url_privacy);
                                break;
                            case 2:
                                // TOS
                                url = resources.getString(R.string.url_tos);
                                break;
                            case 3:
                                // TOS
                                url = resources.getString(R.string.url_seismic);
                                break;
                            case 4:
                                // Show play services license text
                                dialog.dismiss();
                                dialogBuilder
                                        .setMessage(GooglePlayServicesUtil
                                                .getOpenSourceSoftwareLicenseInfo(getApplicationContext()))
                                        .create().show();
                                dialogBuilder.setPositiveButton(android.R.string.ok,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                dialog.dismiss();
                                            }
                                        });
                                return;
                            case 0:
                            default:
                                url = resources.getString(R.string.url_legal);
                                break;
                            }
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                        }
                    });
            dialogBuilder.create().show();
            return true;
        }
    });

    menu.findItem(R.id.menu_app_invite).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            mInvitesFragment.sendGenericInvite();
            return true;
        }
    });

    menu.findItem(R.id.open_help).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_help))));
            return true;
        }
    });

    menu.findItem(R.id.github_santa).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_github_santa))));
            return true;
        }
    });

    menu.findItem(R.id.github_pienoon).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_github_pienoon))));
            return true;
        }
    });

    menu.findItem(R.id.sign_out).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            Games.signOut(mGamesFragment.getGamesApiClient());
            updateSignInState(false);
            return true;
        }
    });

    // TODO Temp menu items for testing notifications
    menu.findItem(R.id.notification_nearby).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            SantaNotificationBuilder.CreateSantaNotification(StartupActivity.this,
                    R.string.notification_nearby);
            /*
            Intent wearIntent = new Intent(StartupActivity.this,
                    PhoneNotificationService.class);
            wearIntent.setAction(NotificationConstants.ACTION_SEND);
            wearIntent.putExtra(NotificationConstants.KEY_CONTENT,
                    StartupActivity.this.getResources()
                            .getString(R.string.notification_nearby));
            StartupActivity.this.startService(wearIntent);
            */
            return true;
        }
    });
    menu.findItem(R.id.notification_takeoff).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            SantaNotificationBuilder.CreateSantaNotification(StartupActivity.this,
                    R.string.notification_takeoff);
            /*
            Intent wearIntent = new Intent(StartupActivity.this,
                    PhoneNotificationService.class);
            wearIntent.setAction(NotificationConstants.ACTION_SEND);
            wearIntent.putExtra(NotificationConstants.KEY_CONTENT,
                    StartupActivity.this.getResources()
                            .getString(R.string.notification_takeoff));
            StartupActivity.this.startService(wearIntent);
            */
            return true;
        }
    });
    menu.findItem(R.id.notification_location)
            .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    /*
                    SantaNotificationBuilder
                            .CreateTriviaNotification(StartupActivity.this, "location",
                                    "photoUrl", "mapUrl", "fact");
                    */
                    SantaNotificationBuilder.CreateInfoNotification(StartupActivity.this, "Title", "text",
                            "https://www.google.com/images/srpr/logo11w.png");
                    return true;
                }
            });

    menu.findItem(R.id.launch_mode).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            enableTrackerMode(true);
            return true;
        }
    });

    menu.findItem(R.id.countdown_mode).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            startCountdown(OFFLINE_SANTA_DEPARTURE);
            return true;
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:com.ichi2.anki.DeckPicker.java

/**
 *  Show a simple snackbar message or notification if the activity is not in foreground
 * @param messageResource String resource for message
 *///  w w  w  .j  a  v a 2  s  .  c  o  m
private void showSyncLogMessage(int messageResource) {
    if (mActivityPaused) {
        Resources res = AnkiDroidApp.getAppResources();
        showSimpleNotification(res.getString(R.string.app_name), res.getString(messageResource));
    } else {
        showSimpleSnackbar(messageResource, false);
    }
}

From source file:com.android.calendar.event.EditEventView.java

private void populateRepeats() {
    Resources r = mActivity.getResources();
    String repeatString;/*ww  w.ja v  a2  s  .  co  m*/
    boolean enabled;
    if (!TextUtils.isEmpty(mRrule)) {
        repeatString = EventRecurrenceFormatter.getRepeatString(mActivity, r, mEventRecurrence, true);

        if (repeatString == null) {
            repeatString = r.getString(R.string.custom);
            Log.e(TAG, "Can't generate display string for " + mRrule);
            enabled = false;
        } else {
            // TODO Should give option to clear/reset rrule
            enabled = RecurrencePickerDialog.canHandleRecurrenceRule(mEventRecurrence);
            if (!enabled) {
                Log.e(TAG, "UI can't handle " + mRrule);
            }
        }
    } else {
        repeatString = r.getString(R.string.does_not_repeat);
        enabled = true;
    }

    mRruleButton.setText(repeatString);

    // Don't allow the user to make exceptions recurring events.
    if (mModel.mOriginalSyncId != null) {
        enabled = false;
    }
    mRruleButton.setOnClickListener(this);
    mRruleButton.setEnabled(enabled);
}

From source file:com.hichinaschool.flashcards.anki.StudyOptionsFragment.java

protected StyledDialog onCreateDialog(int id) {
    StyledDialog dialog = null;//from  w w  w.j ava  2 s.co  m
    Resources res = getResources();
    StyledDialog.Builder builder1 = new StyledDialog.Builder(this.getActivity());

    switch (id) {
    case DIALOG_STATISTIC_TYPE:
        dialog = ChartBuilder.getStatisticsDialog(getActivity(), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                DeckTask.launchDeckTask(DeckTask.TASK_TYPE_LOAD_STATISTICS, mLoadStatisticsHandler,
                        new DeckTask.TaskData(AnkiDroidApp.getCol(), which, false));
            }
        }, mFragmented);
        break;

    case DIALOG_CUSTOM_STUDY:
        builder1.setTitle(res.getString(R.string.custom_study));
        builder1.setIcon(android.R.drawable.ic_menu_sort_by_size);
        builder1.setItems(res.getStringArray(R.array.custom_study_options_labels),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        mCustomDialogChoice = which;
                        showDialog(DIALOG_CUSTOM_STUDY_DETAILS);
                    }
                });
        builder1.setCancelable(true);
        dialog = builder1.create();
        break;

    case DIALOG_CUSTOM_STUDY_DETAILS:
        builder1.setContentView(mCustomStudyDetailsView);
        builder1.setCancelable(true);
        builder1.setNegativeButton(R.string.cancel, null);
        builder1.setPositiveButton(R.string.ok, null);
        dialog = builder1.create();
        break;

    default:
        dialog = null;
    }

    dialog.setOwnerActivity(getActivity());
    return dialog;
}

From source file:com.ichi2.anki2.CardBrowser.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    Resources res = getResources();
    StyledDialog ad = (StyledDialog) dialog;
    switch (id) {
    case DIALOG_ORDER:
        for (int i = 0; i < mOrderByFields.length; ++i) {
            if (i != CARD_ORDER_NONE && i == mOrder) {
                if (mOrderAsc) {
                    ad.changeListItem(i, mOrderByFields[i] + " (\u25b2)");
                } else {
                    ad.changeListItem(i, mOrderByFields[i] + " (\u25bc)");
                }//from  ww w  .j a v a 2 s .  c om
            } else {
                ad.changeListItem(i, mOrderByFields[i]);
            }
        }
        break;
    case DIALOG_CONTEXT_MENU:
        HashMap<String, String> card = mCards.get(mPositionInCardsList);
        int flags = Integer.parseInt(card.get("flags"));
        if (flags == 2 || flags == 3) {
            ad.changeListItem(CONTEXT_MENU_MARK, res.getString(R.string.card_browser_unmark_card));
            Log.d(AnkiDroidApp.TAG, "Selected Card is currently marked");
        } else {
            ad.changeListItem(CONTEXT_MENU_MARK, res.getString(R.string.card_browser_mark_card));
        }
        if (flags == 1 || flags == 3) {
            ad.changeListItem(CONTEXT_MENU_SUSPEND, res.getString(R.string.card_browser_unsuspend_card));
            Log.d(AnkiDroidApp.TAG, "Selected Card is currently suspended");
        } else {
            ad.changeListItem(CONTEXT_MENU_SUSPEND, res.getString(R.string.card_browser_suspend_card));
        }
        ad.setTitle(card.get("sfld"));
        break;
    case DIALOG_TAGS:
        mSelectedTags.clear();
        ad.setMultiChoiceItems(allTags, new boolean[allTags.length], new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String tag = allTags[which];
                if (mSelectedTags.contains(tag)) {
                    Log.d(AnkiDroidApp.TAG, "unchecked tag: " + tag);
                    mSelectedTags.remove(tag);
                } else {
                    Log.d(AnkiDroidApp.TAG, "checked tag: " + tag);
                    mSelectedTags.add(tag);
                }
            }
        });
        break;
    }
}

From source file:com.hichinaschool.flashcards.anki.CardBrowser.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    Resources res = getResources();
    StyledDialog ad = (StyledDialog) dialog;
    switch (id) {
    case DIALOG_ORDER:
        for (int i = 0; i < mOrderByFields.length; ++i) {
            if (i != CARD_ORDER_NONE && i == mOrder) {
                if (mOrderAsc) {
                    ad.changeListItem(i, mOrderByFields[i] + " (\u25b2)");
                } else {
                    ad.changeListItem(i, mOrderByFields[i] + " (\u25bc)");
                }// w  ww.j a  va  2s.c o m
            } else {
                ad.changeListItem(i, mOrderByFields[i]);
            }
        }
        break;
    case DIALOG_CONTEXT_MENU:
        HashMap<String, String> card = mCards.get(mPositionInCardsList);
        int flags = Integer.parseInt(card.get("flags"));
        if (flags == 2 || flags == 3) {
            ad.changeListItem(CONTEXT_MENU_MARK, res.getString(R.string.card_browser_unmark_card));
            // Log.d(AnkiDroidApp.TAG, "Selected Card is currently marked");
        } else {
            ad.changeListItem(CONTEXT_MENU_MARK, res.getString(R.string.card_browser_mark_card));
        }
        if (flags == 1 || flags == 3) {
            ad.changeListItem(CONTEXT_MENU_SUSPEND, res.getString(R.string.card_browser_unsuspend_card));
            // Log.d(AnkiDroidApp.TAG, "Selected Card is currently suspended");
        } else {
            ad.changeListItem(CONTEXT_MENU_SUSPEND, res.getString(R.string.card_browser_suspend_card));
        }
        ad.setTitle(card.get("sfld"));
        break;
    case DIALOG_TAGS:
        mSelectedTags.clear();
        ad.setMultiChoiceItems(allTags, new boolean[allTags.length], new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String tag = allTags[which];
                if (mSelectedTags.contains(tag)) {
                    // Log.d(AnkiDroidApp.TAG, "unchecked tag: " + tag);
                    mSelectedTags.remove(tag);
                } else {
                    // Log.d(AnkiDroidApp.TAG, "checked tag: " + tag);
                    mSelectedTags.add(tag);
                }
            }
        });
        break;
    }
}

From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java

public Thread videoUploadToVideoBin(final Activity activity, final Handler handler,
        final String video_absolutepath, final String title, final String description,
        final String emailAddress, final long sdrecord_id) {

    Log.d(TAG, "doPOSTtoVideoBin starting");

    // Make the progress bar view visible.
    ((VidiomActivity) activity).startedUploading(PublishingUtils.TYPE_VB);
    final Resources res = activity.getResources();

    Thread t = new Thread(new Runnable() {
        public void run() {
            // Do background task.

            boolean failed = false;

            HttpClient client = new DefaultHttpClient();
            client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

            URI url = null;/*  w w  w . j  av  a2s  .co  m*/
            try {
                url = new URI(res.getString(R.string.http_videobin_org_add));
            } catch (URISyntaxException e) {
                // Ours is a fixed URL, so not likely to get here.
                mainapp.removeSDFileRecordIDfromUploadingTrack(sdrecord_id, TYPE_VB);

                e.printStackTrace();
                return;

            }
            HttpPost post = new HttpPost(url);
            MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

            File file = new File(video_absolutepath);
            entity.addPart(res.getString(R.string.video_bin_API_videofile), new FileBody(file));

            try {
                entity.addPart(res.getString(R.string.video_bin_API_api),
                        new StringBody("1", "text/plain", Charset.forName("UTF-8")));

                // title
                entity.addPart(res.getString(R.string.video_bin_API_title),
                        new StringBody(title, "text/plain", Charset.forName("UTF-8")));

                // description
                entity.addPart(res.getString(R.string.video_bin_API_description),
                        new StringBody(description, "text/plain", Charset.forName("UTF-8")));

            } catch (IllegalCharsetNameException e) {
                // error
                e.printStackTrace();
                failed = true;

            } catch (UnsupportedCharsetException e) {
                // error
                e.printStackTrace();
                return;
            } catch (UnsupportedEncodingException e) {
                // error
                e.printStackTrace();
                failed = true;
            }

            post.setEntity(entity);

            // Here we go!
            String response = null;
            try {
                response = EntityUtils.toString(client.execute(post).getEntity(), "UTF-8");
            } catch (ParseException e) {
                // error
                e.printStackTrace();
                failed = true;
            } catch (ClientProtocolException e) {
                // error
                e.printStackTrace();
                failed = true;
            } catch (IOException e) {
                // error
                e.printStackTrace();
                failed = true;
            }

            client.getConnectionManager().shutdown();

            // CHECK RESPONSE FOR SUCCESS!!
            if (!failed && response != null
                    && response.matches(res.getString(R.string.video_bin_API_good_re))) {
                // We got back HTTP response with valid URL
                Log.d(TAG, " video bin got back URL " + response);

            } else {
                Log.d(TAG, " video bin got eror back:\n" + response);
                failed = true;
            }

            if (failed) {
                // Use the handler to execute a Runnable on the
                // main thread in order to have access to the
                // UI elements.
                mainapp.removeSDFileRecordIDfromUploadingTrack(sdrecord_id, TYPE_VB);

                handler.postDelayed(new Runnable() {
                    public void run() {
                        // Update UI

                        // Indicate back to calling activity the result!
                        // update uploadInProgress state also.

                        ((VidiomActivity) activity).finishedUploading(false);

                        ((VidiomActivity) activity)
                                .createNotification(res.getString(R.string.upload_to_videobin_org_failed_));
                    }
                }, 0);

                return;
            }

            // XXX Convert to preference for auto-email on videobin post
            // XXX ADD EMAIL NOTIF to all other upload methods
            // stuck on YES here, if email is defined.

            if (emailAddress != null && response != null) {

                // EmailSender through IR controlled gmail system.
                SSLEmailSender sender = new SSLEmailSender(
                        activity.getString(R.string.automatic_email_username),
                        activity.getString(R.string.automatic_email_password)); // consider
                // this
                // public
                // knowledge.
                try {
                    sender.sendMail(activity.getString(R.string.vidiom_automatic_email), // subject.getText().toString(),
                            activity.getString(R.string.url_of_hosted_video_is_) + " " + response, // body.getText().toString(),
                            activity.getString(R.string.automatic_email_from), // from.getText().toString(),
                            emailAddress // to.getText().toString()
                    );
                } catch (Exception e) {
                    Log.e(TAG, e.getMessage(), e);
                }
            }

            // Log record of this URL in POSTs table
            dbutils.creatHostDetailRecordwithNewVideoUploaded(sdrecord_id,
                    res.getString(R.string.http_videobin_org_add), response, "");

            mainapp.removeSDFileRecordIDfromUploadingTrack(sdrecord_id, TYPE_VB);

            // Use the handler to execute a Runnable on the
            // main thread in order to have access to the
            // UI elements.
            handler.postDelayed(new Runnable() {
                public void run() {
                    // Update UI

                    // Indicate back to calling activity the result!
                    // update uploadInProgress state also.

                    ((VidiomActivity) activity).finishedUploading(true);
                    ((VidiomActivity) activity)
                            .createNotification(res.getString(R.string.upload_to_videobin_org_succeeded_));

                }
            }, 0);
        }
    });

    t.start();

    return t;

}

From source file:com.android.launcher3.Folder.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attribtues set containing the Workspace's customization values.
 *///w  ww  .  j a va  2 s .c  om
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    setAlwaysDrawnWithCacheEnabled(false);
    mInflater = LayoutInflater.from(context);
    mIconCache = app.getIconCache();

    Resources res = getResources();
    mMaxCountX = (int) grid.numColumns;
    // Allow scrolling folders when DISABLE_ALL_APPS is true.
    if (LauncherAppState.isDisableAllApps()) {
        mMaxCountY = mMaxNumItems = Integer.MAX_VALUE;
    } else {
        mMaxCountY = (int) grid.numRows;
        mMaxNumItems = mMaxCountX * mMaxCountY;
    }

    mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration);
    mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
    mMaterialExpandStagger = res.getInteger(R.integer.config_materialFolderExpandStagger);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    if (sHintText == null) {
        sHintText = res.getString(R.string.folder_hint_text);
    }
    mLauncher = (Launcher) context;
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behvior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);
}