Skip to content

Commit 54a24da

Browse files
author
Blanka Kulik
committed
Improve code composition in readme
1 parent ede6424 commit 54a24da

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

README.md

+40-39
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,50 @@ public class MyMainActivity extends Activity {
7474
private TweakStore tweakStore;
7575
private NotificationManager notificationManager;
7676

77-
@Override
78-
protected void onCreate(Bundle savedInstanceState) {
79-
super.onCreate(savedInstanceState);
80-
81-
tweakStore = TweakStore.getInstance(this);
82-
tweakStore.setTweaks(BAXTweaks.allTweaks);
83-
tweakStore.setEnabled(BuildConfig.TWEAKS_ENABLED);
84-
85-
if (tweakStore.isEnabled()) {
86-
showNotification();
87-
}
88-
}
89-
90-
@Override
91-
protected void onStart() {
92-
super.onStart();
93-
if (tweakStore.isEnabled()) {
94-
showNotification();
77+
@Override
78+
protected void onCreate(Bundle savedInstanceState) {
79+
super.onCreate(savedInstanceState);
80+
81+
tweakStore = TweakStore.getInstance(this);
82+
tweakStore.setTweaks(BAXTweaks.allTweaks);
83+
tweakStore.setEnabled(BuildConfig.TWEAKS_ENABLED);
84+
85+
if (tweakStore.isEnabled()) {
86+
showNotification();
87+
}
9588
}
96-
}
97-
98-
@Override
99-
protected void onStop() {
100-
super.onStop();
101-
notificationManager.cancelAll();
102-
}
103-
104-
private void showNotification() {
105-
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
10689

107-
notificationBuilder.setSmallIcon(app_icon_from_resources);
108-
notificationBuilder.setContentTitle(text_from_resources);
109-
notificationBuilder.setPriority(Notification.PRIORITY_MAX);
110-
notificationBuilder.setWhen(0);
111-
notificationBuilder.setDefaults(Notification.DEFAULT_SOUND);
90+
@Override
91+
protected void onStart() {
92+
super.onStart();
93+
if (tweakStore.isEnabled()) {
94+
showNotification();
95+
}
96+
}
11297

113-
Intent intent = new Intent(this, TweakStoreActivity.class);
114-
intent.putExtra(TWEAK_STORE_NAME, tweakStore.getTweakStoreName());
115-
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
116-
notificationBuilder.addAction(button_icon_from_resources, button_text_from_resources, pendingIntent);
98+
@Override
99+
protected void onStop() {
100+
super.onStop();
101+
notificationManager.cancelAll();
102+
}
117103

118-
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
119-
notificationManager.notify(1, notificationBuilder.build());
104+
private void showNotification() {
105+
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
106+
107+
notificationBuilder.setSmallIcon(app_icon_from_resources);
108+
notificationBuilder.setContentTitle(text_from_resources);
109+
notificationBuilder.setPriority(Notification.PRIORITY_MAX);
110+
notificationBuilder.setWhen(0);
111+
notificationBuilder.setDefaults(Notification.DEFAULT_SOUND);
112+
113+
Intent intent = new Intent(this, TweakStoreActivity.class);
114+
intent.putExtra(TWEAK_STORE_NAME, tweakStore.getTweakStoreName());
115+
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
116+
notificationBuilder.addAction(button_icon_from_resources, button_text_from_resources, pendingIntent);
117+
118+
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
119+
notificationManager.notify(1, notificationBuilder.build());
120+
}
120121
}
121122
```
122123

0 commit comments

Comments
 (0)