/*
 * Copyright (c) 2017 Hazuki
 *
 * 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 jp.hazuki.yuzubrowser.tab.manager;

import android.graphics.Bitmap;
import android.view.View;

import java.io.Serializable;

import jp.hazuki.yuzubrowser.webkit.CustomWebView;

public class TabIndexData implements Serializable {
    private String mUrl;
    private String mTitle;
    private int tabType;
    private long mId;
    private long parent;
    private Bitmap thumbnail;
    private boolean thumbnailUpdated;
    private boolean shotThumbnail;

    public TabIndexData() {
    }

    public TabIndexData(String url, String title, int tabType, long id, long parent) {
        this.mUrl = url;
        this.mTitle = title;
        this.tabType = tabType;
        this.mId = id;
        this.parent = parent;
    }

    public String getUrl() {
        return mUrl;
    }

    public String getTitle() {
        return mTitle;
    }

    public int getTabType() {
        return tabType;
    }

    public long getId() {
        return mId;
    }

    public long getParent() {
        return parent;
    }

    void setTabType(int tabType) {
        this.tabType = tabType;
    }

    void setId(long id) {
        this.mId = id;
    }

    void setParent(long parent) {
        this.parent = parent;
    }

    public void setUrl(String url) {
        this.mUrl = url;
    }

    public void setTitle(String title) {
        this.mTitle = title;
    }

    public MainTabData getMainTabData(CustomWebView webView, View view) {
        webView.setIdentityId(mId);

        return new MainTabData(webView, view, this);
    }

    public TabData getTabData(CustomWebView webView) {
        webView.setIdentityId(mId);

        return new TabData(webView, this);
    }

    public Bitmap getThumbnail() {
        return thumbnail;
    }

    public void setThumbnail(Bitmap thumbnail) {
        this.thumbnail = thumbnail;
    }

    public boolean isThumbnailUpdated() {
        return thumbnailUpdated;
    }

    void setThumbnailUpdated(boolean thumbnailUpdated) {
        this.thumbnailUpdated = thumbnailUpdated;
    }

    public boolean isShotThumbnail() {
        return shotThumbnail;
    }

    public void setShotThumbnail(boolean shotThumbnail) {
        this.shotThumbnail = shotThumbnail;
        if (shotThumbnail) {
            thumbnailUpdated = true;
        }
    }
}

@@ -1186,39 +1186,104 @@
 ) %7B%0A        
-this.mUrl = url
+if (url != null)%0A            this.mUrl = url;%0A        else%0A            mUrl = %22%22
 ;%0A        th
@@ -1927,39 +1927,104 @@
 ) %7B%0A        
-this.mUrl = url
+if (url != null)%0A            this.mUrl = url;%0A        else%0A            mUrl = %22%22
 ;%0A    %7D%0A%0A   

fix NPE