Changeset View
Changeset View
Standalone View
Standalone View
app/src/main/java/it/reyboz/bustorino/fragments/ArrivalsFragment.java
Show All 12 Lines | BusTO - Fragments components | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.fragments; | package it.reyboz.bustorino.fragments; | ||||
import android.annotation.SuppressLint; | |||||
import android.content.Context; | import android.content.Context; | ||||
import android.database.Cursor; | import android.database.Cursor; | ||||
import android.net.Uri; | import android.net.Uri; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.widget.*; | |||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.core.widget.NestedScrollView; | |||||
import androidx.loader.app.LoaderManager; | import androidx.loader.app.LoaderManager; | ||||
import androidx.loader.content.CursorLoader; | import androidx.loader.content.CursorLoader; | ||||
import androidx.loader.content.Loader; | import androidx.loader.content.Loader; | ||||
import android.util.Log; | import android.util.Log; | ||||
import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
import android.view.View; | import android.view.View; | ||||
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import android.widget.ImageButton; | |||||
import android.widget.ListAdapter; | |||||
import android.widget.TextView; | |||||
import android.widget.Toast; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
import androidx.recyclerview.widget.DividerItemDecoration; | |||||
import androidx.recyclerview.widget.GridLayoutManager; | |||||
import androidx.recyclerview.widget.LinearLayoutManager; | |||||
import androidx.recyclerview.widget.RecyclerView; | |||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
import it.reyboz.bustorino.adapters.AdapterClickListener; | |||||
import it.reyboz.bustorino.adapters.PalinaAdapter; | import it.reyboz.bustorino.adapters.PalinaAdapter; | ||||
import it.reyboz.bustorino.adapters.RouteOnlyLineAdapter; | |||||
import it.reyboz.bustorino.backend.ArrivalsFetcher; | import it.reyboz.bustorino.backend.ArrivalsFetcher; | ||||
import it.reyboz.bustorino.backend.DBStatusManager; | import it.reyboz.bustorino.backend.DBStatusManager; | ||||
import it.reyboz.bustorino.backend.Fetcher; | import it.reyboz.bustorino.backend.Fetcher; | ||||
import it.reyboz.bustorino.backend.FiveTNormalizer; | import it.reyboz.bustorino.backend.FiveTNormalizer; | ||||
import it.reyboz.bustorino.backend.Palina; | import it.reyboz.bustorino.backend.Palina; | ||||
import it.reyboz.bustorino.backend.Passaggio; | import it.reyboz.bustorino.backend.Passaggio; | ||||
import it.reyboz.bustorino.backend.Route; | import it.reyboz.bustorino.backend.Route; | ||||
import it.reyboz.bustorino.backend.Stop; | import it.reyboz.bustorino.backend.Stop; | ||||
import it.reyboz.bustorino.backend.utils; | import it.reyboz.bustorino.backend.utils; | ||||
import it.reyboz.bustorino.data.AppDataProvider; | import it.reyboz.bustorino.data.AppDataProvider; | ||||
import it.reyboz.bustorino.data.NextGenDB; | import it.reyboz.bustorino.data.NextGenDB; | ||||
import it.reyboz.bustorino.data.UserDB; | import it.reyboz.bustorino.data.UserDB; | ||||
import it.reyboz.bustorino.middleware.AsyncStopFavoriteAction; | import it.reyboz.bustorino.middleware.AsyncStopFavoriteAction; | ||||
import it.reyboz.bustorino.util.LinesNameSorter; | |||||
import it.reyboz.bustorino.util.ViewUtils; | |||||
public class ArrivalsFragment extends ResultListFragment implements LoaderManager.LoaderCallbacks<Cursor> { | public class ArrivalsFragment extends ResultBaseFragment implements LoaderManager.LoaderCallbacks<Cursor> { | ||||
private final static String KEY_STOP_ID = "stopid"; | private final static String KEY_STOP_ID = "stopid"; | ||||
private final static String KEY_STOP_NAME = "stopname"; | private final static String KEY_STOP_NAME = "stopname"; | ||||
private final static String DEBUG_TAG_ALL = "BUSTOArrivalsFragment"; | private final static String DEBUG_TAG_ALL = "BUSTOArrivalsFragment"; | ||||
private String DEBUG_TAG = DEBUG_TAG_ALL; | private String DEBUG_TAG = DEBUG_TAG_ALL; | ||||
private final static int loaderFavId = 2; | private final static int loaderFavId = 2; | ||||
private final static int loaderStopId = 1; | private final static int loaderStopId = 1; | ||||
static final String STOP_TITLE = "messageExtra"; | static final String STOP_TITLE = "messageExtra"; | ||||
private final static String SOURCES_TEXT="sources_textview_message"; | private final static String SOURCES_TEXT="sources_textview_message"; | ||||
private @Nullable String stopID,stopName; | private @Nullable String stopID,stopName; | ||||
private DBStatusManager prefs; | private DBStatusManager prefs; | ||||
private DBStatusManager.OnDBUpdateStatusChangeListener listener; | private DBStatusManager.OnDBUpdateStatusChangeListener listener; | ||||
private boolean justCreated = false; | private boolean justCreated = false; | ||||
private Palina lastUpdatedPalina = null; | private Palina lastUpdatedPalina = null; | ||||
private boolean needUpdateOnAttach = false; | private boolean needUpdateOnAttach = false; | ||||
private boolean fetchersChangeRequestPending = false; | private boolean fetchersChangeRequestPending = false; | ||||
private boolean stopIsInFavorites = false; | private boolean stopIsInFavorites = false; | ||||
//Views | //Views | ||||
protected ImageButton addToFavorites; | protected ImageButton addToFavorites; | ||||
protected TextView timesSourceTextView; | protected TextView timesSourceTextView; | ||||
protected TextView messageTextView; | |||||
protected RecyclerView arrivalsRecyclerView; | |||||
private PalinaAdapter mListAdapter = null; | |||||
//private NestedScrollView theScrollView; | |||||
protected RecyclerView noArrivalsRecyclerView; | |||||
private RouteOnlyLineAdapter noArrivalsAdapter; | |||||
private TextView noArrivalsTitleView; | |||||
private GridLayoutManager layoutManager; | |||||
//private View canaryEndView; | |||||
private List<ArrivalsFetcher> fetchers = null; //new ArrayList<>(Arrays.asList(utils.getDefaultArrivalsFetchers())); | private List<ArrivalsFetcher> fetchers = null; //new ArrayList<>(Arrays.asList(utils.getDefaultArrivalsFetchers())); | ||||
private boolean reloadOnResume = true; | private boolean reloadOnResume = true; | ||||
private final AdapterClickListener<Route> mRouteClickListener = route -> { | |||||
String routeName; | |||||
routeName = FiveTNormalizer.routeInternalToDisplay(route.getNameForDisplay()); | |||||
if (routeName == null) { | |||||
routeName = route.getNameForDisplay(); | |||||
} | |||||
if(getContext()==null) | |||||
Log.e(DEBUG_TAG, "Touched on a route but Context is null"); | |||||
else if (route.destinazione == null || route.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, route.destinazione), Toast.LENGTH_SHORT).show(); | |||||
} | |||||
}; | |||||
public static ArrivalsFragment newInstance(String stopID){ | public static ArrivalsFragment newInstance(String stopID){ | ||||
return newInstance(stopID, null); | return newInstance(stopID, null); | ||||
} | } | ||||
public static ArrivalsFragment newInstance(@NonNull String stopID, @Nullable String stopName){ | public static ArrivalsFragment newInstance(@NonNull String stopID, @Nullable String stopName){ | ||||
ArrivalsFragment fragment = new ArrivalsFragment(); | ArrivalsFragment fragment = new ArrivalsFragment(); | ||||
Bundle args = new Bundle(); | Bundle args = new Bundle(); | ||||
args.putString(KEY_STOP_ID,stopID); | args.putString(KEY_STOP_ID,stopID); | ||||
//parameter for ResultListFragmentrequestArrivalsForStopID | //parameter for ResultListFragmentrequestArrivalsForStopID | ||||
args.putSerializable(LIST_TYPE,FragmentKind.ARRIVALS); | //args.putSerializable(LIST_TYPE,FragmentKind.ARRIVALS); | ||||
if (stopName != null){ | if (stopName != null){ | ||||
args.putString(KEY_STOP_NAME,stopName); | args.putString(KEY_STOP_NAME,stopName); | ||||
} | } | ||||
fragment.setArguments(args); | fragment.setArguments(args); | ||||
return fragment; | return fragment; | ||||
} | } | ||||
public static String getFragmentTag(Palina p) { | |||||
return "palina_"+p.ID; | |||||
} | |||||
@Override | @Override | ||||
public void onCreate(Bundle savedInstanceState) { | public void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
stopID = getArguments().getString(KEY_STOP_ID); | stopID = getArguments().getString(KEY_STOP_ID); | ||||
DEBUG_TAG = DEBUG_TAG_ALL+" "+stopID; | DEBUG_TAG = DEBUG_TAG_ALL+" "+stopID; | ||||
//this might really be null | //this might really be null | ||||
stopName = getArguments().getString(KEY_STOP_NAME); | stopName = getArguments().getString(KEY_STOP_NAME); | ||||
Show All 21 Lines | public class ArrivalsFragment extends ResultBaseFragment implements LoaderManager.LoaderCallbacks<Cursor> { | ||||
} | } | ||||
@Override | @Override | ||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||||
Bundle savedInstanceState) { | Bundle savedInstanceState) { | ||||
View root = inflater.inflate(R.layout.fragment_arrivals, container, false); | View root = inflater.inflate(R.layout.fragment_arrivals, container, false); | ||||
messageTextView = root.findViewById(R.id.messageTextView); | messageTextView = root.findViewById(R.id.messageTextView); | ||||
addToFavorites = root.findViewById(R.id.addToFavorites); | addToFavorites = root.findViewById(R.id.addToFavorites); | ||||
resultsListView = root.findViewById(R.id.resultsListView); | //theScrollView = root.findViewById(R.id.arrivalsScrollView); | ||||
// recyclerview holding the arrival times | |||||
arrivalsRecyclerView = root.findViewById(R.id.arrivalsRecyclerView); | |||||
final LinearLayoutManager manager = new LinearLayoutManager(getContext()); | |||||
arrivalsRecyclerView.setLayoutManager(manager); | |||||
final DividerItemDecoration mDividerItemDecoration = new DividerItemDecoration(arrivalsRecyclerView.getContext(), | |||||
manager.getOrientation()); | |||||
arrivalsRecyclerView.addItemDecoration(mDividerItemDecoration); | |||||
timesSourceTextView = root.findViewById(R.id.timesSourceTextView); | timesSourceTextView = root.findViewById(R.id.timesSourceTextView); | ||||
timesSourceTextView.setOnLongClickListener(view -> { | timesSourceTextView.setOnLongClickListener(view -> { | ||||
if(!fetchersChangeRequestPending){ | if(!fetchersChangeRequestPending){ | ||||
rotateFetchers(); | rotateFetchers(); | ||||
//Show we are changing provider | //Show we are changing provider | ||||
timesSourceTextView.setText(R.string.arrival_source_changing); | timesSourceTextView.setText(R.string.arrival_source_changing); | ||||
mListener.requestArrivalsForStopID(stopID); | mListener.requestArrivalsForStopID(stopID); | ||||
fetchersChangeRequestPending = true; | fetchersChangeRequestPending = true; | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
}); | }); | ||||
timesSourceTextView.setOnClickListener(view -> { | timesSourceTextView.setOnClickListener(view -> { | ||||
Toast.makeText(getContext(), R.string.change_arrivals_source_message, Toast.LENGTH_SHORT) | Toast.makeText(getContext(), R.string.change_arrivals_source_message, Toast.LENGTH_SHORT) | ||||
.show(); | .show(); | ||||
}); | }); | ||||
//Button | //Button | ||||
addToFavorites.setClickable(true); | addToFavorites.setClickable(true); | ||||
addToFavorites.setOnClickListener(v -> { | addToFavorites.setOnClickListener(v -> { | ||||
// add/remove the stop in the favorites | // add/remove the stop in the favorites | ||||
toggleLastStopToFavorites(); | toggleLastStopToFavorites(); | ||||
}); | }); | ||||
resultsListView.setOnItemClickListener((parent, view, position, 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); | String displayName = getArguments().getString(STOP_TITLE); | ||||
if(displayName!=null) | if(displayName!=null) | ||||
setTextViewMessage(String.format( | setTextViewMessage(String.format( | ||||
getString(R.string.passages), displayName)); | getString(R.string.passages), displayName)); | ||||
String probablemessage = getArguments().getString(MESSAGE_TEXT_VIEW); | String probablemessage = getArguments().getString(MESSAGE_TEXT_VIEW); | ||||
if (probablemessage != null) { | if (probablemessage != null) { | ||||
//Log.d("BusTO fragment " + this.getTag(), "We have a possible message here in the savedInstaceState: " + probablemessage); | //Log.d("BusTO fragment " + this.getTag(), "We have a possible message here in the savedInstaceState: " + probablemessage); | ||||
messageTextView.setText(probablemessage); | messageTextView.setText(probablemessage); | ||||
messageTextView.setVisibility(View.VISIBLE); | messageTextView.setVisibility(View.VISIBLE); | ||||
} | } | ||||
//no arrivals stuff | |||||
noArrivalsRecyclerView = root.findViewById(R.id.noArrivalsRecyclerView); | |||||
layoutManager = new GridLayoutManager(getContext(),60); | |||||
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { | |||||
@Override | |||||
public int getSpanSize(int position) { | |||||
return 12; | |||||
} | |||||
}); | |||||
noArrivalsRecyclerView.setLayoutManager(layoutManager); | |||||
noArrivalsTitleView = root.findViewById(R.id.noArrivalsMessageTextView); | |||||
//canaryEndView = root.findViewById(R.id.canaryEndView); | |||||
/*String sourcesTextViewData = getArguments().getString(SOURCES_TEXT); | /*String sourcesTextViewData = getArguments().getString(SOURCES_TEXT); | ||||
if (sourcesTextViewData!=null){ | if (sourcesTextViewData!=null){ | ||||
timesSourceTextView.setText(sourcesTextViewData); | timesSourceTextView.setText(sourcesTextViewData); | ||||
}*/ | }*/ | ||||
//need to do this when we recreate the fragment but we haven't updated the arrival times | //need to do this when we recreate the fragment but we haven't updated the arrival times | ||||
if (lastUpdatedPalina!=null) | if (lastUpdatedPalina!=null) | ||||
showArrivalsSources(lastUpdatedPalina); | showArrivalsSources(lastUpdatedPalina); | ||||
return root; | return root; | ||||
} | } | ||||
@Override | @Override | ||||
public void onResume() { | public void onResume() { | ||||
super.onResume(); | super.onResume(); | ||||
LoaderManager loaderManager = getLoaderManager(); | LoaderManager loaderManager = getLoaderManager(); | ||||
Log.d(DEBUG_TAG, "OnResume, justCreated "+justCreated); | Log.d(DEBUG_TAG, "OnResume, justCreated "+justCreated+", lastUpdatedPalina is: "+lastUpdatedPalina); | ||||
/*if(needUpdateOnAttach){ | /*if(needUpdateOnAttach){ | ||||
updateFragmentData(null); | updateFragmentData(null); | ||||
needUpdateOnAttach=false; | needUpdateOnAttach=false; | ||||
}*/ | }*/ | ||||
/*if(lastUpdatedPalina!=null){ | |||||
updateFragmentData(null); | |||||
showArrivalsSources(lastUpdatedPalina); | |||||
}*/ | |||||
if (mListAdapter!=null) | |||||
resetListAdapter(mListAdapter); | |||||
if(noArrivalsAdapter!=null){ | |||||
noArrivalsRecyclerView.setAdapter(noArrivalsAdapter); | |||||
} | |||||
if(stopID!=null){ | if(stopID!=null){ | ||||
//refresh the arrivals | |||||
if(!justCreated){ | if(!justCreated){ | ||||
fetchers = utils.getDefaultArrivalsFetchers(getContext()); | fetchers = utils.getDefaultArrivalsFetchers(getContext()); | ||||
adjustFetchersToSource(); | adjustFetchersToSource(); | ||||
if (reloadOnResume) | if (reloadOnResume) | ||||
mListener.requestArrivalsForStopID(stopID); | mListener.requestArrivalsForStopID(stopID); | ||||
} | } | ||||
else justCreated = false; | else justCreated = false; | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | public void updateFragmentData(@Nullable Palina p){ | ||||
if (!isAdded()){ | if (!isAdded()){ | ||||
//defer update at next show | //defer update at next show | ||||
if (p==null) | if (p==null) | ||||
Log.w(DEBUG_TAG, "Asked to update the data, but we're not attached and the data is null"); | Log.w(DEBUG_TAG, "Asked to update the data, but we're not attached and the data is null"); | ||||
else needUpdateOnAttach = true; | else needUpdateOnAttach = true; | ||||
} else { | } else { | ||||
final PalinaAdapter adapter = new PalinaAdapter(getContext(), lastUpdatedPalina); | final PalinaAdapter adapter = new PalinaAdapter(getContext(), lastUpdatedPalina, mRouteClickListener, true); | ||||
showArrivalsSources(lastUpdatedPalina); | showArrivalsSources(lastUpdatedPalina); | ||||
super.resetListAdapter(adapter); | resetListAdapter(adapter); | ||||
final ArrayList<String> routesWithNoPassages = lastUpdatedPalina.getRoutesNamesWithNoPassages(); | |||||
Collections.sort(routesWithNoPassages, new LinesNameSorter()); | |||||
noArrivalsAdapter = new RouteOnlyLineAdapter(routesWithNoPassages); | |||||
if(noArrivalsRecyclerView!=null){ | |||||
noArrivalsRecyclerView.setAdapter(noArrivalsAdapter); | |||||
//hide the views if there are no empty routes | |||||
if(routesWithNoPassages.isEmpty()){ | |||||
noArrivalsRecyclerView.setVisibility(View.GONE); | |||||
noArrivalsTitleView.setVisibility(View.GONE); | |||||
} else { | |||||
noArrivalsRecyclerView.setVisibility(View.VISIBLE); | |||||
noArrivalsTitleView.setVisibility(View.VISIBLE); | |||||
} | |||||
} | } | ||||
//canaryEndView.setVisibility(View.VISIBLE); | |||||
//check if canaryEndView is visible | |||||
//boolean isCanaryVisibile = ViewUtils.Companion.isViewPartiallyVisibleInScroll(canaryEndView, theScrollView); | |||||
//Log.d(DEBUG_TAG, "Canary view fully visibile: "+isCanaryVisibile); | |||||
} | } | ||||
} | |||||
/** | /** | ||||
* Set the message of the arrival times source | * Set the message of the arrival times source | ||||
* @param p Palina with the arrival times | * @param p Palina with the arrival times | ||||
*/ | */ | ||||
protected void showArrivalsSources(Palina p){ | protected void showArrivalsSources(Palina p){ | ||||
final Passaggio.Source source = p.getPassaggiSourceIfAny(); | final Passaggio.Source source = p.getPassaggiSourceIfAny(); | ||||
if (source == null){ | if (source == null){ | ||||
Show All 22 Lines | protected void showArrivalsSources(Palina p){ | ||||
throw new IllegalStateException("Unexpected value: " + source); | throw new IllegalStateException("Unexpected value: " + source); | ||||
} | } | ||||
// | // | ||||
final boolean updatedFetchers = adjustFetchersToSource(source); | final boolean updatedFetchers = adjustFetchersToSource(source); | ||||
if(!updatedFetchers) | if(!updatedFetchers) | ||||
Log.w(DEBUG_TAG, "Tried to update the source fetcher but it didn't work"); | Log.w(DEBUG_TAG, "Tried to update the source fetcher but it didn't work"); | ||||
final String base_message = getString(R.string.times_source_fmt, source_txt); | final String base_message = getString(R.string.times_source_fmt, source_txt); | ||||
timesSourceTextView.setText(base_message); | timesSourceTextView.setText(base_message); | ||||
timesSourceTextView.setVisibility(View.VISIBLE); | |||||
if (p.getTotalNumberOfPassages() > 0) { | if (p.getTotalNumberOfPassages() > 0) { | ||||
timesSourceTextView.setVisibility(View.VISIBLE); | timesSourceTextView.setVisibility(View.VISIBLE); | ||||
} else { | } else { | ||||
timesSourceTextView.setVisibility(View.INVISIBLE); | timesSourceTextView.setVisibility(View.INVISIBLE); | ||||
} | } | ||||
fetchersChangeRequestPending = false; | fetchersChangeRequestPending = false; | ||||
} | } | ||||
Show All 10 Lines | public class ArrivalsFragment extends ResultBaseFragment implements LoaderManager.LoaderCallbacks<Cursor> { | ||||
} | } | ||||
protected boolean adjustFetchersToSource(){ | protected boolean adjustFetchersToSource(){ | ||||
if (lastUpdatedPalina == null) return false; | if (lastUpdatedPalina == null) return false; | ||||
final Passaggio.Source source = lastUpdatedPalina.getPassaggiSourceIfAny(); | final Passaggio.Source source = lastUpdatedPalina.getPassaggiSourceIfAny(); | ||||
return adjustFetchersToSource(source); | return adjustFetchersToSource(source); | ||||
} | } | ||||
@Override | |||||
public void setNewListAdapter(ListAdapter adapter) { | |||||
throw new UnsupportedOperationException(); | |||||
} | |||||
/** | /** | ||||
* Update the message in the fragment | * Update the message in the fragment | ||||
* | * | ||||
* It may eventually change the "Add to Favorite" icon | * It may eventually change the "Add to Favorite" icon | ||||
*/ | */ | ||||
private void updateMessage(){ | private void updateMessage(){ | ||||
String message = null; | String message = null; | ||||
if (stopName != null && stopID != null && stopName.length() > 0) { | if (stopName != null && stopID != null && stopName.length() > 0) { | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | public void onLoadFinished(Loader<Cursor> loader, Cursor data) { | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onLoaderReset(Loader<Cursor> loader) { | public void onLoaderReset(Loader<Cursor> loader) { | ||||
//NOTHING TO DO | //NOTHING TO DO | ||||
} | } | ||||
protected void resetListAdapter(PalinaAdapter adapter) { | |||||
mListAdapter = adapter; | |||||
if (arrivalsRecyclerView != null) { | |||||
arrivalsRecyclerView.setAdapter(adapter); | |||||
arrivalsRecyclerView.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); | |||||
messageTextView.setVisibility(View.VISIBLE); | |||||
} | |||||
public void toggleLastStopToFavorites() { | public void toggleLastStopToFavorites() { | ||||
Stop stop = lastUpdatedPalina; | Stop stop = lastUpdatedPalina; | ||||
if (stop != null) { | if (stop != null) { | ||||
// toggle the status in background | // toggle the status in background | ||||
new AsyncStopFavoriteAction(getContext().getApplicationContext(), AsyncStopFavoriteAction.Action.TOGGLE, | new AsyncStopFavoriteAction(getContext().getApplicationContext(), AsyncStopFavoriteAction.Action.TOGGLE, | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | public void updateStarIcon() { | ||||
addToFavorites.setVisibility(View.VISIBLE); | addToFavorites.setVisibility(View.VISIBLE); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onDestroyView() { | public void onDestroyView() { | ||||
arrivalsRecyclerView = null; | |||||
if(getArguments()!=null) { | |||||
getArguments().putString(SOURCES_TEXT, timesSourceTextView.getText().toString()); | getArguments().putString(SOURCES_TEXT, timesSourceTextView.getText().toString()); | ||||
getArguments().putString(MESSAGE_TEXT_VIEW, messageTextView.getText().toString()); | |||||
} | |||||
super.onDestroyView(); | super.onDestroyView(); | ||||
} | } | ||||
public boolean isFragmentForTheSameStop(Palina p) { | |||||
if (getTag() != null) | |||||
return getTag().equals(getFragmentTag(p)); | |||||
else return false; | |||||
} | |||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register