Search in sources :

Example 21 with SecureRandom

use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.

the class SimpleAnimationAdapter method onBindHeaderViewHolder.

@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text);
    textView.setText(String.valueOf(getItem(position).charAt(0)));
    //        viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
    viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff"));
    ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img);
    SecureRandom imgGen = new SecureRandom();
    switch(imgGen.nextInt(3)) {
        case 0:
            imageView.setImageResource(R.drawable.scn1);
            break;
        case 1:
            imageView.setImageResource(R.drawable.jr13);
            break;
        case 2:
            imageView.setImageResource(R.drawable.jr16);
            break;
    }
}
Also used : SecureRandom(java.security.SecureRandom) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 22 with SecureRandom

use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.

the class sectionCommonAdapter method onBindHeaderViewHolder.

/**
     * this is the section header binding
     *
     * @param viewHolder section holder
     * @param position   position
     */
@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text);
    textView.setText(String.valueOf(getItem(hasHeaderView() ? position - 1 : position).charAt(0)));
    //        viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
    viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff"));
    ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img);
    SecureRandom imgGen = new SecureRandom();
    switch(imgGen.nextInt(3)) {
        case 0:
            imageView.setImageResource(R.drawable.scn1);
            break;
        case 1:
            imageView.setImageResource(R.drawable.jr13);
            break;
        case 2:
            imageView.setImageResource(R.drawable.jr16);
            break;
    }
}
Also used : SecureRandom(java.security.SecureRandom) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 23 with SecureRandom

use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.

the class sectionZeroAdapter method withBindHolder.

/*
    @Override
    public long generateHeaderId(int position) {
        // URLogs.d("position--" + position + "   " + getItem(position));
        if (getItem(position).length() > 0)
            return getItem(position).charAt(0);
        else return -1;
    }*/
@Override
protected void withBindHolder(itemCommonBinder holder, String data, int position) {
    holder.textViewSample.setText(data + "just the sample data");
    holder.item_view.setBackgroundColor(Color.parseColor("#AAffffff"));
    SecureRandom imgGen = new SecureRandom();
    switch(imgGen.nextInt(3)) {
        case 0:
            holder.imageViewSample.setImageResource(R.drawable.scn1);
            break;
        case 1:
            holder.imageViewSample.setImageResource(R.drawable.jr13);
            break;
        case 2:
            holder.imageViewSample.setImageResource(R.drawable.jr16);
            break;
    }
}
Also used : SecureRandom(java.security.SecureRandom)

Example 24 with SecureRandom

use of java.security.SecureRandom in project UltimateRecyclerView by cymcsg.

the class SimpleAdapter method onBindHeaderViewHolder.

@Override
public void onBindHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    TextView textView = (TextView) viewHolder.itemView.findViewById(R.id.stick_text);
    textView.setText(String.valueOf(getItem(position).charAt(0)));
    //        viewHolder.itemView.setBackgroundColor(Color.parseColor("#AA70DB93"));
    viewHolder.itemView.setBackgroundColor(Color.parseColor("#AAffffff"));
    ImageView imageView = (ImageView) viewHolder.itemView.findViewById(R.id.stick_img);
    SecureRandom imgGen = new SecureRandom();
    switch(imgGen.nextInt(3)) {
        case 0:
            imageView.setImageResource(R.drawable.jr1);
            break;
        case 1:
            imageView.setImageResource(R.drawable.jr2);
            break;
        case 2:
            imageView.setImageResource(R.drawable.jr3);
            break;
    }
}
Also used : SecureRandom(java.security.SecureRandom) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 25 with SecureRandom

use of java.security.SecureRandom in project android_frameworks_base by ParanoidAndroid.

the class SettingsProvider method ensureAndroidIdIsSet.

private boolean ensureAndroidIdIsSet(int userHandle) {
    final Cursor c = queryForUser(Settings.Secure.CONTENT_URI, new String[] { Settings.NameValueTable.VALUE }, Settings.NameValueTable.NAME + "=?", new String[] { Settings.Secure.ANDROID_ID }, null, userHandle);
    try {
        final String value = c.moveToNext() ? c.getString(0) : null;
        if (value == null) {
            final SecureRandom random = new SecureRandom();
            final String newAndroidIdValue = Long.toHexString(random.nextLong());
            final ContentValues values = new ContentValues();
            values.put(Settings.NameValueTable.NAME, Settings.Secure.ANDROID_ID);
            values.put(Settings.NameValueTable.VALUE, newAndroidIdValue);
            final Uri uri = insertForUser(Settings.Secure.CONTENT_URI, values, userHandle);
            if (uri == null) {
                Slog.e(TAG, "Unable to generate new ANDROID_ID for user " + userHandle);
                return false;
            }
            Slog.d(TAG, "Generated and saved new ANDROID_ID [" + newAndroidIdValue + "] for user " + userHandle);
            // Write a dropbox entry if it's a restricted profile
            if (mUserManager.getUserInfo(userHandle).isRestricted()) {
                DropBoxManager dbm = (DropBoxManager) getContext().getSystemService(Context.DROPBOX_SERVICE);
                if (dbm != null && dbm.isTagEnabled(DROPBOX_TAG_USERLOG)) {
                    dbm.addText(DROPBOX_TAG_USERLOG, System.currentTimeMillis() + ",restricted_profile_ssaid," + newAndroidIdValue + "\n");
                }
            }
        }
        return true;
    } finally {
        c.close();
    }
}
Also used : ContentValues(android.content.ContentValues) DropBoxManager(android.os.DropBoxManager) SecureRandom(java.security.SecureRandom) AbstractCursor(android.database.AbstractCursor) Cursor(android.database.Cursor) Uri(android.net.Uri)

Aggregations

SecureRandom (java.security.SecureRandom)639 SSLContext (javax.net.ssl.SSLContext)94 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)87 IOException (java.io.IOException)68 Test (org.junit.Test)62 SecretKey (javax.crypto.SecretKey)59 KeyGenerator (javax.crypto.KeyGenerator)53 X509Certificate (java.security.cert.X509Certificate)50 TrustManager (javax.net.ssl.TrustManager)50 Cipher (javax.crypto.Cipher)43 X509TrustManager (javax.net.ssl.X509TrustManager)40 KeyPairGenerator (java.security.KeyPairGenerator)38 BigInteger (java.math.BigInteger)35 InvalidKeyException (java.security.InvalidKeyException)34 CertificateException (java.security.cert.CertificateException)33 KeyPair (java.security.KeyPair)30 KeyStore (java.security.KeyStore)29 Random (java.util.Random)28 SecretKeySpec (javax.crypto.spec.SecretKeySpec)28 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)27