Example usage for android.graphics.drawable ColorDrawable ColorDrawable

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

Introduction

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

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.crisFiApps.ubuntufourclocks.activities.Donations.java

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

    setContentView(R.layout.donations);//  w  ww.  j a v a2  s . com

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    DonationsFragment donationsFragment;
    if (BuildConfig.DONATIONS_GOOGLE) {
        donationsFragment = DonationsFragment.newInstance(BuildConfig.DEBUG, true, GOOGLE_PUBKEY,
                GOOGLE_CATALOG, getResources().getStringArray(R.array.donation_google_catalog_values), false,
                null, null, null, false, null, null, false, null);
    }
    ft.replace(R.id.donations_activity_container, donationsFragment, "donationsFragment");
    ft.commit();
    //En versiones superiores a Honeycomb se colorea actionbar con color Ubuntu
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setBackgroundDrawable(new ColorDrawable(Color.rgb(135, 54, 79)));
        }
    }
}

From source file:com.lee.sdk.widget.viewpager.PointPageIndicator.java

/**
 * Initialize//ww  w . ja v a2 s . co  m
 * 
 * @param context context
 */
private void init(Context context) {
    setPointSize(DensityUtils.dip2px(context, 16));
    setPointMargin(DensityUtils.dip2px(context, 10));
    setPointDrawable(new ColorDrawable(Color.WHITE), new ColorDrawable(Color.RED));
}

From source file:com.imagersliderlib.adapter.ImagePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup view, int position) {
    View imageLayout = inflater.inflate(R.layout.image_pager_layout, view, false);
    assert imageLayout != null;
    ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);

    // image loding progressbar
    final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);

    // image scale set
    imageView.setScaleType(ScaleType.FIT_XY);

    // init ImageLoader
    imageLoader = ImageLoader.getInstance();
    imageLoader.init(ImageLoaderConfiguration.createDefault(mContext));

    // ImageLoader set option
    options = new DisplayImageOptions.Builder().showImageForEmptyUri(new ColorDrawable(0xff6e6e6e))
            .showImageOnFail(new ColorDrawable(0xff6e6e6e)).showImageOnLoading(new ColorDrawable(0xff6e6e6e))
            .cacheInMemory(true).cacheOnDisk(true).build();

    imageLoader.displayImage(mImages.get(position), imageView, options, new SimpleImageLoadingListener() {
        @Override/*from  www  .  j  ava2  s .  c  om*/
        public void onLoadingStarted(String imageUri, View view) {
            spinner.setVisibility(View.VISIBLE);
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            String message = null;
            switch (failReason.getType()) {
            case IO_ERROR:
                message = "Input/Output error";
                break;
            case DECODING_ERROR:
                message = "Image can't be decoded";
                break;
            case NETWORK_DENIED:
                message = "Downloads are denied";
                break;
            case OUT_OF_MEMORY:
                message = "Out Of Memory error";
                break;
            case UNKNOWN:
                message = "Unknown error";
                break;
            }
            Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();

            spinner.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            spinner.setVisibility(View.GONE);
        }
    });

    view.addView(imageLayout, 0);
    return imageLayout;
}

From source file:com.linkedin.android.eventsapp.ProfileActivity.java

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

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);//from   w w w.ja v a  2 s .com
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentActivity.finish();
        }
    });

    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
        String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
        APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() {
            @Override
            public void onApiSuccess(ApiResponse apiResponse) {
                try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName = location != null && location.has("name") ? location.getString("name")
                            : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                        new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                        attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                } catch (JSONException e) {

                }

            }

            @Override
            public void onApiError(LIApiError apiError) {

            }
        });

        ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
        View viewOnLI = viewOnLIStub.inflate();
        Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
        viewOnLIButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(),
                        new DeepLinkListener() {
                            @Override
                            public void onDeepLinkSuccess() {

                            }

                            @Override
                            public void onDeepLinkError(LIDeepLinkError error) {

                            }
                        });
            }
        });
    } else {
        attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
}

From source file:com.example.giggle.oschina2.emoji.EmojiPageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    sGrid = new GridView(getActivity());
    sGrid.setNumColumns(KJEmojiConfig.COLUMNS);
    adapter = new EmojiGridAdapter(getActivity(), datas);
    sGrid.setAdapter(adapter);/*from  ww  w. j a  va 2s  .c om*/
    sGrid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EditText editText = (EditText) getActivity().findViewById(R.id.emoji_titile_input);
            if (listener != null) {
                listener.onEmojiClick((Emojicon) parent.getAdapter().getItem(position));
            }
            InputHelper.input2OSC(editText, (Emojicon) parent.getAdapter().getItem(position));
        }
    });
    sGrid.setSelector(new ColorDrawable(android.R.color.transparent));
    return sGrid;
}

From source file:com.brodev.socialapp.view.ImagePagerActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    ColorDrawable color = new ColorDrawable(Color.TRANSPARENT);
    color.setAlpha(128);//from  ww w  .j a v  a2 s .com
    getSupportActionBar().setBackgroundDrawable(color);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.ac_image_pager);

    File cacheDir = new File(this.getCacheDir(), "imgcachedir");
    if (!cacheDir.exists())
        cacheDir.mkdir();

    // phrase manager
    phraseManager = new PhraseManager(getApplicationContext());

    Bundle bundle = getIntent().getExtras();

    String[] imageUrls = bundle.getStringArray("image");
    String[] imagesId = bundle.getStringArray("photo_id");
    String[] HasLike = bundle.getStringArray("HasLike");
    String[] FeedisLike = bundle.getStringArray("FeedisLike");
    String[] Total_like = bundle.getStringArray("Total_like");
    String[] Total_comment = bundle.getStringArray("Total_comment");
    String[] Itemid = bundle.getStringArray("Itemid");
    String[] Type = bundle.getStringArray("Type");

    int pagerPosition = bundle.getInt("position", 0);

    if (savedInstanceState != null) {
        pagerPosition = savedInstanceState.getInt(STATE_POSITION);
    }

    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(this, imageUrls, imagesId, HasLike, FeedisLike, Total_like,
            Total_comment, Itemid, Type));

    pager.setOffscreenPageLimit(2);
    pager.setCurrentItem(pagerPosition);

    this.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
}

From source file:com.example.ibesteeth.git_keybordtest.emoji.EmojiPageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    sGrid = new GridView(getActivity());
    sGrid.setNumColumns(KJEmojiConfig.COLUMNS);
    adapter = new EmojiGridAdapter(getActivity(), datas);
    sGrid.setAdapter(adapter);//from   w  w w . j  a va  2s.c  om
    sGrid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EditText editText = (EditText) getActivity().findViewById(R.id.emoji_titile_input);
            if (listener != null) {
                listener.onEmojiClick((Emojicon) parent.getAdapter().getItem(position));
            }
            InputHelper.input2OSC(editText, (Emojicon) parent.getAdapter().getItem(position));
        }
    });
    sGrid.setSelector(new ColorDrawable(getActivity().getResources().getColor(R.color.transparet)));
    return sGrid;
}

From source file:com.example.pagerslidingtabstrip.MainActivity.java

private void changeColor(int newColor) {

    tabs.setIndicatorColor(newColor);//from w w  w  .  j av a2  s  . c om

    // change ActionBar color just if an ActionBar is available
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

        Drawable colorDrawable = new ColorDrawable(newColor);
        Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom);
        LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });

        if (oldBackground == null) {

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                ld.setCallback(drawableCallback);
            } else {

                getActionBar().setBackgroundDrawable(ld);
            }

        } else {

            TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });

            // workaround for broken ActionBarContainer drawable handling on
            // pre-API 17 builds
            // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
                td.setCallback(drawableCallback);
            } else {
                getActionBar().setBackgroundDrawable(td);
            }

            td.startTransition(200);

        }

        oldBackground = ld;

        // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler

    }

    currentColor = newColor;

}

From source file:com.igniva.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);/*from   www. ja v a 2s .  co  m*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(
            new ColorDrawable(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(
                (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
        if (colourednavigation)
            window.setNavigationBarColor(
                    (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));

    }
    selectItem(0);
}

From source file:com.lrhehe.android.common.share.ShareDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity());
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // may have proble to inject in a dialog fragment
    ViewUtils.inject(getActivity());/*from w  w w .  j  a va2s  .  c o  m*/
    afterViewsInflate(dialog);
    return dialog;
}