Skip to content

Commit

Permalink
Change View to use getResources and getIdentifier instead of R.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmccrackin committed Nov 9, 2014
1 parent 310de54 commit e9f0b19
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/android/CanvasCameraView.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class CanvasCameraView extends Activity implements SurfaceHolder.Callback
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.canvascamera);
setContentView(getResources().getIdentifier("canvascamera", "layout", getPackageName()));

_quality = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt(CanvasCamera.QUALITY , 85);
_destType = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt(CanvasCamera.DESTTYPE , DestinationTypeFileURI);
Expand Down Expand Up @@ -131,13 +131,13 @@ public void onStop() {
@SuppressWarnings("deprecation")
private void getControlVariables()
{
m_imgFlash = (ImageView) findViewById(R.id.imgFlash);
m_imgFlash = (ImageView) findViewById(getResources().getIdentifier("imgFlash", "id", getPackageName()));

m_imgRevert = (ImageView) findViewById(R.id.imgRevert);
m_imgCapture = (ImageView) findViewById(R.id.imgCapture);
m_imgClose = (ImageView) findViewById(R.id.imgClose);
m_imgRevert = (ImageView) findViewById(getResources().getIdentifier("imgRevert", "id", getPackageName()));
m_imgCapture = (ImageView) findViewById(getResources().getIdentifier("imgCapture", "id", getPackageName()));
m_imgClose = (ImageView) findViewById(getResources().getIdentifier("imgClose", "id", getPackageName()));

m_surfaceview = (SurfaceView) findViewById(R.id.surfaceView);
m_surfaceview = (SurfaceView) findViewById(getResources().getIdentifier("surfaceView", "id", getPackageName()));
m_surfaceHolder = m_surfaceview.getHolder();
m_surfaceHolder.addCallback(this);
m_surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
Expand All @@ -148,14 +148,14 @@ private void getControlVariables()
private void initializeUI()
{
if (bFlash)
m_imgFlash.setImageResource(R.drawable.video_sprites_focus_inactive);
m_imgFlash.setImageResource(getResources().getIdentifier("video_sprites_focus_inactive", "drawable", getPackageName()));
else
m_imgFlash.setImageResource(R.drawable.video_sprites_focus);
m_imgFlash.setImageResource(getResources().getIdentifier("video_sprites_focus", "drawable", getPackageName()));

if (bRevert)
m_imgRevert.setImageResource(R.drawable.video_sprites_revert);
m_imgRevert.setImageResource(getResources().getIdentifier("video_sprites_revert", "drawable", getPackageName()));
else
m_imgRevert.setImageResource(R.drawable.video_sprites_revert_inactive);
m_imgRevert.setImageResource(getResources().getIdentifier("video_sprites_revert_inactive", "drawable", getPackageName()));

m_imgFlash.setOnClickListener(flashClickListener);

Expand All @@ -178,14 +178,14 @@ public void onClick(View v) {
if (bFlash)
{
p.setFlashMode(Parameters.FLASH_MODE_OFF);
m_imgFlash.setImageResource(R.drawable.video_sprites_focus);
m_imgFlash.setImageResource(getResources().getIdentifier("video_sprites_focus", "drawable", getPackageName()));

editor.putBoolean(CanvasCamera.FLASH, false);
}
else
{
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
m_imgFlash.setImageResource(R.drawable.video_sprites_focus_inactive);
m_imgFlash.setImageResource(getResources().getIdentifier("video_sprites_focus_inactive","drawable", getPackageName()));

editor.putBoolean(CanvasCamera.FLASH, true);
}
Expand Down Expand Up @@ -215,18 +215,18 @@ public void onClick(View v) {
{
m_camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);

m_imgRevert.setImageResource(R.drawable.video_sprites_revert_inactive);
m_imgRevert.setImageResource(getResources().getIdentifier("video_sprites_revert_inactive", "drawable", getPackageName()));
editor.putBoolean(CanvasCamera.REVERT, false);

m_imgFlash.setImageResource(R.drawable.video_sprites_focus);
m_imgFlash.setImageResource(getResources().getIdentifier("video_sprites_focus", "drawable", getPackageName()));
bFlash = false;
editor.putBoolean(CanvasCamera.FLASH, false);
}
else
{
m_camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);

m_imgRevert.setImageResource(R.drawable.video_sprites_revert);
m_imgRevert.setImageResource(getResources().getIdentifier("video_sprites_revert", "drawable", getPackageName()));

editor.putBoolean(CanvasCamera.REVERT, true);
}
Expand Down Expand Up @@ -426,12 +426,12 @@ public void surfaceCreated(SurfaceHolder holder)
if (bRevert)
{
m_camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
m_imgRevert.setImageResource(R.drawable.video_sprites_revert);
m_imgRevert.setImageResource(getResources().getIdentifier("video_sprites_revert", "drawable", getPackageName()));
}
else
{
m_camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
m_imgRevert.setImageResource(R.drawable.video_sprites_revert_inactive);
m_imgRevert.setImageResource(getResources().getIdentifier("video_sprites_revert_inactive", "drawable", getPackageName()));
}

try
Expand Down

6 comments on commit e9f0b19

@nickbungus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an official version with this change in? I'm using Visual Studio with DevExpress' Devextreme for development and to use a 3rd party plugin it needs to be an official version.

@sandeepadiyar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help. Its working now perfectly :)

@Soorya84
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks alot.. it worked for me ...:)

@Rakonda
Copy link

@Rakonda Rakonda commented on e9f0b19 Jul 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this is working fine now.

@youkeofficial
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks this is working fine

@aleksein
Copy link

@aleksein aleksein commented on e9f0b19 May 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, your solution helps me a lot in another project with another problem with "R.", so thank you a lot!

Please sign in to comment.