Skip to content

Commit 014e812

Browse files
committed
Sample app for testing Android events. Test the nativescript-vue#185 issue
1 parent bb265bd commit 014e812

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const Vue = require('./nativescript-vue')
2+
const application = require('tns-core-modules/application')
3+
const platform = require('tns-core-modules/platform')
4+
5+
Vue.config.silent = false
6+
Vue.config.debug = true
7+
8+
new Vue({
9+
template: `
10+
<Frame>
11+
<Page>
12+
<ActionBar title="Android Event Test" />
13+
<StackLayout>
14+
<Label text="Event List:" />
15+
<ListView class="m-t-10" for="event in androidEvents">
16+
<v-template>
17+
<Label :text="event.eventName" />
18+
</v-template>
19+
</ListView>
20+
<StackLayout class="m-t-10" orientation="horizontal">
21+
<Label text="Switch for checking responsiveness" />
22+
<Switch v-model="switchValue" />
23+
</StackLayout>
24+
</StackLayout>
25+
</Page>
26+
</Frame>
27+
`,
28+
data: {
29+
androidEvents: [],
30+
switchValue: false
31+
},
32+
created() {
33+
if (platform.isAndroid) {
34+
const eventTypes = [
35+
application.AndroidApplication.activityCreatedEvent,
36+
application.AndroidApplication.activityDestroyedEvent,
37+
application.AndroidApplication.activityStartedEvent,
38+
application.AndroidApplication.activityPausedEvent,
39+
application.AndroidApplication.activityResumedEvent,
40+
application.AndroidApplication.activityStoppedEvent,
41+
application.AndroidApplication.saveActivityStateEvent,
42+
application.AndroidApplication.activityResultEvent,
43+
application.AndroidApplication.activityBackPressedEvent
44+
]
45+
for (let i = 0; i < eventTypes.length; i++) {
46+
application.android.on(eventTypes[i], event => {
47+
console.log(`Event: ${event.eventName}, Activity: ${event.activity}`)
48+
this.androidEvents.push(event)
49+
})
50+
}
51+
}
52+
}
53+
}).$start()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy