Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.example.yuen.e_carei.ShowAppointmentList.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("E-care");
    setSupportActionBar(toolbar);//from   w ww  .j a va 2 s  .  c  o  m

    db = new SQLiteHandler(getApplicationContext());
    session = new SessionManager(getApplicationContext());

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    view.getMenu().getItem(1).setChecked(true);
    view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            Toast.makeText(ShowAppointmentList.this, menuItem.getItemId() + " pressed", Toast.LENGTH_LONG)
                    .show();
            Intent intent = new Intent();
            Log.d(R.id.nav_1 + "", menuItem.getItemId() + " ");
            switch (menuItem.getItemId()) {
            case R.id.nav_1:
                intent.setClass(ShowAppointmentList.this, Case_history_review.class);
                startActivity(intent);
                break;
            case R.id.nav_2:
                intent.setClass(ShowAppointmentList.this, ShowAppointmentList.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_3:
                intent.setClass(ShowAppointmentList.this, Appointmentcreate.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_4:
                intent.setClass(ShowAppointmentList.this, AlarmActivity.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_5:
                intent.setClass(ShowAppointmentList.this, PatientReport.class);
                //intent .putExtra("name", "Hello B Activity");
                startActivity(intent);
                break;
            case R.id.nav_6:
                //logout
                AlertDialog.Builder builder = new AlertDialog.Builder(ShowAppointmentList.this);
                //Uncomment the below code to Set the message and title from the strings.xml file
                //builder.setMessage(R.string.dialog_message) .setTitle(R.string.dialog_title);

                //Setting message manually and performing action on button click
                builder.setMessage("Do you want to close this application ?").setCancelable(false)
                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                session.setLogin(false);
                                db.deleteUsers();
                                final Intent intent_logout = new Intent(ShowAppointmentList.this,
                                        LoginActivity.class);
                                startActivity(intent_logout);
                                finish();
                            }
                        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                //  Action for 'NO' Button
                                dialog.cancel();
                            }
                        });

                //Creating dialog box
                AlertDialog alert = builder.create();
                //Setting the title manually
                alert.setTitle("AlertDialogExample");
                alert.show();

                break;
            }
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            return true;
        }
    });

    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
            R.string.drawer_open, R.string.drawer_close) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };

    db = new SQLiteHandler(getApplicationContext());
    dbuser = db.getUserDetails();
    View header = view.getHeaderView(0);
    TextView headerName = (TextView) header.findViewById(R.id.drawer_name);
    username = dbuser.get("name");
    uid = dbuser.get("uid");
    headerName.setText(username);
    ImageLoader imageLoader = AppController.getInstance().getImageLoader();
    com.example.yuen.e_carei_doctor.customlistviewvolley.CirculaireNetworkImageView headerphoto = (com.example.yuen.e_carei_doctor.customlistviewvolley.CirculaireNetworkImageView) header
            .findViewById(R.id.drawer_thumbnail);
    headerphoto.setImageUrl("http://10.89.133.147/test/" + dbuser.get("image"), imageLoader);
    drawerLayout.setDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();

    mListView = (SwipeMenuListView) findViewById(R.id.listView);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);

    swipeRefreshLayout.setOnRefreshListener(this);

    /**
     * Showing Swipe Refresh animation on activity create
     * As animation won't start on onCreate, post runnable is used
     */
    swipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {

            swipeRefreshLayout.setRefreshing(true);
            fetchPatients();
        }
    });

    PD = new ProgressDialog(this);
    //Showing progress dialog before making http request
    PD.setMessage("Loading...");
    PD.show();
    mAdapter = new AppointmentListAdapter(this, appointmentList);
    mListView.setAdapter(mAdapter);
    //fetchPatients();
    // step 1. create a MenuCreator
    SwipeMenuCreator creator = new SwipeMenuCreator() {

        @Override
        public void create(SwipeMenu menu) {

            // create "delete" item
            SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext());
            // set item background
            deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
            // set item width
            deleteItem.setWidth(dp2px(90));
            // set a icon
            deleteItem.setIcon(R.drawable.ic_delete);
            // add to menu
            menu.addMenuItem(deleteItem);
        }
    };
    // set creator
    mListView.setMenuCreator(creator);

    // step 2. listener item click event
    mListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
            AppointmentList item = appointmentList.get(position);
            switch (index) {
            case 0:
                // delete
                //delete(item);
                final String row_aid = aidlist.get(position).toString();
                AlertDialog.Builder builder = new AlertDialog.Builder(ShowAppointmentList.this);

                //Setting message manually and performing action on button click
                builder.setMessage("Do you want to delete this row ?").setCancelable(false)
                        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                delete(uid, row_aid);
                                fetchPatients();
                            }
                        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                //  Action for 'NO' Button
                                dialog.cancel();
                            }
                        });

                //Creating dialog box
                AlertDialog alert = builder.create();
                //Setting the title manually
                alert.setTitle("AlertDialogExample");
                alert.show();
                break;
            }
            return false;
        }
    });

    // set SwipeListener
    mListView.setOnSwipeListener(new SwipeMenuListView.OnSwipeListener() {

        @Override
        public void onSwipeStart(int position) {
            // swipe start
        }

        @Override
        public void onSwipeEnd(int position) {
            // swipe end
        }
    });

    // set MenuStateChangeListener
    mListView.setOnMenuStateChangeListener(new SwipeMenuListView.OnMenuStateChangeListener() {
        @Override
        public void onMenuOpen(int position) {
        }

        @Override
        public void onMenuClose(int position) {
        }
    });

    // other setting
    //      listView.setCloseInterpolator(new BounceInterpolator());

    // test item long click
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getApplicationContext(), position + " long click", Toast.LENGTH_SHORT).show();
            return false;
        }
    });

}

From source file:com.eeshana.icstories.activities.UploadVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // this will copy the license file and the demo video file.
    // to the videokit work folder location.
    // without the license file the library will not work.
    //copyLicenseAndDemoFilesFromAssetsToSDIfNeeded();
    setContentView(R.layout.upload_video_activity);

    height = SignInActivity.getScreenHeight(UploadVideoActivity.this);
    width = SignInActivity.getScreenWidth(UploadVideoActivity.this);
    mProgressDialog = new ProgressDialog(UploadVideoActivity.this);
    pDialog = new ProgressDialog(UploadVideoActivity.this);
    showCustomToast = new ShowCustomToast();
    connectionDetector = new ConnectionDetector(UploadVideoActivity.this);
    //      mProgressDialog=new ProgressDialog(UploadVideoActivity.this,AlertDialog.THEME_HOLO_LIGHT);
    //      mProgressDialog.setFeatureDrawableResource(height,R.drawable.rounded_toast);
    prefs = getSharedPreferences("PREF", MODE_PRIVATE);
    regId = prefs.getString("regid", "NA");
    SharedPreferences pref = getSharedPreferences("DB", 0);
    userid = pref.getString("userid", "1");
    SharedPreferences assign_prefs = getSharedPreferences("ASSIGN", 0);
    assignment_id = assign_prefs.getString("ASSIGN_ID", "");
    videoPath = getIntent().getStringExtra("VIDEOPATH");

    //      iCTextView=(TextView) findViewById(R.id.tvIC);
    //      iCTextView.setTypeface(CaptureVideoActivity.ic_typeface,Typeface.BOLD);
    //      storiesTextView=(TextView) findViewById(R.id.tvStories);
    //      storiesTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.BOLD);
    //      watsStoryTextView=(TextView) findViewById(R.id.tvWhatsStory);
    //      watsStoryTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.ITALIC);

    //      logoImageView=(ImageView) findViewById(R.id.ivLogo);
    //      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams((int) (width/1.9), (int) (height/9.5));
    //      lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //      lp.setMargins(0, 0, 0, 0);
    //      logoImageView.setLayoutParams(lp);

    uploadtTextView = (TextView) findViewById(R.id.tvUpload);
    uploadtTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    //      extension=getIntent().getStringExtra("EXTENSION");
    //      folderPath = Environment.getExternalStorageDirectory().getPath()+"/ICStoriesFolder";
    //      if (!FileUtils.checkIfFolderExists(folderPath)) {
    //         boolean isFolderCreated = FileUtils.createFolder(folderPath);
    //         Log.i(Prefs.TAG, folderPath + " created? " + isFolderCreated);
    //         if (isFolderCreated) {
    ////from   www  . jav a2 s.  c o m
    //         }
    //      }
    //command for rotating video 90 degree
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k "+folderPath+"/out."+extension;

    //Change Video Resolution:
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=3 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/res."+extension;

    //command for compressing video 
    //      String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/test."+extension;
    //      setCommand(commandStr);
    //      runTranscoing();

    thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
    System.out.println("THUMB IMG  in uplaod== " + thumb);

    titleEditText = (EditText) findViewById(R.id.etTitle);
    titleEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    descriptionEditText = (EditText) findViewById(R.id.etDescripton);
    descriptionEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    locationEditText = (EditText) findViewById(R.id.etLocation);
    locationEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton = (Button) findViewById(R.id.buttonCheck);
    isAssignmentButton.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton.setOnClickListener(this);
    dailyAssignTextView = (TextView) findViewById(R.id.tvDailyAssignment);
    dailyAssignTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    uploadButton = (Button) findViewById(R.id.buttonUpload);
    uploadButton.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout uploadRelativeLayout = (RelativeLayout) findViewById(R.id.rlUpload);
    RelativeLayout.LayoutParams lp9 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, height / 17);
    lp9.addRule(RelativeLayout.BELOW, R.id.rlDailyAssignment);
    lp9.setMargins(width / 7, 30, width / 7, 0);
    uploadRelativeLayout.setLayoutParams(lp9);
    uploadButton.setOnClickListener(this);

    //bottom bar

    homeRelativeLayout = (RelativeLayout) findViewById(R.id.rlHome);
    homeRelativeLayout.setBackgroundResource(R.drawable.press_border);
    homeRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    homeTextView = (TextView) homeRelativeLayout.findViewById(R.id.tvHome);
    homeTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    homeTextView.setTextColor(Color.parseColor("#fffffe"));
    RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp4.addRule(RelativeLayout.ALIGN_LEFT);
    homeRelativeLayout.setLayoutParams(lp4);
    homeRelativeLayout.setOnClickListener(this);

    wallRelativeLayout = (RelativeLayout) findViewById(R.id.rlWall);
    wallRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    wallTextView = (TextView) wallRelativeLayout.findViewById(R.id.tvWall);
    wallTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp5.addRule(RelativeLayout.RIGHT_OF, R.id.rlHome);
    wallRelativeLayout.setLayoutParams(lp5);
    wallRelativeLayout.setOnClickListener(this);

    settingsRelativeLayout = (RelativeLayout) findViewById(R.id.rlSettings);
    settingsRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    settingsTextView = (TextView) settingsRelativeLayout.findViewById(R.id.tvSettings);
    settingsTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp6 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp6.addRule(RelativeLayout.RIGHT_OF, R.id.rlWall);
    settingsRelativeLayout.setLayoutParams(lp6);
    settingsRelativeLayout.setOnClickListener(this);

    // current location
    locationDialog = new Dialog(UploadVideoActivity.this);
    locationDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    locationDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    locationDialog.setContentView(R.layout.location_dialog);
    locationDialog.setCancelable(true);
    LinearLayout dialogLayout = (LinearLayout) locationDialog.findViewById(R.id.ll1);
    okButton = (Button) dialogLayout.findViewById(R.id.OkBtn);
    okButton.setOnClickListener(this);
    cancelButton = (Button) dialogLayout.findViewById(R.id.cancelBtn);
    cancelButton.setOnClickListener(this);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    boolean network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    if (network_enabled) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    } else {
        showCustomToast.showToast(UploadVideoActivity.this,
                "Could not find current location. Please enable location services of your device.");
    }
    //      else if(gps_enabled == false){
    //         locationDialog.show();
    //      }
}

From source file:com.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);/*from w ww  .j av a 2  s.  c  o m*/
    View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null);
    final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    //??
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    popupWindow.setWidth(dm.widthPixels);
    popupWindow.setAnimationStyle(R.style.popuwindow);
    //?
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new poponDismissListener_FinancialApplyFragment());

    //PopupWindow-----END
    //PopupWindow
    Button button = (Button) view.findViewById(R.id.take_photo);//??
    Button button1 = (Button) view.findViewById(R.id.all_photo);//?
    Button button2 = (Button) view.findViewById(R.id.out);//?
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,?
            allPhoto();
        }
    });
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,Intent????
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //,??
            File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image");
            //??
            path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg";
            //?IntentIntent?
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
            //?
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            //?Intent??RoundImageView
            startActivityForResult(intent, REQUEST_CODE);
        }
    });
}

From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java

@WorkerThread
private void showPopupAt(final LineNumber lineNumber, final String msg) {
    mHandler.post(new Runnable() {
        @Override//from  w  w  w .  j  a v  a2 s .c  o  m
        public void run() {
            if (isFinishing())
                return;
            //get relative position of expression at edittext
            Point position = mCodeView.getDebugPosition(lineNumber.getLine(), lineNumber.getColumn(),
                    Gravity.TOP);
            DLog.d(TAG, "generate: " + position);
            dismissPopup();
            //create new popup
            PopupWindow window = new PopupWindow(DebugActivity.this);
            LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            View container = inflater.inflate(R.layout.popup_expr_result, null);
            container.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            int windowHeight = container.getMeasuredHeight();
            int windowWidth = container.getMeasuredWidth();

            window.setContentView(container);
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            window.setTouchable(true);
            window.setSplitTouchEnabled(true);
            window.setOutsideTouchable(true);

            window.showAtLocation(mCodeView, Gravity.NO_GRAVITY, position.x - windowWidth / 3,
                    position.y + toolbar.getHeight() - windowHeight);

            TextView txtResult = container.findViewById(R.id.txt_result);
            txtResult.setText(msg);
            AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.5f);
            alphaAnimation.setDuration(1000);
            alphaAnimation.setRepeatMode(Animation.REVERSE);
            alphaAnimation.setRepeatCount(Animation.INFINITE);
            txtResult.startAnimation(alphaAnimation);
            DebugActivity.this.mPopupWindow = window;
        }
    });
}

From source file:android.com.example.contactslist.util.ImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap The new bitmap to set./*from w ww  . ja  v  a  2 s. c om*/
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

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.
 *//*from  w  w  w  .j av a  2 s  . c om*/
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.jackleeentertainment.oq.ui.layout.fragment.util.ImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap The new bitmap to set./*from w  w  w. j a  v  a2s.c  om*/
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(App.getContext().getResources().getColor(android.R.color.transparent)),
                new BitmapDrawable(mResources, bitmap) });
        imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.faayda.imageloader.ImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap The new bitmap to set./*from ww  w  .  j  ava2  s .  c o  m*/
 */
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(mResources.getColor(R.color.transparent)),
                        new BitmapDrawable(mResources, bitmap) });
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
            imageView.setBackground(imageView.getDrawable());
        } else {
            imageView.setBackgroundDrawable(imageView.getDrawable());
        }
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.yattatech.dbtc.activity.MainScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_main_screen);
    final int color = getResources().getColor(R.color.grey2);
    final ActionBar actionBar = getActionBar();
    mFilter = new IntentFilter();
    mLocaleChangedFilter = new IntentFilter();
    mTaskList = (DragSortListView) findViewById(R.id.taskList);
    mTaskListAdapter = new TaskListAdapter(this);
    final String appKey = getString(R.string.dropbox_key);
    final String appSecret = getString(R.string.dropbox_secret);
    final AppKeyPair pair = new AppKeyPair(appKey, appSecret);
    final AndroidAuthSession session = new AndroidAuthSession(pair);
    mDropboxAPI = new DropboxAPI<AndroidAuthSession>(session);
    mToken = FACADE.getDropBoxToken();//from   w  w  w. ja v  a  2s. c om
    mTaskList.setAdapter(mTaskListAdapter);
    mTaskList.setOnItemClickListener(mTaskListListener);
    mTaskList.setDropListener(mDropListener);
    mTaskList.setDragScrollProfile(mScrollProfile);
    mTaskList.setFloatViewManager(new MainViewManager(mTaskList));
    mFilter.addAction(ADD_NEW_TASK_ACTION);
    mFilter.addAction(EDIT_TASK_ACTION);
    mFilter.addAction(REMOVE_TASK_ACTION);
    mFilter.addAction(BACKUP_RESTORE_ACTION);
    mLocaleChangedFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
    actionBar.setIcon(R.drawable.ic_task);
    actionBar.setTitle(R.string.app_name);
    actionBar.setBackgroundDrawable(new ColorDrawable(color));
    Broadcaster.registerLocalReceiver(mReceiver, mFilter);
    registerReceiver(mLocaleChangedReceiver, mLocaleChangedFilter);
    registerForContextMenu(mTaskList);
    final List<Task> tasks = FACADE.getTasks();
    mTaskListAdapter.setElements(FACADE.restoreDataOrder(tasks));
}