展示

view层

package com.bwie.jingdong.frist.view;

import android.content.Context;

import com.bwie.jingdong.bean.BannerBean;
import com.bwie.jingdong.bean.CategoryBean;
import com.bwie.jingdong.bean.MainClassifyBean;
import com.bwie.jingdong.bean.NextClassifyBean;
import com.bwie.jingdong.bean.ProductBean;

import java.util.List;

/**
 * Created by dell on 2018/10/17.
 */

public interface FristView {

    void getBanner(List<BannerBean.DataBean> list);

    void getCategory(List<CategoryBean.DataBean> list);

    void getProduct(List<ProductBean.DataBean> list);

    Context getContext();

    void failed(Exception e);

}
 

model层

package com.bwie.jingdong.frist.model;

import com.bwie.jingdong.callback.ICallBack;
import com.bwie.jingdong.utils.HttpUtils;

import java.lang.reflect.Type;

/**
 * Created by dell on 2018/10/17.
 */

public class FristModel {
    public void getData(String url, ICallBack callBack, Type type){
        HttpUtils.getInstance().get(url,callBack,type);
    }
}
presenter层

package com.bwie.jingdong.frist.presenter;

import android.content.SharedPreferences;

import com.bwie.jingdong.bean.BannerBean;
import com.bwie.jingdong.bean.CategoryBean;
import com.bwie.jingdong.bean.MainClassifyBean;
import com.bwie.jingdong.bean.ProductBean;
import com.bwie.jingdong.callback.ICallBack;
import com.bwie.jingdong.frist.model.FristModel;
import com.bwie.jingdong.frist.view.FristView;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;

/**
 * Created by dell on 2018/10/17.
 */

public class FristPresenter {
    private FristView fv;
    private FristModel fristModel;

    public void attach(FristView fv) {
        this.fv = fv;
        fristModel = new FristModel();
    }

    public void getBanner(){
        Type type = new TypeToken<BannerBean>(){}.getType();

        fristModel.getData("https://www.zhaoapi.cn/ad/getAd", new ICallBack() {
            @Override
            public void onSuccess(Object o) {
                BannerBean bannerBean = (BannerBean) o;
                if (bannerBean != null){
                    fv.getBanner(bannerBean.getData());
                }
            }

            @Override
            public void onFailed(Exception e) {
                fv.failed(e);
            }
        },type);
    }
    public void getCategroy(){
        Type type = new TypeToken<CategoryBean>(){}.getType();

        fristModel.getData("https://www.zhaoapi.cn/product/getCatagory", new ICallBack() {
            @Override
            public void onSuccess(Object o) {
                CategoryBean categoryBean = (CategoryBean) o;
                if (categoryBean != null){
                    fv.getCategory(categoryBean.getData());
                }
            }

            @Override
            public void onFailed(Exception e) {
                fv.failed(e);
            }
        },type);
    }
    public void getProducy(){
        Type type = new TypeToken<ProductBean>(){}.getType();
        fristModel.getData("https://www.zhaoapi.cn/product/getCarts?uid=71", new ICallBack() {
            @Override
            public void onSuccess(Object o) {
                ProductBean productBean = (ProductBean) o;
                if (productBean != null){
                    fv.getProduct(productBean.getData());
                }
            }

            @Override
            public void onFailed(Exception e) {
                fv.failed(e);
            }
        },type);
    }

    public void detach(){
        if (fv != null){
            fv = null;
        }
    }
}
主页面

package com.bwie.jingdong.frist.view;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.bwie.jingdong.R;
import com.bwie.jingdong.bean.MainClassifyBean;
import com.bwie.jingdong.bean.NextClassifyBean;
import com.bwie.jingdong.search.SearchActivity;
import com.bwie.jingdong.adapter.BannerAdapter;
import com.bwie.jingdong.adapter.CategoryAdapter;
import com.bwie.jingdong.adapter.ProductAdapter;
import com.bwie.jingdong.bean.BannerBean;
import com.bwie.jingdong.bean.CategoryBean;
import com.bwie.jingdong.bean.ProductBean;
import com.bwie.jingdong.frist.presenter.FristPresenter;
import com.uuzuche.lib_zxing.activity.CaptureActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dell on 2018/10/15.
 */

public class FristFragment extends Fragment implements FristView, View.OnClickListener {

    private ImageView imgRichscan;
    private EditText etSearch;
    private ImageView imgMessage;
    private RecyclerView rvSudoku;
    private RecyclerView rvProduct;
    private ViewPager vpBanner;

    private List<BannerBean.DataBean> bannerList;
    private List<CategoryBean.DataBean> categoryList;
    private List<ProductBean.DataBean> productList;
    private BannerAdapter bannerAdapter;
    private FristPresenter presenter;

    private ProductAdapter productAdapter;
    private CategoryAdapter categoryAdapter;

    private int REQUEST_CODE = 100;
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 100){
                int current = vpBanner.getCurrentItem();
                if (current<bannerList.size()-1){
                    current++;
                }else {
                    current=0;
                }
                vpBanner.setCurrentItem(current);
                sendEmptyMessageDelayed(100,4000);
            }
        }
    };

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.frist_item,container,false);
        imgMessage = v.findViewById(R.id.img_message);
        imgRichscan = v.findViewById(R.id.img_richscan);
        etSearch = v.findViewById(R.id.et_search);
        rvSudoku = v.findViewById(R.id.rv_sudoku);
        rvProduct = v.findViewById(R.id.rv_product);
        vpBanner = v.findViewById(R.id.vp_banner);

        return v;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();

        setListener();

        presenter = new FristPresenter();
        presenter.attach(this);
        presenter.getBanner();
        presenter.getCategroy();
        presenter.getProducy();


    }

    private void setListener() {
        etSearch.setOnClickListener(this);
        imgRichscan.setOnClickListener(this);
        imgMessage.setOnClickListener(this);
    }

    private void initView() {
        bannerList = new ArrayList<>();
        categoryList = new ArrayList<>();
        productList = new ArrayList<>();

        bannerAdapter = new BannerAdapter(getActivity(),bannerList);
        productAdapter = new ProductAdapter(getActivity(),productList);
        categoryAdapter = new CategoryAdapter(getActivity(),categoryList);

        vpBanner.setAdapter(bannerAdapter);
        rvSudoku.setAdapter(categoryAdapter);
        rvProduct.setAdapter(productAdapter);

        RecyclerView.LayoutManager clayoutManager = new GridLayoutManager(getActivity(),2, LinearLayoutManager.HORIZONTAL,false);
        RecyclerView.LayoutManager playoutManager = new GridLayoutManager(getActivity(),2, LinearLayoutManager.VERTICAL,false);

        rvSudoku.setLayoutManager(clayoutManager);
        rvProduct.setLayoutManager(playoutManager);

        handler.sendEmptyMessageDelayed(100,4000);
    }

    @Override
    public void getBanner(List<BannerBean.DataBean> list) {
        if (list != null){
            bannerList.clear();
            bannerList.addAll(list);
            bannerAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void getCategory(List<CategoryBean.DataBean> list) {
        if (list != null){
            categoryList.clear();
            categoryList.addAll(list);
            categoryAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void getProduct(List<ProductBean.DataBean> list) {
        if (list != null){
            productList.clear();
            productList.addAll(list);
            productAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void failed(Exception e) {
        Toast.makeText(getActivity(),"网络异常",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.et_search:
                startActivity(new Intent(getActivity(), SearchActivity.class));
                break;
            case R.id.img_message:

                break;
            case R.id.img_richscan:
                Intent intent = new Intent(getContext(), CaptureActivity.class);
                startActivityForResult(intent, REQUEST_CODE);
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (presenter != null){
            presenter.detach();
        }
    }
}
 

utils页面

package com.bwie.jingdong.utils;

import android.os.Handler;

import com.bwie.jingdong.callback.ICallBack;
import com.google.gson.Gson;

import java.io.IOException;
import java.lang.reflect.Type;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by dell on 2018/10/16.
 */

public class HttpUtils {

    private static volatile HttpUtils instance;

    private OkHttpClient client;

    private Handler handler = new Handler();

    private HttpUtils(){
        client = new OkHttpClient();
    }

    public static HttpUtils getInstance(){
        if (instance == null){
            synchronized (HttpUtils.class){
                if (null == instance){
                    instance = new HttpUtils();
                }
            }
        }
        return instance;
    }

    public void get(String url, final ICallBack callBack, final Type type){
        Request request = new Request.Builder()
                .get()
                .url(url)
                .build();
        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, final IOException e) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        callBack.onFailed(e);
                    }
                });
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String result = response.body().string();
                Gson gson = new Gson();
                final Object o = gson.fromJson(result,type);
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        callBack.onSuccess(o);
                    }
                });
            }
        });
    }

}
 

 

内容概要:本文围绕“考虑电动汽车聚合可调节能力的含波动性电源电氢耦合系统多目标优化运行”展开研究,提出了一种基于Matlab代码实现的多目标优化模型。该模型深度融合电-氢耦合系统与高比例波动性可再生能源(如风电、光伏),充分挖掘电动汽车(EV)集群作为移动储能单元的灵活调节潜力,通过聚合调控提升系统对新能源的消纳能力与运行经济性。研究系统构建了电动汽车可调度能力、电解水制氢与储氢动态过程、多能源协同互补的优化调度框架,并结合智能优化算法实现经济性、低碳性与运行稳定性等多重目标的协同优化。文中配套提供了完整的Matlab仿真代码、相关数据及可能的论文支撑材料,极大地方便了模型的复现、验证与后续深化研究。; 适合人群:具备电力系统、综合能源系统、优化理论或新能源技术等相关领域基础知识的研究生、科研人员,以及从事新型电力系统规划、清洁能源消纳与智慧能源管理的工程技术人员。; 使用场景及目标:①开展高渗透率可再生能源接入下的综合能源系统多目标优化调度研究;②探究电动汽车集群在电网削峰填谷、平抑新能源出力波动及提供辅助服务方面的应用价值与潜力;③学习并掌握电氢耦合系统的建模方法、多目标优化求解技术及其在Matlab/Simulink环境下的仿真实现流程。; 阅读建议:此资源不仅提供可运行的代码,更蕴含了前沿的科研思路与创新方法,建议读者结合所提供的代码、数据与可能的论文文档,系统性地学习从问题建模、算法设计到仿真分析的完整科研过程,并重点关注其中关于需求侧资源聚合、多能互补协同与绿色低碳运行的核心理念。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值