// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java
// public class NewsNode {
//     @SerializedName("id") public int id;                // 新闻节点 id
//     @SerializedName("name") public String name;         // 名称
// }
// 
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java
// public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView {
//     protected T presenter;
// 
//     @SuppressWarnings("unchecked")
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         presenter = getInstance(this, 1);
//         presenter.attachView((V) this);
// 
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     protected void onDestroy() {
//         if (presenter != null) {
//             presenter.detachView();
//         }
//         super.onDestroy();
//     }
// 
//     @Override
//     public Context getContext() {
//         return this;
//     }
// 
//     @Override
//     public <T> LifecycleTransformer<T> bindToLife() {
//         return this.<T>bindToLifecycle();
//     }
// 
//     @SuppressWarnings("unchecked")
//     public <T> T getInstance(Object o, int i) {
//         try {
//             return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance();
//         } catch (InstantiationException | IllegalAccessException | ClassCastException e) {
//             e.printStackTrace();
//         }
//         return null;
//     }
// }
// 
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java
// public static String trim(CharSequence input) {
//     return input.toString().trim();
// }


import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import moe.yukinoneko.diycode.R;
import moe.yukinoneko.diycode.bean.NewsNode;
import moe.yukinoneko.diycode.mvp.MVPBaseActivity;
import static moe.yukinoneko.diycode.tool.StringHelper.trim;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.AppCompatSpinner;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import com.kennyc.view.MultiStateView;
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.send, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.action_send) {
            presenter.newNews(nodes.get(spinnerNode.getSelectedItemPosition()).id);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void updateNodes(List<NewsNode> nodes) {
        multiStateView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
        this.nodes = nodes;

        List<String> nodeNames = new ArrayList<>();
        for (NewsNode node : nodes) {
            nodeNames.add(node.name);
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, nodeNames);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerNode.setAdapter(adapter);
    }

    @Override
    public String getNewsTitle() {
// Path: app/src/main/java/moe/yukinoneko/diycode/bean/NewsNode.java
// public class NewsNode {
//     @SerializedName("id") public int id;                // 新闻节点 id
//     @SerializedName("name") public String name;         // 名称
// }
// 
// Path: app/src/main/java/moe/yukinoneko/diycode/mvp/MVPBaseActivity.java
// public abstract class MVPBaseActivity<V extends BaseView, T extends BasePresenterImpl<V>> extends BaseActivity implements BaseView {
//     protected T presenter;
// 
//     @SuppressWarnings("unchecked")
//     @Override
//     protected void onCreate(@Nullable Bundle savedInstanceState) {
//         presenter = getInstance(this, 1);
//         presenter.attachView((V) this);
// 
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     protected void onDestroy() {
//         if (presenter != null) {
//             presenter.detachView();
//         }
//         super.onDestroy();
//     }
// 
//     @Override
//     public Context getContext() {
//         return this;
//     }
// 
//     @Override
//     public <T> LifecycleTransformer<T> bindToLife() {
//         return this.<T>bindToLifecycle();
//     }
// 
//     @SuppressWarnings("unchecked")
//     public <T> T getInstance(Object o, int i) {
//         try {
//             return ((Class<T>) ((ParameterizedType) (o.getClass().getGenericSuperclass())).getActualTypeArguments()[i]).newInstance();
//         } catch (InstantiationException | IllegalAccessException | ClassCastException e) {
//             e.printStackTrace();
//         }
//         return null;
//     }
// }
// 
// Path: app/src/main/java/moe/yukinoneko/diycode/tool/StringHelper.java
// public static String trim(CharSequence input) {
//     return input.toString().trim();
// }


// Path: app/src/main/java/moe/yukinoneko/diycode/module/news/create/CreateNewsActivity.java
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import moe.yukinoneko.diycode.R;
import moe.yukinoneko.diycode.bean.NewsNode;
import moe.yukinoneko.diycode.mvp.MVPBaseActivity;
import static moe.yukinoneko.diycode.tool.StringHelper.trim;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.AppCompatSpinner;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import com.kennyc.view.MultiStateView;

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.send, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.action_send) {
            presenter.newNews(nodes.get(spinnerNode.getSelectedItemPosition()).id);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void updateNodes(List<NewsNode> nodes) {
        multiStateView.setViewState(MultiStateView.VIEW_STATE_CONTENT);
        this.nodes = nodes;

        List<String> nodeNames = new ArrayList<>();
        for (NewsNode node : nodes) {
            nodeNames.add(node.name);
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, nodeNames);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerNode.setAdapter(adapter);
    }

    @Override
    public String getNewsTitle() {
        return trim(editTitle.getText());