1
0
mirror of https://gitlab.com/openlp/android.git synced 2024-12-22 03:42:48 +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"?>
<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">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
@ -15,5 +16,4 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
</module>

View File

@ -1,5 +1,5 @@
<?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">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
@ -12,8 +12,9 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<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="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="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
@ -90,5 +91,4 @@
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.6" level="project" />
</component>
</module>
</module>

View File

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

View File

@ -18,24 +18,19 @@
*******************************************************************************/
package org.openlp.android2;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity;
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.widget.DrawerLayout;
import org.openlp.android2.activities.SettingsActivity;
import org.openlp.android2.common.NavigationOptions;
import org.openlp.android2.dialogs.AlertDisplayDialog;
@ -62,8 +57,6 @@ public class OpenLP extends ActionBarActivity
*/
private final String LOG_TAG = OpenLP.class.getName();
private CharSequence mTitle;
private boolean backArrowActive = false;
private Menu dropdownMenu;
@Override
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
public void onNavigationDrawerItemSelected(int position) {
@ -101,41 +100,66 @@ public class OpenLP extends ActionBarActivity
FragmentManager fragmentManager = getFragmentManager();
switch (position) {
case NavigationOptions.Home:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, HomeFragment.newInstance())
.commit();
mTitle = getString(R.string.home);
break;
case NavigationOptions.ServiceList:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, ServiceListFragment.newInstance())
.commit();
mTitle = getString(R.string.service_list);
break;
case NavigationOptions.LiveList:
duelTab();
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();
mTitle = getString(R.string.live_list);
break;
case NavigationOptions.StageView:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, StageWebFragment.newInstance())
.commit();
mTitle = getString(R.string.stage_view);
break;
case NavigationOptions.LiveView:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, LiveWebFragment.newInstance())
.commit();
mTitle = getString(R.string.live_view);
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() {
try {
ActionBar actionBar = getActionBar();
//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
public boolean onCreateOptionsMenu(Menu menu) {
if (!mNavigationDrawerFragment.isDrawerOpen()) {
@ -185,22 +190,16 @@ public class OpenLP extends ActionBarActivity
// as you specify a parent activity in AndroidManifest.xml.
Intent intent;
switch (item.getItemId()) {
case R.id.action_back:
onNavigationDrawerItemSelected(NavigationOptions.ServiceList);
return true;
case R.id.action_preferences:
intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
case R.id.action_refresh:
if (this.mTitle.equals(getString(R.string.service_list))) {
ServiceListFragment fragment = (ServiceListFragment)
getFragmentManager().findFragmentById(R.id.container);
fragment.refreshDisplay();
refreshServiceFragment(R.id.container);
} else if (this.mTitle.equals(getString(R.string.live_list)) ) {
LiveListFragment fragment = (LiveListFragment)
getFragmentManager().findFragmentById(R.id.container);
fragment.refreshDisplay();
refreshServiceFragment(R.id.container_left);
refreshLiveFragment(R.id.container_right);
}
return true;
case R.id.action_blank:
@ -216,43 +215,18 @@ public class OpenLP extends ActionBarActivity
return super.onOptionsItemSelected(item);
}
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* 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 void refreshLiveFragment(int container){
LiveListFragment fragment = (LiveListFragment)
getFragmentManager().findFragmentById(container);
if (fragment != null) {
fragment.refreshDisplay();
}
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_main, container, false);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
//((OpenLP) activity).onSectionAttached(
// getArguments().getInt(ARG_SECTION_NUMBER));
}
public void refreshServiceFragment(int container){
ServiceListFragment fragment = (ServiceListFragment)
getFragmentManager().findFragmentById(container);
if (fragment != null) {
fragment.refreshDisplay();
}
}

View File

@ -46,9 +46,6 @@ import org.openlp.android2.common.OpenLPHttpClient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
public class LiveListFragment extends OpenLPFragment {
@ -134,6 +131,8 @@ public class LiveListFragment extends OpenLPFragment {
if (selected == position) {
text2.setTextColor(Color.parseColor("#000000"));
text2.setTypeface(null, Typeface.BOLD_ITALIC);
} else{
text2.setTypeface(null, Typeface.NORMAL);
}
return view;
@ -160,6 +159,7 @@ public class LiveListFragment extends OpenLPFragment {
public void processUpdate(String response, boolean inError) {
triggerTextRequest(Api.LIVE_TEXT);
}
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.common.JsonHelpers;
import org.openlp.android2.common.NavigationOptions;
import org.openlp.android2.common.OpenLPFragment;
import org.openlp.android2.common.OpenLPHttpClient;
@ -72,21 +71,6 @@ public class ServiceListFragment extends OpenLPFragment {
@Override
public void onActivityCreated(Bundle 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
@ -115,6 +99,7 @@ public class ServiceListFragment extends OpenLPFragment {
public void processUpdate(String response, boolean inError) {
triggerTextRequest(Api.SERVICE_LIST);
((OpenLP) getActivity()).refreshLiveFragment(R.id.container_right);
}
@Override
@ -200,5 +185,4 @@ public class ServiceListFragment extends OpenLPFragment {
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -12,6 +12,26 @@
android:id="@+id/container"
android:layout_width="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
this as a sliding drawer on the left side for left-to-right
@ -24,7 +44,7 @@
android:id="@+id/navigation_drawer"
android:name="org.openlp.android2.fragments.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="start"
tools:layout="@layout/fragment_navigation_drawer" />

View File

@ -1,11 +1,5 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:checkable="true"
android:visible="true"