Example usage for android.text TextUtils equals

List of usage examples for android.text TextUtils equals

Introduction

In this page you can find the example usage for android.text TextUtils equals.

Prototype

public static boolean equals(CharSequence a, CharSequence b) 

Source Link

Document

Returns true if a and b are equal, including if they are both null.

Usage

From source file:com.google.android.marvin.utils.AutomationUtils.java

/**
 * Returns whether a node matches the class specified by
 * {@code className} and exactly match the text or content description
 * specified by {@code text}./*  ww w .jav  a 2  s . c  o  m*/
 */
private static boolean nodeMatchesFilter(Context context, AccessibilityNodeInfoCompat node,
        CharSequence referenceClassName, String findText) {
    final ClassLoadingManager loader = ClassLoadingManager.getInstance();
    final CharSequence nodeClass = node.getClassName();
    final CharSequence nodePackage = node.getPackageName();

    if (!loader.checkInstanceOf(context, nodeClass, nodePackage, referenceClassName)) {
        return false;
    }

    final CharSequence nodeText = node.getText();
    if (TextUtils.equals(findText, nodeText)) {
        return true;
    }

    final CharSequence nodeDesc = node.getContentDescription();
    if (TextUtils.equals(findText, nodeDesc)) {
        return true;
    }

    return false;
}

From source file:com.google.android.apps.muzei.gallery.GalleryArtSource.java

@Override
public IBinder onBind(final Intent intent) {
    if (intent != null && TextUtils.equals(intent.getAction(), ACTION_BIND_GALLERY)) {
        return new Binder();
    }/*from   www . ja  va2s  .c om*/
    return super.onBind(intent);
}

From source file:fm.smart.r1.activity.ItemActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ExceptionHandler.register(this);

    // could check here to see if this was suspended for login and go
    // straight to add_item ...

    setContentView(R.layout.item);//from  w w w.  j a  va  2s.  c  om

    /*
     * ImageView author_icon = (ImageView)
     * findViewById(R.id.item_author_icon); if (item.author_image != null){
     * author_icon.setImageBitmap(item.author_image); }
     */

    TextView cue_and_pronunciation = (TextView) findViewById(R.id.cue_and_pronunciation);
    cue_and_pronunciation.setText(item.cue_text); // TODO handle case where item is null?
    TextView cue_part_of_speech = (TextView) findViewById(R.id.cue_part_of_speech);
    if (!TextUtils.equals(item.part_of_speech, "None")) {
        cue_part_of_speech.setText(item.part_of_speech);
    } else {
        cue_part_of_speech.setVisibility(View.INVISIBLE);
    }
    /*
     * TextView author = (TextView) findViewById(R.id.item_author);
     * author.setText(item.author_name);
     */

    TextView response_and_pronunciation = (TextView) findViewById(R.id.response_and_pronunciation);
    response_and_pronunciation.setText(item.children[0][0]);
    TextView response_part_of_speech = (TextView) findViewById(R.id.response_part_of_speech);
    if (item.type != null && item.type.equals("meaning")) {
        item.type = "Translation";
    }
    response_part_of_speech.setText(item.type);
    response_part_of_speech.setVisibility(View.INVISIBLE);

    ImageView cue_sound = (ImageView) findViewById(R.id.cue_sound);
    setSound(cue_sound, item.cue_sound_url, this, R.id.cue_sound, (String) item.item_node.atts.get("id"),
            item.cue_text);

    ImageView response_sound = (ImageView) findViewById(R.id.response_sound);
    setSound(response_sound, item.response_sound_url, this, R.id.response_sound,
            (String) item.item_node.atts.get("id"), item.response_node.getFirstContents("text"));
    EfficientAdapter adapter = new EfficientAdapter(ItemActivity.this, item.sentence_vector);
    setListAdapter(adapter);
    if (adapter.getCount() == 0 && !ItemActivity.shown_toast) {
        Toast t = Toast.makeText(this, "Know a good example? Click the menu button to add one", 250);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();
        ItemActivity.shown_toast = true;
    }
    // notify();
}

From source file:com.jefftharris.passwdsafe.sync.lib.SyncedFilesFragment.java

/**
 * Initialize the contents of the Activity's standard options menu
 *//*from   w  w w  .  j av a  2 s  .  c  om*/
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_synced_files, menu);

    boolean parentEnabled = !TextUtils.equals(ProviderRemoteFile.PATH_SEPARATOR, itsPathId);

    MenuItem item = menu.findItem(R.id.menu_parent_dir);
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    item.setVisible(parentEnabled);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.classiqo.nativeandroid_32bitz.ui.MusicPlayerActivity.java

private void navigateToBrowser(String mediaId) {
    LogHelper.d(TAG, "navigateToBrowser, mediaId = " + mediaId);

    MediaBrowserFragment fragment = getBrowseFragment();

    if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) {
        fragment = new MediaBrowserFragment();
        fragment.setMediaId(mediaId);//from w  w w . j a v a 2s  .c o m
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.setCustomAnimations(R.animator.slide_in_from_right, R.animator.slide_out_to_left,
                R.animator.slide_in_from_left, R.animator.slide_out_to_right);
        transaction.replace(R.id.container, fragment, FRAGMENT_TAG);

        if (mediaId != null) {
            transaction.addToBackStack(null);
        }
        transaction.commit();
    }
}

From source file:com.dgsd.android.ShiftTracker.Adapter.WeekAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    ViewHolder holder = (ViewHolder) view.getTag();

    final Shift shift = Shift.fromCursor(cursor);
    if (TextUtils.equals(NEW_ROW_KEY, shift.name)) {
        holder.noShiftWrapper.setVisibility(View.VISIBLE);
        holder.shiftWrapper.setVisibility(View.GONE);

        holder.shift = null;//from ww w  .ja  v  a2s.  c  o  m
        holder.julianDay = shift.julianDay;

        return;
    }

    holder.noShiftWrapper.setVisibility(View.GONE);
    holder.shiftWrapper.setVisibility(View.VISIBLE);

    holder.name.setText(shift.name);
    holder.time.setText(getTimeText(shift));

    String payText = getPayText(shift);
    if (mShowIncomePref && !TextUtils.isEmpty(payText)) {
        holder.pay.setText(payText);
        holder.pay.setVisibility(View.VISIBLE);
    } else {
        holder.pay.setText(null);
        holder.pay.setVisibility(View.GONE);
    }

    if (TextUtils.isEmpty(shift.note)) {
        holder.note.setVisibility(View.GONE);
    } else {
        holder.note.setText(shift.note);
        holder.note.setVisibility(View.VISIBLE);
    }

    holder.shift = shift;
    holder.julianDay = shift.julianDay;
}

From source file:com.btmura.android.reddit.app.LoginFragment.java

boolean handleOAuthRedirectUrl(String url) {
    Uri uri = Uri.parse(url);/*  w ww  .jav  a 2s .  c o m*/

    String error = uri.getQueryParameter("error");
    if (!TextUtils.isEmpty(error)) {
        if (listener != null) {
            listener.onLoginCancelled();
        }
        return true;
    }

    String state = uri.getQueryParameter("state");
    String code = uri.getQueryParameter("code");
    if (TextUtils.equals(state, getExpectedStateTokenArg()) && !TextUtils.isEmpty(code)) {
        if (listener != null) {
            listener.onLoginSuccess(code);
        }
        return true;
    }

    return false;
}

From source file:com.loongsoft.qingzhou.WelcomeActivity.java

private void InitViewPager() {
    mPager = (ViewPager) findViewById(R.id.welcome_view_pager);
    mPagerViews = new ArrayList<View>();
    mInflater = getLayoutInflater();//from  w  ww .  j a  v  a2  s .c  o m
    mPagerViews.add(mInflater.inflate(R.layout.welcome_intro, null));
    mPagerViews.add(mInflater.inflate(R.layout.welcome_overview, null));

    View welcome_promise = mInflater.inflate(R.layout.welcome_promise, null);

    mPagerViews.add(welcome_promise);

    Button quit = (Button) welcome_promise.findViewById(R.id.welcome_promise_quit);
    Button agree = (Button) welcome_promise.findViewById(R.id.welcome_promise_agree);

    quit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            finish();
        }
    });

    agree.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mPagerViews.size() < 4) {
                View welcome_setting = mInflater.inflate(R.layout.welcome_settings, null);
                mPagerViews.add(welcome_setting);

                addDot();

                Button finish = (Button) welcome_setting.findViewById(R.id.welcome_finish);
                final EditText name = (EditText) welcome_setting.findViewById(R.id.welcome_name);
                finish.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        //validate input
                        if (TextUtils.isEmpty(mUserName.getText().toString())) {
                            Toast.makeText(WelcomeActivity.this, WelcomeActivity.this.getResources()
                                    .getString(R.string.welcome_settings_name), TOAST_LENGTH).show();
                            return;
                        }

                        if (mPasswordSwitch.isChecked()) {
                            if (TextUtils.isEmpty(mPassword.getText().toString())
                                    || TextUtils.isEmpty(mPasswordConfirmed.getText().toString())) {
                                Toast.makeText(WelcomeActivity.this, WelcomeActivity.this.getResources()
                                        .getString(R.string.password_is_empty), TOAST_LENGTH).show();
                                return;
                            }

                            if (!TextUtils.equals(mPassword.getText().toString(),
                                    mPasswordConfirmed.getText().toString())) {
                                Toast.makeText(WelcomeActivity.this, WelcomeActivity.this.getResources()
                                        .getString(R.string.password_not_equal), TOAST_LENGTH).show();
                                return;
                            }
                        }

                        SharedPreferences pref = getSharedPreferences(MetaData.PREFS_NAME, MODE_PRIVATE);
                        Editor editor = pref.edit();

                        editor.putString(MetaData.USER_NAME, name.getText().toString());
                        editor.putLong(MetaData.PROMISE_TIME, System.currentTimeMillis());
                        editor.putBoolean(MetaData.FIRST_RUN, false);
                        editor.putBoolean(MetaData.USE_PASSWORD, mPasswordSwitch.isChecked());
                        editor.putString(MetaData.PASSWORD, mPassword.getText().toString());

                        editor.commit();

                        MetaData.isFirstRun = false;
                        MetaData.userName = mUserName.getText().toString();
                        MetaData.usePassword = mPasswordSwitch.isChecked();
                        MetaData.promiseTime = System.currentTimeMillis();
                        MetaData.password = mPassword.getText().toString();

                        Intent intent = new Intent(WelcomeActivity.this, SplashActivity.class);
                        startActivity(intent);

                        WelcomeActivity.this.finish();
                    }
                });

                mUserName = (EditText) welcome_setting.findViewById(R.id.welcome_name);
                mPasswordSwitch = (Switch) welcome_setting.findViewById(R.id.welcome_password_switch);
                mPassword = (EditText) welcome_setting.findViewById(R.id.welcome_password);
                mPasswordConfirmed = (EditText) welcome_setting.findViewById(R.id.welcome_password_confirmed);

                mPasswordSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) {
                            mPassword.setVisibility(View.VISIBLE);
                            mPasswordConfirmed.setVisibility(View.VISIBLE);
                        } else {
                            mPassword.setVisibility(View.GONE);
                            mPasswordConfirmed.setVisibility(View.GONE);
                        }
                    }
                });
            }

            mPager.setCurrentItem(mPagerViews.size() - 1, true);
        }
    });

    mPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int index) {
            for (int i = 0; i < mDots.size(); i++) {
                mDots.get(i).setImageDrawable(getResources().getDrawable(R.drawable.welcome_dot_normal));
            }
            mDots.get(index).setImageDrawable(getResources().getDrawable(R.drawable.welcome_dot_selected));
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }
    });
}

From source file:de.jamoo.muzei.WallSource.java

protected void onTryUpdate(int reason) throws RetryException {
    if (DEBUG)/*from w  w w. j a  va  2 s  .  co m*/
        Log.w(TAG, "onTryUpdate");

    if (!isConnectedAsPreferred()) {
        scheduleUpdate(System.currentTimeMillis() + getRotateTimeMillis());
        if (DEBUG)
            Log.v(TAG, "Cancelled! Wrong connection!");
        return;
    }

    String currentToken = (getCurrentArtwork() != null) ? getCurrentArtwork().getToken() : null;

    String WALL_URL = getString(R.string.config_wallpaper_manifest_url);

    JSON response = getJson(WALL_URL);

    if (response == null) {
        throw new RetryException();
    }

    if (response.All.size() == 0) {
        Log.w(TAG, "Whoops! No walls returned!");
        scheduleUpdate(System.currentTimeMillis() + getRotateTimeMillis());
        return;
    }

    List<String> categories = getCategories(response);

    PreferenceHelper.categoriesToPref(WallSource.this, categories);

    ArrayList<NodeWallpaper> wallpapers = getValidWalls(response);

    if (wallpapers.size() == 0 || wallpapers == null) {
        Log.i(TAG, "No valid walls returned.");
        scheduleUpdate(System.currentTimeMillis() + getRotateTimeMillis());
        return;
    }

    Random random = new Random();
    NodeWallpaper wall;
    String token;

    while (true) {
        wall = wallpapers.get(random.nextInt(wallpapers.size()));
        token = wall.url;
        if (wallpapers.size() <= 1 || !TextUtils.equals(token, currentToken)) {
            Log.i(TAG, "Selected wall: " + wall.name);
            break;
        }
    }
    ;

    publishArtwork(new Artwork.Builder().title(wall.name).byline(wall.author).imageUri(Uri.parse(wall.url))
            .token(token).viewIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(wall.url))).build());

    scheduleUpdate(System.currentTimeMillis() + getRotateTimeMillis());
}

From source file:com.rascarlo.aurdroid.MainActivity.java

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key != null && !TextUtils.isEmpty(key)) {
        if (TextUtils.equals(getString(R.string.key_theme), key)) {
            setAppTheme(true);/*from  w  w  w  .j  a v a 2s .c  o m*/
        }
    }
}