Skip to content
Merged
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 application/.idea/misc.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
import com.example.myapplication.ui.setting.PetinfoData;
import com.example.myapplication.ui.setting.ProfileResponse;

import java.util.ArrayList;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class AddPetActivity extends AppCompatActivity {
private String CATDOG;
private ImageView petprofile;
private TextView petAge;
private EditText petBreed,petNickName;
Expand Down Expand Up @@ -105,19 +108,22 @@ public void onClick(DialogInterface dialog, int i) {
AgePicker.show();
}
});
// 개/고양이 버튼 클릭 시에 해당 사진으로 이미지뷰 변경
selectCatButton.setOnClickListener(new View.OnClickListener() {
//개/고양이 버튼 클릭 시에 해당 사진으로 이미지뷰 변경
selectDogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
petprofile.setImageResource(R.drawable.catface);
petprofile.setImageResource(R.drawable.dog2);
CATDOG = "dog";
}
});
selectDogButton.setOnClickListener(new View.OnClickListener() {
selectCatButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
petprofile.setImageResource(R.drawable.dogface);
petprofile.setImageResource(R.drawable.cat2);
CATDOG = "cat";
}
});

}
//반려동물 정보 설정
public void getPetinfo(){
Expand All @@ -126,20 +132,13 @@ public void getPetinfo(){
//String Breed = petBreed.getText().toString().trim();
String Gender = null;
String Neutering = null;
if (man.isEnabled()) {
Gender = man.getText().toString();
} else if (woman.isEnabled()) {
Gender = woman.getText().toString();
}

if (NeuteringYes.isEnabled()) {
Neutering = NeuteringYes.getText().toString();
} else if (NeuteringNo.isEnabled()) {
Neutering = NeuteringNo.getText().toString();
}
if (man.isEnabled()) { Gender = man.getText().toString();
} else if (woman.isEnabled()) { Gender = woman.getText().toString();}

PetinfoData petinfoData = new PetinfoData(Name, Age, null, Gender, Neutering);
if (NeuteringYes.isEnabled()) { Neutering = NeuteringYes.getText().toString();
} else if (NeuteringNo.isEnabled()) { Neutering = NeuteringNo.getText().toString(); }

PetinfoData petinfoData = new PetinfoData(Name, Age, null, Gender, Neutering);
Call<ProfileResponse> call = profileAPI.getPetinfo(petinfoData);

call.enqueue(new Callback<ProfileResponse>() {
Expand All @@ -149,6 +148,7 @@ public void onResponse(Call<ProfileResponse> call, Response<ProfileResponse> res
Toast.makeText(getApplicationContext(),"등록되었습니다.", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(AddPetActivity.this, PetSelectActivity.class);
intent.putExtra("petName", Name);
intent.putExtra("CATDOG", CATDOG);
setResult(Activity.RESULT_OK, intent);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Adapter;
import android.widget.Button;
import android.widget.Toast;

Expand All @@ -16,6 +17,7 @@
import com.example.myapplication.ui.mainPage.MainActivity;

import java.util.ArrayList;
import java.util.Locale;

public class PetSelectActivity extends AppCompatActivity {

Expand All @@ -33,11 +35,9 @@ protected void onCreate(Bundle savedInstanceState) {

// 리사이클러뷰에 데이터추가 (함수가 밑에 구현되어있음)
addItem("cat", "밤이");
addItem("dog", "보리");

mRecyclerViewAdapter = new RecyclerViewAdapter(mList);
mRecyclerView.setAdapter(mRecyclerViewAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));

// 리사이클러뷰 안의 아이템(반려동물 아이콘) 클릭시 메인화면으로 이동
Expand All @@ -62,14 +62,17 @@ public void onClick(View view){
});

}
//사용자가 작성한 반려동물 정보 불러오기
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);

if (requestCode == 101) {
if (resultCode == Activity.RESULT_OK) {
String petName = intent.getExtras().getString("petName");
//리사이클러뷰 새로 생성
if (resultCode == Activity.RESULT_OK) {
if (intent !=null) {
String petName = intent.getStringExtra("petName");
String CATDOG = intent.getStringExtra("CATDOG");
addItem(CATDOG, petName);
mRecyclerViewAdapter.notifyDataSetChanged();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
public void onBindViewHolder(@NonNull RecyclerViewAdapter.ViewHolder holder, int position) {
RecyclerViewItem item = mList.get(position);

if(item.getImgName()=="cat") // 아이템의 이미지 이름이 cat이면 고양이 사진으로 설정
holder.imgView_item.setImageResource(R.drawable.catface);
if(item.getImgName().equals("cat")) // 아이템의 이미지 이름이 cat이면 고양이 사진으로 설정
holder.imgView_item.setImageResource(R.drawable.cat);
else
holder.imgView_item.setImageResource(R.drawable.dogface);
holder.imgView_item.setImageResource(R.drawable.dog);

holder.petNickName.setText(item.getMainText());
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions application/app/src/main/res/layout/newpetprofile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

<ImageView
android:id="@+id/pic"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:src="@drawable/catface" />
android:src="@drawable/dog2" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="25dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="16dp">
<TextView
Expand Down
8 changes: 4 additions & 4 deletions application/app/src/main/res/layout/petprofile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

<ImageView
android:id="@+id/pic"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:src="@drawable/dogface" />
android:src="@drawable/dog2" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="16dp"
android:stretchColumns="*">
Expand Down