// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
// 
//     public abstract long id();
// 
//     public abstract String title();
// 
//     @Nullable
//     public abstract String description();
// 
//     public abstract int width();
// 
//     public abstract int height();
// 
//     public abstract Images images();
// 
//     public abstract long views_count();
// 
//     public abstract long likes_count();
// 
//     public abstract long comments_count();
// 
//     public abstract long attachments_count();
// 
//     public abstract long rebounds_count();
// 
//     public abstract long buckets_count();
// 
//     public abstract Date created_at();
// 
//     public abstract Date updated_at();
// 
//     public abstract String html_url();
// 
//     public abstract String attachments_url();
// 
//     public abstract String buckets_url();
// 
//     public abstract String comments_url();
// 
//     public abstract String likes_url();
// 
//     public abstract String projects_url();
// 
//     public abstract String rebounds_url();
// 
//     public abstract boolean animated();
// 
//     public abstract List<String> tags();
// 
//     @Nullable
//     public abstract User user();
// 
//     @Nullable
//     public abstract Team team();
// 
//     public abstract Shot withUser(User user);
// 
//     public abstract Shot withLikesCount(long likes_count);
// 
//     public static TypeAdapter<Shot> typeAdapter(Gson gson) {
//         return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
//     }
// }
// 
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
// 
//     public static void log(String message) {
//         // no-op for product flavor open
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
// 
//     protected boolean login;
// 
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         login = AccountManager.getInstance().isLogin();
//     }
// 
// }


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.airbnb.deeplinkdispatch.DeepLink;
import com.ge.protein.R;
import com.ge.protein.data.model.Shot;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;
/*
 * Copyright 2017 Jiaheng Ge
 *
 * 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 com.ge.protein.shot;



@DeepLink("https://dribbble.com/shots/{id}")
public class ShotActivity extends BaseProteinActivity {

    public static final String EXTRA_SHOT = "extra_shot";

    private ShotPresenter shotPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FirebaseCrashUtils.log("ShotActivity created");

        setContentView(R.layout.activity_simple_fragment);

        Intent intent = getIntent();
        boolean isDeepLink = intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false);
        long shotId;
        Shot shot;
        // create view
        ShotFragment shotFragment = (ShotFragment) getSupportFragmentManager()
                .findFragmentByTag(ShotFragment.class.getSimpleName());
        if (shotFragment == null) {
            shotFragment = ShotFragment.newInstance();
            getSupportFragmentManager()
                    .beginTransaction()
                    .add(R.id.container, shotFragment, ShotFragment.class.getSimpleName())
                    .commit();
        }
        // hook presenter
        if (isDeepLink) {
            String id = intent.getExtras().getString("id");
            // https://dribbble.com/shots/3495164-Google-people and https://dribbble.com/shots/3495164
            // are both valid
            int dashIndex = TextUtils.isEmpty(id) ? -1 : id.indexOf("-");
            if (dashIndex != -1) {
                id = id.substring(0, dashIndex);
            }
            shotId = Long.parseLong(id);
// Path: app/src/main/java/com/ge/protein/data/model/Shot.java
// @AutoValue
// public abstract class Shot implements Parcelable {
// 
//     public abstract long id();
// 
//     public abstract String title();
// 
//     @Nullable
//     public abstract String description();
// 
//     public abstract int width();
// 
//     public abstract int height();
// 
//     public abstract Images images();
// 
//     public abstract long views_count();
// 
//     public abstract long likes_count();
// 
//     public abstract long comments_count();
// 
//     public abstract long attachments_count();
// 
//     public abstract long rebounds_count();
// 
//     public abstract long buckets_count();
// 
//     public abstract Date created_at();
// 
//     public abstract Date updated_at();
// 
//     public abstract String html_url();
// 
//     public abstract String attachments_url();
// 
//     public abstract String buckets_url();
// 
//     public abstract String comments_url();
// 
//     public abstract String likes_url();
// 
//     public abstract String projects_url();
// 
//     public abstract String rebounds_url();
// 
//     public abstract boolean animated();
// 
//     public abstract List<String> tags();
// 
//     @Nullable
//     public abstract User user();
// 
//     @Nullable
//     public abstract Team team();
// 
//     public abstract Shot withUser(User user);
// 
//     public abstract Shot withLikesCount(long likes_count);
// 
//     public static TypeAdapter<Shot> typeAdapter(Gson gson) {
//         return new AutoValue_Shot.GsonTypeAdapter(gson).nullSafe();
//     }
// }
// 
// Path: app/src/open/java/com/ge/protein/firebase/FirebaseCrashUtils.java
// public class FirebaseCrashUtils {
// 
//     public static void log(String message) {
//         // no-op for product flavor open
//     }
// }
// 
// Path: app/src/main/java/com/ge/protein/ui/activity/BaseProteinActivity.java
// public abstract class BaseProteinActivity extends RxAppCompatActivity {
// 
//     protected boolean login;
// 
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         login = AccountManager.getInstance().isLogin();
//     }
// 
// }


// Path: app/src/main/java/com/ge/protein/shot/ShotActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.airbnb.deeplinkdispatch.DeepLink;
import com.ge.protein.R;
import com.ge.protein.data.model.Shot;
import com.ge.protein.firebase.FirebaseCrashUtils;
import com.ge.protein.ui.activity.BaseProteinActivity;

/*
 * Copyright 2017 Jiaheng Ge
 *
 * 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 com.ge.protein.shot;



@DeepLink("https://dribbble.com/shots/{id}")
public class ShotActivity extends BaseProteinActivity {

    public static final String EXTRA_SHOT = "extra_shot";

    private ShotPresenter shotPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FirebaseCrashUtils.log("ShotActivity created");

        setContentView(R.layout.activity_simple_fragment);

        Intent intent = getIntent();
        boolean isDeepLink = intent.getBooleanExtra(DeepLink.IS_DEEP_LINK, false);
        long shotId;
        Shot shot;
        // create view
        ShotFragment shotFragment = (ShotFragment) getSupportFragmentManager()
                .findFragmentByTag(ShotFragment.class.getSimpleName());
        if (shotFragment == null) {
            shotFragment = ShotFragment.newInstance();
            getSupportFragmentManager()
                    .beginTransaction()
                    .add(R.id.container, shotFragment, ShotFragment.class.getSimpleName())
                    .commit();
        }
        // hook presenter
        if (isDeepLink) {
            String id = intent.getExtras().getString("id");
            // https://dribbble.com/shots/3495164-Google-people and https://dribbble.com/shots/3495164
            // are both valid
            int dashIndex = TextUtils.isEmpty(id) ? -1 : id.indexOf("-");
            if (dashIndex != -1) {
                id = id.substring(0, dashIndex);
            }
            shotId = Long.parseLong(id);
            shotPresenter = new ShotPresenter(shotFragment, shotId);