Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:gridlayout-v7:23.4.0'

compile 'me.dm7.barcodescanner:zxing:1.8.4'
}
35 changes: 30 additions & 5 deletions app/src/main/java/com/munisystem/porst/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
package com.munisystem.porst;

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

import com.munisystem.porst.fragments.MainFragment;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements MainFragment.OnMainFragmentInteractionListener {
private static final String TAG = MainActivity.class.getSimpleName();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Intent intent = new Intent(this, QRReaderActivity.class);
startActivity(intent);
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, MainFragment.newInstance())
.commit();
}

@Override
public void onCardItemClick(View v) {
String text = "";
switch (v.getId()) {
case R.id.card_rental: {
text = "貸出";
break;
}
case R.id.card_return: {
text = "返却";
break;
}
case R.id.card_status: {
text = "状態";
break;
}
}
Log.d(TAG, "onCardItemClick: " + text + " が押されました。");
}
}
81 changes: 81 additions & 0 deletions app/src/main/java/com/munisystem/porst/fragments/MainFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.munisystem.porst.fragments;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.munisystem.porst.R;

public class MainFragment extends Fragment {

private OnMainFragmentInteractionListener mListener;

public MainFragment() {}

public static MainFragment newInstance() {
MainFragment fragment = new MainFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args == null) {
return;
}
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_main, container, false);
v.findViewById(R.id.card_rental)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onCardItemClick(v);
}
});
v.findViewById(R.id.card_return)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onCardItemClick(v);
}
});
v.findViewById(R.id.card_status)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onCardItemClick(v);
}
});
return v;
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnMainFragmentInteractionListener) {
mListener = (OnMainFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnMainFragmentInteractionListener");
}
}

@Override
public void onDetach() {
super.onDetach();
mListener = null;
}

public interface OnMainFragmentInteractionListener {
void onCardItemClick(View v);
}
}
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.munisystem.porst.MainActivity">
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
69 changes: 69 additions & 0 deletions app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<android.support.v7.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:columnCount="2"
app:rowCount="2">

<android.support.v7.widget.CardView
android:id="@+id/card_rental"
android:padding="@dimen/card_padding"
android:layout_margin="@dimen/card_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
app:layout_columnWeight="1"
app:layout_rowWeight="1">

<TextView
android:text="@string/card_rental_text"
android:textSize="@dimen/font_size_large"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
android:id="@+id/card_return"
android:padding="@dimen/card_padding"
android:layout_margin="@dimen/card_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
app:layout_columnWeight="1"
app:layout_rowWeight="1">

<TextView
android:text="@string/card_return_text"
android:textSize="@dimen/font_size_large"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
android:id="@+id/card_status"
android:padding="@dimen/card_padding"
android:layout_margin="@dimen/card_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
app:layout_columnWeight="1"
app:layout_rowWeight="1">

<TextView
android:text="@string/card_status_text"
android:textSize="@dimen/font_size_large"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</android.support.v7.widget.CardView>

</android.support.v7.widget.GridLayout>
7 changes: 6 additions & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

<dimen name="card_padding">5dp</dimen>

<dimen name="font_size_small">12dp</dimen>
<dimen name="font_size_normal">16dp</dimen>
<dimen name="font_size_large">20dp</dimen>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<resources>
<string name="app_name">Porst</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="card_rental_text">貸出</string>
<string name="card_return_text">返却</string>
<string name="card_status_text">状態</string>
</resources>