1
0
mirror of https://gitlab.com/openlp/android.git synced 2024-12-22 20:02:50 +00:00

Code clean up and duel screen LiveListFragment

This commit is contained in:
Tim Bentley 2015-04-11 12:12:51 +01:00
parent 25272f72f7
commit 0219435011
8 changed files with 83 additions and 110 deletions

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4"> <module external.linked.project.id="OpenLP2" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager"> <component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle"> <facet type="java-gradle" name="Java-Gradle">
<configuration> <configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" /> <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration> </configuration>
</facet> </facet>
</component> </component>
@ -16,4 +17,3 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="OpenLP2" external.system.module.version="unspecified" type="JAVA_MODULE" version="4"> <module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="OpenLP2" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager"> <component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle"> <facet type="android-gradle" name="Android-Gradle">
<configuration> <configuration>
@ -12,8 +12,9 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" /> <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" /> <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" /> <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" /> <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" /> <option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
@ -91,4 +92,3 @@
<orderEntry type="library" exported="" name="android-async-http-1.4.6" level="project" /> <orderEntry type="library" exported="" name="android-async-http-1.4.6" level="project" />
</component> </component>
</module> </module>

View File

@ -13,7 +13,8 @@
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
android:name=".OpenLP" android:name=".OpenLP"
android:label="@string/app_name" > android:label="@string/app_name"
android:configChanges="orientation">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -18,24 +18,19 @@
*******************************************************************************/ *******************************************************************************/
package org.openlp.android2; package org.openlp.android2;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.app.ActionBar; import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import org.openlp.android2.activities.SettingsActivity; import org.openlp.android2.activities.SettingsActivity;
import org.openlp.android2.common.NavigationOptions; import org.openlp.android2.common.NavigationOptions;
import org.openlp.android2.dialogs.AlertDisplayDialog; import org.openlp.android2.dialogs.AlertDisplayDialog;
@ -62,8 +57,6 @@ public class OpenLP extends ActionBarActivity
*/ */
private final String LOG_TAG = OpenLP.class.getName(); private final String LOG_TAG = OpenLP.class.getName();
private CharSequence mTitle; private CharSequence mTitle;
private boolean backArrowActive = false;
private Menu dropdownMenu;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -94,6 +87,12 @@ public class OpenLP extends ActionBarActivity
} }
} }
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//here you can handle orientation change
Log.d(LOG_TAG, "Changed direction");
}
@Override @Override
public void onNavigationDrawerItemSelected(int position) { public void onNavigationDrawerItemSelected(int position) {
@ -101,41 +100,66 @@ public class OpenLP extends ActionBarActivity
FragmentManager fragmentManager = getFragmentManager(); FragmentManager fragmentManager = getFragmentManager();
switch (position) { switch (position) {
case NavigationOptions.Home: case NavigationOptions.Home:
singleTab();
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.replace(R.id.container, HomeFragment.newInstance()) .replace(R.id.container, HomeFragment.newInstance())
.commit(); .commit();
mTitle = getString(R.string.home); mTitle = getString(R.string.home);
break; break;
case NavigationOptions.ServiceList: case NavigationOptions.ServiceList:
singleTab();
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.replace(R.id.container, ServiceListFragment.newInstance()) .replace(R.id.container, ServiceListFragment.newInstance())
.commit(); .commit();
mTitle = getString(R.string.service_list); mTitle = getString(R.string.service_list);
break; break;
case NavigationOptions.LiveList: case NavigationOptions.LiveList:
duelTab();
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.replace(R.id.container, LiveListFragment.newInstance()) .replace(R.id.container_left, ServiceListFragment.newInstance())
.commit();
fragmentManager.beginTransaction()
.replace(R.id.container_right, LiveListFragment.newInstance())
.commit(); .commit();
mTitle = getString(R.string.live_list); mTitle = getString(R.string.live_list);
break; break;
case NavigationOptions.StageView: case NavigationOptions.StageView:
singleTab();
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.replace(R.id.container, StageWebFragment.newInstance()) .replace(R.id.container, StageWebFragment.newInstance())
.commit(); .commit();
mTitle = getString(R.string.stage_view); mTitle = getString(R.string.stage_view);
break; break;
case NavigationOptions.LiveView: case NavigationOptions.LiveView:
singleTab();
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.replace(R.id.container, LiveWebFragment.newInstance()) .replace(R.id.container, LiveWebFragment.newInstance())
.commit(); .commit();
mTitle = getString(R.string.live_view); mTitle = getString(R.string.live_view);
break; break;
} }
menuVisible(); }
protected void duelTab(){
toggerContainer(R.id.container, View.GONE);
toggerContainer(R.id.container_right, View.VISIBLE);
toggerContainer(R.id.container_left, View.VISIBLE);
}
protected void singleTab(){
toggerContainer(R.id.container_right, View.GONE);
toggerContainer(R.id.container_left, View.GONE);
toggerContainer(R.id.container, View.VISIBLE);
}
protected void toggerContainer(int container, int direction){
View cTainer = this.findViewById(container);
if (cTainer != null) {
cTainer.setVisibility(direction);
}
} }
public void restoreActionBar() { public void restoreActionBar() {
try { try {
ActionBar actionBar = getActionBar(); ActionBar actionBar = getActionBar();
//actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
@ -146,25 +170,6 @@ public class OpenLP extends ActionBarActivity
} }
} }
public void setMenuActive(){
backArrowActive = true;
}
public void menuVisible() {
if (dropdownMenu != null){
MenuItem checkable = dropdownMenu.findItem(R.id.action_back);
if (checkable != null) {
if (backArrowActive) {
checkable.setVisible(true);
} else {
checkable.setVisible(false);
}
}
}
backArrowActive = false;
//restoreActionBar();
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
if (!mNavigationDrawerFragment.isDrawerOpen()) { if (!mNavigationDrawerFragment.isDrawerOpen()) {
@ -185,22 +190,16 @@ public class OpenLP extends ActionBarActivity
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
Intent intent; Intent intent;
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_back:
onNavigationDrawerItemSelected(NavigationOptions.ServiceList);
return true;
case R.id.action_preferences: case R.id.action_preferences:
intent = new Intent(this, SettingsActivity.class); intent = new Intent(this, SettingsActivity.class);
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.action_refresh: case R.id.action_refresh:
if (this.mTitle.equals(getString(R.string.service_list))) { if (this.mTitle.equals(getString(R.string.service_list))) {
ServiceListFragment fragment = (ServiceListFragment) refreshServiceFragment(R.id.container);
getFragmentManager().findFragmentById(R.id.container);
fragment.refreshDisplay();
} else if (this.mTitle.equals(getString(R.string.live_list)) ) { } else if (this.mTitle.equals(getString(R.string.live_list)) ) {
LiveListFragment fragment = (LiveListFragment) refreshServiceFragment(R.id.container_left);
getFragmentManager().findFragmentById(R.id.container); refreshLiveFragment(R.id.container_right);
fragment.refreshDisplay();
} }
return true; return true;
case R.id.action_blank: case R.id.action_blank:
@ -216,43 +215,18 @@ public class OpenLP extends ActionBarActivity
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
} }
public void refreshLiveFragment(int container){
/** LiveListFragment fragment = (LiveListFragment)
* A placeholder fragment containing a simple view. getFragmentManager().findFragmentById(container);
*/ if (fragment != null) {
public static class PlaceholderFragment extends Fragment { fragment.refreshDisplay();
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
} }
public PlaceholderFragment() {
} }
public void refreshServiceFragment(int container){
@Override ServiceListFragment fragment = (ServiceListFragment)
public View onCreateView(LayoutInflater inflater, ViewGroup container, getFragmentManager().findFragmentById(container);
Bundle savedInstanceState) { if (fragment != null) {
return inflater.inflate(R.layout.fragment_main, container, false); fragment.refreshDisplay();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
//((OpenLP) activity).onSectionAttached(
// getArguments().getInt(ARG_SECTION_NUMBER));
} }
} }

View File

@ -46,9 +46,6 @@ import org.openlp.android2.common.OpenLPHttpClient;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
public class LiveListFragment extends OpenLPFragment { public class LiveListFragment extends OpenLPFragment {
@ -134,6 +131,8 @@ public class LiveListFragment extends OpenLPFragment {
if (selected == position) { if (selected == position) {
text2.setTextColor(Color.parseColor("#000000")); text2.setTextColor(Color.parseColor("#000000"));
text2.setTypeface(null, Typeface.BOLD_ITALIC); text2.setTypeface(null, Typeface.BOLD_ITALIC);
} else{
text2.setTypeface(null, Typeface.NORMAL);
} }
return view; return view;
@ -160,6 +159,7 @@ public class LiveListFragment extends OpenLPFragment {
public void processUpdate(String response, boolean inError) { public void processUpdate(String response, boolean inError) {
triggerTextRequest(Api.LIVE_TEXT); triggerTextRequest(Api.LIVE_TEXT);
} }
public void itemClicked(int position) { public void itemClicked(int position) {

View File

@ -36,7 +36,6 @@ import org.openlp.android2.R;
import org.openlp.android2.api.Api; import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers; import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.NavigationOptions;
import org.openlp.android2.common.OpenLPFragment; import org.openlp.android2.common.OpenLPFragment;
import org.openlp.android2.common.OpenLPHttpClient; import org.openlp.android2.common.OpenLPHttpClient;
@ -72,21 +71,6 @@ public class ServiceListFragment extends OpenLPFragment {
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
AdapterView.OnItemLongClickListener listener = new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long id) {
Toast.makeText(getActivity().getBaseContext(), "Long Clicked ", Toast.LENGTH_SHORT).show();
itemClicked(position);
noScreenUpdate = true;
isDoubleClick = true;
((OpenLP) getActivity()).setMenuActive();
((OpenLP) getActivity()).onNavigationDrawerItemSelected(NavigationOptions.LiveList);
((OpenLP) getActivity()).restoreActionBar();
return false;
}
};
getListView().setOnItemLongClickListener(listener);
} }
@Override @Override
@ -115,6 +99,7 @@ public class ServiceListFragment extends OpenLPFragment {
public void processUpdate(String response, boolean inError) { public void processUpdate(String response, boolean inError) {
triggerTextRequest(Api.SERVICE_LIST); triggerTextRequest(Api.SERVICE_LIST);
((OpenLP) getActivity()).refreshLiveFragment(R.id.container_right);
} }
@Override @Override
@ -200,5 +185,4 @@ public class ServiceListFragment extends OpenLPFragment {
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
} }
} }
} }

View File

@ -12,6 +12,26 @@
android:id="@+id/container" android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container_left"
android:layout_weight="1"
android:layout_gravity="start"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<FrameLayout
android:id="@+id/container_right"
android:layout_weight="1"
android:layout_gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp" />
</LinearLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat <!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right this as a sliding drawer on the left side for left-to-right
@ -24,7 +44,7 @@
android:id="@+id/navigation_drawer" android:id="@+id/navigation_drawer"
android:name="org.openlp.android2.fragments.NavigationDrawerFragment" android:name="org.openlp.android2.fragments.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width" android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent" android:layout_height="fill_parent"
android:layout_gravity="start" android:layout_gravity="start"
tools:layout="@layout/fragment_navigation_drawer" /> tools:layout="@layout/fragment_navigation_drawer" />

View File

@ -1,11 +1,5 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_back"
android:checkable="true"
android:visible="false"
android:icon="@drawable/ic_arrow_back"
android:title="@string/action_back"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_blank" <item android:id="@+id/action_blank"
android:checkable="true" android:checkable="true"
android:visible="true" android:visible="true"