Example usage for java.lang CharSequence toString

List of usage examples for java.lang CharSequence toString

Introduction

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

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:io.engine.EngineIO.java

private void receivedOpen(IOTransport transport, CharSequence message) {
    try {//from www . jav a2 s.  co m
        JSONObject open = new JSONObject(message.toString());
        setSid(open.getString("sid"));
        pingTimeout(open.getInt("pingTimeout"));
        JSONArray jsonUpgrades = open.optJSONArray("upgrades");
        if (isUpgrade() && jsonUpgrades != null && jsonUpgrades.length() != 0) {
            ArrayList<String> upgrades = new ArrayList<String>(jsonUpgrades.length());
            for (int i = 0; i < jsonUpgrades.length(); i++)
                upgrades.add(jsonUpgrades.getString(i));
            tryUpgrade(upgrades);
        }
        callback.onOpen();
    } catch (JSONException e) {
        callback.onError(new EngineIOException("Garbage received", e));
    }
}

From source file:com.github.jknack.handlebars.maven.I18nJsPlugin.java

/**
 * Wrap javaScript code using an anonymous function or the AMD format.
 *
 * @param filename The javascript file name.
 * @param body The javascript code./*from   w  w w.j  a  v  a 2  s.c o  m*/
 * @param amd True, for AMD.
 * @return Some javascript code.
 */
private String wrap(final String filename, final CharSequence body, final boolean amd) {
    if (amd) {
        return String.format("define('%s', ['i18n'], function (I18n) {\n%s});\n", filename, body);
    }
    return String.format("(function() {\n%s})();\n", body.toString());
}

From source file:id.zelory.tanipedia.activity.JawabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_jawab);
    Toolbar toolbar = (Toolbar) findViewById(R.id.anim_toolbar);
    setSupportActionBar(toolbar);//from  ww w  .  j  av a  2  s . co m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Tanya Tani");

    soal = getIntent().getParcelableExtra("soal");
    try {
        idSoal = URLEncoder.encode(soal.getId(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);
    fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);

    recyclerView = (RecyclerView) findViewById(R.id.scrollableview);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    recyclerView.addOnScrollListener(new MyRecyclerScroll() {
        @Override
        public void show() {
            fab.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        }

        @Override
        public void hide() {
            fab.animate().translationY(fab.getHeight() + fabMargin)
                    .setInterpolator(new AccelerateInterpolator(2)).start();
        }
    });

    fab = (FrameLayout) findViewById(R.id.myfab_main);
    fabBtn = (ImageButton) findViewById(R.id.myfab_main_btn);
    View fabShadow = findViewById(R.id.myfab_shadow);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fabShadow.setVisibility(View.GONE);
        fabBtn.setBackground(getDrawable(R.drawable.ripple_accent));
    }

    fab.startAnimation(animation);

    fabBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new MaterialDialog.Builder(JawabActivity.this).title("TaniPedia").content("Kirim Jawaban")
                    .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT)
                    .input("Ketik jawaban anda disini!", null, false, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            try {
                                jawaban = URLEncoder.encode(input.toString(), "UTF-8");
                                new KirimJawaban().execute();
                            } catch (UnsupportedEncodingException e) {
                                Snackbar.make(fabBtn, "Terjadi kesalahan, silahkan coba lagi!",
                                        Snackbar.LENGTH_LONG).show();
                                e.printStackTrace();
                            }
                        }
                    }).positiveColorRes(R.color.primary_dark).positiveText("Kirim")
                    .cancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {

                        }
                    }).negativeColorRes(R.color.primary_dark).negativeText("Batal").show();
        }
    });

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.showProgress(true);
    new DownloadData().execute();
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fabButton.showProgress(true);
            new DownloadData().execute();
        }
    });
}

From source file:com.hubrick.vertx.s3.signature.AWS4SignatureBuilder.java

public AWS4SignatureBuilder canonicalUri(final CharSequence canonicalUri) {
    Preconditions.checkArgument(StringUtils.isNotBlank(canonicalUri), "canonicalUri must not be blank");

    this.canonicalUri = PATH_PARTS_ESCAPER.escape(canonicalUri.toString());
    return this;
}

From source file:com.mercandalli.android.apps.files.admin.UserAddFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.rootView = inflater.inflate(R.layout.fragment_admin_add_user, container, false);

    this.circle = (ImageButton) this.rootView.findViewById(R.id.circle);
    this.circle.setVisibility(View.GONE);

    this.username = (TextView) this.rootView.findViewById(R.id.username);
    this.password = (TextView) this.rootView.findViewById(R.id.password);

    this.newUser = new UserModel();

    this.username.addTextChangedListener(new TextWatcher() {
        @Override//from  w ww  . j av a2s  . c  om
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!StringUtils.isNullOrEmpty(s.toString())
                    && !StringUtils.isNullOrEmpty(password.getText().toString())) {
                circle.setVisibility(View.VISIBLE);
            } else {
                circle.setVisibility(View.GONE);
            }
            newUser.username = s.toString();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    this.password.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!StringUtils.isNullOrEmpty(s.toString())
                    && !StringUtils.isNullOrEmpty(username.getText().toString())) {
                circle.setVisibility(View.VISIBLE);
            } else {
                circle.setVisibility(View.GONE);
            }
            newUser.password = HashUtils.sha1(s.toString());
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    this.circle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Register : POST /user
            List<StringPair> parameters = new ArrayList<>();
            parameters.add(new StringPair("username", "" + newUser.username));
            parameters.add(new StringPair("password", "" + newUser.password));

            if (NetUtils.isInternetConnection(getContext()) && !StringUtils.isNullOrEmpty(newUser.username)
                    && !StringUtils.isNullOrEmpty(newUser.password)) {
                requestLaunched = true;
                (new TaskPost(getActivity(), Constants.URL_DOMAIN + Config.ROUTE_USER,
                        new IPostExecuteListener() {
                            @Override
                            public void onPostExecute(JSONObject json, String body) {
                                try {
                                    if (json != null) {
                                        if (json.has("succeed") && json.getBoolean("succeed")) {
                                            Toast.makeText(getActivity(), "User added", Toast.LENGTH_SHORT)
                                                    .show();
                                        }
                                        if (json.has("user")) {
                                            JSONObject user = json.getJSONObject("user");
                                            if (user.has("id")) {
                                                Config.setUserId(getActivity(), user.getInt("id"));
                                            }
                                        }
                                    } else {
                                        Toast.makeText(getContext(), R.string.server_error, Toast.LENGTH_SHORT)
                                                .show();
                                    }
                                } catch (JSONException e) {
                                    Log.e(getClass().getName(), "Failed to convert Json", e);
                                }
                                requestLaunched = false;
                            }
                        }, parameters)).execute();
            } else {
                requestLaunched = false;
                Toast.makeText(getActivity(), "Request not sent", Toast.LENGTH_SHORT).show();
            }
        }
    });

    return this.rootView;
}

From source file:com.androidquery.simplefeed.activity.FriendsActivity.java

private List<Entity> filter(CharSequence s, List<Entity> items) {

    String str = null;/*w  w w.  j  a va2  s.  c om*/

    if (s != null) {
        str = s.toString();
    } else {
        str = aq.id(R.id.edit_input).getEditable().toString();
    }

    String[] terms = str.split("[\\s]+");

    List<Entity> result = new ArrayList<Entity>();

    for (Entity item : items) {

        String name = item.getName().toLowerCase();

        boolean miss = false;

        for (String term : terms) {

            if (!name.contains(term)) {
                miss = true;
                break;
            }

        }

        if (!miss) {
            result.add(item);
        }
    }

    return result;
}

From source file:chapter4.src.logistic.CsvRecordFactoryPredict.java

private List<String> parseCsvLine(CharSequence line) {
    return parseCsvLine(line.toString());
}

From source file:ch.ethz.tik.hrouting.providers.PlacesAutoCompleteAdapter.java

@Override
public Filter getFilter() {
    return new Filter() {
        @Override/*from  ww  w.  j  av a2s . c  o  m*/
        protected FilterResults performFiltering(CharSequence constraint) {
            FilterResults filterResults = new FilterResults();
            if (constraint != null) {
                // Retrieve the auto-complete results.
                resultList = autocomplete(constraint.toString());

                // Assign the data to the FilterResults
                if (resultList != null) {
                    filterResults.values = resultList;
                    filterResults.count = resultList.size();
                }
            }
            return filterResults;
        }

        @Override
        protected void publishResults(CharSequence constraint, FilterResults results) {
            if (results != null && results.count > 0) {
                notifyDataSetChanged();
            } else {
                notifyDataSetInvalidated();
            }
        }
    };
}

From source file:com.hubrick.vertx.s3.signature.AWS4SignatureBuilder.java

public AWS4SignatureBuilder httpRequestMethod(final CharSequence httpRequestMethod) {
    Preconditions.checkArgument(StringUtils.isNotBlank(httpRequestMethod),
            "httpRequestMethod must not be blank");

    this.httpRequestMethod = httpRequestMethod.toString();
    return this;
}

From source file:com.fusionx.lightirc.ui.IRCFragment.java

@Override
public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) {
    final CharSequence text = mMessageBox.getText();
    if ((event == null || actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE
            || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
            && StringUtils.isNotEmpty(text)) {
        final String message = text.toString();
        mMessageBox.setText("");
        onSendMessage(message);/*from w ww.  j  ava  2  s  .c o  m*/
        return true;
    }
    return false;
}