Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
remicalsoft committed Mar 25, 2018
0 parents commit 76bc351
Show file tree
Hide file tree
Showing 52 changed files with 2,023 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
/app/build
18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
37 changes: 37 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "net.dixq.caloriemanager"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven { url "https://jitpack.io" }
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.5'
compile 'com.android.support:design:22.2.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.dixq.caloriemanager;

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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("net.dixq.caloriemanager", appContext.getPackageName());
}
}
25 changes: 25 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.dixq.caloriemanager">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".takencalories.TakenCaloriesActivity">
</activity>
<activity android:name=".search.CalorieSearchActivity"
android:theme="@style/AppThemeWhite">
</activity>
</application>

</manifest>
59 changes: 59 additions & 0 deletions app/src/main/java/net/dixq/caloriemanager/Graph.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.dixq.caloriemanager;

import android.view.View;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;

import java.util.ArrayList;

/**
* Created by dixq on 2018/03/25.
*/

public class Graph implements View.OnClickListener {

Graph(LineChart lineChart){
ArrayList<LineDataSet> dataSets = new ArrayList<>();

// X軸の値
ArrayList<String> xValues = new ArrayList<>();
xValues.add("");
xValues.add("");
xValues.add("");
xValues.add("");

// value
ArrayList<Entry> value = new ArrayList<>();
value.add(new Entry(50.2f, 0));
value.add(new Entry(48.9f, 1));
value.add(new Entry(51.2f, 2));
value.add(new Entry(50.8f, 3));

LineDataSet valueDataSet = new LineDataSet(value, "sample");
dataSets.add(valueDataSet);

lineChart.animateY(1000);

lineChart.setData(new LineData(xValues, dataSets));

lineChart.getAxisLeft().setStartAtZero(false);
lineChart.getAxisLeft().setAxisMinValue(48);
lineChart.getAxisLeft().setAxisMaxValue(52);

lineChart.getLegend().setEnabled(false);

lineChart.getAxisRight().setEnabled(false);

lineChart.setOnClickListener(this);

lineChart.setDescription("");
}

@Override
public void onClick(View view) {

}
}
59 changes: 59 additions & 0 deletions app/src/main/java/net/dixq/caloriemanager/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.dixq.caloriemanager;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import net.dixq.caloriemanager.common.Define;
import net.dixq.caloriemanager.takencalories.TakenCaloriesActivity;

import java.util.Calendar;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private Graph _graph;
private Calendar _calendar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_calendar = Calendar.getInstance();
initialize();
}

private void initialize(){
_graph = new Graph(findViewById(R.id.graph_mini));
findViewById(R.id.btn_prev_data).setOnClickListener(this);
findViewById(R.id.btn_data).setOnClickListener(this);
findViewById(R.id.btn_next_data).setOnClickListener(this);
findViewById(R.id.btn_taken_calories).setOnClickListener(this);
}

private void onClickPrevData(){
}

private void onClickData(){
}

private void onClickNextData(){
}

private void onClickTakenCalories(){
Intent intent = new Intent(this, TakenCaloriesActivity.class);
intent.putExtra(TakenCaloriesActivity.INTENT_TAG_YEAR, _calendar.get(Calendar.YEAR));
intent.putExtra(TakenCaloriesActivity.INTENT_TAG_MONTH, _calendar.get(Calendar.MONTH));
intent.putExtra(TakenCaloriesActivity.INTENT_TAG_DATE, _calendar.get(Calendar.DATE));
startActivityForResult(intent, Define.REQUEST_CODE_TAKEN_CALORIE);
}

@Override
public void onClick(View v) {
if(v==findViewById(R.id.btn_prev_data)){ onClickPrevData(); }
if(v==findViewById(R.id.btn_data) ){ onClickData(); }
if(v==findViewById(R.id.btn_next_data)){ onClickNextData(); }
if(v==findViewById(R.id.btn_taken_calories)){ onClickTakenCalories(); }
}

}
10 changes: 10 additions & 0 deletions app/src/main/java/net/dixq/caloriemanager/common/Define.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package net.dixq.caloriemanager.common;

/**
* Created by dixq on 2018/03/25.
*/

public class Define {
public static final int REQUEST_CODE_TAKEN_CALORIE = 0;
public static final int REQUEST_CODE_CALORIE_SEARCH = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.dixq.caloriemanager.common;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;

/**
* Created by dixq on 2018/03/25.
*/

public class MesuredListView extends ListView {

private static final int MAX_SIZE = 99;

public MesuredListView(Context context, AttributeSet attrs) {
super(context, attrs);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

int newHeight = 0;
int minHeight = getMinimumHeight();
final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (heightMode != MeasureSpec.EXACTLY) {
ListAdapter listAdapter = getAdapter();
if (listAdapter != null && !listAdapter.isEmpty()) {
int listPosition = 0;
for (listPosition = 0; listPosition < listAdapter.getCount()
&& listPosition < MAX_SIZE; listPosition++) {
View listItem = listAdapter.getView(listPosition, null, this);
if (listItem instanceof ViewGroup) {
listItem.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
listItem.measure(widthMeasureSpec, heightMeasureSpec);
newHeight += listItem.getMeasuredHeight();
}
newHeight += getDividerHeight() * listPosition;
}
if ((heightMode == MeasureSpec.AT_MOST) && (newHeight > heightSize)) {
if (newHeight > heightSize) {
newHeight = heightSize;
}
}
} else {
newHeight = getMeasuredHeight();
}
if(newHeight < minHeight){
newHeight = minHeight;
}
setMeasuredDimension(getMeasuredWidth(), newHeight);
}
}
Loading

0 comments on commit 76bc351

Please sign in to comment.