Example usage for android.support.v4.content ContextCompat getDrawable

List of usage examples for android.support.v4.content ContextCompat getDrawable

Introduction

In this page you can find the example usage for android.support.v4.content ContextCompat getDrawable.

Prototype

public static final Drawable getDrawable(Context context, int i) 

Source Link

Usage

From source file:com.filemanager.free.adapters.Recycleradapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder vholder, @SuppressLint("RecyclerView") final int p) {
    final Recycleradapter.ViewHolder holder = ((Recycleradapter.ViewHolder) vholder);
    if (main.IS_LIST) {
        if (p == getItemCount() - 1) {
            holder.rl.setMinimumHeight(rowHeight);
            if (items.size() == (main.GO_BACK_ITEM ? 1 : 0))
                holder.txtTitle.setText(R.string.nofiles);
            else {
                holder.txtTitle.setText(R.string.footer);
            }//from w  w w  . ja va2s .  co m
            return;
        }
    }
    if (holder.imageView == null)
        return;
    if (!this.stoppedAnimation && !myanim.get(p)) {
        animate(holder);
        myanim.put(p, true);
    }
    final Layoutelements rowItem = items.get(p);
    if (main.IS_LIST) {
        holder.rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                main.onListItemClicked(p, v);
            }
        });

        holder.rl.setOnLongClickListener(new View.OnLongClickListener() {

            public boolean onLongClick(View p1) {

                if (!rowItem.getSize().equals(main.goback)) {
                    Animation iconAnimation = AnimationUtils.loadAnimation(context, R.anim.holder_anim);
                    holder.imageView.setAnimation(iconAnimation);
                    toggleChecked(p);
                }

                return true;
            }
        });

        filetype = -1;
        if (Icons.isPicture((rowItem.getDesc().toLowerCase())))
            filetype = 0;
        else if (Icons.isApk((rowItem.getDesc())))
            filetype = 1;
        else if (Icons.isVideo(rowItem.getDesc()))
            filetype = 2;
        holder.txtTitle.setText(rowItem.getTitle());
        holder.imageView.setImageDrawable(rowItem.getImageId());
        holder.ext.setText("");

        if (holder.about != null) {
            if (main.theme1 == 0)
                holder.about.setColorFilter(grey_color);
            showPopup(holder.about, rowItem);
        }
        holder.imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (!rowItem.getSize().equals(main.goback)) {

                    Animation iconAnimation = AnimationUtils.loadAnimation(context, R.anim.holder_anim);
                    holder.imageView.setAnimation(iconAnimation);
                    toggleChecked(p);
                } else
                    main.goBack();

            }
        });
        holder.viewmageV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!rowItem.getSize().equals(main.goback)) {

                    Animation iconAnimation = AnimationUtils.loadAnimation(context, R.anim.holder_anim);
                    holder.imageView.setAnimation(iconAnimation);
                    toggleChecked(p);
                } else
                    main.goBack();
            }
        });
        holder.apk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!rowItem.getSize().equals(main.goback)) {

                    Animation iconAnimation = AnimationUtils.loadAnimation(context, R.anim.holder_anim);
                    holder.imageView.setAnimation(iconAnimation);
                    toggleChecked(p);
                } else
                    main.goBack();
            }
        });
        holder.imageView.setVisibility(View.VISIBLE);
        holder.viewmageV.setVisibility(View.INVISIBLE);
        if (filetype == 0) {
            if (main.SHOW_THUMBS) {
                if (main.CIRCULAR_IMAGES) {
                    holder.imageView.setVisibility(View.GONE);
                    holder.apk.setVisibility(View.GONE);
                    holder.viewmageV.setVisibility(View.VISIBLE);
                    holder.viewmageV.setImageDrawable(main.DARK_IMAGE);
                    main.ic.cancelLoad(holder.viewmageV);
                    main.ic.loadDrawable(holder.viewmageV, (rowItem.getDesc()), null);
                } else {
                    holder.imageView.setVisibility(View.GONE);
                    holder.apk.setVisibility(View.VISIBLE);
                    holder.apk.setImageDrawable(main.DARK_IMAGE);
                    main.ic.cancelLoad(holder.apk);
                    main.ic.loadDrawable(holder.apk, (rowItem.getDesc()), null);
                }
            }
        } else if (filetype == 1) {
            if (main.SHOW_THUMBS) {
                holder.viewmageV.setVisibility(View.GONE);
                holder.imageView.setVisibility(View.GONE);
                holder.apk.setVisibility(View.VISIBLE);
                holder.apk.setImageDrawable(main.apk);
                main.ic.cancelLoad(holder.apk);
                main.ic.loadDrawable(holder.apk, (rowItem.getDesc()), null);
            }

        } else if (filetype == 2) {
            if (main.SHOW_THUMBS) {
                if (main.CIRCULAR_IMAGES) {
                    holder.imageView.setVisibility(View.GONE);
                    holder.viewmageV.setVisibility(View.VISIBLE);
                    holder.viewmageV.setImageDrawable(main.DARK_VIDEO);
                    main.ic.cancelLoad(holder.viewmageV);
                    main.ic.loadDrawable(holder.viewmageV, (rowItem.getDesc()), null);
                } else {
                    holder.imageView.setVisibility(View.GONE);
                    holder.apk.setVisibility(View.VISIBLE);
                    holder.apk.setImageDrawable(main.DARK_VIDEO);
                    main.ic.cancelLoad(holder.apk);
                    main.ic.loadDrawable(holder.apk, (rowItem.getDesc()), null);
                }
            }
        } else {
            holder.viewmageV.setVisibility(View.GONE);
            holder.apk.setVisibility(View.GONE);
            holder.imageView.setVisibility(View.VISIBLE);
        }
        Boolean checked = myChecked.get(p);
        if (checked != null) {

            if (main.theme1 == 0) {

                holder.rl.setBackgroundResource(R.drawable.safr_ripple_white);
            } else {

                holder.rl.setBackgroundResource(R.drawable.safr_ripple_black);
            }
            holder.rl.setSelected(false);
            if (checked) {
                holder.apk.setVisibility(View.GONE);
                holder.viewmageV.setVisibility(View.GONE);
                holder.imageView.setVisibility(View.VISIBLE);
                holder.imageView.setImageDrawable(
                        ContextCompat.getDrawable(context, R.drawable.abc_ic_cab_done_holo_dark));
                GradientDrawable gradientDrawable = (GradientDrawable) holder.imageView.getBackground();
                gradientDrawable.setColor(c1);
                holder.rl.setSelected(true);
                holder.ext.setText("");
            } else {
                GradientDrawable gradientDrawable = (GradientDrawable) holder.imageView.getBackground();
                if (main.COLORISE_ICONS) {
                    if (rowItem.isDirectory())
                        gradientDrawable.setColor(main.icon_skin_color);
                    else if (Icons.isVideo(rowItem.getDesc()) || Icons.isPicture(rowItem.getDesc()))
                        gradientDrawable.setColor(c2);
                    else if (Icons.isAudio(rowItem.getDesc()))
                        gradientDrawable.setColor(c3);
                    else if (Icons.isPdf(rowItem.getDesc()))
                        gradientDrawable.setColor(c4);
                    else if (Icons.isCode(rowItem.getDesc()))
                        gradientDrawable.setColor(c5);
                    else if (Icons.isText(rowItem.getDesc()))
                        gradientDrawable.setColor(c6);
                    else if (Icons.isArchive(rowItem.getDesc()))
                        gradientDrawable.setColor(c7);
                    else if (Icons.isApk(rowItem.getDesc()))
                        gradientDrawable.setColor(c8);
                    else if (Icons.isgeneric(rowItem.getDesc())) {
                        gradientDrawable.setColor(c9);
                        String ext = MimeTypes.getExtension(new File(rowItem.getDesc()).getName());
                        if (ext != null && ext.trim().length() != 0) {
                            holder.ext.setText(ext);
                            holder.imageView.setImageDrawable(null);
                        }
                    } else {
                        gradientDrawable.setColor(main.icon_skin_color);
                    }
                } else
                    gradientDrawable.setColor((main.icon_skin_color));
                if (rowItem.getSize().equals(main.goback))
                    gradientDrawable.setColor(c1);

            }
        }
        if (main.SHOW_PERMISSIONS)
            holder.perm.setText(rowItem.getPermissions());
        if (main.SHOW_LAST_MODIFIED)
            holder.date.setText(rowItem.getDate());
        String size = rowItem.getSize();

        if (size.equals(main.goback)) {

            holder.date.setText(size);

            holder.txtDesc.setText("");
        } else if (main.SHOW_SIZE)

            holder.txtDesc.setText(rowItem.getSize());
    } else {
        Boolean checked = myChecked.get(p);
        holder.rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                main.onListItemClicked(p, v);
            }
        });

        holder.rl.setOnLongClickListener(new View.OnLongClickListener() {

            public boolean onLongClick(View p1) {

                if (!rowItem.getSize().equals(main.goback)) {
                    Animation iconAnimation = AnimationUtils.loadAnimation(context, R.anim.holder_anim);
                    holder.imageView.setAnimation(iconAnimation);
                    toggleChecked(p);
                }
                return true;
            }
        });
        holder.txtTitle.setText(rowItem.getTitle());
        holder.imageView1.setVisibility(View.INVISIBLE);
        holder.imageView.setVisibility(View.VISIBLE);
        holder.imageView.setImageDrawable(rowItem.getImageId());
        if (Icons.isPicture((rowItem.getDesc().toLowerCase()))
                || Icons.isVideo(rowItem.getDesc().toLowerCase())) {
            holder.imageView.setColorFilter(null);
            holder.imageView1.setVisibility(View.VISIBLE);
            holder.imageView1.setImageDrawable(null);
            if (main.theme == 1)
                holder.imageView1.setBackgroundColor(Color.BLACK);
            main.ic.cancelLoad(holder.imageView1);
            main.ic.loadDrawable(holder.imageView1, (rowItem.getDesc()), null);
        } else if (Icons.isApk((rowItem.getDesc()))) {
            holder.imageView.setColorFilter(null);
            main.ic.cancelLoad(holder.imageView);
            main.ic.loadDrawable(holder.imageView, (rowItem.getDesc()), null);
        }
        if (rowItem.isDirectory())
            holder.imageView.setColorFilter(main.icon_skin_color);

        else if (Icons.isVideo(rowItem.getDesc()))
            holder.imageView.setColorFilter(c2);

        else if (Icons.isAudio(rowItem.getDesc()))
            holder.imageView.setColorFilter(c3);

        else if (Icons.isPdf(rowItem.getDesc()))
            holder.imageView.setColorFilter(c4);

        else if (Icons.isCode(rowItem.getDesc()))
            holder.imageView.setColorFilter(c5);

        else if (Icons.isText(rowItem.getDesc()))
            holder.imageView.setColorFilter(c6);

        else if (Icons.isArchive(rowItem.getDesc()))
            holder.imageView.setColorFilter(c7);

        else if (Icons.isgeneric(rowItem.getDesc()))
            holder.imageView.setColorFilter(c9);

        else if (Icons.isApk(rowItem.getDesc()) || Icons.isPicture(rowItem.getDesc()))
            holder.imageView.setColorFilter(null);

        else
            holder.imageView.setColorFilter(main.icon_skin_color);
        if (rowItem.getSize().equals(main.goback))
            holder.imageView.setColorFilter(c1);
        if (checked != null) {

            if (checked) {
                holder.imageView.setColorFilter(main.icon_skin_color);
                holder.imageView.setImageDrawable(
                        ContextCompat.getDrawable(context, R.drawable.abc_ic_cab_done_holo_dark));
                holder.rl.setBackgroundColor(Color.parseColor("#9f757575"));
            } else {
                if (main.theme1 == 0)
                    holder.rl.setBackgroundResource(R.drawable.item_doc_grid);
                else {
                    holder.rl.setBackgroundResource(R.drawable.ic_grid_card_background_dark);
                    holder.rl.findViewById(R.id.icon_frame).setBackgroundColor(Color.parseColor("#303030"));
                }
            }
        }

        if (holder.about != null) {
            if (main.theme1 == 0)
                holder.about.setColorFilter(grey_color);
            showPopup(holder.about, rowItem);
        }
        if (main.SHOW_LAST_MODIFIED)
            holder.date.setText(rowItem.getDate());
        if (rowItem.getSize().equals(main.goback)) {
            holder.date.setText(rowItem.getSize());
            holder.txtDesc.setText("");
        } /*else if(main.SHOW_SIZE)
          holder.txtDesc.setText(rowItem.getSize());
          */
        if (main.SHOW_PERMISSIONS)
            holder.perm.setText(rowItem.getPermissions());
    }
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.ApptentiveBaseFragment.java

private void showToolbarElevationPreLollipop(boolean visible) {
    if (!isAdded()) {
        return;/*from w  w w .ja  v  a2  s.  c o  m*/
    }

    FrameLayout pager = (FrameLayout) getActivity().findViewById(R.id.apptentive_vp_container);

    if (pager != null) {
        if (visible) {
            Drawable shadow = ContextCompat.getDrawable(getContext(),
                    R.drawable.apptentive_actionbar_compat_shadow);
            pager.setForeground(shadow);
        } else {
            pager.setForeground(new ColorDrawable(0));
        }
    }

}

From source file:com.guerinet.formgenerator.TextViewFormItem.java

/**
 * @param icon {@link Icon} instance/*from  ww  w  . j  av a 2 s.  c om*/
 * @return Drawable to use, null if none
 */
@Nullable
private Drawable getDrawable(Icon icon) {
    return icon.drawableId == 0 ? null : ContextCompat.getDrawable(view.getContext(), icon.drawableId);
}

From source file:com.filemanager.free.fragments.Main.java

void switchToList() {
    IS_LIST = true;//from   w w w .j  a v  a2 s .co m
    if (theme1 == 1) {
        setBackground(new ColorDrawable(ContextCompat.getColor(getContext(), R.color.holo_dark_background)));
    } else {

        if (IS_LIST)
            setBackground(
                    new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.background_light)));
        else
            setBackground(new ColorDrawable(Color.parseColor("#f2f2f2")));
    }
    ic = new IconHolder(getActivity(), SHOW_THUMBS, !IS_LIST);
    folder = ContextCompat.getDrawable(getContext(), R.drawable.ic_grid_folder_new);
    fixIcons();
    if (mLayoutManager == null)
        mLayoutManager = new LinearLayoutManager(getActivity());
    listView.setLayoutManager(mLayoutManager);
    adapter = null;
}

From source file:com.annanovas.bestprice.DashBoardEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dash_board_edit);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  w  w w. j  av  a2s.  c  om
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    //        chosenBrandList.add(new ArrayList<String>());
    //        chosenBrandList.add(new ArrayList<String>());
    //        chosenBrandList.add(new ArrayList<String>());

    etAddress = (EditText) findViewById(R.id.et_address);
    etEmail = (EditText) findViewById(R.id.et_email);
    etShopName = (EditText) findViewById(R.id.et_shop_name);
    etDrivingLicense = (EditText) findViewById(R.id.et_driving_licence);
    etNid = (EditText) findViewById(R.id.et_nid);
    etExperience = (EditText) findViewById(R.id.et_experience);
    etFirstName = (EditText) findViewById(R.id.et_first_name);
    etMiddleName = (EditText) findViewById(R.id.et_middle_name);
    etLastName = (EditText) findViewById(R.id.et_last_name);
    etPhoneNumber = (EditText) findViewById(R.id.et_phone);
    tvAddress = (TextView) findViewById(R.id.tv_address);
    tvArea = (TextView) findViewById(R.id.tv_area);
    tvDealerShip = (LinearLayout) findViewById(R.id.tv_dealership);
    tvDealerShipWith = (TextView) findViewById(R.id.tv_dealership_content);
    tvSelectedProduct = (TextView) findViewById(R.id.tv_select_product_content);
    tvProduct = (LinearLayout) findViewById(R.id.tv_select_product);
    buttonSubmit = (Button) findViewById(R.id.button_submit);
    areaLayout = (LinearLayout) findViewById(R.id.layout_area);
    brandLayout = (LinearLayout) findViewById(R.id.layout_brand);
    productLayout = (LinearLayout) findViewById(R.id.layout_product);
    layoutCamera = (LinearLayout) findViewById(R.id.layout_camera);
    layoutGallery = (LinearLayout) findViewById(R.id.layout_gallery);
    userImage = (ImageView) findViewById(R.id.iv_user_image);
    areaRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_area);
    brandRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_brand);
    productRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_product);
    etProductSearch = (EditText) findViewById(R.id.et_product_name);
    etBrandSearch = (EditText) findViewById(R.id.et_brand_name);
    etAreaSearch = (EditText) findViewById(R.id.et_area_name);
    layoutSearchArea = (LinearLayout) findViewById(R.id.layout_search_area);
    layoutSearchProduct = (LinearLayout) findViewById(R.id.layout_search_product);
    layoutSearchBrand = (LinearLayout) findViewById(R.id.layout_search_brand);
    tvSelectedBrand = (TextView) findViewById(R.id.tv_selected_brand);
    tvSelectedArea = (TextView) findViewById(R.id.tv_setect_area);
    ivArrow1 = (ImageView) findViewById(R.id.iv_arrow1);
    ivArrow2 = (ImageView) findViewById(R.id.iv_arrow2);
    ivArrow3 = (ImageView) findViewById(R.id.iv_arrow3);
    ivArrow4 = (ImageView) findViewById(R.id.iv_arrow4);

    myDB = MyDatabaseManager.getInstance(getApplicationContext());
    sharedPreferences = getSharedPreferences(AppGlobal.MY_PREFS_NAME, MODE_PRIVATE);

    userType = sharedPreferences.getInt("user_type", 1);

    int imageDimen = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimension(R.dimen.size_150dp), getResources().getDisplayMetrics());

    myDB.open();
    Cursor cursor = myDB.getUserInfo(userType, sharedPreferences.getString("user_phone_number", ""));
    if (userType == AppGlobal.CAR_OWNER) {
        userImage.setImageResource(R.drawable.ic_car_owner);
        tvAddress.setVisibility(View.VISIBLE);
        etAddress.setVisibility(View.VISIBLE);
        tvArea.setVisibility(View.VISIBLE);
        areaLayout.setVisibility(View.VISIBLE);

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname")));
                etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename")));
                etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname")));

                if (cursor.getString(cursor.getColumnIndex("address")) != null
                        && !cursor.getString(cursor.getColumnIndex("address")).equals("null")) {
                    etAddress.setText(cursor.getString(cursor.getColumnIndex("address")));
                }

                etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                etEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname")));
                areaId = cursor.getInt(cursor.getColumnIndex("area_id"));
                if (areaId != 0) {
                    tvSelectedArea.setText(myDB.getAreaName(areaId));
                } else {
                    tvSelectedArea.setText(getResources().getString(R.string.select_area));
                }

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getApplicationContext())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_car_owner);
                }
            }
        }
        cursor.close();

        generateAreaRecyclerView();

    } else if (userType == AppGlobal.SUPPLIER) {
        tvAddress.setVisibility(View.VISIBLE);
        etAddress.setVisibility(View.VISIBLE);
        tvDealerShip.setVisibility(View.VISIBLE);
        tvProduct.setVisibility(View.VISIBLE);
        tvArea.setVisibility(View.VISIBLE);
        brandLayout.setVisibility(View.VISIBLE);
        productLayout.setVisibility(View.VISIBLE);
        areaLayout.setVisibility(View.VISIBLE);
        etShopName.setVisibility(View.VISIBLE);

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname")));
                etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename")));
                etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname")));
                etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                etEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname")));
                etAddress.setText(cursor.getString(cursor.getColumnIndex("address")));
                areaId = cursor.getInt(cursor.getColumnIndex("area_id"));
                if (areaId != 0) {
                    tvSelectedArea.setText(myDB.getAreaName(areaId));
                } else {
                    tvSelectedArea.setText(getResources().getString(R.string.select_area));
                }
                selectedProductIdList = myDB.getSelectedProductList(cursor.getInt(cursor.getColumnIndex("id")));
                chosenBrandIdList = myDB.getSelectedBrandList(cursor.getInt(cursor.getColumnIndex("id")));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getApplicationContext())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_supplier);
                }
            }
        }
        cursor.close();

        generateAreaRecyclerView();
        generateProductRecyclerView();

    } else if (userType == AppGlobal.DRIVER) {
        etDrivingLicense.setVisibility(View.VISIBLE);
        etNid.setVisibility(View.VISIBLE);
        etExperience.setVisibility(View.VISIBLE);

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname")));
                etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename")));
                etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname")));
                etAddress.setText(cursor.getString(cursor.getColumnIndex("address")));
                etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                etEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                etDrivingLicense.setText(cursor.getString(cursor.getColumnIndex("drivinglicence")));
                etNid.setText(cursor.getString(cursor.getColumnIndex("nid")));
                etExperience.setText(cursor.getString(cursor.getColumnIndex("yearofexperience")));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getApplicationContext())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_car_owner);
                }
            }
        }
        cursor.close();

    } else if (userType == AppGlobal.SHOP_WORKER) {
        etShopName.setVisibility(View.VISIBLE);
        etNid.setVisibility(View.VISIBLE);

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname")));
                etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename")));
                etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname")));
                etAddress.setText(cursor.getString(cursor.getColumnIndex("address")));
                etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                etEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname")));
                etNid.setText(cursor.getString(cursor.getColumnIndex("nid")));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getApplicationContext())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_car_owner);
                }
            }
        }
        cursor.close();
    }
    myDB.close();

    areaLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (layoutSearchArea.getVisibility() == View.GONE) {
                layoutSearchArea.setVisibility(View.VISIBLE);
                areaRecyclerView.setVisibility(View.VISIBLE);
                ivArrow2.setImageDrawable(
                        ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow));
            } else {
                layoutSearchArea.setVisibility(View.GONE);
                areaRecyclerView.setVisibility(View.GONE);
                ivArrow2.setImageDrawable(
                        ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow));
            }
        }
    });

    brandLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (selectedProductIdList.size() == 0) {
                Toast.makeText(getApplicationContext(), R.string.add_product, Toast.LENGTH_SHORT).show();
                return;
            }
            if (layoutSearchBrand.getVisibility() == View.GONE) {
                layoutSearchBrand.setVisibility(View.VISIBLE);
                brandRecyclerView.setVisibility(View.VISIBLE);
                ivArrow3.setImageDrawable(
                        ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow));
            } else {
                layoutSearchBrand.setVisibility(View.GONE);
                brandRecyclerView.setVisibility(View.GONE);
                ivArrow3.setImageDrawable(
                        ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow));
            }
        }
    });

    productLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (layoutSearchProduct.getVisibility() == View.GONE) {
                layoutSearchProduct.setVisibility(View.VISIBLE);
                productRecyclerView.setVisibility(View.VISIBLE);
                ivArrow1.setImageDrawable(
                        ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow));
            } else {
                layoutSearchProduct.setVisibility(View.GONE);
                productRecyclerView.setVisibility(View.GONE);
                ivArrow1.setImageDrawable(
                        ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow));
            }
        }
    });

    layoutCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                File file = createImageFile();
                imageUri = String.valueOf(file);
                // showLog(imageUri);
                Uri photoURI = FileProvider.getUriForFile(getApplicationContext(),
                        BuildConfig.APPLICATION_ID + ".provider", file);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(intent, REQUEST_CAMERA);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });

    layoutGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            intent.setType("image/*");
            startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
        }
    });

    buttonSubmit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            progressDialog = new ProgressDialog(DashBoardEditActivity.this);
            progressDialog.setMessage(getResources().getString(R.string.please_wait));
            progressDialog.setCancelable(false);
            progressDialog.show();
            UpdateUserInfo updateUserInfo = new UpdateUserInfo(getApplicationContext());
            updateUserInfo.signUpListener = DashBoardEditActivity.this;
            //viewEnable(false);

            if (userType == AppGlobal.CAR_OWNER) {
                boolean hasError = false;
                boolean hasPhoneNoError = false;
                if (etFirstName.getText().length() == 0) {
                    etFirstName.setError(getResources().getString(R.string.enter_first_name));
                    hasError = true;
                }
                if (etLastName.getText().length() == 0) {
                    etLastName.setError(getResources().getString(R.string.enter_last_name));
                    hasError = true;
                }
                if (etPhoneNumber.getText().length() == 0) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no));
                    hasError = true;
                    hasPhoneNoError = true;
                }
                if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no));
                    hasError = true;
                }
                if (etEmail.getText().length() != 0
                        && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) {
                    etEmail.setError(getResources().getString(R.string.enter_valid_email));
                    hasError = true;
                }
                if (etAddress.getText().length() == 0) {
                    etAddress.setError(getResources().getString(R.string.enter_address));
                    hasError = true;
                }
                if (hasError) {
                    if (progressDialog.isShowing())
                        progressDialog.dismiss();
                    return;
                }
                HashMap<String, String> params = new HashMap<>();
                params.put("authentication", AppGlobal.authentication);
                params.put("api_token", sharedPreferences.getString("api_token", ""));
                params.put("phone", etPhoneNumber.getText().toString());
                params.put("firstname", etFirstName.getText().toString());
                if (!etMiddleName.getText().toString().equals("")) {
                    params.put("middlename", etMiddleName.getText().toString());
                }
                params.put("lastname", etLastName.getText().toString());
                params.put("district_id", "1");
                params.put("area_id", String.valueOf(areaId));
                params.put("address", etAddress.getText().toString());
                if (!etEmail.getText().toString().equals("")) {
                    params.put("email", etEmail.getText().toString());
                }
                if (!image.equals("")) {
                    params.put("image", image);
                }
                updateUserInfo.parseData(params, "updateCarOwnerInfo");
            } else if (userType == AppGlobal.SUPPLIER) {
                boolean hasError = false;
                boolean hasPhoneNoError = false;
                if (etFirstName.getText().length() == 0) {
                    etFirstName.setError(getResources().getString(R.string.enter_first_name));
                    hasError = true;
                }
                if (etLastName.getText().length() == 0) {
                    etLastName.setError(getResources().getString(R.string.enter_last_name));
                    hasError = true;
                }
                if (etPhoneNumber.getText().length() == 0) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no));
                    hasError = true;
                    hasPhoneNoError = true;
                }
                if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no));
                    hasError = true;
                }
                if (etEmail.getText().length() != 0
                        && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) {
                    etEmail.setError(getResources().getString(R.string.enter_valid_email));
                    hasError = true;
                }
                if (etShopName.getText().length() == 0) {
                    etShopName.setError(getResources().getString(R.string.enter_shop_name));
                    hasError = true;
                }
                if (etAddress.getText().length() == 0) {
                    etAddress.setError(getResources().getString(R.string.enter_address));
                    hasError = true;
                }

                if (hasError) {
                    if (progressDialog.isShowing())
                        progressDialog.dismiss();
                    return;
                }
                HashMap<String, String> params = new HashMap<>();
                params.put("authentication", AppGlobal.authentication);
                params.put("api_token", sharedPreferences.getString("api_token", ""));
                params.put("phone", etPhoneNumber.getText().toString());
                params.put("firstname", etFirstName.getText().toString());
                if (!etMiddleName.getText().toString().equals("")) {
                    params.put("middlename", etMiddleName.getText().toString());
                }
                params.put("lastname", etLastName.getText().toString());
                params.put("district_id", "1");
                params.put("area_id", String.valueOf(areaId));
                if (!etEmail.getText().toString().equals("")) {
                    params.put("email", etEmail.getText().toString());
                }
                if (!image.equals("")) {
                    params.put("image", image);
                }
                params.put("shopname", etShopName.getText().toString());
                params.put("address", etAddress.getText().toString());
                for (int i = 0; i < selectedProductIdList.size(); i++) {
                    params.put("products[" + i + "]", selectedProductIdList.get(i));
                }
                for (int i = 0; i < chosenBrandIdList.size(); i++) {
                    params.put("brands[" + i + "]", chosenBrandIdList.get(i));
                }
                updateUserInfo.parseData(params, "updateSupplierInfo");
            } else if (userType == AppGlobal.DRIVER) {
                boolean hasError = false;
                boolean hasPhoneNoError = false;
                boolean hasDrivingLicenseNoError = false;
                boolean hasNidNoError = false;
                if (etFirstName.getText().length() == 0) {
                    etFirstName.setError(getResources().getString(R.string.enter_first_name));
                    hasError = true;
                }
                if (etLastName.getText().length() == 0) {
                    etLastName.setError(getResources().getString(R.string.enter_last_name));
                    hasError = true;
                }
                if (etPhoneNumber.getText().length() == 0) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no));
                    hasError = true;
                    hasPhoneNoError = true;
                }
                if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no));
                    hasError = true;
                }
                if (etEmail.getText().length() != 0
                        && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) {
                    etEmail.setError(getResources().getString(R.string.enter_valid_email));
                    hasError = true;
                }

                if (etDrivingLicense.getText().length() == 0) {
                    etDrivingLicense.setError(getResources().getString(R.string.enter_driving_licence));
                    hasError = true;
                    hasDrivingLicenseNoError = true;
                }

                if (!hasDrivingLicenseNoError && etDrivingLicense.getText().length() != 15) {
                    etDrivingLicense.setError(getResources().getString(R.string.enter_valid_driving_licence));
                    hasError = true;
                }
                if (etNid.getText().length() == 0) {
                    etNid.setError(getResources().getString(R.string.enter_nid_no));
                    hasError = true;
                    hasNidNoError = true;
                }
                if (!hasNidNoError && etNid.getText().length() != 17) {
                    etNid.setError(getResources().getString(R.string.enter_valid_nid));
                    hasError = true;
                }

                if (etExperience.getText().length() == 0) {
                    etExperience.setError(getResources().getString(R.string.enter_year_of_experience));
                    hasError = true;
                }

                if (hasError) {
                    if (progressDialog.isShowing())
                        progressDialog.dismiss();
                    return;
                }
                HashMap<String, String> params = new HashMap<>();
                params.put("authentication", AppGlobal.authentication);
                params.put("api_token", sharedPreferences.getString("api_token", ""));
                params.put("phone", etPhoneNumber.getText().toString());
                params.put("firstname", etFirstName.getText().toString());
                if (!etMiddleName.getText().toString().equals("")) {
                    params.put("middlename", etMiddleName.getText().toString());
                }
                params.put("lastname", etLastName.getText().toString());
                params.put("drivinglicence", etDrivingLicense.getText().toString());
                params.put("nid", etNid.getText().toString());
                params.put("yearofexperience", etExperience.getText().toString());
                if (!etEmail.getText().toString().equals("")) {
                    params.put("email", etEmail.getText().toString());
                }
                if (!image.equals("")) {
                    params.put("image", image);
                }
                updateUserInfo.parseData(params, "updateDriverInfo");
            } else if (userType == AppGlobal.SHOP_WORKER) {
                boolean hasError = false;
                boolean hasPhoneNoError = false;
                if (etFirstName.getText().length() == 0) {
                    etFirstName.setError(getResources().getString(R.string.enter_first_name));
                    hasError = true;
                }
                if (etLastName.getText().length() == 0) {
                    etLastName.setError(getResources().getString(R.string.enter_last_name));
                    hasError = true;
                }
                if (etPhoneNumber.getText().length() == 0) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no));
                    hasError = true;
                    hasPhoneNoError = true;
                }
                if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) {
                    etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no));
                    hasError = true;
                }
                if (etEmail.getText().length() != 0
                        && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) {
                    etEmail.setError(getResources().getString(R.string.enter_valid_email));
                    hasError = true;
                }

                if (etNid.getText().length() == 0) {
                    etNid.setError(getResources().getString(R.string.enter_nid_no));
                    hasError = true;
                }

                if (etShopName.getText().length() == 0) {
                    etShopName.setError(getResources().getString(R.string.enter_shop_name));
                    hasError = true;
                }

                if (hasError) {
                    if (progressDialog.isShowing())
                        progressDialog.dismiss();
                    return;
                }
                HashMap<String, String> params = new HashMap<>();
                params.put("authentication", AppGlobal.authentication);
                params.put("api_token", sharedPreferences.getString("api_token", ""));
                params.put("phone", etPhoneNumber.getText().toString());
                params.put("firstname", etFirstName.getText().toString());
                if (!etMiddleName.getText().toString().equals("")) {
                    params.put("middlename", etMiddleName.getText().toString());
                }
                params.put("lastname", etLastName.getText().toString());
                params.put("nid", etNid.getText().toString());
                params.put("shopname", etShopName.getText().toString());
                if (!etEmail.getText().toString().equals("")) {
                    params.put("email", etEmail.getText().toString());
                }
                if (!image.equals("")) {
                    params.put("image", image);
                }
                updateUserInfo.parseData(params, "updateWorkerInfo");
            }
        }
    });
}

From source file:com.afeng.xf.widget.snackbarlight.Light.java

/**
 * Make a customized {@link Snackbar} to display a message without any action.
 * Method {@link Light#make(View, CharSequence, Drawable, int, int, int, Drawable, int) }
 *
 * @param view The view to find a parent from.
 * @param text The message to display. Formatted text is supported.
 * @param textIconRes The left icon of the message. Drawable resource id required.
 * @param backgroundColorRes The background color of the Snackbar. Color resource id required.
 * @param textColorRes The color of action message text. Color resource id required.
 * @param duration How long to show the message.
 *                 Either {@link Light#LENGTH_SHORT} or {@link Light#LENGTH_LONG}.
 * @param actionIconRes The left icon of action message text. Drawable resource id required.
 * @param actionTextColorRes The color of action message text. Color resource id required.
 *
 * @return The customized Snackbar that will be displayed.
 *//*from  ww w. ja v a 2  s .co  m*/
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, @DrawableRes int textIconRes,
        @ColorRes int backgroundColorRes, @ColorRes int textColorRes, int duration,
        @DrawableRes int actionIconRes, @ColorRes int actionTextColorRes) {
    Context context = view.getContext();
    return make(view, text,
            // DO NOT use the resource id directly.
            // It should be a resolved drawable or color.
            ContextCompat.getDrawable(context, textIconRes),
            // getResources().getColor() is deprecated.
            ContextCompat.getColor(context, backgroundColorRes), ContextCompat.getColor(context, textColorRes),
            duration, ContextCompat.getDrawable(context, actionIconRes),
            ContextCompat.getColor(context, actionTextColorRes));
}

From source file:android.support.v7.widget.SuggestionsAdapter.java

/**
 * Gets a drawable given a value provided by a suggestion provider.
 *
 * This value could be just the string value of a resource id
 * (e.g., "2130837524"), in which case we will try to retrieve a drawable from
 * the provider's resources. If the value is not an integer, it is
 * treated as a Uri and opened with// w  w w . ja  va 2s.  co m
 * {@link ContentResolver#openOutputStream(android.net.Uri, String)}.
 *
 * All resources and URIs are read using the suggestion provider's context.
 *
 * If the string is not formatted as expected, or no drawable can be found for
 * the provided value, this method returns null.
 *
 * @param drawableId a string like "2130837524",
 *        "android.resource://com.android.alarmclock/2130837524",
 *        or "content://contacts/photos/253".
 * @return a Drawable, or null if none found
 */
private Drawable getDrawableFromResourceValue(String drawableId) {
    if (drawableId == null || drawableId.length() == 0 || "0".equals(drawableId)) {
        return null;
    }
    try {
        // First, see if it's just an integer
        int resourceId = Integer.parseInt(drawableId);
        // It's an int, look for it in the cache
        String drawableUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + mProviderContext.getPackageName()
                + "/" + resourceId;
        // Must use URI as cache key, since ints are app-specific
        Drawable drawable = checkIconCache(drawableUri);
        if (drawable != null) {
            return drawable;
        }
        // Not cached, find it by resource ID
        drawable = ContextCompat.getDrawable(mProviderContext, resourceId);
        // Stick it in the cache, using the URI as key
        storeInIconCache(drawableUri, drawable);
        return drawable;
    } catch (NumberFormatException nfe) {
        // It's not an integer, use it as a URI
        Drawable drawable = checkIconCache(drawableId);
        if (drawable != null) {
            return drawable;
        }
        Uri uri = Uri.parse(drawableId);
        drawable = getDrawable(uri);
        storeInIconCache(drawableId, drawable);
        return drawable;
    } catch (Resources.NotFoundException nfe) {
        // It was an integer, but it couldn't be found, bail out
        Log.w(LOG_TAG, "Icon resource not found: " + drawableId);
        return null;
    }
}

From source file:com.grarak.kerneladiutor.activities.NavigationActivity.java

private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();/*from  w  w w.ja va  2 s. c  om*/
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED && Prefs.getBoolean("section_icons", false, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable
                                : R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled", true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) : lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}

From source file:com.google.android.apps.santatracker.presentquest.MapsActivity.java

private void setUserProgress() {
    // Set level text
    ((TextView) findViewById(R.id.text_current_level)).setText(String.valueOf(mUser.getLevel()));

    // Set level progress
    ((ProgressBar) findViewById(R.id.progress_level)).setProgress(mUser.getLevelProgress());

    // Set avatar image
    mAvatarView.setImageDrawable(ContextCompat.getDrawable(this, mUser.getAvatar()));

    // Set bag fullness in text and image
    int percentFull = mUser.getBagFillPercentage();
    int bagImageId;
    if (percentFull >= 100) {
        bagImageId = R.drawable.bag_6;/*from  w w w .ja v a 2 s.c  om*/
    } else if (percentFull >= 75) {
        bagImageId = R.drawable.bag_5;
    } else if (percentFull >= 50) {
        bagImageId = R.drawable.bag_4;
    } else if (percentFull >= 25) {
        bagImageId = R.drawable.bag_3;
    } else if (percentFull > 0) {
        bagImageId = R.drawable.bag_2;
    } else {
        bagImageId = R.drawable.bag_1;
    }

    // Show fullness as percentage (0 to 100%)
    String percentString = String.valueOf(percentFull) + "%";
    ((TextView) findViewById(R.id.text_bag_level)).setText(percentString);

    // Show fullness image
    mBagView.setImageResource(bagImageId);

    // Pulse the bag if it's 100% full
    if (percentFull >= 100) {
        mBagAnimator.start();
    } else {
        mBagAnimator.stop();
    }
}

From source file:com.filemanager.free.activities.MainActivity.java

/**
 * Called when the activity is first created.
 *///from  www.j av a 2  s.c om
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initialisePreferences();
    DataUtils.registerOnDataChangedListener(this);
    setContentView(R.layout.main_toolbar);
    initialiseViews();
    context = this;
    tabHandler = new TabHandler(this, null, null, 1);
    utils = new Futils();

    mainActivityHelper = new MainActivityHelper(this);
    initialiseFab();

    history = new HistoryManager(this, "Table2");
    history.initializeTable(DataUtils.HISTORY, 0);
    history.initializeTable(DataUtils.HIDDEN, 0);
    grid = new HistoryManager(this, "listgridmodes");
    grid.initializeTable(DataUtils.LIST, 0);
    grid.initializeTable(DataUtils.GRID, 0);
    grid.initializeTable(DataUtils.BOOKS, 1);
    grid.initializeTable(DataUtils.DRIVE, 1);
    grid.initializeTable(DataUtils.SMB, 1);

    if (!Sp.getBoolean("booksadded", false)) {
        grid.make(DataUtils.BOOKS);
        Sp.edit().putBoolean("booksadded", true).commit();
    }
    DataUtils.setHiddenfiles(history.readTable(DataUtils.HIDDEN));
    DataUtils.setGridfiles(grid.readTable(DataUtils.GRID));
    DataUtils.setListfiles(grid.readTable(DataUtils.LIST));
    // initialize g+ api client as per preferences
    if (Sp.getBoolean("plus_pic", false)) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Plus.API)

                .addScope(Plus.SCOPE_PLUS_LOGIN).build();
    }

    util = new IconUtils(Sp, this);
    icons = new IconUtils(Sp, this);

    timer = new CountDownTimer(5000, 1000) {
        @Override
        public void onTick(long l) {
        }

        @Override
        public void onFinish() {
            utils.crossfadeInverse(buttons, pathbar);
        }
    };
    path = getIntent().getStringExtra("path");
    openprocesses = getIntent().getBooleanExtra("openprocesses", false);
    try {
        intent = getIntent();
        if (intent.getStringArrayListExtra("failedOps") != null) {
            ArrayList<BaseFile> failedOps = intent.getParcelableArrayListExtra("failedOps");
            if (failedOps != null) {
                mainActivityHelper.showFailedOperationDialog(failedOps, intent.getBooleanExtra("move", false),
                        this);
            }
        }
        if (intent.getAction() != null)
            if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) {

                // file picker intent
                mReturnIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) {
                // ringtone picker intent
                mReturnIntent = true;
                mRingtonePickerIntent = true;
                Toast.makeText(this, utils.getString(con, R.string.pick_a_file), Toast.LENGTH_LONG).show();
            } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {

                // zip viewer intent
                Uri uri = intent.getData();
                openzip = true;
                zippath = uri.toString();
            }
    } catch (Exception ignored) {

    }
    updateDrawer();
    if (savedInstanceState == null) {

        if (openprocesses) {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.content_frame, new ProcessViewer());
            //   transaction.addToBackStack(null);
            select = 102;
            openprocesses = false;
            //title.setText(utils.getString(con, R.string.process_viewer));
            //Commit the transaction
            transaction.commit();
            supportInvalidateOptionsMenu();
        } else {
            if (path != null && path.length() > 0) {
                HFile file = new HFile(HFile.UNKNOWN, path);
                file.generateMode(this);
                if (file.isDirectory())
                    goToMain(path);
                else {
                    goToMain("");
                    utils.openFile(new File(path), this);
                }
            } else {
                goToMain("");

            }
        }
    } else {
        COPY_PATH = savedInstanceState.getParcelableArrayList("COPY_PATH");
        MOVE_PATH = savedInstanceState.getParcelableArrayList("MOVE_PATH");
        oppathe = savedInstanceState.getString("oppathe");
        oppathe1 = savedInstanceState.getString("oppathe1");
        oparrayList = savedInstanceState.getParcelableArrayList("oparrayList");
        operation = savedInstanceState.getInt("operation");
        select = savedInstanceState.getInt("selectitem", 0);
        adapter.toggleChecked(select);
    }
    if (theme1 == 1) {
        mDrawerList.setBackgroundColor(ContextCompat.getColor(this, R.color.holo_dark_background));
    }
    mDrawerList.setDivider(null);
    if (!isDrawerLocked) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open,
                R.string.drawer_close) {
            public void onDrawerClosed(View view) {
                mainActivity.onDrawerClosed();
            }

            public void onDrawerOpened(View drawerView) {
                //title.setText("Amaze File Manager");
                // creates call to onPrepareOptionsMenu()
            }
        };
        mDrawerLayout.addDrawerListener(mDrawerToggle);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_drawer_l);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
        }
        mDrawerToggle.syncState();
    }

    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_drawer_l);
    }
    //recents header color implementation
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(con, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }

    //search
    searchView();
    //admob
    mInterstitialAd = new InterstitialAd(this);
    // set the ad unit ID
    mInterstitialAd.setAdUnitId("ca-app-pub-2257698129050878/4313141545");
    requestNewInterstitial();
}