Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2013 Square Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package flow;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static flow.Preconditions.checkArgument;
import static flow.Preconditions.checkNotNull;
/** Holds the current truth, the history of screens, and exposes operations to change it. */
public final class Flow {
static final Object ROOT_KEY = new Object() {
@Override public String toString() {
return Flow.class.getName() + ".ROOT_KEY";
}
};
public static Flow get(View view) {
return get(view.getContext());
}
public static Flow get(Context context) {
return InternalContextWrapper.getFlow(context);
}
/** @return null if context has no Flow key embedded. */
@Nullable public static T getKey(Context context) {
final FlowContextWrapper wrapper = FlowContextWrapper.get(context);
if (wrapper == null) return null;
return wrapper.services.getKey();
}
/** @return null if view's Context has no Flow key embedded. */
@Nullable public static T getKey(View view) {
return getKey(view.getContext());
}
/** @return null if context does not contain the named service. */
@Nullable public static T getService(String serviceName, Context context) {
final FlowContextWrapper wrapper = FlowContextWrapper.get(context);
if (wrapper == null) return null;
return wrapper.services.getService(serviceName);
}
public static Installer configure(Context baseContext, Activity activity) {
return new Installer(baseContext, activity);
}
/** Adds a history as an extra to an Intent. */
public static void addHistory(Intent intent, History history, KeyParceler parceler) {
InternalLifecycleIntegration.addHistoryToIntent(intent, history, parceler);
}
/**
* Handles an Intent carrying a History extra.
*
* @return true if the Intent contains a History and it was handled.
*/
public static boolean onNewIntent(Intent intent, Activity activity) {
checkArgument(intent != null, "intent may not be null");
if (intent.hasExtra(InternalLifecycleIntegration.INTENT_KEY)) {
InternalLifecycleIntegration.find(activity).onNewIntent(intent);
return true;
}
return false;
}
private History history;
private Dispatcher dispatcher;
private PendingTraversal pendingTraversal;
private List