Java Code Examples for android.graphics.drawable.ColorDrawable

The following are top voted examples for showing how to use android.graphics.drawable.ColorDrawable. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Blockly   File: BasicFieldColorViewTest.java   Source Code and License 7 votes vote down vote up
@Test
public void testPopupWindowChangeColor() {
    mFieldColorView.performClick();
    final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow();
    final View popupWindowContentView = popupWindow.getContentView();
    assertThat(popupWindowContentView).isNotNull();

    // Reset color before test.
    mFieldColor.setColor(0);
    assertThat(mFieldColor.getColor()).isEqualTo(0);

    // Simulate click on the color panel.
    popupWindowContentView.onTouchEvent(
            MotionEvent.obtain(0 /* downTime */, 0 /* eventTime */, MotionEvent.ACTION_DOWN,
                    0f /* x */, 0f /* y */, 0 /* metaState */));

    // Verify both field and field view background have been set to correct color.
    final int expectedColour = 0xffffff;
    assertThat(mFieldColor.getColor())
            .isEqualTo(expectedColour);  // setColour() masks out alpha.
    assertThat(((ColorDrawable) mFieldColorView.getBackground()).getColor())
            .isEqualTo(BasicFieldColorView.ALPHA_OPAQUE | expectedColour);

    // Popup window should have disappeared.
    assertThat(popupWindow.isShowing()).isFalse();
}
 
Example 2
Project: GitHub   File: SingleRequestTest.java   Source Code and License 7 votes vote down vote up
@Test
public void testErrorDrawableIsSetOnLoadFailed() {
  Drawable expected = new ColorDrawable(Color.RED);

  MockTarget target = new MockTarget();

  harness.errorDrawable = expected;
  harness.target = target;
  SingleRequest<List> request = harness.getRequest();

  request.onLoadFailed(new GlideException("test"));

  assertEquals(expected, target.currentPlaceholder);
}
 
Example 3
Project: Espresso   File: AppNavigationTest.java   Source Code and License 6 votes vote down vote up
/**
 * A customized {@link Matcher} for testing that
 * if one color match the background color of current view.
 * @param backgroundColor A color int value.
 *
 * @return Match or not.
 */
public static Matcher<View> withBackgroundColor(final int backgroundColor) {
    return new TypeSafeMatcher<View>() {

        @Override
        public boolean matchesSafely(View view) {
            int color = ((ColorDrawable) view.getBackground().getCurrent()).getColor();
            return color == backgroundColor;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("with background color value: " + backgroundColor);
        }
    };
}
 
Example 4
Project: mine-android-repository   File: MenuPopupWindow.java   Source Code and License 6 votes vote down vote up
public MenuPopupWindow(Activity context, OnItemClickListener mListener){
    LayoutInflater inflater = LayoutInflater.from(context);
    view = inflater.inflate(R.layout.layout_popup_menu, null);
    this.mListener = mListener;
    this.setContentView(view);
    this.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    //设置SelectPicPopupWindow弹出窗体的高
    this.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
    //设置SelectPicPopupWindow弹出窗体可点击
    this.setFocusable(false);
    this.setOutsideTouchable(true);
    this.setBackgroundDrawable(new ColorDrawable(0x00000000));

    view.findViewById(R.id.lay_share).setOnClickListener(this);
    view.findViewById(R.id.lay_inform).setOnClickListener(this);
}
 
Example 5
Project: Autocomplete   File: MainActivity.java   Source Code and License 6 votes vote down vote up
private void setupUserAutocomplete() {
    EditText edit = (EditText) findViewById(R.id.single);
    float elevation = 6f;
    Drawable backgroundDrawable = new ColorDrawable(Color.WHITE);
    AutocompletePresenter<User> presenter = new UserPresenter(this);
    AutocompleteCallback<User> callback = new AutocompleteCallback<User>() {
        @Override
        public boolean onPopupItemClicked(Editable editable, User item) {
            editable.clear();
            editable.append(item.getFullname());
            return true;
        }

        public void onPopupVisibilityChanged(boolean shown) {}
    };

    userAutocomplete = Autocomplete.<User>on(edit)
            .with(elevation)
            .with(backgroundDrawable)
            .with(presenter)
            .with(callback)
            .build();
}
 
Example 6
Project: GitHub   File: SingleRequestTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testErrorDrawableSetOnNullModelWithErrorDrawable() {
  Drawable placeholder = new ColorDrawable(Color.RED);
  Drawable errorPlaceholder = new ColorDrawable(Color.GREEN);

  MockTarget target = new MockTarget();

  harness.placeholderDrawable = placeholder;
  harness.errorDrawable = errorPlaceholder;
  harness.target = target;
  harness.model = null;
  SingleRequest<List> request = harness.getRequest();

  request.begin();

  assertEquals(errorPlaceholder, target.currentPlaceholder);
}
 
Example 7
Project: MainCalendar   File: FilePicker.java   Source Code and License 6 votes vote down vote up
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setBackgroundColor(Color.WHITE);
    rootLayout.setOrientation(LinearLayout.VERTICAL);
    ListView listView = new ListView(activity);
    listView.setBackgroundColor(Color.WHITE);
    listView.setDivider(new ColorDrawable(0xFFDDDDDD));
    listView.setDividerHeight(1);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setSelector(R.color.itemSelected);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(this);
    rootLayout.addView(listView);
    return rootLayout;
}
 
Example 8
Project: MyCalendar   File: CancelListActivity.java   Source Code and License 6 votes vote down vote up
private void initView() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
    }
    mCoordinatorLayout = findViewById(R.id.coordinator);

    RecyclerView recyclerView = findViewById(R.id.recycle_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    mAdapter = new CancelAdapter(this, new ArrayList<DayLesson>());
    @SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
    recyclerView.setAdapter(animatorAdapter);

    ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
    ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
    touchHelper.attachToRecyclerView(recyclerView);

    mView_FABMenu = findViewById(R.id.fab_menu_1);
    mView_FABMenu.setVisibility(View.GONE);
}
 
Example 9
Project: simple-share-android   File: SettingsActivity.java   Source Code and License 6 votes vote down vote up
public void changeActionBarColor(int newColor) {

		int color = newColor != 0 ? newColor : SettingsActivity.getPrimaryColor(this);
		Drawable colorDrawable = new ColorDrawable(color);

		if (oldBackground == null) {
            getSupportActionBar().setBackgroundDrawable(colorDrawable);

        } else {
			TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable });
            getSupportActionBar().setBackgroundDrawable(td);
			td.startTransition(200);
		}

		oldBackground = colorDrawable;
	}
 
Example 10
Project: Mix   File: TintManager.java   Source Code and License 6 votes vote down vote up
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) {
    if (view == null || drawable == null) return;
    if (tint.mHasTintList || tint.mHasTintMode) {
        drawable.mutate();
        if (drawable instanceof ColorDrawable) {
            ((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor())));
        } else {
            drawable.setColorFilter(createTintFilter(view.getContext(),
                    tint.mHasTintList ? tint.mTintList : null,
                    tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE,
                    view.getDrawableState()));
        }
    } else {
        drawable.clearColorFilter();
    }

    if (Build.VERSION.SDK_INT <= 23) {
        // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter
        // has changed, so we need to force an invalidation
        drawable.invalidateSelf();
    }
}
 
Example 11
Project: android_nextgis_mobile   File: StyledDialogFragment.java   Source Code and License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}
 
Example 12
Project: MobileAppForPatient   File: GuiUtils.java   Source Code and License 6 votes vote down vote up
public static Dialog showConfirmDialog(Activity activity, boolean cancelable, String title, String message,
           final CustomAlertOnClickListener backHandler) {

       Dialog dialog = new Dialog(activity, R.style.CustomDialog);
       dialog.setContentView(R.layout.confirm_dialog);
       dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
       dialog.setCancelable(cancelable);

       TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_title);
       TextView tvContent = (TextView) dialog.findViewById(R.id.tv_content);
       Button btnBack = (Button) dialog.findViewById(R.id.btn_confirm);

       if (!TextUtils.isEmpty(title)) {
           tvTitle.setText(title);
       }
       tvContent.setText(message);

       dialog.show();

       final Dialog inDialog = dialog;
       btnBack.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               if (backHandler != null) {
                   backHandler.onClick(inDialog, v);
               }
           }
       });

       return dialog;
}
 
Example 13
Project: quickhybrid-android   File: ActionSheet.java   Source Code and License 6 votes vote down vote up
public Attributes(Context context) {
    mContext = context;
    this.background = new ColorDrawable(Color.TRANSPARENT);
    this.cancelButtonBackground = new ColorDrawable(Color.BLACK);
    ColorDrawable gray = new ColorDrawable(Color.GRAY);
    this.otherButtonTopBackground = gray;
    this.otherButtonMiddleBackground = gray;
    this.otherButtonBottomBackground = gray;
    this.otherButtonSingleBackground = gray;
    this.cancelButtonTextColor = Color.WHITE;
    this.otherButtonTextColor = Color.BLACK;
    this.padding = dp2px(20);
    this.otherButtonSpacing = dp2px(2);
    this.cancelButtonMarginTop = dp2px(10);
    this.actionSheetTextSize = dp2px(16);
}
 
Example 14
Project: chromium-for-android-56-debug-video   File: ChromeActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void finishNativeInitialization() {
    // The window background color is used as the resizing background color in Android N+
    // multi-window mode. See crbug.com/602366.
    if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        getWindow().setBackgroundDrawable(new ColorDrawable(
                ApiCompatibilityUtils.getColor(getResources(),
                        R.color.resizing_background_color)));
    } else {
        removeWindowBackground();
    }
    DownloadManagerService.getDownloadManagerService(
            getApplicationContext()).onActivityLaunched();

    super.finishNativeInitialization();
}
 
Example 15
Project: OSchina_resources_android   File: ImageFolderPopupWindow.java   Source Code and License 6 votes vote down vote up
@SuppressLint("InflateParams")
 ImageFolderPopupWindow(Context context, Callback callback) {
    super(LayoutInflater.from(context).inflate(R.layout.popup_window_folder, null),
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    mCallback = callback;

    // init
    setAnimationStyle(R.style.popup_anim_style_alpha);
    setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    setOutsideTouchable(true);
    setFocusable(true);

    // content
    View content = getContentView();
    content.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    content.addOnAttachStateChangeListener(this);

    mFolderView = (RecyclerView) content.findViewById(R.id.rv_popup_folder);
    mFolderView.setLayoutManager(new LinearLayoutManager(context));

}
 
Example 16
Project: EosCommander   File: BaseDialog.java   Source Code and License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // the content
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getContext());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    if (dialog.getWindow() != null) {
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.getWindow().setLayout(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}
 
Example 17
Project: GitHub   File: BaseDialog.java   Source Code and License 6 votes vote down vote up
private void initDialog() {
    contentLayout = new FrameLayout(activity);
    contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    contentLayout.setFocusable(true);
    contentLayout.setFocusableInTouchMode(true);
    //contentLayout.setFitsSystemWindows(true);
    dialog = new Dialog(activity);
    dialog.setCanceledOnTouchOutside(false);//触摸屏幕取消窗体
    dialog.setCancelable(false);//按返回键取消窗体
    dialog.setOnKeyListener(this);
    dialog.setOnDismissListener(this);
    Window window = dialog.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //AndroidRuntimeException: requestFeature() must be called before adding content
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(contentLayout);
    }
    setSize(screenWidthPixels, WRAP_CONTENT);
}
 
Example 18
Project: PowerMenu   File: PowerMenuUtils.java   Source Code and License 6 votes vote down vote up
public static CustomPowerMenu getWritePowerMenu(Context context, LifecycleOwner lifecycleOwner, OnMenuItemClickListener onMenuItemClickListener) {
    ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(R.color.md_blue_grey_300));
    return new CustomPowerMenu.Builder<>(context, new CenterMenuAdapter())
            .addItem("Novel")
            .addItem("Poetry")
            .addItem("Art")
            .addItem("Journals")
            .addItem("Travel")
            .setLifecycleOwner(lifecycleOwner)
            .setAnimation(MenuAnimation.FADE)
            .setMenuRadius(10f)
            .setMenuShadow(10f)
            .setDivider(drawable)
            .setDividerHeight(1)
            .setOnMenuItemClickListener(onMenuItemClickListener)
            .build();
}
 
Example 19
Project: aos-Video   File: BrowserByShow.java   Source Code and License 6 votes vote down vote up
@Override
protected void setColor(int color) {

    int darkColor = VideoInfoCommonClass.getDarkerColor(color);
    ColorDrawable[] colord = {new ColorDrawable(mLastColor), new ColorDrawable(darkColor)};
    TransitionDrawable trans = new TransitionDrawable(colord);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        mApplicationFrameLayout.setBackground(trans);
    else
        mApplicationFrameLayout.setBackgroundDrawable(trans);
    trans.startTransition(200);
    mLastColor = darkColor;
    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
        getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getActivity().getWindow().setStatusBarColor(VideoInfoCommonClass.getAlphaColor(darkColor, 160));
    }

}
 
Example 20
Project: GitHub   File: DrawableTransformationTest.java   Source Code and License 6 votes vote down vote up
@Test
public void load_withColorDrawable_fixedSize_functionalBitmapTransform_doesNotRecycleOutput()
    throws ExecutionException, InterruptedException {
  Drawable colorDrawable = new ColorDrawable(Color.RED);

  int width = 100;
  int height = 200;

  Drawable result = GlideApp.with(context)
      .load(colorDrawable)
      .circleCrop()
      .override(width, height)
      .submit()
      .get();

   BitmapSubject.assertThat(result).isNotRecycled();

  BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  // Make sure we didn't put the same Bitmap twice.
  Bitmap first = bitmapPool.get(width, height, Config.ARGB_8888);
  Bitmap second = bitmapPool.get(width, height, Config.ARGB_8888);

  assertThat(first).isNotSameAs(second);
}
 
Example 21
Project: TheNounProject   File: BaseDialog.java   Source Code and License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getContext());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    if (dialog.getWindow() != null) {
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog.getWindow().setLayout(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
 
Example 22
Project: silly-android   File: Coloring.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a new drawable (implementation of the Drawable object may vary depending on the OS version).
 * The result Drawable will be colored with the given color, and clipped to match the given bounds.
 * Note that the drawable's alpha is set to 0 when argument color is {@link Color#TRANSPARENT}.
 *
 * @param color  Integer color used to color the output drawable
 * @param bounds Four-dimensional vector representing drawable bounds
 * @return Colored and clipped drawable object
 */
@NonNull
public static Drawable createColoredDrawable(@ColorInt final int color, @Nullable final Rect bounds) {
    // create the drawable depending on the OS (pre-Honeycomb couldn't use color drawables inside state lists)
    Drawable drawable;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || bounds != null) {
        drawable = new GradientDrawable(Orientation.BOTTOM_TOP, new int[] { color, color }).mutate();
    } else {
        drawable = new ColorDrawable(color).mutate();
    }

    // set the alpha value
    if (color == Color.TRANSPARENT) {
        drawable.setAlpha(0);
    }

    // update bounds
    if (bounds != null) {
        drawable.setBounds(bounds);
    }
    return drawable;
}
 
Example 23
Project: MiPushFramework   File: EntityHeaderController.java   Source Code and License 6 votes vote down vote up
public EntityHeaderController styleActionBar(AppCompatActivity activity) {
    if (activity == null) {
        Log.w(TAG, "No activity, cannot style actionbar.");
        return this;
    }
    final ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar == null) {
        Log.w(TAG, "No actionbar, cannot style actionbar.");
        return this;
    }
    actionBar.setBackgroundDrawable(
            new ColorDrawable(Utils.getColorAttr(activity, R.attr.colorSettings)));
    actionBar.setElevation(0);
    //if (mRecyclerView != null && mLifecycle != null) {
    //    ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
    //}

    return this;
}
 
Example 24
Project: Quiz-Game   File: MainGameActivity.java   Source Code and License 5 votes vote down vote up
public void correctDialog() {
    final Dialog dialogCorrect = new Dialog(MainGameActivity.this);
    dialogCorrect.requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (dialogCorrect.getWindow() != null) {
        ColorDrawable colorDrawable = new ColorDrawable(Color.TRANSPARENT);
        dialogCorrect.getWindow().setBackgroundDrawable(colorDrawable);
    }
    dialogCorrect.setContentView(R.layout.dialog_correct);
    dialogCorrect.setCancelable(false);
    dialogCorrect.show();

    //Since the dialog is show to user just pause the timer in background
    onPause();


    TextView correctText = (TextView) dialogCorrect.findViewById(R.id.correctText);
    FButton buttonNext = (FButton) dialogCorrect.findViewById(R.id.dialogNext);

    //Setting type faces
    correctText.setTypeface(sb);
    buttonNext.setTypeface(sb);

    //OnCLick listener to go next que
    buttonNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //This will dismiss the dialog
            dialogCorrect.dismiss();
            //it will increment the question number
            qid++;
            //get the que and 4 option and store in the currentQuestion
            currentQuestion = list.get(qid);
            //Now this method will set the new que and 4 options
            updateQueAndOptions();
            //reset the color of buttons back to white
            resetColor();
            //Enable button - remember we had disable them when user ans was correct in there particular button methods
            enableButton();
        }
    });
}
 
Example 25
Project: Mobike   File: PicViewerPage.java   Source Code and License 5 votes vote down vote up
public void onCreate() {
	activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));

	sivViewer = new ScaledImageView(activity);
	sivViewer.setScaleType(ScaleType.MATRIX);
	activity.setContentView(sivViewer);
	if (pic != null) {
		sivViewer.getViewTreeObserver().addOnGlobalLayoutListener(this);
	}
}
 
Example 26
Project: buildAPKsApps   File: GraphListView.java   Source Code and License 5 votes vote down vote up
public GraphListView(Context ctx) {
  super(ctx);
  setCacheColorHint(0xFFFFFFFF);
  setBackgroundColor(0xFFFFFFFF);
  setDivider(new ColorDrawable(0xFF898989));
  setDividerHeight(1);
  db_ = SeismoDbAdapter.getAdapter();
  db_.open(ctx);
  graph_names_ = db_.fetchGraphNames();
  adapter_ = new ArrayAdapter<String>(ctx, R.layout.export, graph_names_);
  setAdapter(adapter_);
  db_.close();
}
 
Example 27
Project: AdaptiveTableLayout   File: SettingsDialog.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    //noinspection ConstantConditions
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    View view = inflater.inflate(R.layout.dialog_settings, container, false);
    swSolidRow = (SwitchCompat) view.findViewById(R.id.swSolidRow);
    swFixedHeaders = (SwitchCompat) view.findViewById(R.id.swFixedHeaders);
    swRtlDirection = (SwitchCompat) view.findViewById(R.id.swRtlDirection);
    swDragAndDropEnabled = (SwitchCompat) view.findViewById(R.id.swDragAndDropEnabled);

    return view;
}
 
Example 28
Project: sealtalk-android-master   File: ContactDetailActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.rc_ac_contact_detail);
    getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    initView();
    initData();
}
 
Example 29
Project: Watermark   File: BucketAdapter.java   Source Code and License 5 votes vote down vote up
public BucketAdapter(
        List<BucketBean> bucketList,
        Configuration configuration,
        @ColorInt int color) {
    this.mBucketList = bucketList;
    this.mConfiguration = configuration;
    this.mDefaultImage = new ColorDrawable(color);
}
 
Example 30
Project: Logistics-guard   File: CircleImageView.java   Source Code and License 5 votes vote down vote up
private Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    try {
        Bitmap bitmap;

        if (drawable instanceof ColorDrawable) {
            bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
        } else {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
        }

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 31
Project: OneDrawable   File: OneDrawable.java   Source Code and License 5 votes vote down vote up
private static Drawable getUnableStateDrawable(Context context, @NonNull Drawable unable) {
    if (isKitkat() && !(unable instanceof ColorDrawable)) {
        return kitkatUnableDrawable(context, unable);
    }
    unable.setAlpha(convertAlphaToInt(0.5f));
    return unable;
}
 
Example 32
Project: MyFire   File: ImgSelFragment.java   Source Code and License 5 votes vote down vote up
private void createPopupFolderList(int width, int height) {
    folderPopupWindow = new ListPopupWindow(getActivity());
    folderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    folderPopupWindow.setAdapter(folderListAdapter);
    folderPopupWindow.setContentWidth(width);
    folderPopupWindow.setWidth(width);
    folderPopupWindow.setHeight(height);
    folderPopupWindow.setAnchorView(rlBottom);
    folderPopupWindow.setModal(true);
    folderListAdapter.setOnFloderChangeListener(new OnFolderChangeListener() {
        @Override
        public void onChange(int position, Folder folder) {
            folderPopupWindow.dismiss();
            if (position == 0) {
                getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
                btnAlbumSelected.setText("所有图片");
            } else {
                imageList.clear();
                if (config.needCamera)
                    imageList.add(new Image());
                imageList.addAll(folder.images);
                imageListAdapter.notifyDataSetChanged();

                btnAlbumSelected.setText(folder.name);
            }
        }
    });
}
 
Example 33
Project: qmui   File: QMUIRadiusImageView.java   Source Code and License 5 votes vote down vote up
private Bitmap getBitmap() {
    Drawable drawable = getDrawable();
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    try {
        Bitmap bitmap;

        if (drawable instanceof ColorDrawable) {
            bitmap = Bitmap.createBitmap(COLOR_DRAWABLE_DIMEN, COLOR_DRAWABLE_DIMEN, BITMAP_CONFIG);
        } else {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
        }

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 34
Project: android-mobile-engage-sdk   File: IamDialog.java   Source Code and License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    Window window = getDialog().getWindow();
    WindowManager.LayoutParams windowParams = window.getAttributes();
    windowParams.dimAmount = 0.0f;
    window.setAttributes(windowParams);

    getDialog().getWindow()
            .setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.MATCH_PARENT);
}
 
Example 35
Project: SmingZZick_App   File: AttackSettingActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);


    int headTextColor;
    if (Build.VERSION.SDK_INT >= 23) {
        headTextColor = getResources().getColor(R.color.setup_item_head_text, null);
    } else {
        headTextColor = getResources().getColor(R.color.setup_item_head_text);
    }

    toolbar.setTitleTextColor(headTextColor);
    setSupportActionBar(toolbar);

    int headColor;
    if (Build.VERSION.SDK_INT >= 23) {
        headColor = getResources().getColor(R.color.setup_item_head, null);
    } else {
        headColor = getResources().getColor(R.color.setup_item_head);
    }

    getSupportActionBar().setTitle("총공 설정");
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(headColor));
    getFragmentManager().beginTransaction()
            .replace(R.id.frame, new AttackSettingFragment())
            .commit();
}
 
Example 36
Project: boohee_v5.6   File: ChangeDateAndTimeTypeFragment.java   Source Code and License 5 votes vote down vote up
public void onStart() {
    super.onStart();
    Window window = getDialog().getWindow();
    LayoutParams params = window.getAttributes();
    params.gravity = 80;
    params.width = -1;
    params.height = DensityUtil.dip2px(getActivity(), 480.0f);
    window.setAttributes(params);
    window.setBackgroundDrawable(new ColorDrawable(0));
}
 
Example 37
Project: GitHub   File: DrawableCrossFadeViewAnimationTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testSetsTransitionDrawableIfPreviousIsNotNull() {
  Drawable previous = new ColorDrawable(Color.WHITE);
  when(harness.adapter.getCurrentDrawable()).thenReturn(previous);
  harness.animation.transition(harness.current, harness.adapter);

  verify(harness.adapter).setDrawable(any(TransitionDrawable.class));
}
 
Example 38
Project: privacyidea-authenticator   File: AboutActivity.java   Source Code and License 5 votes vote down vote up
private void setupActionBar() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Show the Up button in the action bar.
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(PIBLUE)));
    }
}
 
Example 39
Project: LQRWeChat   File: BubbleImageView.java   Source Code and License 5 votes vote down vote up
private Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    try {
        Bitmap bitmap;

        if (drawable instanceof ColorDrawable) {
            bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION,
                    COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
        } else {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                    drawable.getIntrinsicHeight(), BITMAP_CONFIG);
        }

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (OutOfMemoryError e) {
        return null;
    }
}
 
Example 40
Project: Linphone4Android   File: AssistantActivity.java   Source Code and License 5 votes vote down vote up
public void displayRemoteProvisioningInProgressDialog() {
	remoteProvisioningInProgress = true;

	progress = ProgressDialog.show(this, null, null);
	Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE));
	d.setAlpha(200);
	progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
	progress.getWindow().setBackgroundDrawable(d);
	progress.setContentView(R.layout.progress_dialog);
	progress.show();
}
 
Example 41
Project: CCDownload   File: PlayTopPopupWindow.java   Source Code and License 5 votes vote down vote up
public PlayTopPopupWindow(Context context, int height) {
	this.context = context;
	View view = LayoutInflater.from(context).inflate(R.layout.play_top_menu, null);
	
	rgSubtitle = findById(R.id.rg_subtitle, view);
	rgScreenSize = findById(R.id.rg_screensize, view);
	
	popupWindow = new PopupWindow(view, height * 2 / 3, height);
	popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0)));
}
 
Example 42
Project: boohee_v5.6   File: TopicActivity.java   Source Code and License 5 votes vote down vote up
private void initNotice() {
    if (this.mTopicNotice == null || this.mTopicNotice.size() == 0) {
        this.vfNotice.setVisibility(8);
        return;
    }
    int marginTop = 48;
    if (this.mTopic.choice) {
        marginTop = 56;
    } else {
        ((LayoutParams) this.vfNotice.getLayoutParams()).bottomMargin = 0;
    }
    this.mHeaderHeight += ViewUtils.dip2px(this.ctx, (float) marginTop);
    ViewCompat.setTranslationY(this.frameContent, (float) this.mHeaderHeight);
    this.vfNotice.removeAllViews();
    for (final TopicNotice notice : this.mTopicNotice) {
        View itemNotice = LayoutInflater.from(this).inflate(R.layout.jg, null);
        TextView title = (TextView) itemNotice.findViewById(R.id.tv_title);
        this.imageLoader.displayImage(notice.icon_url, (ImageView) itemNotice.findViewById(R
                .id.iv_icon), ImageLoaderOptions.global(new ColorDrawable(866805452)));
        title.setText(notice.title);
        itemNotice.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                BooheeScheme.handleUrl(TopicActivity.this.ctx, notice.url);
            }
        });
        this.vfNotice.addView(itemNotice);
    }
    this.vfNotice.setFlipInterval(BaseImageDownloader.DEFAULT_HTTP_CONNECT_TIMEOUT);
    this.vfNotice.startFlipping();
}
 
Example 43
Project: Auto.js   File: BubblePopupMenu.java   Source Code and License 5 votes vote down vote up
public BubblePopupMenu(Context context, List<String> options) {
    super(context);
    View view = View.inflate(context, R.layout.bubble_popup_menu, null);
    mLittleTriangle = view.findViewById(R.id.little_triangle);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.list);
    mRecyclerView.setAdapter(new SimpleRecyclerViewAdapter<>(R.layout.bubble_popup_menu_item, options, MenuItemViewHolder::new));
    setContentView(view);
    setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    setOutsideTouchable(true);
    setFocusable(true);
}
 
Example 44
Project: foco   File: MusicDialog.java   Source Code and License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    // request a window without the title and set background color
    // (thus the integration of old and new sdk versions is better)
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(
            new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorPrimary)));
    return dialog;
}
 
Example 45
Project: android-mvvm-architecture   File: CommonUtils.java   Source Code and License 5 votes vote down vote up
public static ProgressDialog showLoadingDialog(Context context) {
    ProgressDialog progressDialog = new ProgressDialog(context);
    progressDialog.show();
    if (progressDialog.getWindow() != null) {
        progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }
    progressDialog.setContentView(R.layout.progress_dialog);
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);
    return progressDialog;
}
 
Example 46
Project: Discover   File: CircleImageView.java   Source Code and License 5 votes vote down vote up
private Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    try {
        Bitmap bitmap;

        if (drawable instanceof ColorDrawable) {
            bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
        } else {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
        }

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 47
Project: Weather-Guru-MVP   File: AppUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Show loading progress
 */
public static ProgressDialog showLoadingDialog(Context context) {
  ProgressDialog progressDialog = new ProgressDialog(context);
  progressDialog.show();

  if (progressDialog.getWindow() != null) {
    progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  }
  progressDialog.setContentView(R.layout.dialog_progress);
  progressDialog.setIndeterminate(true);
  progressDialog.setCancelable(true);
  progressDialog.setCanceledOnTouchOutside(false);

  return progressDialog;
}
 
Example 48
Project: ThunderMusic   File: ThemeUtils.java   Source Code and License 5 votes vote down vote up
/**
 * As above but returning a ColorDrawable
 * Handy for actionbar for example
 *
 * @param context
 * @param Theme
 * @return
 */
public static Drawable getThemeDrawable(Context context, int Theme) {
    switch (Theme) {
        case 3:
            return new ColorDrawable(context.getResources().getColor(
                    R.color.google_dark_blue));
        case 1:
            return new ColorDrawable(context.getResources().getColor(
                    R.color.google_dark_blue));
        case 4:
            return new ColorDrawable(context.getResources().getColor(
                    android.R.color.black));
        case 5:
            return new ColorDrawable(context.getResources().getColor(
                    android.R.color.black));
        case 6:
            return new ColorDrawable(Color.parseColor("#"
                    + Integer.toHexString(
                    PreferenceManager.getDefaultSharedPreferences(
                            context).getInt(
                            PreferencesActivity.KEY_CUSTOM_THEME,
                            0xff4285f4)).substring(2)));
        case 7:
            return new ColorDrawable(Color.parseColor("#"
                    + Integer.toHexString(
                    PreferenceManager.getDefaultSharedPreferences(
                            context).getInt(
                            PreferencesActivity.KEY_CUSTOM_THEME,
                            0xff4285f4)).substring(2)));
    }
    return new ColorDrawable(context.getResources().getColor(
            android.R.color.transparent));
}
 
Example 49
Project: ForeverLibrary   File: ActionSheet.java   Source Code and License 5 votes vote down vote up
public ActionSheet(Context context) {
    super(context, android.R.style.Theme_Light_NoTitleBar);// 全屏
    this.mContext = context;
    initViews();
    getWindow().setGravity(Gravity.BOTTOM);
    Drawable drawable = new ColorDrawable();
    drawable.setAlpha(0);// 去除黑色背景
    getWindow().setBackgroundDrawable(drawable);
}
 
Example 50
Project: SimpleDialogFragments   File: SimpleColorWheelDialog.java   Source Code and License 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    try {
        int color = ((255 - mAlphaSlider.getProgress()) << 24)
                + (int) Long.parseLong(s.toString(), 16);
        mColorWheelView.setColor(color, false);
        mNew.setImageDrawable(new ColorDrawable(color));
    } catch (NumberFormatException ignored){}
}
 
Example 51
Project: WhatsAppStatusSaver   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void showHelpPopup(final Activity context) {
    // Inflate the popup_layout.xml
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.help_popup_layout);
    dialog.show();
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.copyFrom(dialog.getWindow().getAttributes());
    dialog.getWindow().setAttributes(lp);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.getWindow().setDimAmount(0);
    // Creating the PopupWindow

    // Clear the default translucent background

    // Displaying the popup at the specified location, + offsets.

    // Getting a reference to Close button, and close the popup when clicked.
    FloatingActionButton close = (FloatingActionButton) dialog.findViewById(R.id.close_help_popup_button);
    close.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.cancel();
        }
    });
}
 
Example 52
Project: fancyDialog   File: FancyAlertDialog.java   Source Code and License 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    if (builder != null) {
        dialog.setCancelable(builder.isCancelable());
        instance.setCancelable(builder.isCancelable());
    }

    return dialog;
}
 
Example 53
Project: Musicoco   File: BottomNavigationController.java   Source Code and License 5 votes vote down vote up
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {

    int[] cs = ColorUtils.get10ThemeColors(activity, themeEnum);

    int statusC = cs[0];
    int toolbarC = cs[1];
    int accentC = cs[2];
    int mainBC = cs[3];
    int vicBC = cs[4];
    int mainTC = cs[5];
    int vicTC = cs[6];
    int navC = cs[7];
    int toolbarMainTC = cs[8];
    int toolbarVicTC = cs[9];

    listViewsController.themeChange(themeEnum, cs);

    mContainer.setBackgroundColor(navC);
    mName.setTextColor(mainTC);
    mArts.setTextColor(vicTC);

    mPlay.setPauseLineColor(mainTC);
    mPlay.setSolidColor(mainTC);
    mPlay.setTriangleColor(mainTC);

    mProgress.setBackgroundColor(accentC);

    ColorDrawable cd = new ColorDrawable(vicBC);
    cd.setAlpha(200);
    mProgressBG.setBackground(cd);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mShowList.getDrawable().setTint(mainTC);
    }
}
 
Example 54
Project: CXJPadProject   File: SelectPicturePopupWindow.java   Source Code and License 5 votes vote down vote up
/**
 * 把一个View控件添加到PopupWindow上并且显示
 *
 * @param activity
 */
public void showPopupWindow(Activity activity) {
    popupWindow = new PopupWindow(mMenuView,    // 添加到popupWindow
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    // ☆ 注意: 必须要设置背景,播放动画有一个前提 就是窗体必须有背景
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.showAtLocation(activity.getWindow().getDecorView(), Gravity.CENTER | Gravity.BOTTOM, 0, 0);
    popupWindow.setAnimationStyle(android.R.style.Animation_InputMethod);   // 设置窗口显示的动画效果
    popupWindow.setFocusable(false);                                        // 点击其他地方隐藏键盘 popupWindow
    popupWindow.update();
}
 
Example 55
Project: LiuAGeAndroid   File: FriendAdapter.java   Source Code and License 5 votes vote down vote up
public FriendAdapter(FriendListPage activity, PullToRequestView view) {
	super(view);
	this.activity = activity;

	curPage = -1;
	hasNext = true;
	map = new HashMap<String, Boolean>();
	follows = new ArrayList<Following>();

	getListView().setDivider(new ColorDrawable(0xffeaeaea));
}
 
Example 56
Project: KUtils-master   File: Buildable.java   Source Code and License 5 votes vote down vote up
protected BuildBean buildCenterSheet(BuildBean bean) {
    AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
    SheetHolder holder = new SheetHolder(bean.mContext);
    builder.setView(holder.rootView);
    AlertDialog dialog = builder.create();
    bean.alertDialog = dialog;
    if (bean.isVertical && !TextUtils.isEmpty(bean.bottomTxt)) {
        Window window = dialog.getWindow();
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }
    holder.assingDatasAndEvents(bean.mContext, bean);
    return bean;
}
 
Example 57
Project: GitHub   File: BasePopupWindow.java   Source Code and License 5 votes vote down vote up
/**
 * 点击外部是否消失
 * <p>
 * dismiss popup when touch ouside from popup
 *
 * @param dismissWhenTouchOuside true for dismiss
 */
public void setDismissWhenTouchOuside(boolean dismissWhenTouchOuside) {
    this.dismissWhenTouchOuside = dismissWhenTouchOuside;
    if (dismissWhenTouchOuside) {
        //指定透明背景,back键相关
        mPopupWindow.setFocusable(true);
        mPopupWindow.setOutsideTouchable(true);
        mPopupWindow.setBackgroundDrawable(new ColorDrawable());
    } else {
        mPopupWindow.setFocusable(false);
        mPopupWindow.setOutsideTouchable(false);
        mPopupWindow.setBackgroundDrawable(null);
    }

}
 
Example 58
Project: PlusGram   File: DrawerProfileCell.java   Source Code and License 5 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    Drawable backgroundDrawable = ApplicationLoader.getCachedWallpaper();
    int color = ApplicationLoader.getServiceMessageColor();
    if (currentColor != color) {
        currentColor = color;
        shadowView.getDrawable().setColorFilter(new PorterDuffColorFilter(color | 0xff000000, PorterDuff.Mode.MULTIPLY));
    }
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    if (ApplicationLoader.isCustomTheme() && backgroundDrawable != null && !themePrefs.getBoolean("drawerHeaderBGCheck", false)) {
        phoneTextView.setTextColor(0xffffffff);
        int visible = INVISIBLE;
        if(!themePrefs.getBoolean("drawerHideBGShadowCheck", false)){
            visible = VISIBLE;
        }
        shadowView.setVisibility(visible);
        if (backgroundDrawable instanceof ColorDrawable) {
            backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            backgroundDrawable.draw(canvas);
        } else if (backgroundDrawable instanceof BitmapDrawable) {
            Bitmap bitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
            float scaleX = (float) getMeasuredWidth() / (float) bitmap.getWidth();
            float scaleY = (float) getMeasuredHeight() / (float) bitmap.getHeight();
            float scale = scaleX < scaleY ? scaleY : scaleX;
            int width = (int) (getMeasuredWidth() / scale);
            int height = (int) (getMeasuredHeight() / scale);
            int x = (bitmap.getWidth() - width) / 2;
            int y = (bitmap.getHeight() - height) / 2;
            srcRect.set(x, y, x + width, y + height);
            destRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
            canvas.drawBitmap(bitmap, srcRect, destRect, paint);
        }
    } else {
        shadowView.setVisibility(INVISIBLE);
        phoneTextView.setTextColor(0xffc2e5ff);
        super.onDraw(canvas);
    }
    updateTheme();
}
 
Example 59
Project: Hitalk   File: SideBar.java   Source Code and License 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    final int action = event.getAction();
    final float y = event.getY();// 点击y坐标
    final int oldChoose = choose;
    final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener;
    final int c = (int) (y / getHeight() * b.length);// 点击y坐标所占总高度的比例*b数组的长度就等于点击b中的个数.

    switch (action) {
        case MotionEvent.ACTION_UP:
            setBackgroundDrawable(new ColorDrawable(0x00000000));
            choose = -1;//
            invalidate();
            if (mTextDialog != null) {
                mTextDialog.setVisibility(View.INVISIBLE);
            }
            break;

        default:
            setBackgroundResource(R.drawable.sidebar_background);
            if (oldChoose != c) {
                if (c >= 0 && c < b.length) {
                    if (listener != null) {
                        listener.onTouchingLetterChanged(b[c]);
                    }
                    if (mTextDialog != null) {
                        mTextDialog.setText(b[c]);
                        mTextDialog.setVisibility(View.VISIBLE);
                    }

                    choose = c;
                    invalidate();
                }
            }

            break;
    }
    return true;
}
 
Example 60
Project: GitHub   File: DrawableTransformationTest.java   Source Code and License 5 votes vote down vote up
@Test
public void load_withColorDrawable_sizeOriginal_requiredTransform_fails()
    throws ExecutionException, InterruptedException {
  Drawable colorDrawable = new ColorDrawable(Color.RED);

  expectedException.expect(ExecutionException.class);
  Glide.with(context)
      .load(colorDrawable)
      .apply(new RequestOptions()
          .centerCrop())
      .submit()
      .get();
}