Example usage for java.lang Character toString

List of usage examples for java.lang Character toString

Introduction

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

Prototype

public static String toString(int codePoint) 

Source Link

Document

Returns a String object representing the specified character (Unicode code point).

Usage

From source file:org.ale.openwatch.FeedFragmentActivity.java

private String capitalizeFirstChar(String in) {
    in = in.toLowerCase();
    return Character.toString(in.charAt(0)).toUpperCase() + in.substring(1);
}

From source file:ConsumerServer.java

public void processMessages() {
    // for this exercise start from offset 0
    // produce batches of n size for jdbc and insert

    // for this table
    // char(10), char(20), long
    String sqlInsert = "INSERT INTO kblog.BLOGDATA VALUES (?,?,?,?,?)";
    String sqlUpsert = "UPSERT INTO kblog.BLOGDATA VALUES (?,?,?,?,?)";
    final String UDFCALL = " select * from udf(kblog.kaf3('nap007:9092'," + " 'gid'," + " 'blogit'," + "  0,"
            + " 'null'," + " 'C10C20IC55C55'," + " '|'," + "  -1," + "  1000 ))";
    final String SQLUPSERT = "upsert using load into kblog.blogdata ";
    final String SQLINSERT = "insert into kblog.blogdata ";
    final String SQLUPSERT2 = "upsert into kblog.blogdata ";

    try {//from   w w  w .  jav  a2  s  .c om
        if (t2Connect) {
            // T2
            Class.forName("org.apache.trafodion.jdbc.t2.T2Driver");
            conn = DriverManager.getConnection("jdbc:t2jdbc:");
        } else {
            // T4
            Class.forName("org.trafodion.jdbc.t4.T4Driver");
            conn = DriverManager.getConnection("jdbc:t4jdbc://nap007:23400/:", "trafodion", "passw");
        }
        conn.setAutoCommit(autoCommit);
    } catch (SQLException sx) {
        System.out.println("SQL error: " + sx.getMessage());
        System.exit(1);
    } catch (ClassNotFoundException cx) {
        System.out.println("Driver class not found: " + cx.getMessage());
        System.exit(2);

    }

    // message processing loop
    String[] msgFields;
    long numRows = 0;
    long totalRows = 0;
    int[] batchResult;

    if (udfMode == 0 && insMode == 0) {
        // missing cmd line setting
        System.out.println("*** Neither UDF nor INSERT mode specified - aborting ***");
        System.exit(2);
    }

    try {
        if (udfMode > 0) {
            long diff = 0;

            long startTime = System.currentTimeMillis();
            switch (udfMode) {
            case 1: // upsert using load
                pStmt = conn.prepareStatement(SQLUPSERT + UDFCALL);
                totalRows = pStmt.executeUpdate();
                diff = (System.currentTimeMillis() - startTime);
                System.out.println("Upsert loaded row count: " + totalRows + " in " + diff + " ms");
                break;

            case 2: // insert 
                pStmt = conn.prepareStatement(SQLINSERT + UDFCALL);
                totalRows = pStmt.executeUpdate();
                if (!autoCommit) {
                    conn.commit();
                    diff = (System.currentTimeMillis() - startTime);
                    System.out
                            .println("Insert row count (autocommit off): " + totalRows + " in " + diff + " ms");
                } else {
                    diff = (System.currentTimeMillis() - startTime);
                    System.out
                            .println("Insert row count (autocommit on): " + totalRows + " in " + diff + " ms");
                }
                break;

            case 3: // upsert 
                pStmt = conn.prepareStatement(SQLUPSERT2 + UDFCALL);
                totalRows = pStmt.executeUpdate();
                if (!autoCommit) {
                    conn.commit();
                    diff = (System.currentTimeMillis() - startTime);
                    System.out
                            .println("Upsert row count (autocommit off): " + totalRows + " in " + diff + " ms");
                } else {
                    diff = (System.currentTimeMillis() - startTime);
                    System.out
                            .println("Upsert row count (autocommit on): " + totalRows + " in " + diff + " ms");
                }
                break;

            default: // illegal value
                System.out.println("*** Only udf values 1,2,3 allowed; found: " + udfMode);
                System.exit(2);

            } // switch

        } // udfMode
        else { // iterative insert/upsert

            switch (insMode) {
            case 1: // insert
                pStmt = conn.prepareStatement(sqlInsert);
                break;
            case 2: //upsert
                pStmt = conn.prepareStatement(sqlUpsert);
                break;
            default: // illegal
                System.out.println("*** Only insert values 1,2 allowed; found: " + insMode);
                System.exit(2);
            } // switch

            kafka.subscribe(Arrays.asList(topic));
            // priming poll
            kafka.poll(100);
            // always start from beginning
            kafka.seekToBeginning(Arrays.asList(new TopicPartition(topic, 0)));

            // enable autocommit and singleton inserts for comparative timings

            long startTime = System.currentTimeMillis();
            while (true) {
                // note that we don't commitSync to kafka - tho we should
                ConsumerRecords<String, String> records = kafka.poll(streamTO);
                if (records.isEmpty())
                    break; // timed out
                for (ConsumerRecord<String, String> msg : records) {
                    msgFields = msg.value().split("\\" + Character.toString(delimiter));

                    // position info for this message
                    long offset = msg.offset();
                    int partition = msg.partition();
                    String topic = msg.topic();

                    pStmt.setString(1, msgFields[0]);
                    pStmt.setString(2, msgFields[1]);
                    pStmt.setLong(3, Long.parseLong(msgFields[2]));
                    pStmt.setString(4, msgFields[3]);
                    pStmt.setString(5, msgFields[4]);
                    numRows++;
                    totalRows++;
                    if (autoCommit) {
                        // single ins/up sert
                        pStmt.executeUpdate();
                    } else {
                        pStmt.addBatch();
                        if ((numRows % commitCount) == 0) {
                            numRows = 0;
                            batchResult = pStmt.executeBatch();
                            conn.commit();
                        }
                    }

                } // for each msg

            } // while true

            // get here when poll returns no records
            if (numRows > 0 && !autoCommit) {
                // remaining rows
                batchResult = pStmt.executeBatch();
                conn.commit();
            }
            long diff = (System.currentTimeMillis() - startTime);
            if (autoCommit)
                System.out.println("Total rows: " + totalRows + " in " + diff + " ms");
            else
                System.out.println(
                        "Total rows: " + totalRows + " in " + diff + " ms; batch size = " + commitCount);

            kafka.close();
        } // else

    } // try
    catch (ConsumerTimeoutException to) {
        System.out.println("consumer time out; " + to.getMessage());
        System.exit(1);
    } catch (BatchUpdateException bx) {
        int[] insertCounts = bx.getUpdateCounts();
        int count = 1;
        for (int i : insertCounts) {
            if (i == Statement.EXECUTE_FAILED)
                System.out.println("Error on request #" + count + ": Execute failed");
            else
                count++;
        }
        System.out.println(bx.getMessage());
        System.exit(1);

    } catch (SQLException sx) {
        System.out.println("SQL error: " + sx.getMessage());
        System.exit(1);
    }

}

From source file:com.hexidec.ekit.component.UnicodeDialog.java

private void populateButtons(int index, int page) {
    int blockPages = ((unicodeBlockEnd[index] / UNICODEBLOCKSIZE)
            - (unicodeBlockStart[index] / UNICODEBLOCKSIZE)) + 1;
    if (blockPages != jcmbPageSelector.getItemCount()) {
        jcmbPageSelector.setActionCommand("");
        jcmbPageSelector.setEnabled(false);
        jcmbPageSelector.removeAllItems();
        for (int i = 0; i < blockPages; i++) {
            jcmbPageSelector.addItem("" + (i + 1));
        }/*w  w w  .j  ava2s  .com*/
        jcmbPageSelector.setEnabled(true);
        jcmbPageSelector.update(this.getGraphics());
        jcmbPageSelector.setActionCommand(CMDCHANGEBLOCK);
    }
    if (page > (jcmbPageSelector.getItemCount() - 1)) {
        page = 0;
    }

    int firstInt = ((unicodeBlockStart[index] / UNICODEBLOCKSIZE) * UNICODEBLOCKSIZE)
            + (page * UNICODEBLOCKSIZE);
    int currInt = firstInt;
    for (int charInt = 0; charInt < UNICODEBLOCKSIZE; charInt++) {
        currInt = firstInt + charInt;
        buttonArray[charInt].setSelected(false);
        if (currInt < unicodeBlockStart[index] || currInt > unicodeBlockEnd[index]) {
            buttonArray[charInt].setText(" ");
            buttonArray[charInt].getModel().setActionCommand(" ");
            buttonArray[charInt].setEnabled(false);
            buttonArray[charInt].setVisible(false);
        } else {
            char unichar = (char) currInt;
            String symbol = Character.toString(unichar);
            if (buttonFont.canDisplay(unichar)) {
                buttonArray[charInt].setText(symbol);
            } else {
                buttonArray[charInt].setText(" ");
            }
            buttonArray[charInt].getModel().setActionCommand(symbol);
            buttonArray[charInt].setEnabled(true);
            buttonArray[charInt].setVisible(true);
            buttonArray[charInt].update(this.getGraphics());
        }
    }
}

From source file:org.dussan.vaadin.dcharts.DCharts.java

public DCharts autoSelectDecimalAndThousandsSeparator(Locale locale) {
    decimalSeparator = Character.toString(((DecimalFormat) NumberFormat.getNumberInstance(locale))
            .getDecimalFormatSymbols().getDecimalSeparator());
    thousandsSeparator = Character.toString(((DecimalFormat) NumberFormat.getNumberInstance(locale))
            .getDecimalFormatSymbols().getGroupingSeparator());
    chartData.put(DECIMAL_SEPARATOR, decimalSeparator);
    chartData.put(THOUSANDS_SEPARATOR, thousandsSeparator);
    return this;
}

From source file:au.org.ala.delta.translation.PrintFile.java

/**
 * Output a pair of strings, separated by multiple instances of a supplied
 * padding character. The padding character is used to ensure that the
 * content fills the print width exactly.
 * //from   w w  w  .j av a 2 s .c om
 * E.g. str1.........................str2
 * 
 * @param str1
 *            The first string
 * @param str2
 *            The second string
 * @param paddingChar
 *            the padding character
 */
public void outputStringPairWithPaddingCharacter(String str1, String str2, char paddingChar) {
    indent();
    writeJustifiedText(str1, -1);

    int currentLineLength = _outputBuffer.length();
    if (currentLineLength + str2.length() >= _printWidth) {
        _outputBuffer
                .append(StringUtils.repeat(Character.toString(paddingChar), _printWidth - currentLineLength));
        printBufferLine(_indentOnLineWrap);
        currentLineLength = _outputBuffer.length();
        _outputBuffer.append(StringUtils.repeat(Character.toString(paddingChar),
                _printWidth - currentLineLength - str2.length()));
        _outputBuffer.append(str2);
        printBufferLine();
    } else {
        _outputBuffer.append(StringUtils.repeat(Character.toString(paddingChar),
                _printWidth - currentLineLength - str2.length()));
        _outputBuffer.append(str2);
        printBufferLine();
    }
}

From source file:com.lgallardo.qbittorrentclient.TorrentDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Tell the host activity that your fragment has menu options that it
    // wants to add/replace/delete using the onCreateOptionsMenu method.
    setHasOptionsMenu(true);// w w  w .  java  2 s . c o  m

    View rootView;

    if (MainActivity.qb_version.equals("3.2.x")) {
        rootView = inflater.inflate(R.layout.torrent_details, container, false);
    } else {
        rootView = inflater.inflate(R.layout.torrent_details_old, container, false);
    }

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.RecyclerViewContentFiles); // Assigning the RecyclerView Object to the xml View
    rAdapter = new ContentFilesRecyclerViewAdapter((MainActivity) getActivity(), getActivity(),
            new ArrayList<TorrentDetailsItem>());
    rAdapter.notifyDataSetChanged();

    mRecyclerViewTrackers = (RecyclerView) rootView.findViewById(R.id.RecyclerViewTrackers); // Assigning the RecyclerView Object to the xml View
    trackerAdapter = new TrackersRecyclerViewAdapter((MainActivity) getActivity(), getActivity(),
            new ArrayList<TorrentDetailsItem>());
    trackerAdapter.notifyDataSetChanged();

    mRecyclerViewGeneralInfo = (RecyclerView) rootView.findViewById(R.id.RecyclerViewGeneralInfo); // Assigning the RecyclerView Object to the xml View
    generalInfoAdapter = new GeneralInfoRecyclerViewAdapter((MainActivity) getActivity(), getActivity(),
            new ArrayList<GeneralInfoItem>());
    generalInfoAdapter.notifyDataSetChanged();

    if (mRecyclerView == null) {
        Log.d("Debug", "mRecyclerView is null");
    }

    if (rAdapter == null) {
        Log.d("Debug", "rAdapter is null");
    }

    try {
        mRecyclerView.setAdapter(rAdapter);
        mRecyclerViewTrackers.setAdapter(trackerAdapter);
        mRecyclerViewGeneralInfo.setAdapter(generalInfoAdapter);

        mLayoutManager = new LinearLayoutManager(rootView.getContext()); // Creating a layout Manager
        mLayoutManagerTrackers = new LinearLayoutManager(rootView.getContext()); // Creating a layout Manager
        mLayoutManagerGeneralInfo = new LinearLayoutManager(rootView.getContext()); // Creating a layout Manager

        mRecyclerView.setLayoutManager(mLayoutManager); // Setting the layout Manager
        mRecyclerViewTrackers.setLayoutManager(mLayoutManagerTrackers); // Setting the layout Manager
        mRecyclerViewGeneralInfo.setLayoutManager(mLayoutManagerGeneralInfo); // Setting the layout Manager
    } catch (Exception e) {
        Log.e("Debug", e.toString());
    }

    // TODO: Check if this can be removed
    registerForContextMenu(mRecyclerView);
    //        registerForContextMenu(mRecyclerViewTrackers);
    //        registerForContextMenu(mRecyclerViewGeneralInfo);

    // Get Refresh Listener
    refreshListener = (RefreshListener) getActivity();
    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.details_refresh_layout);

    if (mSwipeRefreshLayout != null) {
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                refreshListener.swipeRefresh();
            }
        });
    }

    // Hide herderInfo and title in phone's view
    if (getActivity().findViewById(R.id.one_frame) != null && MainActivity.headerInfo != null) {
        MainActivity.headerInfo.setVisibility(View.GONE);

        ((MainActivity) getActivity()).setTitle("");
    }

    savePath = "";
    creationDate = "";
    comment = "";
    uploadRateLimit = "";
    downloadRateLimit = "";
    totalWasted = "";
    totalUploaded = "";
    totalDownloaded = "";
    timeElapsed = "";
    nbConnections = "";
    shareRatio = "";

    try {

        if (savedInstanceState != null) {

            // Get saved values
            name = savedInstanceState.getString("torrentDetailName", "");
            size = savedInstanceState.getString("torrentDetailSize", "");
            hash = savedInstanceState.getString("torrentDetailHash", "");
            ratio = savedInstanceState.getString("torrentDetailRatio", "");
            state = savedInstanceState.getString("torrentDetailState", "");
            leechs = savedInstanceState.getString("torrentDetailLeechs", "");
            seeds = savedInstanceState.getString("torrentDetailSeeds", "");
            progress = savedInstanceState.getString("torrentDetailProgress", "");
            priority = savedInstanceState.getString("torrentDetailPriority", "");
            eta = savedInstanceState.getString("torrentDetailEta", "");
            uploadSpeed = savedInstanceState.getString("torrentDetailUploadSpeed", "");
            downloadSpeed = savedInstanceState.getString("torrentDetailDownloadSpeed", "");
            downloaded = savedInstanceState.getString("torrentDetailDownloaded", "");
            addedOn = savedInstanceState.getString("torrentDetailsAddedOn", "");
            completionOn = savedInstanceState.getString("torrentDetailsCompletionOn", "");
            label = savedInstanceState.getString("torrentDetailsLabel", "");
            hashToUpdate = hash;

            // Only for Pro version
            if (MainActivity.packageName.equals("com.lgallardo.qbittorrentclientpro")) {
                int index = progress.indexOf(".");

                if (index == -1) {
                    index = progress.indexOf(",");

                    if (index == -1) {
                        index = progress.length();
                    }
                }

                percentage = progress.substring(0, index);
            }

        } else {

            // Get values from current activity
            name = this.torrent.getFile();
            size = this.torrent.getSize();
            hash = this.torrent.getHash();
            ratio = this.torrent.getRatio();
            state = this.torrent.getState();
            leechs = this.torrent.getLeechs();
            seeds = this.torrent.getSeeds();
            progress = this.torrent.getProgress();
            priority = this.torrent.getPriority();
            eta = this.torrent.getEta();
            uploadSpeed = this.torrent.getUploadSpeed();
            downloadSpeed = this.torrent.getDownloadSpeed();
            downloaded = this.torrent.getDownloaded();
            addedOn = this.torrent.getAddedOn();
            completionOn = this.torrent.getCompletionOn();
            label = this.torrent.getLabel();

            hashToUpdate = hash;

            // Only for Pro version
            if (MainActivity.packageName.equals("com.lgallardo.qbittorrentclientpro")) {
                int index = this.torrent.getProgress().indexOf(".");

                if (index == -1) {
                    index = this.torrent.getProgress().indexOf(",");

                    if (index == -1) {
                        index = this.torrent.getProgress().length();
                    }
                }

                percentage = this.torrent.getProgress().substring(0, index);
            }
        }

        TextView nameTextView = (TextView) rootView.findViewById(R.id.torrentName);
        TextView sizeTextView = (TextView) rootView.findViewById(R.id.torrentSize);
        TextView ratioTextView = (TextView) rootView.findViewById(R.id.torrentRatio);
        TextView progressTextView = (TextView) rootView.findViewById(R.id.torrentProgress);
        TextView stateTextView = (TextView) rootView.findViewById(R.id.torrentState);
        TextView priorityTextView = (TextView) rootView.findViewById(R.id.torrentPriority);
        TextView leechsTextView = (TextView) rootView.findViewById(R.id.torrentLeechs);
        TextView seedsTextView = (TextView) rootView.findViewById(R.id.torrentSeeds);
        TextView hashTextView = (TextView) rootView.findViewById(R.id.torrentHash);
        TextView etaTextView = (TextView) rootView.findViewById(R.id.torrentEta);
        TextView uploadSpeedTextView = (TextView) rootView.findViewById(R.id.torrentUploadSpeed);
        TextView downloadSpeedTextView = (TextView) rootView.findViewById(R.id.torrentDownloadSpeed);

        CheckBox sequentialDownloadCheckBox;
        CheckBox firstLAstPiecePrioCheckBox;

        nameTextView.setText(name);
        ratioTextView.setText(ratio);
        stateTextView.setText(state);
        leechsTextView.setText(leechs);
        seedsTextView.setText(seeds);
        progressTextView.setText(progress);
        hashTextView.setText(hash);
        etaTextView.setText(eta);
        priorityTextView.setText(priority);

        if (MainActivity.qb_version.equals("3.2.x")) {
            sequentialDownloadCheckBox = (CheckBox) rootView.findViewById(R.id.torrentSequentialDownload);
            firstLAstPiecePrioCheckBox = (CheckBox) rootView.findViewById(R.id.torrentFirstLastPiecePrio);

            sequentialDownloadCheckBox.setChecked(this.torrent.getSequentialDownload());
            firstLAstPiecePrioCheckBox.setChecked(this.torrent.getisFirstLastPiecePrio());

            TextView addedOnTextView = (TextView) rootView.findViewById(R.id.torrentAddedOn);
            TextView completionOnTextView = (TextView) rootView.findViewById(R.id.torrentCompletionOn);
            TextView labelTextView = (TextView) rootView.findViewById(R.id.torrentLabel);

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");

            if (addedOn != null && !(addedOn.equals("null")) && !(addedOn.equals("4294967295"))) {
                if (Integer.parseInt(MainActivity.qb_api) < 10) {
                    // Old time format 2016-07-25T20:52:07
                    addedOnTextView
                            .setText(new SimpleDateFormat("dd/MM/yyyy - HH:mm").format(sdf.parse(addedOn)));
                } else {
                    // New unix timestamp format 4294967295
                    addedOnTextView.setText(Common.timestampToDate(addedOn));
                }
            } else {
                addedOnTextView.setText("");
            }

            if (completionOn != null && !(completionOn.equals("null"))
                    && !(completionOn.equals("4294967295"))) {

                if (Integer.parseInt(MainActivity.qb_api) < 10) {
                    // Old time format 2016-07-25T20:52:07
                    completionOnTextView.setText(
                            new SimpleDateFormat("dd/MM/yyyy - HH:mm").format(sdf.parse(completionOn)));
                } else {
                    // New unix timestamp format 4294967295
                    completionOnTextView.setText(Common.timestampToDate(completionOn));
                }
            } else {
                completionOnTextView.setText("");
            }

            if (label != null && !(label.equals("null"))) {
                labelTextView.setText(label);
            } else {
                labelTextView.setText("");
            }

        }

        // Set Downloaded vs Total size
        sizeTextView.setText(downloaded + " / " + size);

        // Only for Pro version
        if (MainActivity.packageName.equals("com.lgallardo.qbittorrentclientpro")) {
            downloadSpeedTextView.setText(Character.toString('\u2193') + " " + downloadSpeed);
            uploadSpeedTextView.setText(Character.toString('\u2191') + " " + uploadSpeed);

            // Set progress bar
            ProgressBar progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar1);
            TextView percentageTV = (TextView) rootView.findViewById(R.id.percentage);

            progressBar.setProgress(Integer.parseInt(percentage));
            percentageTV.setText(percentage + "%");
        } else {
            downloadSpeedTextView.setText(downloadSpeed);
            uploadSpeedTextView.setText(uploadSpeed);
        }

        nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_recheck, 0, 0, 0);

        // Set status icon
        if ("pausedUP".equals(state) || "pausedDL".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.paused, 0, 0, 0);
        }

        if ("stalledUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.stalledup, 0, 0, 0);
        }

        if ("stalledDL".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.stalleddl, 0, 0, 0);
        }

        if ("downloading".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.downloading, 0, 0, 0);
        }

        if ("uploading".equals(state) || "forcedUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.uploading, 0, 0, 0);
        }

        if ("queuedDL".equals(state) || "queuedUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.queued, 0, 0, 0);
        }

        if ("checkingDL".equals(state) || "checkingUP".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_recheck, 0, 0, 0);
        }

        if ("error".equals(state) || "missingFiles".equals(state) || "unknown".equals(state)) {
            nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.error, 0, 0, 0);
        }

        // Get Content files in background
        ContentFileTask cft = new ContentFileTask();
        cft.execute(new String[] { hash });

        // Get trackers in background
        TrackersTask tt = new TrackersTask();
        tt.execute(new String[] { hash });

        // Get General info labels
        generalInfoItems = new ArrayList<GeneralInfoItem>();

        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_save_path), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_created_date), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_comment), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_total_wasted), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_total_uploaded), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_total_downloaded), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_time_elapsed), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_num_connections), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_share_ratio), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_upload_rate_limit), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));
        generalInfoItems.add(new GeneralInfoItem(getString(R.string.torrent_details_download_rate_limit), null,
                GeneralInfoItem.GENERALINFO, "generalInfo"));

        // Get general info in background
        GeneralInfoTask git = new GeneralInfoTask();
        git.execute(new String[] { hash });

    } catch (Exception e) {
        Log.e("Debug", "TorrentDetailsFragment - onCreateView: " + e.toString());
    }

    if (MainActivity.packageName.equals("com.lgallardo.qbittorrentclient")) {
        // Load banner
        loadBanner();
    }

    return rootView;
}

From source file:mobisocial.musubi.identity.AphidIdentityProvider.java

private byte[] getAphidResultForIdentity(IBIdentity ident, String property) throws IdentityProviderException {
    Log.d(TAG, "Getting key for " + ident.principal_);

    // Populate tokens from identity providers (only Google and Facebook for now)
    try {//  w  ww  .  j  a  va  2  s .c  om
        cacheGoogleTokens();
    } catch (IdentityProviderException.Auth e) {
        // No need to continue if this is our identity and token fetch failed
        if (e.identity.equalsStable(ident)) {
            throw new IdentityProviderException.Auth(ident);
        }
    } catch (IdentityProviderException.NeedsRetry e) {
        if (e.identity.equalsStable(ident)) {
            throw new IdentityProviderException.NeedsRetry(ident);
        }
    }
    try {
        cacheCurrentFacebookToken();
    } catch (IdentityProviderException e) {
        // No need to continue if this is our identity and token fetch failed
        if (e.identity.equalsStable(ident)) {
            throw new IdentityProviderException.Auth(ident);
        }
    }

    String aphidType = null;
    String aphidToken = null;
    // Get a service-specific token if it exists
    Pair<Authority, String> userProperties = new Pair<Authority, String>(ident.authority_, ident.principal_);
    if (mKnownTokens.containsKey(userProperties)) {
        aphidToken = mKnownTokens.get(userProperties);
    }

    // The IBE server has its own identifiers for providers
    switch (ident.authority_) {
    case Facebook:
        aphidType = "facebook";
        break;
    case Email:
        if (mKnownTokens.containsKey(userProperties)) {
            aphidType = "google";
        }
        break;
    case PhoneNumber:
        // Aphid doesn't return keys for a phone number without verification
        throw new IdentityProviderException.TwoPhase(ident);
    }

    // Do not ask the server for identities we don't know how to handle
    if (aphidType == null || aphidToken == null) {
        throw new IdentityProviderException(ident);
    }

    // Bundle arguments as JSON
    JSONObject jsonObj = new JSONObject();
    try {
        jsonObj.put("type", aphidType);
        jsonObj.put("token", aphidToken);
        jsonObj.put("starttime", ident.temporalFrame_);
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
    JSONArray userinfo = new JSONArray();
    userinfo.put(jsonObj);

    // Contact the server
    try {
        JSONObject resultObj = getAphidResult(userinfo);
        if (resultObj == null) {
            throw new IdentityProviderException.NeedsRetry(ident);
        }
        String encodedKey = resultObj.getString(property);
        boolean hasError = resultObj.has("error");
        if (!hasError) {
            long temporalFrame = resultObj.getLong("time");
            if (encodedKey != null && temporalFrame == ident.temporalFrame_) {
                // Success!
                return Base64.decode(encodedKey, Base64.DEFAULT);
            } else {
                // Might have jumped the gun a little bit, so try again later
                throw new IdentityProviderException.NeedsRetry(ident);
            }
        } else {
            // Aphid authentication error means Musubi has a bad token
            String error = resultObj.getString("error");
            if (error.contains("401")) {
                // Authentication errors require user action
                String accountType = Character.toString(Character.toUpperCase(aphidType.charAt(0)))
                        + aphidType.substring(1);
                sendNotification(accountType);
                throw new IdentityProviderException.Auth(ident);
            } else {
                // Other failures should be retried silently
                throw new IdentityProviderException.NeedsRetry(ident);
            }
        }
    } catch (IOException e) {
        Log.e(TAG, e.toString());
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
    throw new IdentityProviderException.NeedsRetry(ident);
}

From source file:org.dussan.vaadin.dcharts.DCharts.java

public DCharts autoSelectDecimalSeparator(Locale locale) {
    decimalSeparator = Character.toString(((DecimalFormat) NumberFormat.getNumberInstance(locale))
            .getDecimalFormatSymbols().getDecimalSeparator());
    chartData.put(DECIMAL_SEPARATOR, decimalSeparator);
    return this;
}

From source file:com.duy.pascal.ui.view.console.ConsoleView.java

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    outAttrs.inputType = InputType.TYPE_NULL;
    //        outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
    return new InputConnection() {
        /**//from   w  ww  .j  a  v a  2  s  . c om
         * Used to handle composing text requests
         */
        private int mCursor;
        private int mComposingTextStart;
        private int mComposingTextEnd;
        private int mSelectedTextStart = 0;
        private int mSelectedTextEnd = 0;
        private boolean mInBatchEdit;

        private void sendText(CharSequence text) {
            DLog.d(TAG, "sendText: " + text);
            int n = text.length();
            for (int i = 0; i < n; i++) {
                mKeyBuffer.push(text.charAt(i));
                putString(Character.toString(text.charAt(i)));
            }
        }

        @Override
        public boolean performEditorAction(int actionCode) {
            DLog.d(TAG, "performEditorAction: " + actionCode);
            if (actionCode == EditorInfo.IME_ACTION_DONE || actionCode == EditorInfo.IME_ACTION_GO
                    || actionCode == EditorInfo.IME_ACTION_NEXT || actionCode == EditorInfo.IME_ACTION_SEND
                    || actionCode == EditorInfo.IME_ACTION_UNSPECIFIED) {
                sendText("\n");
                return true;
            }
            return false;
        }

        public boolean beginBatchEdit() {
            {
                DLog.w(TAG, "beginBatchEdit");
            }
            setImeBuffer("");
            mCursor = 0;
            mComposingTextStart = 0;
            mComposingTextEnd = 0;
            mInBatchEdit = true;
            return true;
        }

        public boolean clearMetaKeyStates(int arg0) {
            {
                DLog.w(TAG, "clearMetaKeyStates " + arg0);
            }
            return false;
        }

        public boolean commitCompletion(CompletionInfo arg0) {
            {
                DLog.w(TAG, "commitCompletion " + arg0);
            }
            return false;
        }

        @Override
        public boolean commitCorrection(CorrectionInfo correctionInfo) {
            return false;
        }

        public boolean endBatchEdit() {
            {
                DLog.w(TAG, "endBatchEdit");
            }
            mInBatchEdit = false;
            return true;
        }

        public boolean finishComposingText() {
            {
                DLog.w(TAG, "finishComposingText");
            }
            sendText(mImeBuffer);
            setImeBuffer("");
            mComposingTextStart = 0;
            mComposingTextEnd = 0;
            mCursor = 0;
            return true;
        }

        public int getCursorCapsMode(int arg0) {
            {
                DLog.w(TAG, "getCursorCapsMode(" + arg0 + ")");
            }
            return 0;
        }

        public ExtractedText getExtractedText(ExtractedTextRequest arg0, int arg1) {
            {
                DLog.w(TAG, "getExtractedText" + arg0 + "," + arg1);
            }
            return null;
        }

        public CharSequence getTextAfterCursor(int n, int flags) {
            {
                DLog.w(TAG, "getTextAfterCursor(" + n + "," + flags + ")");
            }
            int len = Math.min(n, mImeBuffer.length() - mCursor);
            if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) {
                return "";
            }
            return mImeBuffer.substring(mCursor, mCursor + len);
        }

        public CharSequence getTextBeforeCursor(int n, int flags) {
            {
                DLog.w(TAG, "getTextBeforeCursor(" + n + "," + flags + ")");
            }
            int len = Math.min(n, mCursor);
            if (len <= 0 || mCursor < 0 || mCursor >= mImeBuffer.length()) {
                return "";
            }
            return mImeBuffer.substring(mCursor - len, mCursor);
        }

        public boolean performContextMenuAction(int arg0) {
            {
                DLog.w(TAG, "performContextMenuAction" + arg0);
            }
            return true;
        }

        public boolean performPrivateCommand(String arg0, Bundle arg1) {
            {
                DLog.w(TAG, "performPrivateCommand" + arg0 + "," + arg1);
            }
            return true;
        }

        @Override
        public boolean requestCursorUpdates(int cursorUpdateMode) {
            return false;
        }

        @Override
        public Handler getHandler() {
            return null;
        }

        @Override
        public void closeConnection() {

        }

        @Override
        public boolean commitContent(@NonNull InputContentInfo inputContentInfo, int flags, Bundle opts) {
            return false;
        }

        public boolean reportFullscreenMode(boolean arg0) {
            {
                DLog.w(TAG, "reportFullscreenMode" + arg0);
            }
            return true;
        }

        public boolean commitText(CharSequence text, int newCursorPosition) {
            {
                DLog.w(TAG, "commitText(\"" + text + "\", " + newCursorPosition + ")");
            }
            char[] characters = text.toString().toCharArray();
            for (char character : characters) {
                mKeyBuffer.push(character);
            }
            clearComposingText();
            sendText(text);
            setImeBuffer("");
            mCursor = 0;
            return true;
        }

        private void clearComposingText() {
            setImeBuffer(
                    mImeBuffer.substring(0, mComposingTextStart) + mImeBuffer.substring(mComposingTextEnd));
            if (mCursor < mComposingTextStart) {
                // do nothing
            } else if (mCursor < mComposingTextEnd) {
                mCursor = mComposingTextStart;
            } else {
                mCursor -= mComposingTextEnd - mComposingTextStart;
            }
            mComposingTextEnd = mComposingTextStart = 0;
        }

        public boolean deleteSurroundingText(int leftLength, int rightLength) {
            {
                DLog.w(TAG, "deleteSurroundingText(" + leftLength + "," + rightLength + ")");
            }
            if (leftLength > 0) {
                for (int i = 0; i < leftLength; i++) {
                    sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
                }
            } else if ((leftLength == 0) && (rightLength == 0)) {
                // Delete key held down / repeating
                sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }
            // TODO: handle forward deletes.
            return true;
        }

        @Override
        public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) {
            return false;
        }

        public boolean sendKeyEvent(KeyEvent event) {
            {
                DLog.w(TAG, "sendKeyEvent(" + event + ")");
            }
            // Some keys are sent here rather than to commitText.
            // In particular, del and the digit keys are sent here.
            // (And I have reports that the HTC Magic also sends Return here.)
            // As a bit of defensive programming, handle every key.
            dispatchKeyEvent(event);
            return true;
        }

        public boolean setComposingText(CharSequence text, int newCursorPosition) {
            {
                DLog.w(TAG, "setComposingText(\"" + text + "\", " + newCursorPosition + ")");
            }

            setImeBuffer(mImeBuffer.substring(0, mComposingTextStart) + text
                    + mImeBuffer.substring(mComposingTextEnd));
            mComposingTextEnd = mComposingTextStart + text.length();
            mCursor = newCursorPosition > 0 ? mComposingTextEnd + newCursorPosition - 1
                    : mComposingTextStart - newCursorPosition;
            return true;
        }

        public boolean setSelection(int start, int end) {
            {
                DLog.w(TAG, "setSelection" + start + "," + end);
            }
            int length = mImeBuffer.length();
            if (start == end && start > 0 && start < length) {
                mSelectedTextStart = mSelectedTextEnd = 0;
                mCursor = start;
            } else if (start < end && start > 0 && end < length) {
                mSelectedTextStart = start;
                mSelectedTextEnd = end;
                mCursor = start;
            }
            return true;
        }

        public boolean setComposingRegion(int start, int end) {
            {
                DLog.w(TAG, "setComposingRegion " + start + "," + end);
            }
            if (start < end && start > 0 && end < mImeBuffer.length()) {
                clearComposingText();
                mComposingTextStart = start;
                mComposingTextEnd = end;
            }
            return true;
        }

        public CharSequence getSelectedText(int flags) {
            try {

                {
                    DLog.w(TAG, "getSelectedText " + flags);
                }

                if (mImeBuffer.length() < 1) {
                    return "";
                }

                return mImeBuffer.substring(mSelectedTextStart, mSelectedTextEnd + 1);

            } catch (Exception ignored) {

            }

            return "";
        }

    };
}

From source file:org.dussan.vaadin.dcharts.DCharts.java

public DCharts autoSelectThousandsSeparator(Locale locale) {
    thousandsSeparator = Character.toString(((DecimalFormat) NumberFormat.getNumberInstance(locale))
            .getDecimalFormatSymbols().getGroupingSeparator());
    chartData.put(THOUSANDS_SEPARATOR, thousandsSeparator);
    return this;
}