blob: 44a3368e845b33e7ecb138e2e12c1bf73f2b583f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.libreoffice.impressremote;
import org.libreoffice.impressremote.communication.CommunicationService;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.view.View.OnClickListener;
import com.actionbarsherlock.app.SherlockActivity;
public class StartPresentationActivity extends SherlockActivity {
private CommunicationService mCommunicationService = null;
private ActivityChangeBroadcastProcessor mBroadcastProcessor;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_startpresentation);
bindService(new Intent(this, CommunicationService.class), mConnection,
Context.BIND_IMPORTANT);
IntentFilter aFilter = new IntentFilter(
CommunicationService.MSG_SLIDESHOW_STARTED);
mBroadcastProcessor = new ActivityChangeBroadcastProcessor(this);
mBroadcastProcessor.addToFilter(aFilter);
LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
aFilter);
findViewById(R.id.startpresentation_button).setOnClickListener(
mClickListener);
}
@Override
public void onBackPressed() {
Intent aIntent = new Intent(this, SelectorActivity.class);
aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(aIntent);
mCommunicationService.disconnect();
}
@Override
protected void onDestroy() {
super.onDestroy();
unbindService(mConnection);
LocalBroadcastManager.getInstance(this).unregisterReceiver(mListener);
}
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName aClassName,
IBinder aService) {
mCommunicationService = ((CommunicationService.CBinder) aService)
.getService();
}
@Override
public void onServiceDisconnected(ComponentName aClassName) {
mCommunicationService = null;
}
};
private OnClickListener mClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (mCommunicationService != null) {
mCommunicationService.getTransmitter().startPresentation();
}
}
};
private BroadcastReceiver mListener = new BroadcastReceiver() {
@Override
public void onReceive(Context aContext, Intent aIntent) {
mBroadcastProcessor.onReceive(aContext, aIntent);
}
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|