init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.yutou.jianrmg_v2.gamedatamodel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.yutou.jianrmg_v2.gamedatamodel.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
2
GameDataModel/src/main/AndroidManifest.xml
Normal file
2
GameDataModel/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.yutou.jianrmg_v2.gamedatamodel" />
|
||||
@@ -0,0 +1,31 @@
|
||||
package Interfaces;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
|
||||
/**
|
||||
* Created by 58381 on 2018/2/27.
|
||||
*/
|
||||
|
||||
public interface BaseActivityInterface {
|
||||
void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent);
|
||||
void onRestart();
|
||||
void onResume();
|
||||
void onPause();
|
||||
void onDestroy();
|
||||
void getIntent(Intent intent);
|
||||
boolean onKeyDown(int keyCode, KeyEvent event);
|
||||
boolean onKeyUp(int keyCode, KeyEvent event);
|
||||
boolean onTouchEvent(MotionEvent event);
|
||||
Data getData();
|
||||
class Data{
|
||||
private String type;
|
||||
private String url;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package Interfaces;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public interface BaseFragmeneInerface {
|
||||
void init(Context context);
|
||||
View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.yutou.jianrmg_v2.gamedatamodel;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Interfaces.BaseActivityInterface;
|
||||
import Interfaces.BaseFragmeneInerface;
|
||||
|
||||
|
||||
public class MainFragmene implements BaseFragmeneInerface {
|
||||
private Context context;
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
this.context=context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
LinearLayout view=new LinearLayout(context);
|
||||
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
view.setLayoutParams(params);
|
||||
view.setOrientation(LinearLayout.HORIZONTAL);
|
||||
PieChart pieChart=new PieChart(context);
|
||||
view.addView(pieChart);
|
||||
List<PieEntry> entries = new ArrayList<>();
|
||||
|
||||
entries.add(new PieEntry(120000, "弹"));
|
||||
entries.add(new PieEntry(230000, "钢"));
|
||||
entries.add(new PieEntry(50000, "铝"));
|
||||
entries.add(new PieEntry(80000, "油"));
|
||||
|
||||
PieDataSet set = new PieDataSet(entries, "当前资源");
|
||||
PieData data = new PieData(set);
|
||||
pieChart.setData(data);
|
||||
pieChart.setLayoutParams(params);
|
||||
|
||||
pieChart.invalidate();
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
3
GameDataModel/src/main/res/values/strings.xml
Normal file
3
GameDataModel/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">GameDataModel</string>
|
||||
</resources>
|
||||
2
GameDataModel/src/main/res/values/values.xml
Normal file
2
GameDataModel/src/main/res/values/values.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yutou.jianrmg_v2.gamedatamodel;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user