Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soohyun #5

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ dependencies {
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"

def room_version = "2.2.5"

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.wordmemorizationgame.database;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

@Entity
public class Word {
@PrimaryKey(autoGenerate = true)
public int id;

@ColumnInfo(name = "word_english")
public String word_english;

@ColumnInfo(name = "word_korean")
public String word_korean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.wordmemorizationgame.database;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

import java.util.List;

@Dao
public interface WordDao {
@Query("SELECT * FROM word")
List<Word> getAll();

@Query("SELECT word_english FROM word")
List<String> getWord_englishAll();

@Query("SELECT word_korean FROM word")
List<String> getWord_koreanAll();

@Insert
void insertAll(Word... words);

@Delete
void delete(Word word);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.wordmemorizationgame.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.wordmemorizationgame.ui.voca.MyvocaFragment;

@Database(entities = {Word.class}, version = 1)
public abstract class WordDatabase extends RoomDatabase {
private static WordDatabase INSTANCE;
public abstract WordDao wordDao();

public static WordDatabase getAppDatabase(Context context){
if(INSTANCE == null){
INSTANCE = Room.databaseBuilder(context, WordDatabase.class , "word-db").allowMainThreadQueries().build();
}
return INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void startSplash() {
@Override
public void run() {
//
Intent intent = new Intent(getApplicationContext(),UserActivity.class);
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package com.example.wordmemorizationgame.ui.main;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;

import android.os.Bundle;

import com.example.wordmemorizationgame.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// MainActivity
// develop
// branch

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navi);
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.navHost_main);
NavigationUI.setupWithNavController(bottomNavigationView,navHostFragment.getNavController());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.example.wordmemorizationgame.ui.voca;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.wordmemorizationgame.R;

import java.util.ArrayList;

public class MyvocaAdapter extends RecyclerView.Adapter<MyvocaAdapter.ViewHolder> {
private ArrayList<MyvocaItem> mData = null;

MyvocaAdapter(ArrayList<MyvocaItem> list) {
mData = list;
}

@Override
public MyvocaAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext() ;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View view = inflater.inflate(R.layout.myvoca_item, parent, false);
MyvocaAdapter.ViewHolder vh = new MyvocaAdapter.ViewHolder(view);

return vh;
}

@Override
public void onBindViewHolder(MyvocaAdapter.ViewHolder holder, int position) {
MyvocaItem item = mData.get(position);

holder.word_english.setText(item.getWord_english());
holder.word_korean.setText(item.getWord_korean());
}

@Override
public int getItemCount() {
return mData.size();
}

public class ViewHolder extends RecyclerView.ViewHolder {
TextView word_english;
TextView word_korean;

ViewHolder(View itemView) {
super(itemView) ;

word_english = itemView.findViewById(R.id.word_english);
word_korean = itemView.findViewById(R.id.word_korean);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.example.wordmemorizationgame.ui.voca;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.example.wordmemorizationgame.R;
import com.example.wordmemorizationgame.database.Word;
import com.example.wordmemorizationgame.database.WordDatabase;

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

public class MyvocaFragment extends Fragment {

public MyvocaFragment() {
// Required empty public constructor
}

RecyclerView mRecyclerView = null;
MyvocaAdapter mAdapter = null;
ArrayList<MyvocaItem> mList = new ArrayList<MyvocaItem>();

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

LinearLayout layout = (LinearLayout)inflater.inflate(R.layout.fragment_myvoca, container, false);
mRecyclerView = (RecyclerView)layout.findViewById(R.id.recycler);
WordDatabase wordDatabase = WordDatabase.getAppDatabase(getContext());

mAdapter = new MyvocaAdapter(mList);
mRecyclerView.setAdapter(mAdapter);

mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

List<String> word_english_list = wordDatabase.wordDao().getWord_englishAll();
List<String> word_korean_list = wordDatabase.wordDao().getWord_koreanAll();

String[] word_english_array = word_english_list.toArray(new String[word_english_list.size()]);
String[] word_korean_array = word_korean_list.toArray(new String[word_korean_list.size()]);

for(int i=0; i<word_english_array.length; i++){
addItem(word_english_array[i], word_korean_array[i]);
}

//테스트
/*
Word new_word = new Word();
new_word.word_english = "peach";
new_word.word_korean = "복숭아";
wordDatabase.wordDao().insertAll(new_word);

addItem("apple", "사과");
addItem("orange", "오렌지");
addItem("banana", "바나나");
*/

mAdapter.notifyDataSetChanged();

return layout;
}

public void addItem(String word_english, String word_korean) { //String word_english, String word_korean
MyvocaItem item = new MyvocaItem();

item.setWord_english(word_english);
item.setWord_korean(word_korean);

mList.add(item);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.wordmemorizationgame.ui.voca;

import android.graphics.drawable.Drawable;

public class MyvocaItem {
private String word_english ;
private String word_korean ;

public void setWord_english(String word_english) {
this.word_english = word_english;
}
public void setWord_korean(String word_korean) {
this.word_korean = word_korean;
}

public String getWord_english() {
return word_english;
}
public String getWord_korean() {
return word_korean;
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_check_box_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"
android:fillColor="#000000"/>
</vector>
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/ic_menu_book_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M21,5c-1.11,-0.35 -2.33,-0.5 -3.5,-0.5c-1.95,0 -4.05,0.4 -5.5,1.5c-1.45,-1.1 -3.55,-1.5 -5.5,-1.5S2.45,4.9 1,6v14.65c0,0.25 0.25,0.5 0.5,0.5c0.1,0 0.15,-0.05 0.25,-0.05C3.1,20.45 5.05,20 6.5,20c1.95,0 4.05,0.4 5.5,1.5c1.35,-0.85 3.8,-1.5 5.5,-1.5c1.65,0 3.35,0.3 4.75,1.05c0.1,0.05 0.15,0.05 0.25,0.05c0.25,0 0.5,-0.25 0.5,-0.5V6C22.4,5.55 21.75,5.25 21,5zM21,18.5c-1.1,-0.35 -2.3,-0.5 -3.5,-0.5c-1.7,0 -4.15,0.65 -5.5,1.5V8c1.35,-0.85 3.8,-1.5 5.5,-1.5c1.2,0 2.4,0.15 3.5,0.5V18.5z"
android:fillColor="#000000"/>
<path
android:pathData="M17.5,10.5c0.88,0 1.73,0.09 2.5,0.26V9.24C19.21,9.09 18.36,9 17.5,9c-1.7,0 -3.24,0.29 -4.5,0.83v1.66C14.13,10.85 15.7,10.5 17.5,10.5z"
android:fillColor="#000000"/>
<path
android:pathData="M13,12.49v1.66c1.13,-0.64 2.7,-0.99 4.5,-0.99c0.88,0 1.73,0.09 2.5,0.26V11.9c-0.79,-0.15 -1.64,-0.24 -2.5,-0.24C15.8,11.66 14.26,11.96 13,12.49z"
android:fillColor="#000000"/>
<path
android:pathData="M17.5,14.33c-1.7,0 -3.24,0.29 -4.5,0.83v1.66c1.13,-0.64 2.7,-0.99 4.5,-0.99c0.88,0 1.73,0.09 2.5,0.26v-1.52C19.21,14.41 18.36,14.33 17.5,14.33z"
android:fillColor="#000000"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_military_tech_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M17,10.43V2H7v8.43c0,0.35 0.18,0.68 0.49,0.86l4.18,2.51l-0.99,2.34l-3.41,0.29l2.59,2.24L9.07,22L12,20.23L14.93,22l-0.78,-3.33l2.59,-2.24l-3.41,-0.29l-0.99,-2.34l4.18,-2.51C16.82,11.11 17,10.79 17,10.43zM13,12.23l-1,0.6l-1,-0.6V3h2V12.23z"
android:fillColor="#000000"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_person_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"
android:fillColor="#000000"/>
</vector>
23 changes: 16 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
tools:context=".ui.main.MainActivity">

<fragment
android:id="@+id/fragment3"
android:name="com.example.wordmemorizationgame.auth.LoginFragment"
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/navHost_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_main" />

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@android:color/white"
app:itemIconTint="#000000"
app:itemTextColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:menu="@menu/bottom_menu"
tools:layout_editor_absoluteX="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_user" />
app:navGraph="@navigation/nav_main" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading