Skip to content

Commit

Permalink
Removed outdated code for DisplayOneActivity with resource image
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisfeld committed Sep 23, 2017
1 parent aa372ac commit 085e869
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Kamera benutzen. Bitte informieren Sie mich, wenn solche Probleme auftreten.</p>
<item>Fehlerkorrekturen</item>
<item>Verwendung von externem LED-Blitz. Fehlerkorrekturen</item>
<item>Fehlerkorrekturen</item>
<item>Verwendung der Frontkamera möglich. Rotation der Bilder. Fehlerkorrekturen</item>
<item>Verwendung der Frontkamera möglich. Rotation der Bilder.</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ primera vez con un nuevo dispositivo o con una nueva cámara. Por favor, me info
<item>Corrección de errores</item>
<item>Uso del flash LED externo. Corrección de errores</item>
<item>Corrección de errores</item>
<item>Activado el uso de la cámara frontal. Rotación de imágenes. Corrección de errores</item>
<item>Activado el uso de la cámara frontal. Rotación de imágenes</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ when using the app for the first time with a new device or with a new camera. Pl
<item>Bugfixes</item>
<item>Enabled use of external LED flash. Bugfixes</item>
<item>Bugfixes</item>
<item>Enabled use of front camera. Rotation of images. Bugfixes</item>
<item>Enabled use of front camera. Rotation of images</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,10 @@
* @author Joerg
*/
public class DisplayOneActivity extends DisplayImageActivity {
/**
* The resource key for the image type (TYPE_FILENAME or TYPE_FILERESOURCE).
*/
private static final String STRING_EXTRA_TYPE = "de.jeisfeld.augendiagnoselib.TYPE";
/**
* The resource key for the file path.
*/
private static final String STRING_EXTRA_FILE = "de.jeisfeld.augendiagnoselib.FILE";
/**
* The resource key for the file resource.
*/
private static final String STRING_EXTRA_FILERESOURCE = "de.jeisfeld.augendiagnoselib.FILERESOURCE";

/**
* Type value set if the activity shows an image by filename.
*/
private static final int TYPE_FILENAME = 1;
/**
* Type value set if the activity shows an image by resource id.
*/
private static final int TYPE_FILERESOURCE = 2;

/**
* The fragment tag.
Expand All @@ -66,20 +49,6 @@ public class DisplayOneActivity extends DisplayImageActivity {
public static void startActivity(@NonNull final Context context, final String filename) {
Intent intent = new Intent(context, DisplayOneActivity.class);
intent.putExtra(STRING_EXTRA_FILE, filename);
intent.putExtra(STRING_EXTRA_TYPE, TYPE_FILENAME);
context.startActivity(intent);
}

/**
* Static helper method to start the activity, passing the path of the picture.
*
* @param context The context in which the activity is started.
* @param fileResource The resource id of the picture.
*/
public static void startActivity(@NonNull final Context context, final int fileResource) {
Intent intent = new Intent(context, DisplayOneActivity.class);
intent.putExtra(STRING_EXTRA_FILERESOURCE, fileResource);
intent.putExtra(STRING_EXTRA_TYPE, TYPE_FILERESOURCE);
context.startActivity(intent);
}

Expand All @@ -90,22 +59,15 @@ public static void startActivity(@NonNull final Context context, final int fileR
protected final void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

int type = getIntent().getIntExtra(STRING_EXTRA_TYPE, -1);
String file = getIntent().getStringExtra(STRING_EXTRA_FILE);
int fileResource = getIntent().getIntExtra(STRING_EXTRA_FILERESOURCE, -1);

setContentView(R.layout.activity_display_one);

mFragmentImage = (DisplayImageFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG);

if (mFragmentImage == null) {
mFragmentImage = new DisplayImageFragment();
if (type == TYPE_FILENAME) {
mFragmentImage.setParameters(file, 1, null);
}
else {
mFragmentImage.setParameters(fileResource, 1);
}
mFragmentImage.setParameters(file, 1, null);

getFragmentManager().beginTransaction().add(R.id.fragment_image, mFragmentImage, FRAGMENT_TAG).commit();
getFragmentManager().executePendingTransactions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,10 @@
* Variant of DisplayOneFragment that includes overlay handling.
*/
public class DisplayImageFragment extends Fragment implements GuiElementUpdater, OnColorSelectedListener {
/**
* The resource key for the image type (TYPE_FILENAME or TYPE_FILERESOURCE).
*/
private static final String STRING_TYPE = "de.jeisfeld.augendiagnoselib.TYPE";
/**
* The resource key for the file path.
*/
private static final String STRING_FILE = "de.jeisfeld.augendiagnoselib.FILE";
/**
* The resource key for the file resource.
*/
private static final String STRING_FILERESOURCE = "de.jeisfeld.augendiagnoselib.FILERESOURCE";
/**
* The resource kay for the image index (in case of multiple images).
*/
Expand All @@ -89,15 +81,6 @@ public class DisplayImageFragment extends Fragment implements GuiElementUpdater,
*/
private static final String STRING_RIGHTLEFT = "de.jeisfeld.augendiagnoselib.RIGHTLEFT";

/**
* Type value set if the fragment shows an image by filename.
*/
private static final int TYPE_FILENAME = 1;
/**
* Type value set if the fragment shows an image by resource id.
*/
private static final int TYPE_FILERESOURCE = 2;

/**
* The size of the circle overlay bitmap.
*/
Expand All @@ -111,16 +94,6 @@ public class DisplayImageFragment extends Fragment implements GuiElementUpdater,
*/
private static final int CIRCLE_RADIUS_PUPIL = 384;

/**
* Type (TYPE_FILENAME or TYPE_FILERESOURCE).
*/
private int mType;

/**
* The file resource id.
*/
private int mFileResource;

/**
* The file path.
*/
Expand Down Expand Up @@ -290,7 +263,6 @@ public final void setParameters(final String initialFile, final int initialImage
@Nullable final RightLeft initialRightLeft) {
Bundle args = new Bundle();
args.putString(STRING_FILE, initialFile);
args.putInt(STRING_TYPE, TYPE_FILENAME);
args.putInt(STRING_IMAGEINDEX, initialImageIndex);
if (initialRightLeft != null) {
args.putSerializable(STRING_RIGHTLEFT, initialRightLeft);
Expand All @@ -299,31 +271,14 @@ public final void setParameters(final String initialFile, final int initialImage
setArguments(args);
}

/**
* Initialize the fragment with the file resource.
*
* @param initialFileResource The file resource.
* @param initialImageIndex The index of the view (required if there are multiple such fragments)
*/
public final void setParameters(final int initialFileResource, final int initialImageIndex) {
Bundle args = new Bundle();
args.putInt(STRING_FILERESOURCE, initialFileResource);
args.putInt(STRING_TYPE, TYPE_FILERESOURCE);
args.putInt(STRING_IMAGEINDEX, initialImageIndex);

setArguments(args);
}

/*
* Retrieve parameters.
*/
@Override
public final void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mType = getArguments().getInt(STRING_TYPE, -1);
mFile = getArguments().getString(STRING_FILE);
mFileResource = getArguments().getInt(STRING_FILERESOURCE, -1);
mImageIndex = getArguments().getInt(STRING_IMAGEINDEX, 0);
mRightLeft = (RightLeft) getArguments().getSerializable(STRING_RIGHTLEFT);
}
Expand Down Expand Up @@ -1297,7 +1252,7 @@ else if (mOverlayStatus == OverlayStatus.NON_JPEG) {
else {
fragmentView.findViewById(R.id.buttonOverlayLayout).setVisibility(View.GONE);
fragmentView.findViewById(R.id.buttonGuidedTopoLayout).setVisibility(View.VISIBLE);
if (mOverlayStatus == OverlayStatus.GUIDED && mType == TYPE_FILENAME) {
if (mOverlayStatus == OverlayStatus.GUIDED) {
mRotateImageButton.setVisibility(View.VISIBLE);
}
else {
Expand Down Expand Up @@ -1350,12 +1305,7 @@ public final void onSaveInstanceState(@NonNull final Bundle outState) {
* Initialize images - to be called after the views have restored instance state.
*/
public final void initializeImages() {
if (mType == TYPE_FILERESOURCE) {
mImageView.setImage(mFileResource, getActivity(), mImageIndex);
}
else {
mImageView.setImage(mFile, getActivity(), mImageIndex);
}
mImageView.setImage(mFile, getActivity(), mImageIndex);

if (mImageView.getEyePhoto().getRightLeft() == null && mRightLeft != null) {
mImageView.getEyePhoto().setRightLeft(mRightLeft);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<item>Fehlerkorrekturen</item>
<item>Verwendung von externem LED-Blitz. Fehlerkorrekturen</item>
<item>Fehlerkorrekturen</item>
<item>Verwendung der Frontkamera möglich. Rotation der Bilder. Fehlerkorrekturen</item>
<item>Verwendung der Frontkamera möglich. Rotation der Bilder</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<item>Corrección de errores</item>
<item>Uso del flash LED externo. Corrección de errores</item>
<item>Corrección de errores</item>
<item>Activado el uso de la cámara frontal. Rotación de imágenes. Corrección de errores</item>
<item>Activado el uso de la cámara frontal. Rotación de imágenes</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<item>Bugfixes</item>
<item>Enabled use of external LED flash. Bugfixes</item>
<item>Bugfixes</item>
<item>Enabled use of front camera. Rotation of images. Bugfixes</item>
<item>Enabled use of front camera. Rotation of images</item>
</string-array>

</resources>

0 comments on commit 085e869

Please sign in to comment.