Skip to content

Commit

Permalink
Add "R" class helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonjza committed Apr 3, 2019
1 parent 5ec08ce commit 0976928
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions agent/src/android/lib/libjava.ts
Expand Up @@ -20,3 +20,15 @@ export const getApplicationContext = (): any => {

return currentApplication.getApplicationContext();
};

// A helper method to access the R class for the app.
// Typical usage within an app would be something like:
// R.id.content_frame.
//
// Using this method, the above example would be:
// R("content_frame", "id")
export const R = (name: string, type: string): any => {
const context = getApplicationContext();
// https://github.com/bitpay/android-sdk/issues/14#issue-202495610
return context.getResources().getIdentifier(name, type, context.getPackageName());
};

0 comments on commit 0976928

Please sign in to comment.