mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 05:11:04 +00:00
RCApp: show positioning list in login (Android 4.0.4)
This commit is contained in:
1 parent
d55422b15c
commit
4a341a019f
5 files changed
+148
-157
No files matched your search
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/listView_row_height"
|
||||
android:background="?sap_gray_black_30">
|
||||
@@ -18,7 +20,8 @@
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="?white"
|
||||
android:textSize="@dimen/textSize_26" />
|
||||
android:textSize="@dimen/textSize_26"
|
||||
tools:text="ListItem"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/list_item_subtitle"
|
||||
@@ -28,7 +31,9 @@
|
||||
android:layout_below="@id/list_item"
|
||||
android:textColor="?sap_light_gray"
|
||||
android:textSize="@dimen/textSize_18"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"
|
||||
tools:text="ListItemSubtitle"
|
||||
tools:visibility="visible"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
@@ -39,7 +44,8 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingRight="@dimen/default_padding"
|
||||
android:src="?check_18dp"
|
||||
android:visibility="invisible" />
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
@@ -47,5 +53,5 @@
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginLeft="@dimen/default_margin"
|
||||
android:layout_marginRight="@dimen/default_margin"
|
||||
android:background="?sap_gray" />
|
||||
android:background="?sap_gray"/>
|
||||
</RelativeLayout>
|
||||
+5
-3
@@ -131,9 +131,11 @@ public class LoginActivity extends BaseActivity
|
||||
if (sign_in != null) {
|
||||
sign_in.setEnabled(false);
|
||||
}
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.position_fragment, positionFragment, AreaPositionListFragmentTag);
|
||||
transaction.commitAllowingStateLoss();
|
||||
if (getFragmentManager().findFragmentByTag(AreaPositionListFragmentTag) == null) {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.position_fragment, positionFragment, AreaPositionListFragmentTag);
|
||||
transaction.commitAllowingStateLoss();
|
||||
}
|
||||
ExLog.i(this, "LoginActivity", "PositionFragment created.");
|
||||
}
|
||||
|
||||
|
||||
+116
-126
@@ -8,16 +8,11 @@ import android.content.IntentFilter;
|
||||
import android.graphics.Point;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.*;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.ui.activities.LoginActivity;
|
||||
@@ -54,26 +49,23 @@ public class LoginListViews extends LoggableDialogFragment implements View.OnCli
|
||||
RelativeLayout position_header = (RelativeLayout) view.findViewById(R.id.position_header);
|
||||
|
||||
// create the toggle container instances
|
||||
this.event_container = new EventToggleContainer(
|
||||
(FrameLayout) view.findViewById(R.id.event_fragment),
|
||||
event_header,
|
||||
(TextView) view.findViewById(R.id.selected_event)
|
||||
);
|
||||
this.area_container = new AreaToggleContainer(
|
||||
(FrameLayout) view.findViewById(R.id.area_fragment),
|
||||
area_header,
|
||||
(TextView) view.findViewById(R.id.selected_area)
|
||||
);
|
||||
this.position_container = new PositionToggleContainer(
|
||||
(FrameLayout) view.findViewById(R.id.position_fragment),
|
||||
position_header,
|
||||
(TextView) view.findViewById(R.id.selected_position)
|
||||
);
|
||||
this.event_container = new EventToggleContainer((FrameLayout) view.findViewById(R.id.event_fragment), event_header, (TextView) view
|
||||
.findViewById(R.id.selected_event));
|
||||
this.area_container = new AreaToggleContainer((FrameLayout) view.findViewById(R.id.area_fragment), area_header, (TextView) view
|
||||
.findViewById(R.id.selected_area));
|
||||
this.position_container = new PositionToggleContainer((FrameLayout) view
|
||||
.findViewById(R.id.position_fragment), position_header, (TextView) view.findViewById(R.id.selected_position));
|
||||
|
||||
// add listeners to the click areas
|
||||
if (event_header != null) event_header.setOnClickListener(this);
|
||||
if (area_header != null) area_header.setOnClickListener(this);
|
||||
if (position_header != null) position_header.setOnClickListener(this);
|
||||
if (event_header != null) {
|
||||
event_header.setOnClickListener(this);
|
||||
}
|
||||
if (area_header != null) {
|
||||
area_header.setOnClickListener(this);
|
||||
}
|
||||
if (position_header != null) {
|
||||
position_header.setOnClickListener(this);
|
||||
}
|
||||
|
||||
sign_up = (Button) view.findViewById(R.id.login_submit);
|
||||
if (sign_up != null) {
|
||||
@@ -135,7 +127,6 @@ public class LoginListViews extends LoggableDialogFragment implements View.OnCli
|
||||
showButton();
|
||||
}
|
||||
|
||||
|
||||
public void closeAll() {
|
||||
event_container.close();
|
||||
area_container.close();
|
||||
@@ -145,128 +136,127 @@ public class LoginListViews extends LoggableDialogFragment implements View.OnCli
|
||||
|
||||
private void showButton() {
|
||||
sign_up.setVisibility(View.GONE);
|
||||
if (event_container.isClosed() && area_container.isClosed() && position_container.isClosed()){
|
||||
if (event_container.isClosed() && area_container.isClosed() && position_container.isClosed()) {
|
||||
sign_up.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class ToggleContainer {
|
||||
private FrameLayout frame;
|
||||
private TextView text;
|
||||
private RelativeLayout header;
|
||||
|
||||
public ToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
this.frame = frame;
|
||||
this.text = text;
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public void toggle(){
|
||||
final int[] pos = new int[2];
|
||||
|
||||
// reset the header text
|
||||
if (text != null) {
|
||||
text.setText(null);
|
||||
}
|
||||
|
||||
if (frame != null && frame.getLayoutParams() != null) {
|
||||
// open the frame
|
||||
if (frame.getLayoutParams().height == 0) {
|
||||
frame.getLocationOnScreen(pos);
|
||||
frame.getLayoutParams().height = getScreenHeight() - pos[1];
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
frame.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public void close(){
|
||||
if (frame != null && frame.getLayoutParams() != null) {
|
||||
frame.getLayoutParams().height = 0;
|
||||
frame.requestLayout();
|
||||
setHeaderText();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetHeaderText(){
|
||||
if (text != null) text.setText(null);
|
||||
}
|
||||
|
||||
public boolean isClosed(){
|
||||
if (frame != null && frame.getLayoutParams() != null && frame.getLayoutParams().height == 0) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public RelativeLayout getHeader(){
|
||||
return this.header;
|
||||
}
|
||||
|
||||
private int getScreenHeight() {
|
||||
WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
return point.y;
|
||||
}
|
||||
|
||||
public void setHeaderText(){}
|
||||
private abstract class ToggleContainer {
|
||||
private FrameLayout frame;
|
||||
private TextView text;
|
||||
private RelativeLayout header;
|
||||
|
||||
public ToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
this.frame = frame;
|
||||
this.text = text;
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
private class EventToggleContainer extends ToggleContainer {
|
||||
public EventToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
super(frame, header, text);
|
||||
public void toggle() {
|
||||
final int[] pos = new int[2];
|
||||
|
||||
// reset the header text
|
||||
if (text != null) {
|
||||
text.setText(null);
|
||||
}
|
||||
|
||||
public void setHeaderText(){
|
||||
super.text.setText(activity.getEventName());
|
||||
if (frame != null && frame.getLayoutParams() != null) {
|
||||
// open the frame
|
||||
if (frame.getLayoutParams().height == 0) {
|
||||
frame.getLocationOnScreen(pos);
|
||||
frame.getLayoutParams().height = getScreenHeight() - pos[1];
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
frame.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private class AreaToggleContainer extends ToggleContainer {
|
||||
public AreaToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
super(frame, header, text);
|
||||
}
|
||||
public void setHeaderText(){
|
||||
super.text.setText(activity.getCourseName());
|
||||
public void close() {
|
||||
if (frame != null && frame.getLayoutParams() != null) {
|
||||
frame.getLayoutParams().height = 0;
|
||||
frame.requestLayout();
|
||||
setHeaderText();
|
||||
}
|
||||
}
|
||||
|
||||
private class PositionToggleContainer extends ToggleContainer {
|
||||
public PositionToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
super(frame, header, text);
|
||||
}
|
||||
public void setHeaderText(){
|
||||
super.text.setText(StringHelper.on(activity).getAuthor(activity.getPositionName()));
|
||||
public void resetHeaderText() {
|
||||
if (text != null) {
|
||||
text.setText(null);
|
||||
}
|
||||
}
|
||||
|
||||
private class IntentListener extends BroadcastReceiver {
|
||||
public boolean isClosed() {
|
||||
return (frame != null && frame.getLayoutParams() != null && frame.getLayoutParams().height == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
switch (action) {
|
||||
case AppConstants.INTENT_ACTION_TOGGLE:
|
||||
String data = intent.getExtras().getString(AppConstants.INTENT_ACTION_EXTRA);
|
||||
if (AppConstants.INTENT_ACTION_TOGGLE_EVENT.equals(data)) {
|
||||
onClick(event_container.getHeader());
|
||||
}
|
||||
if (AppConstants.INTENT_ACTION_TOGGLE_AREA.equals(data)) {
|
||||
onClick(area_container.getHeader());
|
||||
}
|
||||
if (AppConstants.INTENT_ACTION_TOGGLE_POSITION.equals(data)) {
|
||||
onClick(position_container.getHeader());
|
||||
}
|
||||
break;
|
||||
public RelativeLayout getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
private int getScreenHeight() {
|
||||
WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
return point.y;
|
||||
}
|
||||
|
||||
public abstract void setHeaderText();
|
||||
}
|
||||
|
||||
private class EventToggleContainer extends ToggleContainer {
|
||||
public EventToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
super(frame, header, text);
|
||||
}
|
||||
|
||||
public void setHeaderText() {
|
||||
super.text.setText(activity.getEventName());
|
||||
}
|
||||
}
|
||||
|
||||
private class AreaToggleContainer extends ToggleContainer {
|
||||
public AreaToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
super(frame, header, text);
|
||||
}
|
||||
|
||||
public void setHeaderText() {
|
||||
super.text.setText(activity.getCourseName());
|
||||
}
|
||||
}
|
||||
|
||||
private class PositionToggleContainer extends ToggleContainer {
|
||||
public PositionToggleContainer(FrameLayout frame, RelativeLayout header, TextView text) {
|
||||
super(frame, header, text);
|
||||
}
|
||||
|
||||
public void setHeaderText() {
|
||||
super.text.setText(StringHelper.on(activity).getAuthor(activity.getPositionName()));
|
||||
}
|
||||
}
|
||||
|
||||
private class IntentListener extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
switch (action) {
|
||||
case AppConstants.INTENT_ACTION_TOGGLE:
|
||||
String data = intent.getExtras().getString(AppConstants.INTENT_ACTION_EXTRA);
|
||||
if (AppConstants.INTENT_ACTION_TOGGLE_EVENT.equals(data)) {
|
||||
onClick(event_container.getHeader());
|
||||
}
|
||||
if (AppConstants.INTENT_ACTION_TOGGLE_AREA.equals(data)) {
|
||||
onClick(area_container.getHeader());
|
||||
}
|
||||
if (AppConstants.INTENT_ACTION_TOGGLE_POSITION.equals(data)) {
|
||||
onClick(position_container.getHeader());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -60,9 +60,8 @@ public abstract class NamedListFragment<T extends Named> extends LoggableListFra
|
||||
|
||||
}
|
||||
}
|
||||
this.getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
this.setListAdapter(listAdapter);
|
||||
getListView().setDivider(null);
|
||||
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
setListAdapter(listAdapter);
|
||||
|
||||
showProgressBar(true);
|
||||
loadItems();
|
||||
|
||||
+14
-20
@@ -29,25 +29,6 @@ public class PositionListFragment extends LoggableListFragment {
|
||||
return new PositionListFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
final ArrayList<String> values = new ArrayList<>();
|
||||
values.add(getString(R.string.login_type_officer_on_start_vessel));
|
||||
values.add(getString(R.string.login_type_officer_on_finish_vessel));
|
||||
values.add(getString(R.string.login_type_shore_control));
|
||||
values.add(getString(R.string.login_type_viewer));
|
||||
|
||||
this.preferences = AppPreferences.on(getActivity().getApplicationContext());
|
||||
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity().getBaseContext(), R.layout.login_list_item, R.id.list_item, values);
|
||||
setListAdapter(adapter);
|
||||
getListView().setDivider(null);
|
||||
|
||||
host = (PositionSelectedListenerHost) getActivity();
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
@@ -55,6 +36,20 @@ public class PositionListFragment extends LoggableListFragment {
|
||||
if (view != null) {
|
||||
parent.addView(view, 1);
|
||||
}
|
||||
|
||||
final ArrayList<String> values = new ArrayList<>();
|
||||
values.add(getString(R.string.login_type_officer_on_start_vessel));
|
||||
values.add(getString(R.string.login_type_officer_on_finish_vessel));
|
||||
values.add(getString(R.string.login_type_shore_control));
|
||||
values.add(getString(R.string.login_type_viewer));
|
||||
|
||||
preferences = AppPreferences.on(getActivity());
|
||||
|
||||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity().getBaseContext(), R.layout.login_list_item, R.id.list_item, values);
|
||||
setListAdapter(adapter);
|
||||
|
||||
host = (PositionSelectedListenerHost) getActivity();
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -98,5 +93,4 @@ public class PositionListFragment extends LoggableListFragment {
|
||||
public LogEventAuthorImpl getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user