Kaydet (Commit) 2f88fd3f authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

Further style fixes + use Local BroadcastManager.

Change-Id: I2af6acbcb27c6c8000e638ac5414fa1d89583b1c
üst 83291636
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/org.libreoffice.impressremote"
android:id="@+id/presentation_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
......@@ -8,16 +7,18 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<pl.polidea.coverflow.CoverFlow
xmlns:coverflow="http://schemas.android.com/apk/res/org.libreoffice.impressremote"
android:id="@+id/presentation_coverflow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginLeft="15dp"
coverflow:imageHeight="200dip"
coverflow:imageWidth="240dip"
coverflow:withReflection="false" />
......@@ -26,7 +27,7 @@
android:id="@+id/presentation_slidenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_gravity="center_horizontal|center_vertical"
android:text="" />
</LinearLayout>
......
......@@ -28,7 +28,6 @@ import com.actionbarsherlock.app.SherlockActivity;
public class PairingActivity extends SherlockActivity {
private CommunicationService mCommunicationService;
private boolean mIsBound = false;
private TextView mPinText;
/** Called when the activity is first created. */
......@@ -38,7 +37,6 @@ public class PairingActivity extends SherlockActivity {
bindService(new Intent(this, CommunicationService.class), mConnection,
Context.BIND_IMPORTANT);
mIsBound = true;
IntentFilter aFilter = new IntentFilter(
CommunicationService.MSG_PAIRING_STARTED);
......@@ -48,6 +46,12 @@ public class PairingActivity extends SherlockActivity {
}
@Override
protected void onPause() {
super.onPause();
unbindService(mConnection);
}
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName aClassName,
......@@ -60,7 +64,7 @@ public class PairingActivity extends SherlockActivity {
.setText(MessageFormat
.format(getResources()
.getString(R.string.pairing_instructions_2_deviceName),
mCommunicationService
CommunicationService
.getDeviceName()));
if (mCommunicationService.getState() == State.CONNECTING) {
......
......@@ -36,7 +36,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
public class PresentationActivity extends SherlockFragmentActivity {
private CommunicationService mCommunicationService;
private boolean mIsBound = false;
private FrameLayout mLayout;
private FrameLayout mOuterLayout;
private ThumbnailFragment mThumbnailFragment;
......@@ -49,7 +48,6 @@ public class PresentationActivity extends SherlockFragmentActivity {
bindService(new Intent(this, CommunicationService.class), mConnection,
Context.BIND_IMPORTANT);
mIsBound = true;
setContentView(R.layout.activity_presentation);
mOuterLayout = (FrameLayout) findViewById(R.id.framelayout);
......@@ -59,21 +57,30 @@ public class PresentationActivity extends SherlockFragmentActivity {
mLayout.setId(R.id.presentation_innerFrame);
//((FrameLayout) findViewById(R.id.framelayout)).addView(mLayout);
mThumbnailFragment = new ThumbnailFragment();
mPresentationFragment = new PresentationFragment();
if (savedInstanceState == null) {
mThumbnailFragment = new ThumbnailFragment();
mPresentationFragment = new PresentationFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction();
fragmentTransaction.add(R.id.presentation_innerFrame,
mPresentationFragment, "fragment_presentation");
fragmentTransaction.commit();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction();
fragmentTransaction.add(R.id.presentation_innerFrame,
mPresentationFragment, "fragment_presentation");
fragmentTransaction.commit();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("thumbnail_enabled", mThumbnailFragment.isVisible());
}
@Override
protected void onDestroy() {
mActionBarManager.stop();
unbindService(mConnection);
super.onDestroy();
}
......
......@@ -59,8 +59,7 @@ public class PresentationFragment extends SherlockFragment {
if (mTopView != null) {
mTopView.setAdapter(new ThumbnailAdapter(mContext,
mCommunicationService.getSlideShow()));
mTopView.setSelection(mCommunicationService.getSlideShow()
.getCurrentSlide(), true);
mTopView.setSelection(mCommunicationService.getSlideShow().getCurrentSlide(), true);
mTopView.setOnItemSelectedListener(new ClickListener());
}
......
......@@ -24,6 +24,7 @@ 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 android.widget.LinearLayout;
......@@ -49,7 +50,8 @@ public class SelectorActivity extends SherlockActivity {
IntentFilter aFilter = new IntentFilter(
CommunicationService.MSG_SERVERLIST_CHANGED);
registerReceiver(mListener, aFilter);
LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
aFilter);
mBluetoothContainer = findViewById(R.id.selector_container_bluetooth);
mBluetoothList = (LinearLayout) findViewById(R.id.selector_list_bluetooth);
......@@ -63,7 +65,7 @@ public class SelectorActivity extends SherlockActivity {
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mListener);
LocalBroadcastManager.getInstance(this).unregisterReceiver(mListener);
}
@Override
......@@ -112,6 +114,7 @@ public class SelectorActivity extends SherlockActivity {
mCommunicationService = ((CommunicationService.CBinder) aService)
.getService();
mCommunicationService.startSearching();
refreshLists();
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment