List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable
@Deprecated
public BitmapDrawable(java.io.InputStream is)
From source file:com.azcltd.android.test.kolesov.DrawableManager.java
private Drawable getThumbnail(Drawable image) { if (image != null) { Bitmap b = ((BitmapDrawable) image).getBitmap(); float coef = (float) b.getWidth() / (float) b.getHeight(); Bitmap bitmapResized = Bitmap.createScaledBitmap(b, (int) (100 * coef), 100, false); return new BitmapDrawable(bitmapResized); }/* w ww . j a v a2s.c o m*/ return null; }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
@SuppressWarnings("deprecation") public View billboardView(ImageView icon) { LinearLayout billboardLayout = new LinearLayout(context); LayoutParams layoutParams = null;/*from www. ja v a2 s. c om*/ if (bgImg != null) { billboardLayout.setBackgroundDrawable(new BitmapDrawable(bgImg)); layoutParams = new LayoutParams(UZCoreUtil.dipToPix(width), UZCoreUtil.dipToPix(height)); } else { billboardLayout.setBackgroundResource(UZResourcesIDFinder.getResDrawableID("mo_bmap_popupmap")); layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, UZCoreUtil.dipToPix(height)); } billboardLayout.setLayoutParams(layoutParams); billboardLayout.setOrientation(LinearLayout.HORIZONTAL); if (getIconAlign().equals("left")) { if (iconStr != null && !iconStr.isEmpty()) billboardLayout.addView(icon); billboardLayout.addView(titleLayout()); } else { billboardLayout.addView(titleLayout()); if (iconStr != null && !iconStr.isEmpty()) billboardLayout.addView(icon()); } return billboardLayout; }
From source file:com.campusconnect.GoogleSignInActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_google); rootView = (LinearLayout) findViewById(R.id.main_layout); BitmapFactory.Options bm_opts = new BitmapFactory.Options(); bm_opts.inScaled = false;/*from w ww . ja v a 2s.c o m*/ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.default_portrait_two, bm_opts); BitmapDrawable background = new BitmapDrawable(bitmap); rootView.setBackground(background); iv_branchProfileImage = (ImageView) findViewById(R.id.branch_profile_image); tv_branchUserName = (TextView) findViewById(R.id.branch_tv_username); try { String photourl = Branch.getInstance().getLatestReferringParams().getString("photourl"); if (photourl.isEmpty()) { iv_branchProfileImage.setImageResource(R.mipmap.ccnoti); } else { Picasso.with(GoogleSignInActivity.this).load(photourl).error(R.mipmap.ic_launcher) .memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE) .placeholder(R.mipmap.ccnoti).into(iv_branchProfileImage); } tv_branchUserName.setText(Branch.getInstance().getLatestReferringParams().getString("profileName") + " " + "is Waiting For You"); iv_branchProfileImage.setVisibility(View.VISIBLE); tv_branchUserName.setVisibility(View.VISIBLE); } catch (JSONException e) { e.printStackTrace(); } if (!getIntent().hasExtra("logout")) { if (getSharedPreferences("CC", MODE_PRIVATE).contains("profileId")) { Intent home = new Intent(GoogleSignInActivity.this, HomeActivity2.class); home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(home); finish(); } } firebaseAnalytics = FirebaseAnalytics.getInstance(this); // Views // mStatusTextView = (TextView) findViewById(R.id.status); // mDetailTextView = (TextView) findViewById(R.id.detail); // Button listeners findViewById(R.id.sign_in_button).setOnClickListener(this); findViewById(R.id.sign_out_button).setOnClickListener(this); findViewById(R.id.disconnect_button).setOnClickListener(this); // [START config_signin] // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build(); // [END config_signin] mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); // [START initialize_auth] mAuth = FirebaseAuth.getInstance(); // [END initialize_auth] // [START auth_state_listener] mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out Log.d(TAG, "onAuthStateChanged:signed_out"); } // [START_EXCLUDE] updateUI(user); // [END_EXCLUDE] } }; // [END auth_state_listener] }
From source file:it.openyoureyes.test.panoramio.Panoramio.java
public List<GeoItem> examinePanoramio(Location current, double distance, Drawable myImage, Intent intent) { ArrayList<GeoItem> result = new ArrayList<GeoItem>(); /*//from ww w. j av a 2 s . com * var requiero_fotos = new Json.Remote( * "http://www.panoramio.com/map/get_panoramas.php?order=popularity& * set= * full&from=0&to=10&minx=-5.8&miny=42.59&maxx=-5.5&maxy=42.65&size= * medium " */ Location loc1 = new Location("test"); Location loc2 = new Location("test_"); AbstractGeoItem.calcDestination(current.getLatitude(), current.getLongitude(), 225, distance / 2, loc1); AbstractGeoItem.calcDestination(current.getLatitude(), current.getLongitude(), 45, distance / 2, loc2); try { URL url = new URL( "http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=full&from=0&to=10&minx=" + loc1.getLongitude() + "&miny=" + loc1.getLatitude() + "&maxx=" + loc2.getLongitude() + "&maxy=" + loc2.getLatitude() + "&size=thumbnail"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); String line; BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuffer buf = new StringBuffer(); while ((line = reader.readLine()) != null) { buf.append(line + " "); } reader.close(); is.close(); conn.disconnect(); // while (is.read(buffer) != -1); String jsontext = buf.toString(); Log.d("Json Panoramio", jsontext); JSONObject entrie = new JSONObject(jsontext); JSONArray arr = entrie.getJSONArray("photos"); for (int i = 0; i < arr.length(); i++) { JSONObject panoramioObj = arr.getJSONObject(i); double longitude = panoramioObj.getDouble("longitude"); double latitude = panoramioObj.getDouble("latitude"); String urlFoto = panoramioObj.getString("photo_file_url"); String idFoto = panoramioObj.getString("photo_id"); Bundle bu = intent.getExtras(); if (bu == null) bu = new Bundle(); bu.putString("id", idFoto); intent.replaceExtras(bu); BitmapDrawable bb = new BitmapDrawable(downloadFile(urlFoto)); PanoramioItem item = new PanoramioItem(latitude, longitude, false, bb, intent); result.add(item); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return result; }
From source file:com.kik.phonegap.plugin.messenger.KikMessengerPlugin.java
@Override public PluginResult execute(String action, JSONArray arg1, String arg2) { // Here we are going to basically going to read the json object and proccess the response Log.d("KikMessangerPlugin", "Plugin Called"); if (action.equals(ACTION)) { try {/*from w ww.ja v a 2s. co m*/ // The first argument is the string containing the JSONObject // that we will have to parse out String messageString = arg1.getString(0); System.out.println(messageString); JSONObject messageObject = new JSONObject(messageString); String title = messageObject.getString(TITLE); String desription = messageObject.getString(DESCRIPTION); JSONArray gen_urls = messageObject.getJSONArray(GENERICURIS); JSONArray ios_urls = messageObject.getJSONArray(IPHONEURIS); JSONArray android_urls = messageObject.getJSONArray(ANDROIDURIS); String preview = messageObject.getString(PREVIEW); String fileLocation = messageObject.getString(FILELOCATION); String previewURL = messageObject.getString(PREVIEWURL); KikMessage message = new KikMessage(_appID); message.setText(desription); message.setTitle(title); if (fileLocation.length() != 0) { try { File file = new File(fileLocation); message.setFile(file); } catch (IOException e) { return new PluginResult(PluginResult.Status.ERROR, "Error Attaching File"); } } if (preview.length() != 0) { byte[] data_bytes = Base64.decode(preview, 0); message.setImage( new BitmapDrawable(BitmapFactory.decodeByteArray(data_bytes, 0, data_bytes.length))); } else if (previewURL.length() != 0) { BitmapDrawable drawable = new BitmapDrawable(previewURL); message.setImage(drawable); } for (int i = 0; i < ios_urls.length(); i++) { message.setIphoneDownloadUri(ios_urls.getString(i)); } for (int i = 0; i < gen_urls.length(); i++) { message.setFallbackUri(gen_urls.getString(i)); } for (int i = 0; i < android_urls.length(); i++) { message.setAndroidDownloadUri(android_urls.getString(i)); } try { final KikMessage _messageToSend = message; // These will be key value pairs that we will use this.ctx.runOnUiThread(new Runnable() { public void run() { KikClient.sendMessage(ctx, _messageToSend); } }); return new PluginResult(Status.OK); } catch (Exception e) { return new PluginResult(PluginResult.Status.ERROR, "Error passing message to UI thread"); } } catch (JSONException e) { // If there is an issue parsing the JSON object then // we will return a bad result return new PluginResult(PluginResult.Status.ERROR, "Invalid JSON input, expected JSONObject as first item"); } // If we want to initialize the context } else if (action.equals(INIT_ACTION)) { try { String appID = arg1.getString(2); // We just want to take the AppId from this _appID = appID; if (_appID.length() == 0) { return new PluginResult(PluginResult.Status.ERROR, "Invalid App ID"); } else { return new PluginResult(PluginResult.Status.OK); } } catch (JSONException e) { // If there is an issue parsing the JSON object then // we will return a bad result return new PluginResult(PluginResult.Status.ERROR, "Invalid JSON input, expected JSONObject as first item"); } } else if (action.equals(HAS_MESSAGE)) { Intent i = this.ctx.getIntent(); KikData data = KikClient.getDataFromIntent(i); if (data.getType() == KikData.TYPE_PICK || data.getType() == KikData.TYPE_VIEW) { // We will only write back the javascript // if its a valid KikData object String output = "setTimeout(function() { KikAPIClient.message_ready( '" + SerializeKikData(data) + "'); }, 0 );"; super.sendJavascript(output); } return new PluginResult(PluginResult.Status.OK); } // This should not really occur return new PluginResult(PluginResult.Status.INVALID_ACTION, "INVALID COMMAND"); }
From source file:com.android.datacloud.Entity.java
/** * Devuelve un bitmap del recurso en la aplicacin * //from w ww . j a va 2s .co m * @param name nombre del campo * @return valor (Tipo bitmap) */ public Bitmap getBitmap(String name) { int id = DataCloud.getInstance().getContext().getResources().getIdentifier( DataCloud.getInstance().getPackage() + ":drawable/" + getValue(name).toString(), null, null); java.io.InputStream is = DataCloud.getInstance().getContext().getResources().openRawResource(id); BitmapDrawable bmd = new BitmapDrawable(BitmapFactory.decodeStream(is)); return bmd.getBitmap(); }
From source file:com.magizdev.babyoneday.profilewizard.AvatarFragment.java
private void showResizeImage(Intent data) { Bundle extras = data.getExtras();/*from w w w . java2 s . co m*/ if (extras != null) { Bitmap photo = extras.getParcelable("data"); mPage.getData().putParcelable(Profile.AVATAR, photo); Drawable drawable = new BitmapDrawable(photo); mAvatarBtn.setImageDrawable(drawable); } }
From source file:cn.finalteam.galleryfinal.widget.FloatingActionButton.java
void updateBackground() { float circleLeft = mShadowRadius; float circleTop = mShadowRadius - mShadowOffset; final RectF circleRect = new RectF(circleLeft, circleTop, circleLeft + mCircleSize, circleTop + mCircleSize);//from w ww . ja v a 2 s. c o m LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { new BitmapDrawable(getResources()), createFillDrawable(circleRect), new BitmapDrawable(getResources()), getIconDrawable() }); float iconOffset = (mCircleSize - getDimension(R.dimen.fab_icon_size)) / 2f; int iconInsetHorizontal = (int) (mShadowRadius + iconOffset); int iconInsetTop = (int) (circleTop + iconOffset); int iconInsetBottom = (int) (mShadowRadius + mShadowOffset + iconOffset); layerDrawable.setLayerInset(3, iconInsetHorizontal, iconInsetTop, iconInsetHorizontal, iconInsetBottom); setBackgroundCompat(layerDrawable); }
From source file:com.android.datacloud.Entity.java
/** * Devuelve un BitmapDrawable del recurso en la aplicacin * //w ww.ja va 2 s. c o m * @param name nombre del campo * @return valor (Tipo BitmapDrawable) */ public BitmapDrawable getBitmapDrawable(String name) { int id = DataCloud.getInstance().getContext().getResources().getIdentifier( DataCloud.getInstance().getPackage() + ":drawable/" + getValue(name).toString(), null, null); java.io.InputStream is = DataCloud.getInstance().getContext().getResources().openRawResource(id); BitmapDrawable bmd = new BitmapDrawable(BitmapFactory.decodeStream(is)); return bmd; }
From source file:com.mk4droid.IMC_Activities.Fragment_Filters.java
/** * OnCreateView /*from w w w. ja v a2s . c o m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ctx = this.getActivity(); resources = setResources(); FActivity_TabHost.IndexGroup = 3; v = inflater.inflate(R.layout.fragment_filters, container, false); dialogFiltersCh = new ProgressDialog(ctx); FiltInflater = inflater; //--------- Categories: Separate Parents (or Groups) from Children ---------------- int NCategs = Service_Data.mCategL.size(); ArrayList<String> ParentsL = new ArrayList<String>(); ArrayList<Integer> ParentsL_index = new ArrayList<Integer>(); ArrayList<Boolean> ParentsL_values = new ArrayList<Boolean>(); ArrayList<Bitmap> ParentsL_Bitmaps = new ArrayList<Bitmap>(); // Find Parents for (int i = 0; i < NCategs; i++) { if (Service_Data.mCategL.get(i)._level == 1) { ParentsL.add(Service_Data.mCategL.get(i)._name); ParentsL_values.add(Service_Data.mCategL.get(i)._visible == 1); ParentsL_index.add(Service_Data.mCategL.get(i)._id); byte[] ic = Service_Data.mCategL.get(i)._icon; ParentsL_Bitmaps.add(BitmapFactory.decodeByteArray(ic, 0, ic.length)); } } NParents = ParentsL_values.size(); groups = new String[NParents]; groups_check_values = new boolean[NParents]; groups_icon_values = new Drawable[NParents]; groups_id = new int[NParents]; for (int i = 0; i < NParents; i++) { groups[i] = ParentsL.get(i); groups_check_values[i] = ParentsL_values.get(i); groups_icon_values[i] = new BitmapDrawable(ParentsL_Bitmaps.get(i)); groups_id[i] = ParentsL_index.get(i); } //------------- Children ------------------------------- ChildrenL = new ArrayList<ArrayList<String>>(); ArrayList<ArrayList<Boolean>> ChildrenC = new ArrayList<ArrayList<Boolean>>(); ArrayList<ArrayList<Drawable>> ChildrenD = new ArrayList<ArrayList<Drawable>>(); ArrayList<ArrayList<Integer>> ChildrenID = new ArrayList<ArrayList<Integer>>(); for (int iParentSerial = 0; iParentSerial < NParents; iParentSerial++) { int IndexParent = ParentsL_index.get(iParentSerial); ChildrenL.add(new ArrayList<String>()); ChildrenC.add(new ArrayList<Boolean>()); ChildrenD.add(new ArrayList<Drawable>()); ChildrenID.add(new ArrayList<Integer>()); for (int i = 0; i < NCategs; i++) { if (Service_Data.mCategL.get(i)._parentid == IndexParent) { ChildrenL.get(iParentSerial).add(Service_Data.mCategL.get(i)._name); ChildrenC.get(iParentSerial).add(Service_Data.mCategL.get(i)._visible == 1); byte[] ic = Service_Data.mCategL.get(i)._icon; ChildrenD.get(iParentSerial) .add(new BitmapDrawable(BitmapFactory.decodeByteArray(ic, 0, ic.length))); ChildrenID.get(iParentSerial).add(Service_Data.mCategL.get(i)._id); } } } children = new String[NParents][]; children_check_values = new boolean[NParents][]; children_icon_values = new Drawable[NParents][]; children_id = new int[NParents][]; for (int i = 0; i < NParents; i++) { int NChildren = ChildrenL.get(i).size(); children[i] = new String[NChildren]; children_check_values[i] = new boolean[NChildren]; children_icon_values[i] = new Drawable[NChildren]; children_id[i] = new int[NChildren]; for (int j = 0; j < NChildren; j++) { children[i][j] = ChildrenL.get(i).get(j).toString(); children_check_values[i][j] = ChildrenC.get(i).get(j); children_icon_values[i][j] = ChildrenD.get(i).get(j); children_id[i][j] = ChildrenID.get(i).get(j); } } //------------ btSelectAllFilters = (Button) v.findViewById(R.id.btSelectAllFilters); btReverseAllFilters = (Button) v.findViewById(R.id.btReverseAllFilters); //-------- List View- ------------------------ llfilters = (LinearLayout) v.findViewById(R.id.llfilters); //------------ Set All other categories -------- elv = (ExpandableListView) v.findViewById(R.id.elvMain); adapter_explist = new FilterCateg_ExpandableListAdapter(elv, llfilters); // -------- Exp List View ----------- elv.setAdapter(adapter_explist); // expand children with 1 child so as to remove expander icon for (int i = 0; i < NParents; i++) { if (ChildrenL.get(i).size() == 0) { elv.expandGroup(i); } } //----------- Radio button for State Categories --------- ctv_Open = (CheckedTextView) v.findViewById(R.id.ctv_Open); ctv_Ack = (CheckedTextView) v.findViewById(R.id.ctv_Ack); ctv_Closed = (CheckedTextView) v.findViewById(R.id.ctv_Closed); ctv_Open.setChecked(OpenSW); ctv_Ack.setChecked(AckSW); ctv_Closed.setChecked(ClosedSW); ctv_Open.setOnClickListener(this); ctv_Ack.setOnClickListener(this); ctv_Closed.setOnClickListener(this); ctv_Open.setText(resources.getString(R.string.OpenIssue)); ctv_Ack.setText(resources.getString(R.string.AckIssue)); ctv_Closed.setText(resources.getString(R.string.ClosedIssue)); //--------------- Button Reverse All Filters ------------- btReverseAllFilters.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { FiltersChangedFlag = true; //--------- Set DB ---------------- DatabaseHandler dbHandler = new DatabaseHandler(ctx); for (int i = 0; i < NParents; i++) { int NChildren = ChildrenL.get(i).size(); groups_check_values[i] = !groups_check_values[i]; dbHandler.setCategory(groups_id[i], groups_check_values[i] ? 1 : 0); // Send as integer for (int j = 0; j < NChildren; j++) { children_check_values[i][j] = !children_check_values[i][j]; dbHandler.setCategory(children_id[i][j], children_check_values[i][j] ? 1 : 0); // Send as integer } } dbHandler.db.close(); //--------- Set GUI ---------------- adapter_explist = new FilterCateg_ExpandableListAdapter(elv, llfilters); elv.setAdapter(adapter_explist); // expand children with 1 child so as to remove expander icon for (int i = 0; i < NParents; i++) { if (ChildrenL.get(i).size() == 0) { elv.expandGroup(i); } } } }); //--------------- Button Select All Filters ------------- //------ Check to see if all inactive -------- int sumVisible = 0; for (int i = 0; i < NCategs; i++) sumVisible += Service_Data.mCategL.get(i)._visible; if (sumVisible > 0) btSelectAllFilters.setTag(false); else btSelectAllFilters.setTag(true); //------------- btSelectAllFilters.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { FiltersChangedFlag = true; //----- Set DB --------- DatabaseHandler dbHandler = new DatabaseHandler(ctx); for (int i = 0; i < NParents; i++) { int NChildren = ChildrenL.get(i).size(); groups_check_values[i] = (Boolean) btSelectAllFilters.getTag(); dbHandler.setCategory(groups_id[i], groups_check_values[i] ? 1 : 0); // Send as integer for (int j = 0; j < NChildren; j++) { children_check_values[i][j] = (Boolean) btSelectAllFilters.getTag(); dbHandler.setCategory(children_id[i][j], children_check_values[i][j] ? 1 : 0); // Send as integer } } dbHandler.db.close(); btSelectAllFilters.setTag(!(Boolean) btSelectAllFilters.getTag()); //------ Set GUI ----- adapter_explist = new FilterCateg_ExpandableListAdapter(elv, llfilters); elv.setAdapter(adapter_explist); // expand children with 1 child so as to remove expander icon for (int i = 0; i < NParents; i++) { if (ChildrenL.get(i).size() == 0) { elv.expandGroup(i); } } } }); return v; }