Example usage for java.lang CharSequence equals

List of usage examples for java.lang CharSequence equals

Introduction

In this page you can find the example usage for java.lang CharSequence equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:edu.cornell.med.icb.geo.tools.FileGeneList.java

private boolean matchesProbesetId(final CharSequence probesetValue, boolean add) {
    for (final String probeId : probeIDsSet) { // for each probe in the gene list file...
        if (probeId.length() >= 1 && probesetValue.equals(probeId)) {
            matchingGeneIds.add(probesetValue.toString());
            add = true;// w  w w .j a  v  a  2  s . co m
        }
    }
    return add;
}

From source file:net.sourceforge.servestream.service.AppWidgetOneProvider.java

/**
 * Update all active widget instances by pushing changes 
 *//*  w  ww.jav  a 2 s .com*/
public void performUpdate(MediaPlaybackService service, int[] appWidgetIds, String what) {
    final Resources res = service.getResources();
    final RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.appwidget_one);

    if (what.equals(MediaPlaybackService.PLAYER_CLOSED)) {
        defaultAppWidget(service, appWidgetIds);
    } else {
        CharSequence trackName = service.getTrackName();
        CharSequence artistName = service.getArtistName();
        //CharSequence errorState = null;

        if (trackName == null || trackName.equals(Media.UNKNOWN_STRING)) {
            trackName = res.getText(R.string.widget_one_track_info_unavailable);
        }

        if (artistName == null || artistName.equals(Media.UNKNOWN_STRING)) {
            artistName = service.getMediaUri();
        }

        // Show media info
        views.setViewVisibility(R.id.title, View.VISIBLE);
        views.setTextViewText(R.id.title, trackName);
        views.setViewVisibility(R.id.artist, View.VISIBLE);
        views.setTextViewText(R.id.artist, artistName);

        // Set correct drawable for pause state
        final boolean playing = service.isPlaying();
        if (playing) {
            views.setImageViewResource(R.id.control_play, android.R.drawable.ic_media_pause);
        } else {
            views.setImageViewResource(R.id.control_play, android.R.drawable.ic_media_play);
        }

        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap b = BitmapFactory.decodeStream(
                service.getResources().openRawResource(R.drawable.albumart_mp_unknown_widget), null, opts);

        views.setImageViewBitmap(R.id.coverart, b);

        if (service.getAudioId() >= 0) {
            views.setImageViewBitmap(R.id.coverart, service.getAlbumArt(true));
        }

        // Link actions buttons to intents
        linkButtons(service, views, true);
        pushUpdate(service, appWidgetIds, views);
    }
}

From source file:com.android.projectz.teamrocket.thebusapp.settings.SettingGeneralActivity.java

/**
 * Metodo che serve a far visualizzare la lista con le relative personalizzazioni all'interno della schermata
 * <p>/*from  w  w w .jav  a  2s.c  o m*/
 * ho deciso di fare ci in modo tale da richiamare il metodo quando la lingua viene cambiata, cosi la vista 
 * aggiornata con la lingua selezionata
 */
@Override
protected void onStart() {
    super.onStart();
    String[] settingText = { getResources().getString(R.string.setting_theme),
            getResources().getString(R.string.setting_instrictions) };
    String[] settingSubtext = {
            SharedPreferencesUtils.getSelectedTheme(SettingGeneralActivity.this).equals("AppTheme") ? "Light"
                    : "Dark",
            getResources().getString(R.string.short_instruction) };
    Resources res = getResources();
    Drawable[] settingImg = { ContextCompat.getDrawable(this, R.drawable.ic_theme_chooser),
            ContextCompat.getDrawable(this, R.drawable.ic_instruction) };
    CustomListSettingOther adapter = new CustomListSettingOther(SettingGeneralActivity.this, settingText,
            settingSubtext, settingImg);
    ListView list = (ListView) findViewById(R.id.general_setting_list);
    list.setAdapter(adapter);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            switch (position) {
            case 0:
                new MaterialDialog.Builder(SettingGeneralActivity.this).title(R.string.dialog_title_theme)
                        .items(R.array.theme)
                        .itemsCallbackSingleChoice(
                                SharedPreferencesUtils.getSelectedTheme(SettingGeneralActivity.this)
                                        .equals("AppTheme") ? 0 : 1,
                                new MaterialDialog.ListCallbackSingleChoice() {
                                    @Override
                                    public boolean onSelection(MaterialDialog dialog, View view, int which,
                                            CharSequence text) {
                                        try {
                                            SharedPreferencesUtils.setSelectedTheme(SettingGeneralActivity.this,
                                                    text.equals("Light") ? "AppTheme" : "ThemeDark");
                                            reload();
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                            SharedPreferencesUtils.setSelectedLanguage(
                                                    SettingGeneralActivity.this, "AppTheme");
                                        }
                                        return true;
                                    }
                                })
                        .positiveText(R.string.dialog_ok_button).show();

                break;
            case 1:
                Intent inst = new Intent(SettingGeneralActivity.this, IntroApp.class);
                startActivity(inst);
                SettingGeneralActivity.this.overridePendingTransition(R.anim.anim_slide_in_right,
                        R.anim.anim_slide_out_right);
                break;
            }
        }
    });
}

From source file:wseemann.media.fmpdemo.fragment.MiniControllerFragment.java

private void updateNowPlaying() {
    if (mNowPlayingView == null) {
        return;/*from  w ww  .  ja  va  2s  .  c  o  m*/
    }
    try {
        if (true && mService != null && mService.getAudioId() != -1) {
            mTitle.setSelected(true);
            mArtist.setSelected(true);

            CharSequence trackName = mService.getTrackName();
            CharSequence artistName = mService.getArtistName();

            String UNKNOWN_STRING = "Unknown";

            if (trackName == null || trackName.equals(UNKNOWN_STRING)) {
                mTitle.setText(R.string.widget_one_track_info_unavailable);

            } else {
                mTitle.setText(trackName);
            }

            if (artistName == null || artistName.equals(UNKNOWN_STRING)) {
                artistName = mService.getMediaUri();
            }

            mArtist.setText(artistName);

            mPauseButton.setVisibility(View.VISIBLE);

            if (mService.isPlaying()) {
                mPauseButton.setImageResource(R.drawable.ic_av_pause_light);
            } else {
                mPauseButton.setImageResource(R.drawable.ic_av_play_light);
            }

            mPauseButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    try {
                        if (mService.isPlaying()) {
                            mService.pause();
                        } else {
                            mService.play();
                        }
                    } catch (RemoteException e) {
                    }
                }
            });

            if (mNowPlayingView.getVisibility() != View.VISIBLE) {
                Animation fade_in = AnimationUtils.loadAnimation(getActivity(), R.anim.player_in);
                mNowPlayingView.startAnimation(fade_in);
            }

            mNowPlayingView.setVisibility(View.VISIBLE);
            mNowPlayingView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Context c = v.getContext();
                    c.startActivity(new Intent(c, MediaPlayerActivity.class));
                }
            });

            return;
        }
    } catch (RemoteException ex) {
    }
    Animation fade_out = AnimationUtils.loadAnimation(getActivity(), R.anim.player_out);
    mNowPlayingView.startAnimation(fade_out);
    mNowPlayingView.setVisibility(View.GONE);
}

From source file:de.mkrtchyan.recoverytools.ScriptManagerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_script_manager, container, false);
    mFileNameAdapter = new ArrayAdapter<>(mContext, R.layout.custom_list_item);
    mFileList = new ArrayList<>();
    mQueue = (ListView) mRootView.findViewById(R.id.lvQueue);
    mQueue.setAdapter(mFileNameAdapter);
    mQueue.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override//from w  w w  .  j  a v a  2  s  .  co m

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mFileList.remove(position);
            mFileNameAdapter.clear();
            for (File i : mFileList) {
                mFileNameAdapter.add(i.getName());
            }
        }
    });
    if (mStartFile != null) {
        if (mStartFile.exists()) {
            if (Common.stringEndsWithArray(mStartFile.getName(), mAllowedEXT)) {
                addFileToQueue(mStartFile);
            } else {
                Toast.makeText(mContext, R.string.wrong_format, Toast.LENGTH_SHORT).show();
            }
        }
    }

    AppCompatButton AddZip = (AppCompatButton) mRootView.findViewById(R.id.addZip);
    AddZip.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mFileChooser = new FileChooserDialog(mContext);
            File startFolder = new File("/");
            if (mFileList.size() > 0) {
                startFolder = mFileList.get(mFileList.size() - 1);
                if (startFolder.isFile()) {
                    startFolder = startFolder.getParentFile();
                }
            }
            mFileChooser.setStartFolder(startFolder);
            mFileChooser.setOnFileChooseListener(new FileChooserDialog.OnFileChooseListener() {
                @Override
                public void OnFileChoose(File file) {
                    addFileToQueue(file);
                }
            });
            mFileChooser.setAllowedEXT(mAllowedEXT);
            mFileChooser.setBrowseUpAllowed(true);
            mFileChooser.setWarn(false);
            mFileChooser.show();
        }
    });
    AppCompatButton FlashZip = (AppCompatButton) mRootView.findViewById(R.id.bFlashZip);
    FlashZip.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AppCompatCheckBox cbBakSystem = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupSystem);
            AppCompatCheckBox cbBakData = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupData);
            AppCompatCheckBox cbBakCache = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupCache);
            AppCompatCheckBox cbBakRecovery = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupRecovery);
            AppCompatCheckBox cbBakBoot = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupBoot);
            AppCompatCheckBox cbSkipMD5 = (AppCompatCheckBox) mRootView.findViewById(R.id.cbSkipMD5);
            AppCompatEditText etBakName = (AppCompatEditText) mRootView.findViewById(R.id.etBackupName);
            AppCompatCheckBox cbWipeCache = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeCache);
            AppCompatCheckBox cbWipeDalvik = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeDalvik);
            AppCompatCheckBox cbWipeData = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeData);
            final StringBuilder command = new StringBuilder();
            command.append("echo #####Script created by Rashr#####;");
            if (cbBakBoot.isChecked() || cbBakCache.isChecked() || cbBakData.isChecked()
                    || cbBakRecovery.isChecked() || cbBakSystem.isChecked()) {
                command.append("backup ");
                if (cbBakBoot.isChecked())
                    command.append("B");
                if (cbBakCache.isChecked())
                    command.append("C");
                if (cbBakData.isChecked())
                    command.append("D");
                if (cbBakRecovery.isChecked())
                    command.append("R");
                if (cbBakSystem.isChecked())
                    command.append("S");
                if (cbSkipMD5.isChecked())
                    command.append("M");

                CharSequence BackupName = etBakName.getText();
                if (BackupName != null && !BackupName.equals("")) {
                    command.append(" ");
                    command.append(BackupName);
                }
                command.append(CMD_END);

            }

            if (cbWipeCache.isChecked())
                command.append("wipe cache;");
            if (cbWipeDalvik.isChecked())
                command.append("wipe dalvik;");
            if (cbWipeData.isChecked())
                command.append("wipe data;");

            for (File i : mFileList) {
                command.append("install ");
                command.append(i.getAbsolutePath());
                command.append(CMD_END);
            }

            if (!command.toString().equals("")) {
                String commands = "";
                int index = 0;
                for (String i : command.toString().split(CMD_END)) {
                    if (!i.equals("")) {
                        if (index > 0) {
                            commands += index++ + ". " + i + "\n";
                        } else {
                            index++;
                        }
                    }
                }
                final AlertDialog.Builder CommandsPreview = new AlertDialog.Builder(mContext);
                CommandsPreview.setTitle(R.string.recovery_script_review);
                CommandsPreview.setPositiveButton(R.string.run, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            for (String split : command.toString().split(";")) {
                                if (!split.equals("")) {
                                    mShell.execCommand(
                                            "echo " + split + " >> /cache/recovery/openrecoveryscript");
                                }
                            }
                            new Toolbox(mShell).reboot(Toolbox.REBOOT_RECOVERY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                });
                CommandsPreview.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                CommandsPreview.setMessage(commands);
                CommandsPreview.show();
            } else {
                Toast.makeText(mContext, "No job to do :)", Toast.LENGTH_LONG).show();
            }
        }
    });
    return mRootView;
}

From source file:org.jtheque.primary.impl.dao.DaoLendings.java

/**
 * Return all the lendings of the specific primary implementation.
 *
 * @param impl The primary implementation.
 *
 * @return A Collection containing all the lendings of the specific primary implementation.
 *///  w ww . ja  v  a2  s  . co  m
private Collection<Lending> getLendings(CharSequence impl) {
    if (StringUtils.isEmpty(impl)) {
        return getAll();
    }

    load();

    Collection<Lending> lendings = new ArrayList<Lending>(getCache().size() / 2);

    for (Lending lending : getCache().values()) {
        if (impl.equals(lending.getPrimaryImpl())) {
            lendings.add(lending);
        }
    }

    return lendings;
}

From source file:ar.rulosoft.custompref.SeekBarCustomPreference.java

public void setInfo(CharSequence info) {
    if (info == null && this.mInfo != null || info != null && !info.equals(this.mInfo)) {
        mInfo = info;//from   w  w  w .j  a va 2 s.  com
        onInfoChanged();
    }
}

From source file:android.support.v7.preference.ListPreference.java

/**
 * Sets the summary for this Preference with a CharSequence.
 * If the summary has a/*from  www  .ja  v  a 2 s . com*/
 * {@linkplain java.lang.String#format String formatting}
 * marker in it (i.e. "%s" or "%1$s"), then the current entry
 * value will be substituted in its place when it's retrieved.
 *
 * @param summary The summary for the preference.
 */
@Override
public void setSummary(CharSequence summary) {
    super.setSummary(summary);
    if (summary == null && mSummary != null) {
        mSummary = null;
    } else if (summary != null && !summary.equals(mSummary)) {
        mSummary = summary.toString();
    }
}

From source file:com.google.android.apps.mytracks.fragments.ChooseActivityDialogFragment.java

/**
 * Gets the display info./* w w w.  j  ava2s .com*/
 */
private List<DisplayInfo> getDisplayInfos() {
    List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>();
    Intent intent = ShareCompat.IntentBuilder.from(getActivity()).setType(IntentUtils.TEXT_PLAIN_TYPE)
            .getIntent();
    List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfos != null && resolveInfos.size() > 0) {
        int size = resolveInfos.size();
        ResolveInfo firstResolveInfo = resolveInfos.get(0);
        for (int i = 1; i < size; i++) {
            ResolveInfo resolveInfo = resolveInfos.get(i);
            if (firstResolveInfo.priority != resolveInfo.priority
                    || firstResolveInfo.isDefault != resolveInfo.isDefault) {
                while (i < size) {
                    resolveInfos.remove(i);
                    size--;
                }
            }
        }
        if (size > 1) {
            ResolveInfo.DisplayNameComparator displayNameComparator = new ResolveInfo.DisplayNameComparator(
                    packageManager);
            Collections.sort(resolveInfos, displayNameComparator);
        }

        firstResolveInfo = resolveInfos.get(0);
        int start = 0;
        CharSequence firstLabel = firstResolveInfo.loadLabel(packageManager);
        for (int i = 1; i < size; i++) {
            if (firstLabel == null) {
                firstLabel = firstResolveInfo.activityInfo.packageName;
            }
            ResolveInfo resolveInfo = resolveInfos.get(i);
            CharSequence label = resolveInfo.loadLabel(packageManager);
            if (label == null) {
                label = resolveInfo.activityInfo.packageName;
            }
            if (label.equals(firstLabel)) {
                continue;
            }
            processGroup(resolveInfos, displayInfos, start, i - 1);
            firstResolveInfo = resolveInfo;
            firstLabel = label;
            start = i;
        }
        // Process last group
        processGroup(resolveInfos, displayInfos, start, size - 1);
    }
    return displayInfos;
}

From source file:br.com.bioscada.apps.biotracks.fragments.ChooseActivityDialogFragment.java

/**
 * Gets the display info./*from  ww  w.j a v a  2s .c o m*/
 */
private List<DisplayInfo> getDisplayInfos(FragmentActivity fragmentActivity) {
    List<DisplayInfo> displayInfos = new ArrayList<DisplayInfo>();
    Intent intent = ShareCompat.IntentBuilder.from(fragmentActivity).setType(IntentUtils.TEXT_PLAIN_TYPE)
            .getIntent();
    List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfos != null && resolveInfos.size() > 0) {
        int size = resolveInfos.size();
        ResolveInfo firstResolveInfo = resolveInfos.get(0);
        for (int i = 1; i < size; i++) {
            ResolveInfo resolveInfo = resolveInfos.get(i);
            if (firstResolveInfo.priority != resolveInfo.priority
                    || firstResolveInfo.isDefault != resolveInfo.isDefault) {
                while (i < size) {
                    resolveInfos.remove(i);
                    size--;
                }
            }
        }
        if (size > 1) {
            ResolveInfo.DisplayNameComparator displayNameComparator = new ResolveInfo.DisplayNameComparator(
                    packageManager);
            Collections.sort(resolveInfos, displayNameComparator);
        }

        firstResolveInfo = resolveInfos.get(0);
        int start = 0;
        CharSequence firstLabel = firstResolveInfo.loadLabel(packageManager);
        for (int i = 1; i < size; i++) {
            if (firstLabel == null) {
                firstLabel = firstResolveInfo.activityInfo.packageName;
            }
            ResolveInfo resolveInfo = resolveInfos.get(i);
            CharSequence label = resolveInfo.loadLabel(packageManager);
            if (label == null) {
                label = resolveInfo.activityInfo.packageName;
            }
            if (label.equals(firstLabel)) {
                continue;
            }
            processGroup(resolveInfos, displayInfos, start, i - 1);
            firstResolveInfo = resolveInfo;
            firstLabel = label;
            start = i;
        }
        // Process last group
        processGroup(resolveInfos, displayInfos, start, size - 1);
    }
    return displayInfos;
}