public void addFirstSong() { if (MusicService.CurrentSong.size() > 0) { // Set player background to black // findViewById(R.id.fondPlayer).setBackgroundColor(Color.BLACK); String artist = MusicService.CurrentSong.get(0).getArtist(); TextView firstsongView = (TextView) findViewById(R.id.firstsong_title); TextView firstartistView = (TextView) findViewById(R.id.firstsong_artist); ImageView firstcoverart = (ImageView) findViewById(R.id.coverart); LinearLayout covfond = (LinearLayout) findViewById(R.id.coverartfond); DownloadImageTask task = new DownloadImageTask(firstcoverart, this, MusicService.CurrentSong.get(0).getAlbumId()); task.execute(MusicService.CurrentSong.get(0).getBitmapUri()); BlurImageTask taskBlur = new BlurImageTask(covfond, this); taskBlur.execute(MusicService.CurrentSong.get(0).getBitmapUri()); if (artist.equals("<unknown>")) { firstartistView.setText(""); } else { firstartistView.setText(MusicService.CurrentSong.get(0).getArtist()); } firstsongView.setText(MusicService.CurrentSong.get(0).getTitle()); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) convertView = LayoutInflater.from(context).inflate(R.layout.row, parent, false); if (convertView != null) { try { ((TextView) convertView.findViewById(R.id.text1)) .setText(jsonArray.getJSONObject(position).getString("trackName")); ((TextView) convertView.findViewById(R.id.text2)) .setText(jsonArray.getJSONObject(position).getString("artistName")); String url = jsonArray.getJSONObject(position).getString("artworkUrl100"); ImageView imageView = (ImageView) convertView.findViewById(R.id.image); if (cancelPotentialDownload(url, imageView)) { DownloadImageTask task = new DownloadImageTask(imageView, url); DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task); imageView.setImageDrawable(downloadedDrawable); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) task.execute(); else task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } catch (JSONException e) { Log.e(Constants.LOG_TAG, "Bad JSON object from results array at " + position, e); } } return convertView; }
@Override public int onStartCommand(Intent intent, int flags, int startId) { String url = intent.getStringExtra("url"); if (downloadTask != null && !downloadTask.isCancelled()) { Toast.makeText(getApplicationContext(), "正在下载中!", Toast.LENGTH_SHORT).show(); return startId; } downloadTask = new DownloadImageTask(); downloadTask.execute(url); return super.onStartCommand(intent, flags, startId); }
@Override public void onBindViewHolder(MyViewHolder holder, int position) { LocationNoteInfor currentInformation = data.get(position); holder.userName.setText("wdjkawhkjdwa"); holder.locationName.setText(currentInformation.getLocation()); holder.content.setText(currentInformation.getContent()); holder.numberOfLike.setText("" + currentInformation.getNumberOfLike()); holder.numberOfComment.setText("" + currentInformation.getNumberOfComment()); holder.postTime.setText("" + currentInformation.getTime().toString()); DownloadImageTask downloadImageTask = new DownloadImageTask(holder.iconProfile); downloadImageTask.execute(currentInformation.getAccount()); }
@Override protected void onCreate(Bundle savedInstanceState) { Log.d("test", "entered displaycard"); super.onCreate(savedInstanceState); setContentView(R.layout.display_card); // access url imageview ID from bundled data url = savedInstanceState.getString("url"); // int id = savedInstanceState.getInt("viewId"); ImageView imageView = (ImageView) findViewById(R.id.imageView2); DownloadImageTask task = new DownloadImageTask(getApplicationContext(), imageView); task.execute(url); }
private void getImage() { if ("file".equals(mUri.getScheme())) { File img = new File(mUri.getPath()); if (img.exists()) { loadImage(img.getAbsolutePath()); } else { timeOut.setVisibility(View.VISIBLE); timeOut.setText(R.string.no_data_need_retry); } } else { task = new DownloadImageTask(); task.execute(mUri); } }
private void download(Tweet tweet) { DownloadImageTask task = new DownloadImageTask(tweet); task.execute(context); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.cancel: Intent cancelIntent = new Intent(getBaseContext(), MainActivity.class); switch (_navigationSource) { case AllContacts: cancelIntent = new Intent(getBaseContext(), MainActivity.class); cancelIntent.putExtra("selectedTab", MainActivity.TAB_CONTACTS); break; case GroupContacts: cancelIntent = new Intent(getBaseContext(), GroupActivity.class); cancelIntent.putExtra("groupId", _contact.getGroupId()); break; case ViewContact: cancelIntent = new Intent(getBaseContext(), ViewContactActivity.class); cancelIntent.putExtra("contactId", _contact.getId()); break; } cancelIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getBaseContext().startActivity(cancelIntent); return true; case R.id.update: if (_name.getText().toString().length() > 0) { String meetupId = _contact.getMeetupId(); String name = _name.getText().toString(); String website = _website.getText().toString(); String contactPhotoThumbnailLocation = ""; String link = ""; String twitterId = ""; String linkedInId = ""; String facebookId = ""; String tumblrId = ""; String flickrId = ""; for (int i = 0; i < _contacts.size(); i++) { if ((_contacts.get(i).getName().trim().toLowerCase()) .equals(_name.getText().toString().trim().toLowerCase())) { meetupId = _contacts.get(i).getMeetupId(); name = _contacts.get(i).getName(); link = _contacts.get(i).getLink(); twitterId = _contacts.get(i).getTwitterId(); linkedInId = _contacts.get(i).getLinkedInId(); facebookId = _contacts.get(i).getFacebookId(); tumblrId = _contacts.get(i).getTumblrId(); flickrId = _contacts.get(i).getFlickrId(); contactPhotoThumbnailLocation = _contacts.get(i).getPhotoThumbnail(); break; } } ContactDataAccess contactDataAccess = new ContactDataAccess(this); contactDataAccess.updateContact( _contact.getId(), meetupId, new byte[0], name, website, _email.getText().toString(), _phone.getText().toString(), _notes.getText().toString(), link, twitterId, linkedInId, facebookId, tumblrId, flickrId); if (contactPhotoThumbnailLocation.trim().length() > 0) { DownloadImageTask downloadImageTask = new DownloadImageTask(this, meetupId, contactPhotoThumbnailLocation); downloadImageTask.execute(); } Intent returnIntent = new Intent(getBaseContext(), ViewContactActivity.class); returnIntent.putExtra("navigationSource", _navigationSource); returnIntent.putExtra("contactId", _contact.getId()); returnIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getBaseContext().startActivity(returnIntent); return true; } else { Toast.makeText(this, R.string.you_need_to_provide_a_name, Toast.LENGTH_SHORT).show(); } } return false; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_appointment_list); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setIcon(R.drawable.logo); mNotificationAppointmentId = getIntent().getStringExtra("notificationAppointmentId"); /* ImageView banner = (ImageView)findViewById(R.id.banner);*/ Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); ImageView banner = (ImageView) findViewById(R.id.banner); // banner.setImageDrawable(getResources().getDrawable(R.drawable.ic_launcher)); DownloadImageTask task = new DownloadImageTask(banner); String url = "http://portal.appiplus.com/Content/Images/banner.png?w=%d&h=%d"; // url = String.format(url, "1", size.x, 75); url = String.format(url, size.x, size.y / 12); task.execute(url); try { // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key mClient = new MobileServiceClient( "https://appiplus.azure-mobile.net/", "eEXnmuvGaUMkxatSJqEAOqsthQhwLo28", this) .withFilter(new RefreshTokenCacheFilter()); NotificationsManager.handleNotifications(this, SENDER_ID, MyHandler.class); // Get the Mobile Service Table instance to use // mAppointmentTable = mClient.getTable(Appointment.class); mAppointmentTable = mClient.getTable(MemberAppointments.class); // Authenticate passing false to load the current token cache if available. authenticate(false); if (findViewById(R.id.appointment_detail_container) != null) { // The detail container view will be present only in the // large-screen layouts (res/values-large and // res/values-sw600dp). If this view is present, then the // activity should be in two-pane mode. mTwoPane = true; // In two-pane mode, list items should be given the // 'activated' state when touched. ((AppointmentListFragment) getSupportFragmentManager().findFragmentById(R.id.appointment_list)) .setActivateOnItemClick(true); } // TODO: If exposing deep links into your app, handle intents here. } catch (MalformedURLException e) { createAndShowDialog( new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error"); } }
public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView; if (convertView == null) { view = inflater.inflate(R.layout.room_list_item, null); } YouRoomEntry roomEntry = (YouRoomEntry) this.getItem(position); TextView name = null; TextView content = null; TextView createdTime = null; TextView descendantsCount = null; TextView attachmentType = null; ImageView memberImageView = new ImageView(getBaseContext()); if (roomEntry != null) { name = (TextView) view.findViewById(R.id.name); createdTime = (TextView) view.findViewById(R.id.created_time); content = (TextView) view.findViewById(R.id.content); attachmentType = (TextView) view.findViewById(R.id.attachment_type); memberImageView = (ImageView) view.findViewById(R.id.member_image); } if (name != null) { name.setText(roomEntry.getParticipationName()); } if (createdTime != null) { createdTime.setTextColor(Color.LTGRAY); createdTime.setText(YouRoomUtil.convertDatetime(roomEntry.getCreatedTime())); } if (content != null) { content.setText(roomEntry.getContent()); } String type = roomEntry.getAttachmentType(); if (attachmentType != null) { if (type.equals("")) { attachmentType.setText(""); } else { StringBuffer sb = new StringBuffer(); sb.append(getString(R.string.display_attachment)); if (type.equals("Text")) sb.append(getString(R.string.attachment_type_text)); if (type.equals("Image")) sb.append(getString(R.string.attachment_type_image)); if (type.equals("File")) sb.append(getString(R.string.attachment_type_file)); if (type.equals("Link")) sb.append(getString(R.string.attachment_type_link)); attachmentType.setText(sb.toString()); } } if (memberImageView != null) { memberImageView.setImageResource(R.drawable.default_member_image); String participationId = roomEntry.getParticipationId(); memberImageView.setTag(participationId); byte[] data = roomEntry.getMemberImage(); Bitmap memberImageBitmap = null; if (data != null) { memberImageBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); memberImageView.setImageBitmap(memberImageBitmap); } else { DownloadImageTask downloadImageTask = new DownloadImageTask(memberImageView, activity); downloadImageTask.execute(roomEntry); } } descendantsCount = (TextView) view.findViewById(R.id.descendants_count); int count = roomEntry.getDescendantsCount(); if (count == -1) { descendantsCount.setText(""); } else { // TODO レイアウト修正直書き descendantsCount.setText("[ " + count + "comments ] > "); } UserSession session = UserSession.getInstance(); String roomAccessTime = session.getRoomAccessTime(roomId); if (roomAccessTime != null) { int compareResult = YouRoomUtil.calendarCompareTo(roomAccessTime, roomEntry.getUpdatedTime()); if (compareResult < 0) { createdTime.setTextColor(Color.RED); } } return view; }