Page MenuHomeGitPull.it

D17.1779724696.diff
No OneTemporary

Authored By
Unknown
Size
30 KB
Referenced Files
None
Subscribers
None

D17.1779724696.diff

diff --git a/build.gradle b/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -1,84 +1,84 @@
-buildscript {
- repositories {
- jcenter()
- maven { url 'https://maven.google.com' }
- google()
-
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.1.0'
- }
- ext {
- support_ver = "25.4.0"
- }
-}
-allprojects {
- repositories {
- jcenter()
- maven { url 'https://maven.google.com' }
- google()
-
- }
-}
-
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 25
- buildToolsVersion '27.0.3'
-
- defaultConfig {
- applicationId "it.reyboz.bustorino"
- minSdkVersion 9
- targetSdkVersion 25
- versionCode 27
- versionName "1.11"
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
- }
- buildTypes {
- debug {
- applicationIdSuffix ".debug"
- versionNameSuffix "-dev"
- }
- }
-
- lintOptions {
- abortOnError false
- }
-
- repositories {
- jcenter()
- mavenLocal()
- }
-
- dependencies {
- implementation "com.android.support:support-v4:$support_ver"
- implementation "com.android.support:appcompat-v7:$support_ver"
- implementation "com.android.support:design:$support_ver"
- implementation "com.android.support:recyclerview-v7:$support_ver"
- implementation "com.android.support:preference-v7:$support_ver"
- implementation "com.android.support:cardview-v7:$support_ver"
-
-
- implementation 'org.jsoup:jsoup:1.11.3'
- implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
- implementation 'com.android.volley:volley:1.1.1'
- }
-}
+buildscript {
+ repositories {
+ jcenter()
+ maven { url 'https://maven.google.com' }
+ google()
+
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.0'
+ }
+ ext {
+ support_ver = "25.4.0"
+ }
+}
+allprojects {
+ repositories {
+ jcenter()
+ maven { url 'https://maven.google.com' }
+ google()
+
+ }
+}
+
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion '27.0.3'
+
+ defaultConfig {
+ applicationId "it.reyboz.bustorino"
+ minSdkVersion 9
+ targetSdkVersion 25
+ versionCode 27
+ versionName "1.11"
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDirs = ['src']
+ resources.srcDirs = ['src']
+ aidl.srcDirs = ['src']
+ renderscript.srcDirs = ['src']
+ res.srcDirs = ['res']
+ assets.srcDirs = ['assets']
+ }
+ }
+ buildTypes {
+ debug {
+ applicationIdSuffix ".debug"
+ versionNameSuffix "-dev"
+ }
+ }
+
+ lintOptions {
+ abortOnError false
+ }
+
+ repositories {
+ jcenter()
+ mavenLocal()
+ }
+
+ dependencies {
+ implementation "com.android.support:support-v4:$support_ver"
+ implementation "com.android.support:appcompat-v7:$support_ver"
+ implementation "com.android.support:design:$support_ver"
+ implementation "com.android.support:recyclerview-v7:$support_ver"
+ implementation "com.android.support:preference-v7:$support_ver"
+ implementation "com.android.support:cardview-v7:$support_ver"
+
+
+ implementation 'org.jsoup:jsoup:1.11.3'
+ implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
+ implementation 'com.android.volley:volley:1.1.1'
+ }
+}
diff --git a/res/layout/fragment_list_view.xml b/res/layout/fragment_list_view.xml
--- a/res/layout/fragment_list_view.xml
+++ b/res/layout/fragment_list_view.xml
@@ -1,28 +1,46 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:fab="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
- android:layout_marginStart="16dp"
- android:layout_marginTop="10dp"
- android:id="@+id/messageTextView" android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:minHeight="48dp"
- android:layout_marginBottom="10dp" />
- <ListView
- android:layout_below="@id/messageTextView"
- android:id="@+id/resultsListView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clickable="true"
- android:descendantFocusability="blocksDescendants"
- android:visibility="visible"
- />
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:fab="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+
+ <TextView
+ android:id="@+id/messageTextView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginEnd="307dp"
+ android:layout_marginRight="10dp"
+ android:layout_marginBottom="10dp"
+ android:layout_toStartOf="@+id/addToFavorites"
+ android:layout_toLeftOf="@+id/addToFavorites"
+ android:gravity="center_vertical"
+ android:minHeight="48dp"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <ImageButton
+ android:id="@+id/addToFavorites"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/resultsListView"
+ android:layout_alignParentRight="true"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginRight="16dp"
+ android:layout_marginBottom="16dp"
+ android:background="@android:color/transparent"
+ fab:srcCompat="@android:drawable/btn_star_big_off" />
+
+ <ListView
+ android:layout_below="@id/messageTextView"
+ android:id="@+id/resultsListView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clickable="true"
+ android:descendantFocusability="blocksDescendants"
+ android:visibility="visible"
+ />
</RelativeLayout>
\ No newline at end of file
diff --git a/src/it/reyboz/bustorino/fragments/ResultListFragment.java b/src/it/reyboz/bustorino/fragments/ResultListFragment.java
--- a/src/it/reyboz/bustorino/fragments/ResultListFragment.java
+++ b/src/it/reyboz/bustorino/fragments/ResultListFragment.java
@@ -1,293 +1,295 @@
-/*
- BusTO - Fragments components
- Copyright (C) 2016 Fabio Mazza
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-package it.reyboz.bustorino.fragments;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.support.v4.widget.SwipeRefreshLayout;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import android.widget.*;
-import android.support.design.widget.FloatingActionButton;
-import it.reyboz.bustorino.ActivityMain;
-import it.reyboz.bustorino.R;
-import it.reyboz.bustorino.backend.FiveTNormalizer;
-import it.reyboz.bustorino.backend.Palina;
-import it.reyboz.bustorino.backend.Route;
-import it.reyboz.bustorino.backend.Stop;
-
-/**
- * This is a generalized fragment that can be used both for
- *
- *
- */
-public class ResultListFragment extends Fragment{
- // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- static final String LIST_TYPE = "list-type";
- private static final String STOP_TITLE = "messageExtra";
- protected static final String LIST_STATE = "list_state";
-
-
- private static final String MESSAGE_TEXT_VIEW = "message_text_view";
- private FragmentKind adapterKind;
-
- private boolean adapterSet = false;
- protected FragmentListener mListener;
- private TextView messageTextView;
-
- private FloatingActionButton fabutton;
- private ListView resultsListView;
- private ListAdapter mListAdapter = null;
- boolean listShown;
- private Parcelable mListInstanceState = null;
-
- public ResultListFragment() {
- // Required empty public constructor
- }
-
- public ListView getResultsListView() {
- return resultsListView;
- }
-
- /**
- * Use this factory method to create a new instance of
- * this fragment using the provided parameters.
- *
- * @param listType whether the list is used for STOPS or LINES (Orari)
- * @return A new instance of fragment ResultListFragment.
- */
- public static ResultListFragment newInstance(FragmentKind listType, String eventualStopTitle) {
- ResultListFragment fragment = new ResultListFragment();
- Bundle args = new Bundle();
- args.putSerializable(LIST_TYPE, listType);
- if (eventualStopTitle != null)
- args.putString(STOP_TITLE, eventualStopTitle);
- fragment.setArguments(args);
- return fragment;
- }
-
- public static ResultListFragment newInstance(FragmentKind listType) {
- return newInstance(listType, null);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getArguments() != null) {
- adapterKind = (FragmentKind) getArguments().getSerializable(LIST_TYPE);
- }
- }
-
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View root = inflater.inflate(R.layout.fragment_list_view, container, false);
- messageTextView = (TextView) root.findViewById(R.id.messageTextView);
- if (adapterKind != null) {
- resultsListView = (ListView) root.findViewById(R.id.resultsListView);
- switch (adapterKind) {
- case STOPS:
- resultsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- /*
- * Casting because of Javamerda
- * @url http://stackoverflow.com/questions/30549485/androids-list-view-parameterized-type-in-adapterview-onitemclicklistener
- */
- Stop busStop = (Stop) parent.getItemAtPosition(position);
- mListener.createFragmentForStop(busStop.ID);
- }
- });
-
- //set the textviewMessage
- setTextViewMessage(getString(R.string.results));
- break;
- case ARRIVALS:
- resultsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- String routeName;
-
- Route r = (Route) parent.getItemAtPosition(position);
- routeName = FiveTNormalizer.routeInternalToDisplay(r.getNameForDisplay());
- if (routeName == null) {
- routeName = r.getNameForDisplay();
- }
- if (r.destinazione == null || r.destinazione.length() == 0) {
- Toast.makeText(getContext(),
- getString(R.string.route_towards_unknown, routeName), Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(getContext(),
- getString(R.string.route_towards_destination, routeName, r.destinazione), Toast.LENGTH_SHORT).show();
- }
- }
- });
- String displayName = getArguments().getString(STOP_TITLE);
- setTextViewMessage(String.format(
- getString(R.string.passages), displayName));
- break;
- default:
- throw new IllegalStateException("Argument passed was not of a supported type");
- }
-
- String probablemessage = getArguments().getString(MESSAGE_TEXT_VIEW);
- if (probablemessage != null) {
- //Log.d("BusTO fragment " + this.getTag(), "We have a possible message here in the savedInstaceState: " + probablemessage);
- messageTextView.setText(probablemessage);
- messageTextView.setVisibility(View.VISIBLE);
- }
-
- } else
- Log.d(getString(R.string.list_fragment_debug), "No content root for fragment");
- return root;
- }
-
- public boolean isFragmentForTheSameStop(Palina p) {
- return adapterKind.equals(FragmentKind.ARRIVALS) && getTag().equals(getFragmentTag(p));
- }
-
- public static String getFragmentTag(Palina p) {
- return p.ID;
- }
-
-
- @Override
- public void onResume() {
- super.onResume();
- //Log.d(getString(R.string.list_fragment_debug),"Fragment restored, saved listAdapter is "+(mListAdapter));
- if (mListAdapter != null) {
-
- ListAdapter adapter = mListAdapter;
- mListAdapter = null;
- setListAdapter(adapter);
- }
- if (mListInstanceState != null) {
- Log.d("resultsListView", "trying to restore instance state");
- resultsListView.onRestoreInstanceState(mListInstanceState);
- }
- switch (adapterKind) {
- case ARRIVALS:
- resultsListView.setOnScrollListener(new CommonScrollListener(mListener, true));
- fabutton.show();
- break;
- case STOPS:
- resultsListView.setOnScrollListener(new CommonScrollListener(mListener, false));
- break;
- default:
- //NONE
- }
- mListener.readyGUIfor(adapterKind);
-
- }
-
- @Override
- public void onPause() {
- if (adapterKind.equals(FragmentKind.ARRIVALS)) {
- SwipeRefreshLayout reflay = (SwipeRefreshLayout) getActivity().findViewById(R.id.listRefreshLayout);
- reflay.setEnabled(false);
- Log.d("BusTO Fragment " + this.getTag(), "RefreshLayout disabled");
- }
- super.onPause();
- }
-
- @Override
- public void onAttach(Context context) {
- super.onAttach(context);
- if (context instanceof FragmentListener) {
- mListener = (FragmentListener) context;
- fabutton = (FloatingActionButton) getActivity().findViewById(R.id.floatingActionButton);
- } else {
- throw new RuntimeException(context.toString()
- + " must implement ResultFragmentListener");
- }
-
- }
-
-
- @Override
- public void onDetach() {
- mListener = null;
- if (fabutton != null)
- fabutton.show();
- super.onDetach();
- }
-
-
- @Override
- public void onDestroyView() {
- resultsListView = null;
- //Log.d(getString(R.string.list_fragment_debug), "called onDestroyView");
- getArguments().putString(MESSAGE_TEXT_VIEW, messageTextView.getText().toString());
- super.onDestroyView();
- }
-
-
- @Override
- public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
- super.onViewStateRestored(savedInstanceState);
- Log.d("ResultListFragment", "onViewStateRestored");
- if (savedInstanceState != null) {
- mListInstanceState = savedInstanceState.getParcelable(LIST_STATE);
- Log.d("ResultListFragment", "listInstanceStatePresent :" + mListInstanceState);
- }
- }
-
- public void setListAdapter(ListAdapter adapter) {
- boolean hadAdapter = mListAdapter != null;
- mListAdapter = adapter;
- if (resultsListView != null) {
- resultsListView.setAdapter(adapter);
- resultsListView.setVisibility(View.VISIBLE);
- }
- }
-
- /**
- * Set the message textView
- * @param message the whole message to write in the textView
- */
- public void setTextViewMessage(String message) {
- messageTextView.setText(message);
- switch (adapterKind) {
- case ARRIVALS:
- final ActivityMain activ = (ActivityMain) getActivity();
- messageTextView.setClickable(true);
- messageTextView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mListener.addLastStopToFavorites();
- }
- });
- break;
- case STOPS:
- messageTextView.setClickable(false);
- break;
- }
-
- messageTextView.setVisibility(View.VISIBLE);
- }
-}
+/*
+ BusTO - Fragments components
+ Copyright (C) 2016 Fabio Mazza
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+package it.reyboz.bustorino.fragments;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import android.widget.*;
+import android.support.design.widget.FloatingActionButton;
+import it.reyboz.bustorino.ActivityMain;
+import it.reyboz.bustorino.R;
+import it.reyboz.bustorino.backend.FiveTNormalizer;
+import it.reyboz.bustorino.backend.Palina;
+import it.reyboz.bustorino.backend.Route;
+import it.reyboz.bustorino.backend.Stop;
+
+/**
+ * This is a generalized fragment that can be used both for
+ *
+ *
+ */
+public class ResultListFragment extends Fragment{
+ // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
+ static final String LIST_TYPE = "list-type";
+ private static final String STOP_TITLE = "messageExtra";
+ protected static final String LIST_STATE = "list_state";
+
+
+ private static final String MESSAGE_TEXT_VIEW = "message_text_view";
+ private FragmentKind adapterKind;
+
+ private boolean adapterSet = false;
+ protected FragmentListener mListener;
+ private TextView messageTextView;
+ private ImageButton addToFavorites;
+
+ private FloatingActionButton fabutton;
+ private ListView resultsListView;
+ private ListAdapter mListAdapter = null;
+ boolean listShown;
+ private Parcelable mListInstanceState = null;
+
+ public ResultListFragment() {
+ // Required empty public constructor
+ }
+
+ public ListView getResultsListView() {
+ return resultsListView;
+ }
+
+ /**
+ * Use this factory method to create a new instance of
+ * this fragment using the provided parameters.
+ *
+ * @param listType whether the list is used for STOPS or LINES (Orari)
+ * @return A new instance of fragment ResultListFragment.
+ */
+ public static ResultListFragment newInstance(FragmentKind listType, String eventualStopTitle) {
+ ResultListFragment fragment = new ResultListFragment();
+ Bundle args = new Bundle();
+ args.putSerializable(LIST_TYPE, listType);
+ if (eventualStopTitle != null)
+ args.putString(STOP_TITLE, eventualStopTitle);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ public static ResultListFragment newInstance(FragmentKind listType) {
+ return newInstance(listType, null);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getArguments() != null) {
+ adapterKind = (FragmentKind) getArguments().getSerializable(LIST_TYPE);
+ }
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View root = inflater.inflate(R.layout.fragment_list_view, container, false);
+ messageTextView = (TextView) root.findViewById(R.id.messageTextView);
+ addToFavorites = (ImageButton) root.findViewById(R.id.addToFavorites);
+ if (adapterKind != null) {
+ resultsListView = (ListView) root.findViewById(R.id.resultsListView);
+ switch (adapterKind) {
+ case STOPS:
+ resultsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ /*
+ * Casting because of Javamerda
+ * @url http://stackoverflow.com/questions/30549485/androids-list-view-parameterized-type-in-adapterview-onitemclicklistener
+ */
+ Stop busStop = (Stop) parent.getItemAtPosition(position);
+ mListener.createFragmentForStop(busStop.ID);
+ }
+ });
+
+ //set the textviewMessage
+ setTextViewMessage(getString(R.string.results));
+ break;
+ case ARRIVALS:
+ resultsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ String routeName;
+
+ Route r = (Route) parent.getItemAtPosition(position);
+ routeName = FiveTNormalizer.routeInternalToDisplay(r.getNameForDisplay());
+ if (routeName == null) {
+ routeName = r.getNameForDisplay();
+ }
+ if (r.destinazione == null || r.destinazione.length() == 0) {
+ Toast.makeText(getContext(),
+ getString(R.string.route_towards_unknown, routeName), Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(getContext(),
+ getString(R.string.route_towards_destination, routeName, r.destinazione), Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ String displayName = getArguments().getString(STOP_TITLE);
+ setTextViewMessage(String.format(
+ getString(R.string.passages), displayName));
+ break;
+ default:
+ throw new IllegalStateException("Argument passed was not of a supported type");
+ }
+
+ String probablemessage = getArguments().getString(MESSAGE_TEXT_VIEW);
+ if (probablemessage != null) {
+ //Log.d("BusTO fragment " + this.getTag(), "We have a possible message here in the savedInstaceState: " + probablemessage);
+ messageTextView.setText(probablemessage);
+ messageTextView.setVisibility(View.VISIBLE);
+ }
+
+ } else
+ Log.d(getString(R.string.list_fragment_debug), "No content root for fragment");
+ return root;
+ }
+
+ public boolean isFragmentForTheSameStop(Palina p) {
+ return adapterKind.equals(FragmentKind.ARRIVALS) && getTag().equals(getFragmentTag(p));
+ }
+
+ public static String getFragmentTag(Palina p) {
+ return p.ID;
+ }
+
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ //Log.d(getString(R.string.list_fragment_debug),"Fragment restored, saved listAdapter is "+(mListAdapter));
+ if (mListAdapter != null) {
+
+ ListAdapter adapter = mListAdapter;
+ mListAdapter = null;
+ setListAdapter(adapter);
+ }
+ if (mListInstanceState != null) {
+ Log.d("resultsListView", "trying to restore instance state");
+ resultsListView.onRestoreInstanceState(mListInstanceState);
+ }
+ switch (adapterKind) {
+ case ARRIVALS:
+ resultsListView.setOnScrollListener(new CommonScrollListener(mListener, true));
+ fabutton.show();
+ break;
+ case STOPS:
+ resultsListView.setOnScrollListener(new CommonScrollListener(mListener, false));
+ break;
+ default:
+ //NONE
+ }
+ mListener.readyGUIfor(adapterKind);
+
+ }
+
+ @Override
+ public void onPause() {
+ if (adapterKind.equals(FragmentKind.ARRIVALS)) {
+ SwipeRefreshLayout reflay = (SwipeRefreshLayout) getActivity().findViewById(R.id.listRefreshLayout);
+ reflay.setEnabled(false);
+ Log.d("BusTO Fragment " + this.getTag(), "RefreshLayout disabled");
+ }
+ super.onPause();
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ if (context instanceof FragmentListener) {
+ mListener = (FragmentListener) context;
+ fabutton = (FloatingActionButton) getActivity().findViewById(R.id.floatingActionButton);
+ } else {
+ throw new RuntimeException(context.toString()
+ + " must implement ResultFragmentListener");
+ }
+
+ }
+
+
+ @Override
+ public void onDetach() {
+ mListener = null;
+ if (fabutton != null)
+ fabutton.show();
+ super.onDetach();
+ }
+
+
+ @Override
+ public void onDestroyView() {
+ resultsListView = null;
+ //Log.d(getString(R.string.list_fragment_debug), "called onDestroyView");
+ getArguments().putString(MESSAGE_TEXT_VIEW, messageTextView.getText().toString());
+ super.onDestroyView();
+ }
+
+
+ @Override
+ public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
+ super.onViewStateRestored(savedInstanceState);
+ Log.d("ResultListFragment", "onViewStateRestored");
+ if (savedInstanceState != null) {
+ mListInstanceState = savedInstanceState.getParcelable(LIST_STATE);
+ Log.d("ResultListFragment", "listInstanceStatePresent :" + mListInstanceState);
+ }
+ }
+
+ public void setListAdapter(ListAdapter adapter) {
+ boolean hadAdapter = mListAdapter != null;
+ mListAdapter = adapter;
+ if (resultsListView != null) {
+ resultsListView.setAdapter(adapter);
+ resultsListView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ /**
+ * Set the message textView
+ * @param message the whole message to write in the textView
+ */
+ public void setTextViewMessage(String message) {
+ messageTextView.setText(message);
+ switch (adapterKind) {
+ case ARRIVALS:
+ final ActivityMain activ = (ActivityMain) getActivity();
+ addToFavorites.setClickable(true);
+ addToFavorites.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mListener.addLastStopToFavorites();
+ }
+ });
+ break;
+ case STOPS:
+ addToFavorites.setClickable(false);
+ break;
+ }
+
+ messageTextView.setVisibility(View.VISIBLE);
+ }
+}
\ No newline at end of file

File Metadata

Mime Type
text/plain
Expires
Mon, May 25, 17:58 (15 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1920809
Default Alt Text
D17.1779724696.diff (30 KB)

Event Timeline