package com.zzliaoyuan.decorate_touch.activity;

import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import com.zzliaoyuan.decorate_touch.MainApplication;
import com.zzliaoyuan.decorate_touch.R;

public class PushActivity extends ReactActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_push);

        Log.d("TPush", "********************PushActivity");
        Uri uri = getIntent().getData();
        if (uri != null) {
            //String url = uri.toString();
            String type = uri.getQueryParameter("type");
            String id = uri.getQueryParameter("target_id");

            String msg = "?type="+type+"&target_id="+id;

            Log.d("TPush", msg);

            MainApplication.GetReactPackage().reactModule.sendMsgToRN("PushFromAndroid", msg);
        }
        finish();
    }

    @Override
    protected String getMainComponentName() {
        return "decorate_touch";
    }

    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegate(this, getMainComponentName()) {
            @Override
            protected ReactRootView createRootView() {
                return new RNGestureHandlerEnabledRootView(PushActivity.this);
            }
        };
    }
}
