Last active
August 29, 2015 14:01
-
-
Save CoffeeCode/a085cbb510ed668f75e1 to your computer and use it in GitHub Desktop.
Viewer Fragment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Viewer extends Fragment { | |
private static final String TAG = "Viewer"; | |
//Fragment Static strings | |
public static final String IMAGE_RESOURCE_ID = "iconResourceID"; | |
public static final String ITEM_NAME = "itemName"; | |
//Static strings for Bundel and etc. | |
public static final String PREFERENCE_LAST_IMAGE = "lastImage"; | |
public static final String BUNDEL_SELECTED_IMAGE = "selectedImage"; | |
protected String imagePath; | |
protected Button filter1; | |
protected Button filter2; | |
protected Button filter3; | |
protected Button filter4; | |
protected TextView textViewExif; | |
protected TextView textViewInfo1; | |
protected TextView textViewInfo2; | |
protected RenderScript renderScript; | |
protected SubsamplingScaleImageView imageView; | |
protected Context context; | |
public static Viewer init(String imagePath) { | |
Viewer viewerFragment = new Viewer(); | |
Bundle args = new Bundle(); | |
args.putString("imagePath", imagePath); | |
viewerFragment.setArguments(args); | |
return viewerFragment; | |
} | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
imagePath = getArguments().getString("imagePath"); | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
View view = inflater.inflate(R.layout.fragment_viewer, container, false); | |
context = super.getActivity(); | |
renderScript = RenderScript.create(context); | |
imageView = (SubsamplingScaleImageView) view.findViewById(R.id.previewImage); | |
try { | |
imageView.setImageFile(imagePath); | |
Log.d(TAG, "setting imagePath in onCreateView : " + imagePath); | |
textViewExif.setText(imagePath); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
setHasOptionsMenu(true); | |
initializeInheritance(view); //nur für klassen die diese vererben | |
toggleHideyBar(); | |
return view; | |
} | |
@Override | |
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | |
inflater.inflate(R.menu.viewer, menu); | |
super.onCreateOptionsMenu(menu,inflater); | |
} | |
protected void initializeInheritance(View view){ | |
} | |
protected void showMetadata(ImageData imageData){ | |
textViewExif.setText(imageData.getExposureTime() + " " + | |
imageData.getfNumber() + " " + | |
imageData.getFilmSpeed() + " " + | |
imageData.getFocalLength()); | |
textViewInfo1.setText(String.valueOf(imageData.getLaplaceSum())); | |
textViewInfo2.setText(String.valueOf(imageData.getMaxLaplaceValue())); | |
} | |
@Override | |
public void onDetach() { | |
super.onDetach(); | |
toggleHideyBar(); | |
} | |
/** | |
* Detects and toggles immersive mode (also known as "hidey bar" mode). | |
*/ | |
public void toggleHideyBar() { | |
... | |
} | |
protected void setImageFile(File filteredImageFile){ | |
try { | |
imageView.setImageFile(filteredImageFile.getAbsolutePath()); | |
} catch (IOException e) { e.printStackTrace(); } | |
} | |
protected void setImageBitmap(Bitmap filteredImageBitmap){ | |
try { | |
imageView.setImageBitmap(filteredImageBitmap); | |
} catch (IOException e) { e.printStackTrace(); } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment