// Path: app/src/main/java/com/xd/demi/fragment/ProfitsChartFragment.java
// public class ProfitsChartFragment extends Fragment {
//     private TabContainer tab;
//     private ProfitsChartView chart;
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         View view = inflater.inflate(R.layout.fragment_profit_chart, container, false);
//         tab =view.findViewById(R.id.tab);
//         chart = view.findViewById(R.id.chart);
//         return view;
//     }
// 
//     @Override
//     public void onViewCreated(View view, Bundle savedInstanceState) {
//         super.onViewCreated(view, savedInstanceState);
//         getDatas();
//     }
// 
// 
//     public void getDatas() {
//         OkHttpClient okHttpClient = new OkHttpClient();
//         Retrofit retrofit = new Retrofit.Builder()
//                 .baseUrl("https://fq-api.zixuan.com/stock-portfolios/")
//                 .addConverterFactory(new ProfitsConverterFactory())
//                 .client(okHttpClient)
//                 .build();
//         UrlService service = retrofit.create(UrlService.class);
//         Call<ResponseData<DailyYeildsInfo>> call = service.getDatas("520","LAST_ALL");
//         call.enqueue(new Callback<ResponseData<DailyYeildsInfo>>() {
//             @Override
//             public void onResponse(Call<ResponseData<DailyYeildsInfo>> call, Response<ResponseData<DailyYeildsInfo>> response) {
//                 // JSONObject js =new JSONObject(json);
//                 if(response.body() == null){
//                     chart.setData(createDatas());
//                     Toast.makeText(getContext(),"服务器挂了！！！",2000).show();
//                     return;
//                 }
//                 chart.setData(response.body().getInfo());
//             }
// 
//             @Override
//             public void onFailure(Call<ResponseData<DailyYeildsInfo>> call, Throwable t) {
//                 t.printStackTrace();
//                 chart.setData(createDatas());
//             }
//         });
//     }
// 
//     private DailyYeildsInfo createDatas(){
//         DailyYeildsInfo data = new DailyYeildsInfo();
//         ArrayList<Profits> hs300 = new ArrayList<>();
//         ArrayList<Profits> profits = new ArrayList<>();
//         for (int i = 0; i <10 ; i++) {
//             Profits hs300d = new Profits(1529581311000L+i*100,Math.random() *30 +2.4);
//             Profits profitsd = new Profits(1529581311000L+i*100,Math.random() *10 +3.2);
//             hs300.add(hs300d);
//             profits.add(profitsd);
//         }
//         data.setHS300(hs300);
//         data.setPORTFOLIO(profits);
//         return data;
//     }
// }


import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.xd.demi.R;
import com.xd.demi.fragment.ProfitsChartFragment;
package com.xd.demi.activity;



/**
 * Created by demi on 2017/5/12.
 * 收益走势图
 */

public class PortfoliosActivity extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_portfolios);
        if (savedInstanceState == null) {
// Path: app/src/main/java/com/xd/demi/fragment/ProfitsChartFragment.java
// public class ProfitsChartFragment extends Fragment {
//     private TabContainer tab;
//     private ProfitsChartView chart;
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         View view = inflater.inflate(R.layout.fragment_profit_chart, container, false);
//         tab =view.findViewById(R.id.tab);
//         chart = view.findViewById(R.id.chart);
//         return view;
//     }
// 
//     @Override
//     public void onViewCreated(View view, Bundle savedInstanceState) {
//         super.onViewCreated(view, savedInstanceState);
//         getDatas();
//     }
// 
// 
//     public void getDatas() {
//         OkHttpClient okHttpClient = new OkHttpClient();
//         Retrofit retrofit = new Retrofit.Builder()
//                 .baseUrl("https://fq-api.zixuan.com/stock-portfolios/")
//                 .addConverterFactory(new ProfitsConverterFactory())
//                 .client(okHttpClient)
//                 .build();
//         UrlService service = retrofit.create(UrlService.class);
//         Call<ResponseData<DailyYeildsInfo>> call = service.getDatas("520","LAST_ALL");
//         call.enqueue(new Callback<ResponseData<DailyYeildsInfo>>() {
//             @Override
//             public void onResponse(Call<ResponseData<DailyYeildsInfo>> call, Response<ResponseData<DailyYeildsInfo>> response) {
//                 // JSONObject js =new JSONObject(json);
//                 if(response.body() == null){
//                     chart.setData(createDatas());
//                     Toast.makeText(getContext(),"服务器挂了！！！",2000).show();
//                     return;
//                 }
//                 chart.setData(response.body().getInfo());
//             }
// 
//             @Override
//             public void onFailure(Call<ResponseData<DailyYeildsInfo>> call, Throwable t) {
//                 t.printStackTrace();
//                 chart.setData(createDatas());
//             }
//         });
//     }
// 
//     private DailyYeildsInfo createDatas(){
//         DailyYeildsInfo data = new DailyYeildsInfo();
//         ArrayList<Profits> hs300 = new ArrayList<>();
//         ArrayList<Profits> profits = new ArrayList<>();
//         for (int i = 0; i <10 ; i++) {
//             Profits hs300d = new Profits(1529581311000L+i*100,Math.random() *30 +2.4);
//             Profits profitsd = new Profits(1529581311000L+i*100,Math.random() *10 +3.2);
//             hs300.add(hs300d);
//             profits.add(profitsd);
//         }
//         data.setHS300(hs300);
//         data.setPORTFOLIO(profits);
//         return data;
//     }
// }


// Path: app/src/main/java/com/xd/demi/activity/PortfoliosActivity.java
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.xd.demi.R;
import com.xd.demi.fragment.ProfitsChartFragment;

package com.xd.demi.activity;



/**
 * Created by demi on 2017/5/12.
 * 收益走势图
 */

public class PortfoliosActivity extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_portfolios);
        if (savedInstanceState == null) {
            ProfitsChartFragment profitsFragment = new ProfitsChartFragment();