Back to project page demo-flickr-feed-android.
The source code is released under:
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...
If you think the Android project demo-flickr-feed-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.org.tomek.flickrfeed.activity; //from w w w. j ava 2 s . co m import android.app.Activity; import android.content.res.Resources; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import butterknife.ButterKnife; import butterknife.InjectView; import uk.org.tomek.flickrfeed.R; import uk.org.tomek.flickrfeed.model.Item; import uk.org.tomek.flickrfeed.utils.Logger; public class ImageDetailsActivity extends Activity { public static final String ITEM_ARG = "item_arg"; private final Logger mLogger = Logger.getLogger(ImageDetailsActivity.class); private Item mItem; @InjectView(R.id.details_image_container) ImageView mImageView; @InjectView(R.id.details_image_title) TextView mTitle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_details); ButterKnife.inject(this); mItem = getIntent().getParcelableExtra(ITEM_ARG); mLogger.v("ImageDetailsActivity launched with item:%s", mItem); } @Override protected void onResume() { if (mItem != null && mImageView != null) { Resources resources = getResources(); int viewSize = (int)resources.getDimension(R.dimen.details_image_size); String imageUrl = mItem.getMedia().getM(); mLogger.v("imageUrl:%s Calculated viewSize:%d", imageUrl, viewSize); Picasso.with(this).load(imageUrl).resize(viewSize, viewSize).centerCrop().into(mImageView); mTitle.setText(mItem.getTitle()); } super.onResume(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_image_details, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override protected void onDestroy() { super.onDestroy(); ButterKnife.reset(this); } }