Example usage for android.graphics Color BLACK

List of usage examples for android.graphics Color BLACK

Introduction

In this page you can find the example usage for android.graphics Color BLACK.

Prototype

int BLACK

To view the source code for android.graphics Color BLACK.

Click Source Link

Usage

From source file:com.raspi.chatapp.ui.image.SingleImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // set the status bar color
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().setStatusBarColor(Color.BLACK);
    }/*from  w  w  w  . j a  v a 2 s  . c o  m*/
    setHasOptionsMenu(true);
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_single_image, container, false);
}

From source file:com.crystal.CrystalBeanWallpapers.Wallpaper.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final WallpaperLoader loader = new WallpaperLoader();
    switch (item.getItemId()) {
    case MENU_APPLY:
        if (mCustomizable) {
            final CharSequence[] items = getResources().getStringArray(R.array.customize_colors);
            int resId = mWallpapers.get(mCurrentFragment);
            Drawable d = mContext.getResources().getDrawable(resId);
            final Bitmap stockBitmap = ((BitmapDrawable) d).getBitmap();

            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setTitle(getString(R.string.pick_color));
            builder.setItems(items, new DialogInterface.OnClickListener() {
                @Override//from  w  w w.ja va 2s . c  om
                public void onClick(DialogInterface dialog, int item) {
                    int color = Color.BLACK;
                    boolean setColor = true;
                    switch (item) {
                    case 0:
                        color = Color.RED;
                        break;
                    case 1:
                        color = Color.GREEN;
                        break;
                    case 2:
                        color = Color.BLUE;
                        break;
                    case 3:
                        setColor = false;
                        break;
                    }

                    loader.setBitmap(setColor ? getColoredBitmap(stockBitmap, color) : stockBitmap);
                    loader.execute();
                }
            });
            AlertDialog alert = builder.create();
            alert.setCancelable(false);
            alert.show();
        } else {
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), mWallpapers.get(mCurrentFragment));
            loader.setBitmap(bitmap);
            loader.execute();
        }
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.infthink.demo.webrtc.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

    setContentView(R.layout.activity_fullscreen);

    // init flint related
    String APPLICATION_ID = "~flint_android_webrtc_demo";
    Flint.FlintApi.setApplicationId(APPLICATION_ID);

    mWebrtcChannel = new MyWebrtcChannel();

    mMediaRouter = MediaRouter.getInstance(getApplicationContext());
    mMediaRouteSelector = new MediaRouteSelector.Builder()
            .addControlCategory(FlintMediaControlIntent.categoryForFlint(APPLICATION_ID)).build();

    mMediaRouterCallback = new MediaRouterCallback();
    mFlingListener = new FlingListener();
    mConnectionCallbacks = new ConnectionCallbacks();

    mIceConnected = false;/*w  w  w.j a v  a2s .  com*/

    // init views
    mRootView = findViewById(android.R.id.content);
    mEncoderStatView = (TextView) findViewById(R.id.encoder_stat);
    mMenuBar = findViewById(R.id.menubar_fragment);
    mRoomName = (TextView) findViewById(R.id.room_name);
    mVideoView = (GLSurfaceView) findViewById(R.id.glview);

    mMediaRouteButton = (MediaRouteButton) mMenuBar.findViewById(R.id.media_route_button);
    mMediaRouteButton.setRouteSelector(mMediaRouteSelector);

    VideoRendererGui.setView(mVideoView);

    mScalingType = ScalingType.SCALE_ASPECT_FILL;
    mRemoteRender = VideoRendererGui.create(0, 0, 100, 100, mScalingType, false);
    mLocalRender = VideoRendererGui.create(0, 0, 100, 100, mScalingType, true);

    mVideoView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int visibility = mMenuBar.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE;
            mEncoderStatView.setVisibility(visibility);
            mMenuBar.setVisibility(visibility);
            mRoomName.setVisibility(visibility);
            if (visibility == View.VISIBLE) {
                mEncoderStatView.bringToFront();
                mMenuBar.bringToFront();
                mRoomName.bringToFront();
                mRootView.invalidate();
            }
        }
    });

    ((ImageButton) findViewById(R.id.button_disconnect)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            logAndToast("Disconnecting call.");
            disconnect();
        }
    });

    ((ImageButton) findViewById(R.id.button_switch_camera)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPeerConn != null) {
                mPeerConn.switchCamera();
            }
        }
    });

    ((ImageButton) findViewById(R.id.button_toggle_debug)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int visibility = mHudView.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE;
            mHudView.setVisibility(visibility);

            // use this to send view switch
            if (mApiClient != null && mApiClient.isConnected()) {
                mWebrtcChannel.sendSwitchView(mApiClient);
            }
        }
    });

    mVideoScalingButton = (ImageButton) findViewById(R.id.button_scaling_mode);
    mVideoScalingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mScalingType == ScalingType.SCALE_ASPECT_FILL) {
                mVideoScalingButton.setBackgroundResource(R.drawable.ic_action_full_screen);
                mScalingType = ScalingType.SCALE_ASPECT_FIT;
            } else {
                mVideoScalingButton.setBackgroundResource(R.drawable.ic_action_return_from_full_screen);
                mScalingType = ScalingType.SCALE_ASPECT_FILL;
            }
            updateVideoView();
        }
    });

    mHudView = new TextView(this);
    mHudView.setTextColor(Color.BLACK);
    mHudView.setBackgroundColor(Color.WHITE);
    mHudView.setAlpha(0.4f);
    mHudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
    mHudView.setVisibility(View.INVISIBLE);
    addContentView(mHudView, mHudLayout);

    // Create and audio manager that will take care of audio routing,
    // audio modes, audio device enumeration etc.
    mAudioManager = AppRTCAudioManager.create(this);

    // ready to init webrtc params
    mWebrtcHelper = new WebRtcHelper(this);
    mWebrtcHelper.initParams();
}

From source file:com.pdftron.pdf.controls.ReflowPagerAdapter.java

public void initialize() {
    // set loading file depending on night mode
    if (sIsNightMode) {
        mLoadingFile = NIGHT_MODE_LOADING_FILE;
    } else {/* w w  w  . java 2 s. c  o  m*/
        mLoadingFile = NORMAL_MODE_LOADING_FILE;
    }

    if (mWebViewRepository != null) {
        mWebViewRepository.reset();
    }

    ReflowWebView[] webViews = mWebViewRepository.getWebViews();
    for (final ReflowWebView webView : webViews) {
        webView.clearCache(true); // reset reading css file
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWillNotCacheDrawing(false);
        if (sIsNightMode) {
            webView.setBackgroundColor(Color.BLACK);
        } else {
            webView.setBackgroundColor(Color.WHITE);
        }
        webView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        webView.loadUrl("about:blank");
        webView.setListener(this);

        webView.setWebChromeClient(new WebChromeClient()); // enable the use of methods like alert in javascript
        webView.setWebViewClient(new WebViewClient() {
            // now all links the user clicks load in your WebView
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                super.onReceivedError(view, errorCode, description, failingUrl);
                Log.e(TAG, description + " url: " + failingUrl);
            }

            @Override
            public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
                super.onReceivedSslError(view, handler, error);
                Log.e(TAG, error.toString());
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (url.startsWith("file:///") && url.endsWith(".html")) {
                    int slashPos = url.lastIndexOf('/');
                    try {
                        int objNum = Integer.parseInt(url.substring(slashPos + 1, url.length() - 5));
                        int pageNum = 0;
                        for (int i = 1; i <= mPageCount; i++) {
                            try {
                                Page page = mDoc.getPage(i);
                                if (page.getSDFObj().getObjNum() == objNum) {
                                    pageNum = i;
                                    break;
                                }
                            } catch (Exception e) {
                            }
                        }
                        if (pageNum != 0) {
                            mViewPager.setCurrentItem(pageNum - 1);
                        }
                    } catch (NumberFormatException e) {
                        return true;
                    }
                } else {
                    if (url.startsWith("mailto:")
                            || android.util.Patterns.EMAIL_ADDRESS.matcher(url).matches()) {
                        if (url.startsWith("mailto:")) {
                            url = url.substring(7);
                        }
                        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", url, null));
                        mContext.startActivity(Intent.createChooser(intent,
                                mContext.getResources().getString(R.string.tools_misc_sendemail)));
                    } else {
                        // ACTION_VIEW needs the address to have http or https
                        if (!url.startsWith("https://") && !url.startsWith("http://")) {
                            url = "http://" + url;
                        }
                        if (DEBUG)
                            Log.d(TAG, url);
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        mContext.startActivity(Intent.createChooser(intent,
                                mContext.getResources().getString(R.string.tools_misc_openwith)));
                    }
                }
                return true;
            }
        });
    }
}

From source file:com.android.example.alwaysonstopwatch.StopwatchActivity.java

@Override
public void onEnterAmbient(Bundle ambientDetails) {
    Log.d(TAG, "ENTER Ambient");
    super.onEnterAmbient(ambientDetails);

    if (mRunning) {
        mActiveModeUpdateHandler.removeMessages(R.id.msg_update);
        mNotice.setVisibility(View.VISIBLE);
    }//from  w w w  .java 2s  .c  o  m

    mActiveClockUpdateHandler.removeMessages(R.id.msg_update);

    mTimeView.setTextColor(Color.WHITE);
    Paint textPaint = mTimeView.getPaint();
    textPaint.setAntiAlias(false);
    textPaint.setStyle(Paint.Style.STROKE);
    textPaint.setStrokeWidth(2);

    mStartStopButton.setVisibility(View.INVISIBLE);
    mResetButton.setVisibility(View.INVISIBLE);
    mBackground.setBackgroundColor(Color.BLACK);

    mClockView.setTextColor(Color.WHITE);
    mClockView.getPaint().setAntiAlias(false);

    updateDisplayAndSetRefresh();
}

From source file:br.com.anteros.android.synchronism.view.AbstractSynchronismFragment.java

@Override
public void onStartSendData(int countRequests) {
    lbStatus.setTextColor(Color.BLACK);
    lbActions.setText("Processando requisies");
    pbActions.setMax(countRequests);//www.  j av a  2  s. c o m
    pbActions.setProgress(0);
}

From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java

@SuppressLint("SdCardPath")
@Override/*from  w w  w  . ja v  a 2s. co m*/
public void bindView(View view, Context context, Cursor cursor) {
    System.out.println("MessageAdapter.java in bindView() ");
    final MessageListItemViews tagView = (MessageListItemViews) view.getTag();
    v = view;
    this.context = context;
    SipMessage msg = new SipMessage(cursor);
    // System.out.println("msg:"+msg);

    System.out.println("Cursor row count:" + cursor.getCount());

    String number = msg.getRemoteNumber();
    long date = msg.getDate();
    String message = msg.getBodyContent();
    subject = message;
    System.out.println("subject--" + subject);
    if (message.contains("[Offline message -") && !number.equals("sip:registrar@kamailio.org")) {
        System.out.println("offline message");
        String[] finalMessage = message.split("]");
        subject = finalMessage[finalMessage.length - 1];
    } else {
        subject = message;
    }

    String errorTxt = msg.getErrorContent();
    String mimeType = msg.getMimeType();
    int type = msg.getType();

    Log.setLogLevel(6);
    Log.d("Col count", cursor.getColumnCount() + " @");

    String[] columnname = cursor.getColumnNames();
    for (int i = 0; i < columnname.length; i++) {
        Log.d("columnname " + i, columnname[i] + " @");
        Log.d(columnname[i], cursor.getString(cursor.getColumnIndex(columnname[i])) + " @");

    }

    tv_msg_info = (TextView) view.findViewById(R.id.tv_msg_info);
    pb_uploading = (ProgressBar) view.findViewById(R.id.pb_uploading);

    String timestamp = "";
    if (System.currentTimeMillis() - date > 1000 * 60 * 60 * 24) {
        // If it was recieved one day ago or more display relative
        // timestamp - SMS like behavior
        int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
        timestamp = (String) DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(),
                DateUtils.MINUTE_IN_MILLIS, flags);
    } else {
        // If it has been recieved recently show time of reception - IM
        // like behavior
        timestamp = dateFormatter.format(new Date(date));
    }

    tagView.dateView.setText(timestamp);

    // Delivery state
    if (type == SipMessage.MESSAGE_TYPE_QUEUED) {
        tagView.deliveredIndicator.setVisibility(View.VISIBLE);
        tagView.deliveredIndicator.setImageResource(R.drawable.error_watch_not_send);
        tagView.deliveredIndicator.setContentDescription("");
    } else if (type == SipMessage.MESSAGE_TYPE_FAILED) {
        tagView.deliveredIndicator.setVisibility(View.VISIBLE);
        tagView.deliveredIndicator.setImageResource(R.drawable.error_watch_not_send);
        tagView.deliveredIndicator.setContentDescription("");
    } else {
        tagView.deliveredIndicator.setVisibility(View.VISIBLE);
        tagView.deliveredIndicator.setImageResource(R.drawable.todo_send);
        tagView.deliveredIndicator.setContentDescription("");
    }

    if (TextUtils.isEmpty(errorTxt)) {
        tagView.errorView.setVisibility(View.GONE);
    } else {
        tagView.errorView.setVisibility(View.GONE);
        tagView.errorView.setText(errorTxt);
    }

    // Subject
    tagView.contentView.setText(formatMessage(number, subject, mimeType));
    if (msg.isOutgoing()) {
        setPhotoSide(tagView, ArrowPosition.LEFT);
        LinearLayout linerLayout = (LinearLayout) view.findViewById(R.id.message_block);
        linerLayout.setBackgroundResource(R.drawable.chatedittextdesign);
        text_view = (TextView) view.findViewById(R.id.text_view);
        text_view.setTextColor(Color.BLACK);

        // Photo
        tagView.quickContactView.assignContactUri(personalInfo.contactContentUri);
        /*
        ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, 
            tagView.quickContactView.getImageView(),
            personalInfo,
            R.drawable.ic_contact_picture_holo_dark);
         */

        System.out.println("msg adp out - 0");
        String path = "/sdcard/R4W/ProfilePic/ProfilePic.png";
        File user_imageFile = new File(path);
        if (user_imageFile.exists()) {
            try {
                if (bm != null) {
                    //      bm = null;
                }
                bm = BitmapFactory.decodeFile(path);
                bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth());
                tagView.quickContactView.getImageView().setImageBitmap(bm);
            } catch (Exception e) {
                // TODO: handle exception
                try {
                    tagView.quickContactView.getImageView().setImageURI(Uri.parse(path));

                } catch (Exception e2) {
                    ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext,
                            tagView.quickContactView.getImageView(), personalInfo,
                            R.drawable.ic_contact_picture_holo_dark);
                    // TODO: handle exception
                }
            }
        } else {
            ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext,
                    tagView.quickContactView.getImageView(), personalInfo,
                    R.drawable.ic_contact_picture_holo_dark);

        }

        outgoingImage(number);

    } else {

        setPhotoSide(tagView, ArrowPosition.RIGHT);
        LinearLayout linerLayout = (LinearLayout) view.findViewById(R.id.message_block);
        linerLayout.setBackgroundResource(R.drawable.messagebodyleft);

        // Contact
        CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, msg.getFullFrom());

        text_view = (TextView) view.findViewById(R.id.text_view);
        text_view.setTextColor(Color.BLACK);
        pb_uploading.setVisibility(ProgressBar.GONE);

        // Photo
        tagView.quickContactView.assignContactUri(info.contactContentUri);
        /*
        ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, 
            tagView.quickContactView.getImageView(),
            info,
            R.drawable.ic_contact_picture_holo_dark);
           */
        System.out.println("msg adp in - 1");
        String nu = stripNumber(number);
        String path = "/sdcard/R4W/ProfilePic/" + nu + ".png";
        System.out.println("msg adp out - path=" + path);
        File user_imageFile = new File(path);
        if (user_imageFile.exists()) {
            try {
                if (bm != null) {
                    //      bm = null;
                }
                bm = BitmapFactory.decodeFile(path);
                bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth());
                tagView.quickContactView.getImageView().setImageBitmap(bm);
            } catch (Exception e) {
                // TODO: handle exception
                try {
                    tagView.quickContactView.getImageView().setImageURI(Uri.parse(path));

                } catch (Exception e2) {
                    ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext,
                            tagView.quickContactView.getImageView(), info,
                            R.drawable.ic_contact_picture_holo_dark); // TODO: handle exception
                }
            }
        } else {
            ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext,
                    tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark);
        }
        incomingImage();
    }

}

From source file:com.ota.updates.activities.MainActivity.java

/**
 * Creates an DrawableAwesome based on the string input given
 * Will also be coloured as per the drawerIconColors attribute
 * @param icon  the R.string that is requested
 * @return DrawableAwesome//w  ww  . j a  v a  2 s. c  o  m
 */
private DrawableAwesome getNavigationViewIcon(int icon) {
    int[] attrs = { R.attr.drawerIconColors };
    TypedArray typedArray = this.obtainStyledAttributes(attrs);
    DrawableAwesome drawableAwesome = new DrawableAwesome(icon, 28, typedArray.getColor(0, Color.BLACK), true,
            false, 0, 0, 0, 0, mContext);
    typedArray.recycle();
    return drawableAwesome;
}

From source file:com.jwetherell.quick_response_code.EncoderActivity.java

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    com.ranorex.android.RanorexAndroidAutomation.Hook(this);
    // Get text views
    textoSsid = (TextView) findViewById(R.id.ssid);
    textoPassword = (TextView) findViewById(R.id.password);
    descripcion = (TextView) findViewById(R.id.descripcion);
    icon = (ImageView) findViewById(R.id.icon);
    //textoCifrado = (TextView) findViewById(R.id.cifrado);

    settings = getSharedPreferences(MainActivity.PREFS, 0);

    // if(settings.contains("connected_wifi_5ghz") && settings.getBoolean("connected_wifi_5ghz", false))
    //      descripcion.setText("");

    final ProgressDialog dialog = new ProgressDialog(EncoderActivity.this);

    dialog.setMessage("Generando Qr...");
    dialog.show();/*from ww  w  .  j a va 2  s. com*/
    dialog.setCancelable(false);

    try {

        if (settings.contains("ssid") && settings.contains("password1")) {
            // Get ssid, psk and encrypted of settings.

            if (!getIntent().getBooleanExtra("is_5ghz", false)) // Network 2.4 GHz.
            {
                cifradoSettings = settings.getString("cifrado", "WPA");
                ssidSettings = settings.getString("ssid", "");
                pskSettings = settings.getString("password1", "");
                if (settings.contains("connected_wifi_5ghz")
                        && !settings.getBoolean("connected_wifi_5ghz", false)
                        || !settings.contains("connected_wifi_5ghz")) {
                    descripcion.setVisibility(View.VISIBLE);
                }
            } else // Network 5 GHz.
            {
                cifradoSettings = settings.getString("cifrado5ghz", "WPA");
                ssidSettings = settings.getString("ssid5ghz", "");
                pskSettings = settings.getString("password5ghz", "");
                icon.setImageResource(R.drawable.wifiplus120);
                ((TextView) findViewById(R.id.textView1)).setText("WifiPlus");
                if (settings.contains("connected_wifi_5ghz")
                        && settings.getBoolean("connected_wifi_5ghz", false)) {
                    descripcion.setVisibility(View.VISIBLE);
                }
            }

            ssidFull = ssidSettings;
            pskFull = pskSettings;

            if (cifradoSettings.contains("WPA")) {
                cifradoQR = "WPA";
                string = "WIFI:T:" + cifradoQR + ";S:" + ssidSettings + ";P:" + pskSettings + ";;";
            } else if (cifradoSettings.contains("abierta")) {
                cifradoQR = "nopass";
                string = "WIFI:T:" + cifradoQR + ";S:" + ssidSettings + ";;";
            } else if (cifradoSettings.contains("WEP")) {
                cifradoQR = "WEP";
                string = "WIFI:T:" + cifradoQR + ";S:" + ssidSettings + ";P:" + pskSettings + ";;";
            }

            // Update texts
            textoSsid.setText(ssidSettings);

            try {
                if (pskSettings.length() > 39)
                    pskSettings = ellipsis(pskSettings, 39);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            if (pskSettings.equalsIgnoreCase("sin password") || pskSettings.equalsIgnoreCase(""))
                pskSettings = "Sin password";

            textoPassword.setText(pskSettings);

        }

    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Could not encode barcode", e);
    }

    new AsyncTask<String, Integer, Bitmap>() {

        @Override
        protected Bitmap doInBackground(String... params) {
            QRCodeEncoder qrCodeEncoder = null;
            // This assumes the view is full screen, which is a good assumption
            WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
            Display display = manager.getDefaultDisplay();
            int width = display.getWidth();
            int height = display.getHeight();
            int smallerDimension = width < height ? width : height;
            smallerDimension = smallerDimension * 7 / 8;

            try {
                qrCodeEncoder = new QRCodeEncoder(string, null, Contents.Type.TEXT,
                        BarcodeFormat.QR_CODE.toString(), smallerDimension);
                Hashtable hints = new Hashtable();
                hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
                QRCodeWriter qrcw = new QRCodeWriter();
                BitMatrix matrix = qrcw.encode(string, BarcodeFormat.QR_CODE, width, height, hints);
                bm = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
                for (int y = 0; y < matrix.getHeight(); y++) {
                    for (int x = 0; x < matrix.getWidth(); x++) {
                        if (!matrix.get(x, y))
                            bm.setPixel(x, y, Color.WHITE);
                        else
                            bm.setPixel(x, y, Color.BLACK);
                    }
                }
            } catch (WriterException we) {
                we.printStackTrace();
                Log.e(TAG, "Could not encode barcode", we);
            }

            return bm;
        }

        protected void onPostExecute(Bitmap bitmap) {
            if (bitmap != null) {
                viewCode = (ImageView) findViewById(R.id.image_view);
                viewCode.setImageBitmap(bitmap);//bitmap);
                dialog.dismiss();
            } else {
                Toast.makeText(EncoderActivity.this, "Problema al generar Qr", Toast.LENGTH_LONG).show();
            }
        }
    }.execute();

    if (bm != null) {
        dialog.dismiss();
    }

}

From source file:com.heneryh.aquanotes.ui.controllers.GraphsFragment.java

/**
 * Handle {@link VendorsQuery} {@link Cursor}.
 *//*from  w w  w  .j a  v  a2  s . c o  m*/
private void onProbeDataQueryComplete(Cursor cursor) {
    if (mCursor != null) {
        // In case cancelOperation() doesn't work and we end up with consecutive calls to this
        // callback.
        getActivity().stopManagingCursor(mCursor);
        mCursor = null;
    }
    mySimpleXYPlot = (XYPlot) mRootView.findViewById(R.id.mySimpleXYPlot);
    mySimpleXYPlot.setOnTouchListener(this);
    mySimpleXYPlot.clear();

    //Creation of the series
    final Vector<Double> vector = new Vector<Double>();
    int numDataPoints = 0;
    String probeName = null;
    Long timestamp = (long) 0;
    String valueS = null;
    try {
        /** For each datapoint in the database, */
        while (cursor.moveToNext()) {
            probeName = cursor.getString(ProbeDataViewQuery.NAME);
            timestamp = cursor.getLong(ProbeDataViewQuery.TIMESTAMP);
            valueS = cursor.getString(ProbeDataViewQuery.VALUE);
            Double valueD = Double.valueOf(valueS);
            vector.add(timestamp.doubleValue());
            vector.add(valueD);
            numDataPoints++;
        } // end of while()
    } finally {
        cursor.close();
        if (numDataPoints < 2)
            return;
    }
    // create our series from our array of nums:
    mySeries = new SimpleXYSeries(vector, ArrayFormat.XY_VALS_INTERLEAVED, probeName);

    mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint()
            .setPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1));
    mySimpleXYPlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    mySimpleXYPlot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
    mySimpleXYPlot.getBorderPaint().setStrokeWidth(1);
    mySimpleXYPlot.getBorderPaint().setAntiAlias(false);
    mySimpleXYPlot.getBorderPaint().setColor(Color.WHITE);

    // Create a formatter to use for drawing a series using LineAndPointRenderer:
    LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.rgb(0, 100, 0), // line color
            Color.rgb(0, 100, 0), // point color
            Color.rgb(100, 200, 0)); // fill color

    // setup our line fill paint to be a slightly transparent gradient:
    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    //lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.GREEN, Shader.TileMode.MIRROR));

    LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb(0, 0, 0), Color.BLUE, Color.RED);
    //       formatter.setFillPaint(lineFill);
    formatter.setFillPaint(null);
    //       formatter.setVertexPaint(null);
    formatter.getLinePaint().setShadowLayer(0, 0, 0, 0);
    mySimpleXYPlot.getGraphWidget().setPaddingRight(2);
    mySimpleXYPlot.addSeries(mySeries, formatter);

    // draw a domain tick for each year:
    //mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE, numDataPoints);

    // customize our domain/range labels
    mySimpleXYPlot.setDomainLabel("Time");
    mySimpleXYPlot.setRangeLabel(probeName);

    // get rid of decimal points in our range labels:
    mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("#0.00"));

    mySimpleXYPlot.setDomainValueFormat(new MyDateFormat());

    // by default, AndroidPlot displays developer guides to aid in laying out your plot.
    // To get rid of them call disableAllMarkup():
    mySimpleXYPlot.disableAllMarkup();

    //Set of internal variables for keeping track of the boundaries
    mySimpleXYPlot.calculateMinMaxVals();
    minXY = new PointF(mySimpleXYPlot.getCalculatedMinX().floatValue(),
            mySimpleXYPlot.getCalculatedMinY().floatValue()); //initial minimum data point
    absMinX = minXY.x; //absolute minimum data point
    //absolute minimum value for the domain boundary maximum
    minNoError = Math.round(mySeries.getX(1).floatValue() + 2);
    maxXY = new PointF(mySimpleXYPlot.getCalculatedMaxX().floatValue(),
            mySimpleXYPlot.getCalculatedMaxY().floatValue()); //initial maximum data point
    absMaxX = maxXY.x; //absolute maximum data point
    //absolute maximum value for the domain boundary minimum
    maxNoError = (float) Math.round(mySeries.getX(mySeries.size() - 1).floatValue()) - 2;

    //Check x data to find the minimum difference between two neighboring domain values
    //Will use to prevent zooming further in than this distance
    double temp1 = mySeries.getX(0).doubleValue();
    double temp2 = mySeries.getX(1).doubleValue();
    double temp3;
    double thisDif;
    minDif = 100000000; //increase if necessary for domain values
    for (int i = 2; i < mySeries.size(); i++) {
        temp3 = mySeries.getX(i).doubleValue();
        thisDif = Math.abs(temp1 - temp3);
        if (thisDif < minDif)
            minDif = thisDif;
        temp1 = temp2;
        temp2 = temp3;
    }
    minDif = minDif + difPadding; //with padding, the minimum difference

    mySimpleXYPlot.redraw();

}