Example usage for android.graphics Color DKGRAY

List of usage examples for android.graphics Color DKGRAY

Introduction

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

Prototype

int DKGRAY

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

Click Source Link

Usage

From source file:com.example.michaelg.myapplication.Item.discreteseekbar.DiscreteSeekBar.java

public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setFocusable(true);/* www  .j av  a  2 s  .c  om*/
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar, defStyleAttr,
            R.style.Widget_DiscreteSeekBar);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_allowTrackClickToDrag, mAllowTrackClick);
    mIndicatorPopupEnabled = a.getBoolean(R.styleable.DiscreteSeekBar_dsb_indicatorPopupEnabled,
            mIndicatorPopupEnabled);
    mTrackHeight = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_trackHeight, (int) (1 * density));
    mScrubberHeight = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_scrubberHeight,
            (int) (4 * density));
    int thumbSize = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_thumbSize,
            (int) (density * ThumbDrawable.DEFAULT_SIZE_DP));
    int separation = a.getDimensionPixelSize(R.styleable.DiscreteSeekBar_dsb_indicatorSeparation,
            (int) (SEPARATION_DP * density));

    //Extra pixels for a minimum touch area of 32dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = Math.max(0, (touchBounds - thumbSize) / 2);

    int indexMax = R.styleable.DiscreteSeekBar_dsb_max;
    int indexMin = R.styleable.DiscreteSeekBar_dsb_min;
    int indexValue = R.styleable.DiscreteSeekBar_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSeekBar_dsb_indicatorFormatter);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_rippleColor);
    boolean editMode = isInEditMode();
    if (editMode || rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode || trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode || progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { DEFAULT_THUMB_COLOR });
    }

    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    mThumb = new ThumbDrawable(progressColor, thumbSize);
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax), thumbSize,
                thumbSize + mAddedTouchBounds + separation);
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

}

From source file:sjizl.com.FileUploadTest.java

@SuppressLint("NewApi")
@Override/* w  w  w  . ja v a2 s .com*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.fileuploadtest2);
    //ac_image_grid
    TextView textView2_under_title;
    final ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(getApplicationContext()));
    progressBar_hole = (ProgressBar) findViewById(R.id.progressBar_hole);
    progressBar_hole.setVisibility(View.INVISIBLE);
    right_lin = (LinearLayout) findViewById(R.id.right_lin);
    rand = CommonUtilities.randInt(111, 999);
    middle_lin = (LinearLayout) findViewById(R.id.middle_lin);
    //right_lin.setBackgroundColor(Color.BLUE);
    right_lin = (LinearLayout) findViewById(R.id.right_lin);
    left_lin1 = (LinearLayout) findViewById(R.id.left_lin1);

    left_lin3 = (LinearLayout) findViewById(R.id.left_lin3);
    left_lin4 = (LinearLayout) findViewById(R.id.left_lin4);
    middle_lin = (LinearLayout) findViewById(R.id.middle_lin);

    upload_photo_text = (LinearLayout) findViewById(R.id.upload_photo_text);

    textView2_under_title = (TextView) findViewById(R.id.textView2_under_title);
    ((LinearLayout) textView2_under_title.getParent()).removeView(textView2_under_title);
    textView2_under_title.setVisibility(View.GONE);
    ImageView imageView2_dashboard = (ImageView) findViewById(R.id.imageView2_dashboard);
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    Button upload_photo0 = (Button) findViewById(R.id.upload_photo0);
    Button upload_photo1 = (Button) findViewById(R.id.upload_photo1);
    Button upload_photo2 = (Button) findViewById(R.id.upload_photo2);

    upload_photo0.setVisibility(View.GONE);
    upload_photo1.setVisibility(View.GONE);
    upload_photo2.setVisibility(View.GONE);

    upload_photo0.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            CommonUtilities.custom_toast(getApplicationContext(), FileUploadTest.this, "UploadActivity! ", null,
                    R.drawable.iconbd);

            Intent dashboard = new Intent(getApplicationContext(), UploadActivity.class);

            startActivity(dashboard);
        }
    });
    upload_photo1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Toast.makeText(getApplicationContext(), "FileChooserExampleActivity!", Toast.LENGTH_LONG).show();
            Intent dashboard = new Intent(getApplicationContext(), FileChooserExampleActivity.class);

            startActivity(dashboard);
        }
    });

    upload_photo2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "FileChooserExampleActivity!", Toast.LENGTH_LONG).show();
            Intent dashboard = new Intent(getApplicationContext(), FileChooserExampleActivity.class);

            startActivity(dashboard);
        }
    });

    final ImageView left_button;

    left_button = (ImageView) findViewById(R.id.imageView1_back);
    Button button1 = (Button) findViewById(R.id.upload_photo1);

    SharedPreferences sp = getApplicationContext().getSharedPreferences("loginSaved", Context.MODE_PRIVATE);
    naam = sp.getString("naam", null);
    username = sp.getString("username", null);
    password = sp.getString("password", null);
    foto = sp.getString("foto", null);
    foto_num = sp.getString("foto_num", null);
    imageLoader.displayImage("http://sjizl.com/fotos/" + foto_num + "/thumbs/" + foto, imageView2_dashboard,
            options);

    Brows();

    listView.setLongClickable(true);
    registerForContextMenu(listView);

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //startImagePagerActivity(position);

            if (position == 0) {
                openGallery(SELECT_FILE1);
            } else {

                listView.showContextMenuForChild(view);
                //  registerForContextMenu(view); 
                //  openContextMenu(view);
                //  unregisterForContextMenu(view);
            }

        }
    });

    left_lin1.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE
                    || event.getAction() == MotionEvent.ACTION_POINTER_DOWN) {
                left_lin1.setBackgroundColor(Color.DKGRAY);
                v.setBackgroundColor(Color.DKGRAY);
                onBackPressed();
            } else if (event.getAction() == MotionEvent.ACTION_UP
                    || event.getAction() == MotionEvent.ACTION_CANCEL) {
                left_lin1.setBackgroundColor(Color.BLACK);
                v.setBackgroundColor(Color.BLACK);
            }
            return false;
        }
    });
    CommonUtilities u = new CommonUtilities();
    u.setHeaderConrols(getApplicationContext(), this,

            right_lin,

            left_lin3, left_lin4, left_lin1, left_button);
    ;

    middle_lin.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE
                    || event.getAction() == MotionEvent.ACTION_POINTER_DOWN) {
                middle_lin.setBackgroundColor(Color.DKGRAY);
                v.setBackgroundColor(Color.DKGRAY);
            } else if (event.getAction() == MotionEvent.ACTION_UP
                    || event.getAction() == MotionEvent.ACTION_CANCEL) {
                middle_lin.setBackgroundColor(Color.BLACK);
                v.setBackgroundColor(Color.BLACK);
            }
            return false;
        }
    });

}

From source file:com.bfemmer.portdawgtoolkit.DashboardFragment.java

private RadarData getRadarData() {
    ArrayList<String> labels = new ArrayList<>();
    labels.add("F2F");
    labels.add("EPR");
    labels.add("IMR");
    labels.add("TFAT");
    labels.add("UGR");
    labels.add("UOO");
    labels.add("VEH");
    labels.add("483");

    ArrayList<Entry> entries = new ArrayList<>();
    entries.add(new Entry(80, 0));
    entries.add(new Entry(100, 1));
    entries.add(new Entry(100, 2));
    entries.add(new Entry(100, 3));
    entries.add(new Entry(100, 4));
    entries.add(new Entry(100, 5));
    entries.add(new Entry(20, 6));
    entries.add(new Entry(60, 7));

    ArrayList<Entry> entries2 = new ArrayList<>();
    entries2.add(new Entry(60, 0));
    entries2.add(new Entry(100, 1));
    entries2.add(new Entry(80, 2));
    entries2.add(new Entry(100, 3));
    entries2.add(new Entry(100, 4));
    entries2.add(new Entry(60, 5));
    entries2.add(new Entry(100, 6));
    entries2.add(new Entry(0, 7));

    ArrayList<Entry> entries3 = new ArrayList<>();
    entries3.add(new Entry(100, 0));
    entries3.add(new Entry(80, 1));
    entries3.add(new Entry(80, 2));
    entries3.add(new Entry(80, 3));
    entries3.add(new Entry(80, 4));
    entries3.add(new Entry(60, 5));
    entries3.add(new Entry(100, 6));
    entries3.add(new Entry(50, 7));

    ArrayList<Entry> entries4 = new ArrayList<>();
    entries4.add(new Entry(70, 0));
    entries4.add(new Entry(85, 1));
    entries4.add(new Entry(85, 2));
    entries4.add(new Entry(85, 3));
    entries4.add(new Entry(100, 4));
    entries4.add(new Entry(100, 5));
    entries4.add(new Entry(75, 6));
    entries4.add(new Entry(75, 7));

    ArrayList<Entry> entries5 = new ArrayList<>();
    entries5.add(new Entry(65, 0));
    entries5.add(new Entry(65, 1));
    entries5.add(new Entry(65, 2));
    entries5.add(new Entry(65, 3));
    entries5.add(new Entry(65, 4));
    entries5.add(new Entry(65, 5));
    entries5.add(new Entry(65, 6));
    entries5.add(new Entry(65, 7));

    ArrayList<Entry> entries6 = new ArrayList<>();
    entries6.add(new Entry(25, 0));
    entries6.add(new Entry(55, 1));
    entries6.add(new Entry(25, 2));
    entries6.add(new Entry(55, 3));
    entries6.add(new Entry(25, 4));
    entries6.add(new Entry(55, 5));
    entries6.add(new Entry(25, 6));
    entries6.add(new Entry(55, 7));

    ArrayList<Entry> entries7 = new ArrayList<>();
    entries7.add(new Entry(30, 0));
    entries7.add(new Entry(30, 1));
    entries7.add(new Entry(30, 2));
    entries7.add(new Entry(30, 3));
    entries7.add(new Entry(30, 4));
    entries7.add(new Entry(30, 5));
    entries7.add(new Entry(30, 6));
    entries7.add(new Entry(30, 7));

    //        ArrayList<Entry> entries = new ArrayList<>();
    //        entries.add(new Entry(0.8f, 0));
    //        entries.add(new Entry(1f, 1));
    //        entries.add(new Entry(1f, 2));
    //        entries.add(new Entry(1f, 3));
    //        entries.add(new Entry(1f, 4));
    //        entries.add(new Entry(1f, 5));
    //        entries.add(new Entry(0.2f, 6));
    //        entries.add(new Entry(0.6f, 7));
    ///*  w w  w. j  a v a2  s  .com*/
    //        ArrayList<Entry> entries2 = new ArrayList<>();
    //        entries2.add(new Entry(0.6f, 0));
    //        entries2.add(new Entry(1f, 1));
    //        entries2.add(new Entry(0.8f, 2));
    //        entries2.add(new Entry(1f, 3));
    //        entries2.add(new Entry(1f, 4));
    //        entries2.add(new Entry(0.6f, 5));
    //        entries2.add(new Entry(1f, 6));
    //        entries2.add(new Entry(0f, 7));
    //
    //        ArrayList<Entry> entries3 = new ArrayList<>();
    //        entries3.add(new Entry(1f, 0));
    //        entries3.add(new Entry(0.8f, 1));
    //        entries3.add(new Entry(0.8f, 2));
    //        entries3.add(new Entry(0.8f, 3));
    //        entries3.add(new Entry(0.8f, 4));
    //        entries3.add(new Entry(0.6f, 5));
    //        entries3.add(new Entry(1f, 6));
    //        entries3.add(new Entry(0.5f, 7));

    RadarDataSet radardataset = new RadarDataSet(entries, "Fleet");
    RadarDataSet cargoradardataset = new RadarDataSet(entries2, "Cargo");
    RadarDataSet rampradardataset = new RadarDataSet(entries3, "Ramp");
    RadarDataSet paxradardataset = new RadarDataSet(entries4, "Pax");
    RadarDataSet atocradardataset = new RadarDataSet(entries5, "ATOC");
    RadarDataSet lpradardataset = new RadarDataSet(entries6, "L/P");
    RadarDataSet shradardataset = new RadarDataSet(entries7, "S/H");

    radardataset.setColor(Color.BLUE);
    cargoradardataset.setColor(Color.RED);
    rampradardataset.setColor(Color.GREEN);
    paxradardataset.setColor(Color.YELLOW);
    atocradardataset.setColor(Color.CYAN);
    lpradardataset.setColor(Color.MAGENTA);
    shradardataset.setColor(Color.DKGRAY);

    radardataset.setDrawFilled(false);
    cargoradardataset.setDrawFilled(false);
    rampradardataset.setDrawFilled(false);
    paxradardataset.setDrawFilled(false);
    atocradardataset.setDrawFilled(false);
    lpradardataset.setDrawFilled(false);
    shradardataset.setDrawFilled(false);

    List<RadarDataSet> radarDataSets = new ArrayList<>();
    radarDataSets.add(radardataset);
    radarDataSets.add(cargoradardataset);
    radarDataSets.add(rampradardataset);
    radarDataSets.add(paxradardataset);
    radarDataSets.add(atocradardataset);
    radarDataSets.add(lpradardataset);
    radarDataSets.add(shradardataset);

    RadarData data = new RadarData(labels, radarDataSets);

    return data;
}

From source file:com.digi.android.wva.fragments.ChartFragment.java

/**
 * Create the components that go into the chart.
 *
 * <p>This method is protected, rather than private, due to a bug between JaCoCo and
 * the Android build tools which causes the instrumented bytecode to be invalid when this
 * method is private://from   w w  w  .  ja  v a  2s .c o  m
 * http://stackoverflow.com/questions/17603192/dalvik-transformation-using-wrong-invoke-opcode
 * </p>
 */
protected void buildGraphPieces() {
    if (mRenderer != null || mDataset != null || mRpmRenderer != null || mSpeedRenderer != null) {
        // Don't want to leak any memory or whatnot.
        return;
    }
    mRenderer = new XYMultipleSeriesRenderer(2);
    mDataset = new XYMultipleSeriesDataset();
    mSpeedRenderer = new XYSeriesRenderer();
    mRpmRenderer = new XYSeriesRenderer();

    // Initialize renderer settings
    mRenderer.setShowGrid(true);
    mRenderer.setFitLegend(true);
    // Number of grid lines in either direction by default
    mRenderer.setXLabels(0);
    mRenderer.setYLabels(10);
    mRenderer.setXLabelsAlign(Align.RIGHT);
    mRenderer.setYLabelsAlign(Align.RIGHT);
    mRenderer.setPointSize(5f);
    // AChartEngine output defaults to a black background.
    // This doesn't fit with the general WVA color scheme.
    mRenderer.setApplyBackgroundColor(true);
    mRenderer.setBackgroundColor(Color.WHITE);
    mRenderer.setMarginsColor(Color.WHITE);
    mRenderer.setAxesColor(Color.DKGRAY);
    mRenderer.setLabelsColor(Color.BLACK);
    mRenderer.setXLabelsColor(Color.DKGRAY);
    mRenderer.setYLabelsColor(0, Color.DKGRAY);
    mRenderer.setYLabelsColor(1, Color.DKGRAY);
    mRenderer.setGridColor(Color.LTGRAY);
    mRenderer.setPanEnabled(false, false);
    mRenderer.setZoomEnabled(false, false);
    mRenderer.setXAxisMin(startTime);
    mRenderer.setXAxisMax(endTime);
    mRenderer.setXAxisMin(startTime, 1);
    mRenderer.setXAxisMax(endTime, 1);
    mRenderer.setYAxisMin(0, 0);
    mRenderer.setYAxisMax(100, 0);

    mSpeedRenderer.setColor(Color.RED);
    mSpeedRenderer.setPointStyle(PointStyle.CIRCLE);
    mSpeedRenderer.setFillPoints(true);

    mRpmRenderer.setColor(Color.BLUE);
    mRpmRenderer.setPointStyle(PointStyle.SQUARE);
    mRpmRenderer.setFillPoints(true);

    XYSeries speedSeries = new XYSeries("Vehicle Speed");
    XYSeries rpmSeries = new XYSeries("Engine RPM", 1);

    mDataset.addSeries(0, speedSeries);
    mDataset.addSeries(1, rpmSeries);
    mRenderer.addSeriesRenderer(0, mSpeedRenderer);
    mRenderer.addSeriesRenderer(1, mRpmRenderer);

    mRenderer.setYAxisMin(0, 1);
    mRenderer.setYAxisMax(10000, 1);

    mRenderer.setYTitle("VehicleSpeed");
    mRenderer.setYTitle("EngineSpeed", 1);
    mRenderer.setYAxisAlign(Align.RIGHT, 1);
    mRenderer.setYLabelsAlign(Align.RIGHT, 1);

    // Add X-axis labels with time.
    Log.d(TAG, "Time range: " + startTime + " to " + endTime);
    SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss", Locale.US);
    for (double t = startTime; t <= endTime; t += 60 * 1000) {
        String time = fmt.format(new Date((long) t));
        Log.d(TAG, "Adding label " + t + ", " + time);
        mRenderer.addXTextLabel(t, time);
    }
}

From source file:com.bigpigs.fragments.SearchFragment.java

public void drawLine(int index, LatLng start, LatLng end, String distance, String des) {

    Polyline polyline = map.addPolyline(new PolylineOptions()
            .add(new LatLng(start.latitude, start.longitude), new LatLng(end.latitude, end.longitude)).width(4)
            .color(Color.DKGRAY));
    polylines.add(polyline);//w  w w .ja  va 2  s .  c o  m
}

From source file:com.hmatalonga.greenhub.ui.TaskListActivity.java

/**
 * This is the standard support library way of implementing "swipe to delete" feature. You can do custom drawing in onChildDraw method
 * but whatever you draw will disappear once the swipe is over, and while the items are animating to their new position the recycler view
 * background will be visible. That is rarely an desired effect.
 *//*  w  w  w  . j a v  a2s  .c  o m*/
private void setUpItemTouchHelper() {
    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0,
            ItemTouchHelper.LEFT) {

        // we want to cache these and not allocate anything repeatedly in the onChildDraw method
        Drawable background;
        Drawable xMark;
        int xMarkMargin;
        boolean initiated;

        private void init() {
            background = new ColorDrawable(Color.DKGRAY);
            xMark = ContextCompat.getDrawable(TaskListActivity.this, R.drawable.ic_delete_white_24dp);
            xMark.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
            xMarkMargin = (int) TaskListActivity.this.getResources().getDimension(R.dimen.fab_margin);
            initiated = true;
        }

        // not important, we don't want drag & drop
        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            int position = viewHolder.getAdapterPosition();
            TaskAdapter testAdapter = (TaskAdapter) recyclerView.getAdapter();
            if (testAdapter.isUndoOn() && testAdapter.isPendingRemoval(position)) {
                return 0;
            }
            return super.getSwipeDirs(recyclerView, viewHolder);
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
            int swipedPosition = viewHolder.getAdapterPosition();
            TaskAdapter adapter = (TaskAdapter) mRecyclerView.getAdapter();
            boolean undoOn = adapter.isUndoOn();
            if (undoOn) {
                adapter.pendingRemoval(swipedPosition);
            } else {
                adapter.remove(swipedPosition);
            }
        }

        @Override
        public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                float dX, float dY, int actionState, boolean isCurrentlyActive) {

            View itemView = viewHolder.itemView;

            // not sure why, but this method get's called for viewholder that are already swiped away
            if (viewHolder.getAdapterPosition() == -1) {
                // not interested in those
                return;
            }

            if (!initiated) {
                init();
            }

            // draw background
            background.setBounds(itemView.getRight() + (int) dX, itemView.getTop(), itemView.getRight(),
                    itemView.getBottom());
            background.draw(canvas);

            // draw x mark
            int itemHeight = itemView.getBottom() - itemView.getTop();
            int intrinsicWidth = xMark.getIntrinsicWidth();
            int intrinsicHeight = xMark.getIntrinsicWidth();

            int xMarkLeft = itemView.getRight() - xMarkMargin - intrinsicWidth;
            int xMarkRight = itemView.getRight() - xMarkMargin;
            int xMarkTop = itemView.getTop() + (itemHeight - intrinsicHeight) / 2;
            int xMarkBottom = xMarkTop + intrinsicHeight;
            xMark.setBounds(xMarkLeft, xMarkTop, xMarkRight, xMarkBottom);

            xMark.draw(canvas);

            super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }

    };
    ItemTouchHelper mItemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    mItemTouchHelper.attachToRecyclerView(mRecyclerView);
}

From source file:com.metinkale.prayerapp.vakit.WidgetService.java

private static void extractColors() {
    if (COLOR_1ST != null) {
        return;//w w  w  .j  a v  a2s.c o m
    }

    try {
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(App.getContext());
        mBuilder.setContentTitle(COLOR_SEARCH_1ST).setContentText(COLOR_SEARCH_2ND);
        Notification ntf = mBuilder.build();
        LinearLayout group = new LinearLayout(App.getContext());
        ViewGroup event = (ViewGroup) ntf.contentView.apply(App.getContext(), group);
        recurseGroup(event);
        group.removeAllViews();
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (COLOR_1ST == null) {
        COLOR_1ST = Color.BLACK;
    }
    if (COLOR_2ND == null) {
        COLOR_2ND = Color.DKGRAY;
    }
}

From source file:com.timothy.android.api.fragment.PageFragment.java

public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) {
    Log.i(LOG_TAG, "setAllComponent()...");
    for (HtmlCleanAPI.HtmlContent hc : hcList) {
        String tag = hc.getTag();
        String content = hc.getContent();
        String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(StringUtil.mergeBlank(content)));
        String contentRSpecial = StringUtil.rmvSpecial(contentRBlank);

        if (StringUtil.isEmpty(content) || StringUtil.isEmpty(contentRBlank)
                || StringUtil.isEmpty(contentRSpecial)) {
            continue;
        }//from   w w  w  .  j  a  v  a 2  s  .  c  om

        Log.i(LOG_TAG, "tag:" + tag);
        Log.i(LOG_TAG, "content:" + content);

        if (tag.equalsIgnoreCase("P")) {
            final TextView tagPTV = new TextView(mContext);
            tagPTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagPTV.setLayoutParams(lp);
            tagPTV.setPadding(3, 3, 3, 3);
            tagPTV.setPaddingRelative(3, 3, 3, 3);
            tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPTV.setTextColor(Color.BLACK);
            tagPTV.setText(contentRSpecial);
            tagPTV.setTextSize(TEXT_SIZE);
            tagPTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPTV);

        } else if (tag.equalsIgnoreCase("pre")) {
            final TextView tagPre = new TextView(mContext);
            tagPre.setBackgroundColor(Color.parseColor("#D2EADE"));
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagPre.setLayoutParams(lp);
            tagPre.setPadding(2, 2, 2, 2);
            tagPre.setPaddingRelative(2, 2, 2, 2);
            tagPre.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPre.setTextColor(Color.BLACK);
            //            String contentRSpecial = StringUtil.rmvSpecial(content);
            tagPre.setText(StringUtil.rmvSpecial(content));
            tagPre.setTextSize(TEXT_SIZE);
            tagPre.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPre.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPre);
        } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2")
                || tag.equalsIgnoreCase("H3")) {//title
            TextView tagDtHTV = new TextView(mContext);
            tagDtHTV.setBackgroundColor(Color.DKGRAY);
            tagDtHTV.setTypeface(null, Typeface.BOLD);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 0, 2, 0);
            tagDtHTV.setLayoutParams(lp);
            tagDtHTV.setPadding(2, 2, 2, 2);
            tagDtHTV.setPaddingRelative(2, 2, 2, 2);
            tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDtHTV.setTextColor(Color.WHITE);
            tagDtHTV.setText(contentRSpecial);
            tagDtHTV.setTextSize(TEXT_SIZE);
            lineLayout.addView(tagDtHTV);
        } else if (tag.equalsIgnoreCase("dd")) {
            final TextView tagDD = new TextView(mContext);
            tagDD.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagDD.setLayoutParams(lp);
            tagDD.setPadding(3, 3, 3, 3);
            tagDD.setPaddingRelative(3, 3, 3, 3);
            tagDD.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDD.setTextColor(Color.BLACK);
            tagDD.setText(contentRSpecial);
            tagDD.setTextSize(TEXT_SIZE);
            tagDD.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagDD.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagDD);
        } else if (tag.equalsIgnoreCase("li")) {
            final TextView tagLigTV = new TextView(mContext);
            tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagLigTV.setLayoutParams(lp);
            tagLigTV.setPaddingRelative(2, 2, 2, 2);
            tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagLigTV.setTextColor(Color.BLACK);
            tagLigTV.setText(contentRSpecial);
            tagLigTV.setTextSize(TEXT_SIZE);
            tagLigTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagLigTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagLigTV);
        } else if (tag.equalsIgnoreCase("img")) {
            final TextView imgTV = new TextView(mContext);
            imgTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            imgTV.setLayoutParams(lp);
            imgTV.setPaddingRelative(2, 2, 2, 2);
            imgTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            imgTV.setTextColor(Color.BLACK);
            imgTV.setText(content);
            imgTV.setTextSize(TEXT_SIZE);
            imgTV.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    TextView tv = (TextView) v;
                    String path = tv.getText().toString();
                    if (path != null && path.trim().length() > 0) {
                        openDialog2(path);
                    }
                }
            });
            lineLayout.addView(imgTV);
        }
    }
}

From source file:com.simas.vc.nav_drawer.NavDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 *//* w ww . ja  v a  2  s  .c  o  m*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // Set a custom shadow that overlays the main content when the drawer opens
    getDrawerLayout().setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // Unlock the drawer
    getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);

    // Enable drawer arrow
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), getDrawerLayout(), getToolbar(),
            R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            mDrawerState = DrawerState.CLOSED;

            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerClosed(drawerView);
            }
            getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            // Set the choice mode ONLY IF IT'S NOT SINGLE
            // Otherwise, will cause the AbsListView to reset its mCheckState array!!!
            if (getListView().getChoiceMode() != ListView.CHOICE_MODE_SINGLE) {
                getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            }
            if (!isAdded()) {
                return;
            }

            getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mDrawerState = DrawerState.OPEN;

            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerOpened(drawerView);
            }
            if (!isAdded()) {
                return;
            }

            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

            getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerSlide(drawerView, slideOffset);
            }
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);
            for (DrawerLayout.DrawerListener listener : mDrawerStateListeners) {
                listener.onDrawerStateChanged(newState);
            }
        }
    };

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        setDrawerOpen(true);
    }

    // Defer code dependent on restoration of previous instance state.
    getDrawerLayout().post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    getDrawerLayout().setDrawerListener(mDrawerToggle);

    // The adapter needs a reference to the list its connected to
    mAdapter = new NavAdapter(getActivity(), getListView());
    getListView().setAdapter(mAdapter);

    // Select either the default item (0) or the last selected item.
    if (mPreviousSelection != ListView.INVALID_POSITION) {
        selectItem(mPreviousSelection);
    }

    if (mNavCAB == null) {
        // Newly created CAB
        mNavCAB = new NavCAB(this);
    } else {
        // Previous CAB
        mNavCAB.mNavDrawerFragment = this;
        getListView().post(new Runnable() {
            @Override
            public void run() {
                // Update list if CAB has checked items
                if (mNavCAB.checkedPositions != null && mNavCAB.checkedPositions.size() > 0) {
                    // Copy the array, because it will be modified when checking the LV items
                    List<Integer> positions = new ArrayList<>();
                    positions.addAll(mNavCAB.checkedPositions);

                    // Update the LV's item checked state
                    getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
                    for (Integer position : positions) {
                        getListView().setItemChecked(position, true);
                    }
                }
            }
        });
    }

    getListView().setMultiChoiceModeListener(mNavCAB);

    // Click listeners
    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Make sure it's not the header
            if (position != 0) {
                selectItem(position);
                // Change the item's background based on its checked state
                if (getListView().isItemChecked(position)) {
                    view.setBackgroundColor(Color.DKGRAY);
                } else {
                    view.setBackgroundColor(Color.TRANSPARENT);
                }
            } else {
                ((MainActivity) getActivity()).showFileChooser(false);
            }
        }
    });

    getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // Make sure it's not the header that's been clicked
            if (position == 0) {
                return false;
            } else {
                // Make sure a valid item has been clicked
                boolean valid = (mAdapter.getItem(position - 1).getState() == NavItem.State.VALID);
                if (!valid)
                    return false;

                // Need to enable multiple mode and force-check manually, so CAB is called
                getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
                getListView().setItemChecked(position, true);
                return true;
            }
        }
    });

    //      // Scroll to previous ScrollY
    //      Log.e(TAG, "selection: " + mPreviousSelection);
    //      if (mFromSavedInstanceState && mPreviousSelection != ListView.INVALID_POSITION) {
    //         getListView().setSelection(mPreviousSelection);
    //      }
}

From source file:in.sc9.discreteslider.DiscreteSlider.java

public DiscreteSlider(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setFocusable(true);//from w w  w.  j  ava2 s.  com
    setWillNotDraw(false);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTrackHeight = (int) (1 * density);
    mScrubberHeight = (int) (4 * density);
    int thumbSize = (int) (density * ThumbDrawable.DEFAULT_SIZE_DP);

    //Extra pixels for a touch area of 48dp
    int touchBounds = (int) (density * 32);
    mAddedTouchBounds = (touchBounds - thumbSize) / 2;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSlider, defStyleAttr,
            R.style.Widget_DiscreteSeekBar);

    int max = 100;
    int min = 0;
    int value = 0;
    mMirrorForRtl = a.getBoolean(R.styleable.DiscreteSlider_dsb_mirrorForRtl, mMirrorForRtl);
    mAllowTrackClick = a.getBoolean(R.styleable.DiscreteSlider_dsb_allowTrackClickToDrag, mAllowTrackClick);
    mIndicatorPopupEnabled = a.getBoolean(R.styleable.DiscreteSlider_dsb_indicatorPopupEnabled,
            mIndicatorPopupEnabled);
    mIndicatorTextFromArray = a.getBoolean(R.styleable.DiscreteSlider_dsb_indicatorTextFromArray,
            mIndicatorTextFromArray);
    int indexMax = R.styleable.DiscreteSlider_dsb_max;
    int indexMin = R.styleable.DiscreteSlider_dsb_min;
    int indexValue = R.styleable.DiscreteSlider_dsb_value;
    final TypedValue out = new TypedValue();
    //Not sure why, but we wanted to be able to use dimensions here...
    if (a.getValue(indexMax, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            max = a.getDimensionPixelSize(indexMax, max);
        } else {
            max = a.getInteger(indexMax, max);
        }
    }
    if (a.getValue(indexMin, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            min = a.getDimensionPixelSize(indexMin, min);
        } else {
            min = a.getInteger(indexMin, min);
        }
    }
    if (a.getValue(indexValue, out)) {
        if (out.type == TypedValue.TYPE_DIMENSION) {
            value = a.getDimensionPixelSize(indexValue, value);
        } else {
            value = a.getInteger(indexValue, value);
        }
    }

    mMin = min;
    mMax = Math.max(min + 1, max);
    mValue = Math.max(min, Math.min(max, value));
    updateKeyboardRange();

    mIndicatorFormatter = a.getString(R.styleable.DiscreteSlider_dsb_indicatorFormatter);

    mDiscretePointsEnabled = a.getBoolean(R.styleable.DiscreteSlider_dsb_discretePointsEnabled, false);
    mDiscretePointsShowAlways = a.getBoolean(R.styleable.DiscreteSlider_dsb_discretePointsShowAlways, false);

    ColorStateList trackColor = a.getColorStateList(R.styleable.DiscreteSlider_dsb_trackColor);
    ColorStateList progressColor = a.getColorStateList(R.styleable.DiscreteSlider_dsb_progressColor);
    ColorStateList rippleColor = a.getColorStateList(R.styleable.DiscreteSlider_dsb_rippleColor);
    int discretePointColor = a.getColor(R.styleable.DiscreteSlider_dsb_discretePointsColor, Color.RED);

    mtextColor = a.getColor(R.styleable.DiscreteSlider_dsb_textColor, Color.BLACK);
    mTextSize = a.getDimensionPixelSize(R.styleable.DiscreteSlider_dsb_TextSize, mTextSize);
    mTextPaddingTop = a.getDimensionPixelSize(R.styleable.DiscreteSlider_dsb_TextSize, mTextPaddingTop);
    textStyle = a.getInt(R.styleable.DiscreteSlider_dsb_TextStyle, textStyle);

    boolean editMode = isInEditMode();
    if (editMode || rippleColor == null) {
        rippleColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.DKGRAY });
    }
    if (editMode || trackColor == null) {
        trackColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { Color.GRAY });
    }
    if (editMode || progressColor == null) {
        progressColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { DEFAULT_THUMB_COLOR });
    }
    if (editMode) {
        discretePointColor = Color.RED;
        mtextColor = Color.BLACK;
    }
    mRipple = SeekBarCompat.getRipple(rippleColor);
    if (isLollipopOrGreater) {
        SeekBarCompat.setBackground(this, mRipple);
    } else {
        mRipple.setCallback(this);
    }

    TrackRectDrawable shapeDrawable = new TrackRectDrawable(trackColor);
    mTrack = shapeDrawable;
    mTrack.setCallback(this);

    shapeDrawable = new TrackRectDrawable(progressColor);
    mScrubber = shapeDrawable;
    mScrubber.setCallback(this);

    mThumb = new ThumbDrawable(progressColor, thumbSize);
    mThumb.setCallback(this);
    mThumb.setBounds(0, 0, mThumb.getIntrinsicWidth(), mThumb.getIntrinsicHeight());

    textArray = new String[((mMax - mMin) + 1)];

    int j = mMin;
    for (int i = 0; i < ((mMax - mMin) + 1); i++) {
        if (j <= mMax) {
            textArray[i] = j + "";
            j++;
        } else
            break;
    }

    if (!editMode) {
        mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax));
        mIndicator.setListener(mFloaterListener);
    }
    a.recycle();

    setNumericTransformer(new DefaultNumericTransformer());

    mDiscretePoints = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDiscretePoints.setColor(discretePointColor);
    mDiscretePoints.setStyle(Paint.Style.FILL);
    mDiscretePointsTran = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDiscretePointsTran.setColor(Color.TRANSPARENT);
    mDiscretePointsTran.setStyle(Paint.Style.FILL_AND_STROKE);
    position = new RectF();

}