Skip to content

Commit 6dceb8c

Browse files
authored
Revert "fix mContext memory leak"
1 parent 12df21c commit 6dceb8c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

android/src/main/java/cn/jpush/reactnativejpush/JPushModule.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void onCatalystInstanceDestroy() {
108108

109109
@ReactMethod
110110
public void initPush() {
111-
mContext = getReactApplicationContext();
111+
mContext = getCurrentActivity();
112112
JPushInterface.init(getReactApplicationContext());
113113
Logger.toast(mContext, "Init push success");
114114
Logger.i(TAG, "init Success!");
@@ -133,7 +133,7 @@ public void getInfo(Callback successCallback) {
133133

134134
@ReactMethod
135135
public void stopPush() {
136-
mContext = getReactApplicationContext();
136+
mContext = getCurrentActivity();
137137
JPushInterface.stopPush(getReactApplicationContext());
138138
Logger.i(TAG, "Stop push");
139139
Logger.toast(mContext, "Stop push success");
@@ -148,7 +148,7 @@ public void hasPermission(Callback callback) {
148148

149149
@ReactMethod
150150
public void resumePush() {
151-
mContext = getReactApplicationContext();
151+
mContext = getCurrentActivity();
152152
JPushInterface.resumePush(getReactApplicationContext());
153153
Logger.i(TAG, "Resume push");
154154
Logger.toast(mContext, "Resume push success");
@@ -381,7 +381,7 @@ public void getAlias(Callback callback) {
381381
*/
382382
@ReactMethod
383383
public void setStyleBasic() {
384-
mContext = getReactApplicationContext();
384+
mContext = getCurrentActivity();
385385
if (mContext != null) {
386386
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(mContext);
387387
builder.statusBarDrawable = IdHelper.getDrawable(mContext, "ic_launcher");
@@ -399,7 +399,7 @@ public void setStyleBasic() {
399399
*/
400400
@ReactMethod
401401
public void setStyleCustom() {
402-
mContext = getReactApplicationContext();
402+
mContext = getCurrentActivity();
403403
CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(mContext
404404
, IdHelper.getLayout(mContext, "customer_notification_layout"),
405405
IdHelper.getViewID(mContext, "icon"), IdHelper.getViewID(mContext, "title"),
@@ -451,7 +451,7 @@ public void clearAllNotifications() {
451451
@ReactMethod
452452
public void clearNotificationById(int id) {
453453
try {
454-
mContext = getReactApplicationContext();
454+
mContext = getCurrentActivity();
455455
JPushInterface.clearNotificationById(mContext, id);
456456
} catch (Exception e) {
457457
e.printStackTrace();
@@ -461,7 +461,7 @@ public void clearNotificationById(int id) {
461461
@ReactMethod
462462
public void setLatestNotificationNumber(int number) {
463463
try {
464-
mContext = getReactApplicationContext();
464+
mContext = getCurrentActivity();
465465
JPushInterface.setLatestNotificationNumber(mContext, number);
466466
} catch (Exception e) {
467467
e.printStackTrace();
@@ -471,7 +471,7 @@ public void setLatestNotificationNumber(int number) {
471471
@ReactMethod
472472
public void setPushTime(ReadableMap map) {
473473
try {
474-
mContext = getReactApplicationContext();
474+
mContext = getCurrentActivity();
475475
ReadableArray array = map.getArray("days");
476476
Set<Integer> days = new HashSet<Integer>();
477477
for (int i=0; i < array.size(); i++) {
@@ -492,7 +492,7 @@ public void setPushTime(ReadableMap map) {
492492
@ReactMethod
493493
public void setSilenceTime(ReadableMap map) {
494494
try {
495-
mContext = getReactApplicationContext();
495+
mContext = getCurrentActivity();
496496
String starTime = map.getString("startTime");
497497
String endTime = map.getString("endTime");
498498
String[] sTime = starTime.split(":");

0 commit comments

Comments
 (0)