|
|
@@ -4,30 +4,35 @@ import android.Manifest;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.PackageManager;
|
|
|
-import android.os.Bundle;
|
|
|
+import android.net.Uri;
|
|
|
import android.support.annotation.NonNull;
|
|
|
import android.util.Log;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.google.gson.GsonBuilder;
|
|
|
-
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.util.Set;
|
|
|
+import com.google.android.gms.tasks.OnFailureListener;
|
|
|
+import com.google.android.gms.tasks.OnSuccessListener;
|
|
|
+import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
|
|
|
+import com.google.firebase.dynamiclinks.PendingDynamicLinkData;
|
|
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
import kr.co.zumo.app.R;
|
|
|
import kr.co.zumo.app.lifeplus.application.App;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.PushBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.EventDeliveryBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.EventDetailBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
|
|
|
+import kr.co.zumo.app.lifeplus.config.NetworkConfigProvider;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModelInit;
|
|
|
import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.ActivityDeliveryHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.supervisor.PushMessageManager;
|
|
|
+import kr.co.zumo.app.lifeplus.tool.ShareKakaoTalk;
|
|
|
import kr.co.zumo.app.lifeplus.util.PermissionUtil;
|
|
|
+import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
+import kr.co.zumo.app.lifeplus.view.IWaiterCallable;
|
|
|
+import kr.co.zumo.app.lifeplus.view.animation.LoadingDriver;
|
|
|
+import kr.co.zumo.app.lifeplus.view.screen.event.EventDetailDelegate;
|
|
|
|
|
|
/**
|
|
|
* Splash 화면
|
|
|
@@ -46,38 +51,90 @@ public class SplashActivity extends ActivityBaseSetup {
|
|
|
|
|
|
@Override
|
|
|
protected void setup() {
|
|
|
-
|
|
|
- Context context = App.getInstance().getContext();
|
|
|
-
|
|
|
- // has push message ?
|
|
|
- Bundle bundle = getIntent().getExtras();
|
|
|
- if (null != bundle) {
|
|
|
- // push message 는 pageId 가 있어야한다.
|
|
|
- if(bundle.get("pageId") != null ) {
|
|
|
- Log.d("APP# SplashActivity | setup", "| extras: " + bundle);
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- Set<String> keys = bundle.keySet();
|
|
|
- for (String key : keys) {
|
|
|
- try {
|
|
|
- json.put(key, JSONObject.wrap(bundle.get(key)));
|
|
|
- } catch (JSONException e) {
|
|
|
- //Handle exception here
|
|
|
+ FirebaseDynamicLinks.getInstance()
|
|
|
+ .getDynamicLink(getIntent())
|
|
|
+ .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
|
|
|
+ // Get deep link from result (may be null if no link is found)
|
|
|
+ Uri uri = null;
|
|
|
+ if (pendingDynamicLinkData != null) {
|
|
|
+ uri = pendingDynamicLinkData.getLink();
|
|
|
+
|
|
|
+ final String itemNo = null != uri ? uri.getQueryParameter(ShareKakaoTalk.CONTENTS_ITEM_NO) : "";
|
|
|
+ final String page = null != uri ? uri.getQueryParameter(ShareKakaoTalk.CONTENTS_ITEM_PAGE) : "0";
|
|
|
+ final String pageType = null != uri ? uri.getQueryParameter(ShareKakaoTalk.LINK_TYPE) : ShareKakaoTalk.LINK_TYPE_CONTENTS;
|
|
|
+
|
|
|
+ Log.i("APP# SplashActivity | setup", "|" + " pageType: " + pageType + " itemNo: " + itemNo + ", page: " + page);
|
|
|
+
|
|
|
+ if (StringUtil.isFull(itemNo)) {
|
|
|
+
|
|
|
+ if (ShareKakaoTalk.LINK_TYPE_CONTENTS.equals(pageType)) {
|
|
|
+ // contents 데이터 준비
|
|
|
+ LifeplusContentsBean lifeplusContentsBean = new LifeplusContentsBean();
|
|
|
+ lifeplusContentsBean.setItemNo(itemNo);
|
|
|
+
|
|
|
+ ContentsDeliveryBean contentsDeliveryBean = new ContentsDeliveryBean.Builder(lifeplusContentsBean).pageIndex(Integer.parseInt(page)).build();
|
|
|
+
|
|
|
+ ActivityDeliveryHelper.getInstance().setPackaging(contentsDeliveryBean);
|
|
|
+ SuperModel.getInstance().setContentsLink(true);
|
|
|
+
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // event
|
|
|
+ // 이벤트 구분 후 전달해야한다.
|
|
|
+ SuperModelInit.instant(getApplicationContext());
|
|
|
+ NetworkConfigProvider.init();
|
|
|
+ LoadingDriver loadingDriver = new LoadingDriver();
|
|
|
+ new EventDetailDelegate().loadEvent(itemNo, new EventDetailDelegate.IEventDetailDelegateListener() {
|
|
|
+ @Override
|
|
|
+ public void onLoadSuccess(EventDetailBean eventDetailBean, int screenId, EventDeliveryBean eventDeliveryBean) {
|
|
|
+ SuperModel.getInstance().setEventLink(true);
|
|
|
+ ActivityDeliveryHelper.getInstance().setPackaging(eventDeliveryBean);
|
|
|
+ next();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoadFail(String errorMessage) {
|
|
|
+ Log.e("APP# ContentsGateActivity | onLoadFail", "|" + errorMessage);
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ }, new IWaiterCallable() {
|
|
|
+ @Override
|
|
|
+ public void showWaiter() {
|
|
|
+ loadingDriver.create(SplashActivity.this, 10);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void hideWaiter() {
|
|
|
+ loadingDriver.remove();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ next();
|
|
|
}
|
|
|
}
|
|
|
+ })
|
|
|
+ .addOnFailureListener(this, new OnFailureListener() {
|
|
|
+ @Override
|
|
|
+ public void onFailure(@NonNull Exception e) {
|
|
|
+ Log.e("APP# SplashActivity | onFailure", "|" + "e -> " + e);
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- Gson gson = new GsonBuilder().create();
|
|
|
-
|
|
|
- PushBean bean = gson.fromJson(json.toString(), PushBean.class);
|
|
|
- Log.d("APP# SplashActivity | setup", "|" + bean.toJson());
|
|
|
+ private void next() {
|
|
|
+ setupInternal();
|
|
|
+ }
|
|
|
|
|
|
- SuperModelInit.instant(getApplicationContext());
|
|
|
- PushMessageManager.onReceived(bean);
|
|
|
+ protected void setupInternal() {
|
|
|
|
|
|
- // fixme PushGateActivity 와 중복되는 부분이 있다.
|
|
|
- ActivityDeliveryHelper.getInstance().setPackaging(bean);
|
|
|
- SuperModel.getInstance().setPushLink(true);
|
|
|
- }
|
|
|
- }
|
|
|
+ Context context = App.getInstance().getContext();
|
|
|
|
|
|
// 앱이 실행 중인지 판단한다.
|
|
|
if (SuperModel.getInstance().isAppInitialized()) {
|