package io.xujiaji.hnbc.fragments;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.Toolbar;
import android.view.View;

import butterknife.BindView;
import butterknife.OnClick;
import io.xujiaji.hnbc.R;
import io.xujiaji.hnbc.activities.MainActivity;
import io.xujiaji.hnbc.config.C;
import io.xujiaji.hnbc.contracts.AboutContract;
import io.xujiaji.hnbc.fragments.base.BaseMainFragment;
import io.xujiaji.hnbc.presenters.AboutPresenter;
import io.xujiaji.hnbc.utils.ActivityUtils;
import io.xujiaji.hnbc.utils.ToastUtil;
import io.xujiaji.hnbc.widget.TextViewNew;

/**
 * Created by jiana on 01/12/16.
 */

public class AboutFragment extends BaseMainFragment<AboutPresenter> implements AboutContract.View {

    @BindView(R.id.tvNowVersion)
    TextViewNew tvNowVersion;
    @BindView(R.id.toolbar)
    Toolbar toolbar;

    @OnClick(R.id.btnContactMe)
    void clickContactMe(View view) {
        Uri uri = Uri.parse(getString(R.string.sen_email_to_xu));
        Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
        //intent.putExtra(Intent.EXTRA_CC, email); // 抄送人
        intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.from_hnbc)); // 主题
        // intent.putExtra(Intent.EXTRA_TEXT, "这是邮件的正文部分"); // 正文
        try {
            startActivity(intent);
        } catch (Exception e) {
            ToastUtil.getInstance().showLongT(getString(R.string.cannot_find_email_app));
        }
    }

    public static AboutFragment newInstance() {
        return new AboutFragment();
    }

    @Override
    protected void onInit() {
        super.onInit();
        ActivityUtils.initBar(toolbar, R.string.about);
        presenter.getNowVersion();
    }

    @Override
    protected void onListener() {
        super.onListener();
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clickBack();
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_about;
    }

    @Override
    public boolean clickBack() {
        if (super.clickBack()) {
            setDeleted(true);
            MainActivity.startFragment(C.fragment.SET);
        }
        return true;
    }

    @Override
    public void showNowVersion(String version) {
        tvNowVersion.setText(getString(R.string.now_version) + " : " + version);
    }


}

@@ -2153,32 +2153,63 @@
 ckBack()) %7B%0A    
+        return true;%0A        %7D%0A
         setDelet
@@ -2218,20 +2218,16 @@
 (true);%0A
-    
         
@@ -2270,26 +2270,16 @@
 t.SET);%0A
-        %7D%0A
         

Repair about page can not be return.