From 37d751dc0c10cabec13c580b4e35cb3f9558112d Mon Sep 17 00:00:00 2001 From: hb7829 Date: Fri, 14 Aug 2020 11:46:49 +0900 Subject: [PATCH 1/3] update replaceFragment --- .../ddamiapp/activity/MainActivity.java | 14 +++++---- .../ddamiapp/fragment/MyRoomFragment.java | 2 +- .../doubleslash/ddamiapp/model/MyPieceX.kt | 21 ++++++++++++++ .../doubleslash/ddamiapp/model/StudentX.kt | 13 +++++++++ .../doubleslash/ddamiapp/model/UserRoomDAO.kt | 11 +++++++ .../com/doubleslash/ddamiapp/model/UserX.kt | 29 +++++++++++++++++++ .../ddamiapp/network/kotlin/UserRoomApi.kt | 12 ++++++++ .../main/res/drawable/myroom_img_shape.xml | 4 +-- .../app/src/main/res/layout/item_myroom.xml | 18 +++++++----- .../src/main/res/layout/nav_header_main2.xml | 2 +- 10 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/MyPieceX.kt create mode 100644 DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/StudentX.kt create mode 100644 DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserRoomDAO.kt create mode 100644 DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserX.kt create mode 100644 DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/network/kotlin/UserRoomApi.kt diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/activity/MainActivity.java b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/activity/MainActivity.java index 73137cc..2169f89 100644 --- a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/activity/MainActivity.java +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/activity/MainActivity.java @@ -14,6 +14,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; @@ -53,7 +54,7 @@ public class MainActivity extends AppCompatActivity { BottomNavigationView bottomNavigationView; Button btn_verification; TextView nav_main, nav_myroom, nav_like, nav_shop, nav_purchase, nav_shop_like, nav_activities, nav_interested_activities, nav_settings; - TextView nav_header_program; + TextView nav_header_program, nav_tv_name; ImageView nav_profile_img; Fragment fragment; @@ -80,7 +81,7 @@ protected void onCreate(Bundle savedInstanceState) { nav_settings = (TextView) findViewById(R.id.nav_settings); nav_header_program = (TextView) findViewById(R.id.nav_header_program); nav_profile_img = (ImageView) findViewById(R.id.nav_profile_img); - + nav_tv_name = (TextView) findViewById(R.id.textView_name); Bundle bundle = new Bundle(); JsonObject input = new JsonObject(); @@ -109,8 +110,10 @@ protected void onCreate(Bundle savedInstanceState) { bundle.putString("ProfileImg", it.getMyInfo().getImageUrl()); bundle.putString("Program", it.getMyInfo().getStudent().getDepartment()); - //set profile img + //set profile nav_profile Picasso.get().load(it.getMyInfo().getImageUrl()).into(nav_profile_img); + nav_tv_name.setText(it.getMyInfo().getUserName()); + }, it -> { Log.e("fff@@@!!!", it.toString()); @@ -251,9 +254,8 @@ public void onClick(View v) { //화면 전환 public void replaceFragment(Fragment fr) { - Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment); - if(fragment != null) - getSupportFragmentManager().beginTransaction().remove(fragment).add(R.id.nav_host_fragment,fr).commit(); + getSupportFragmentManager().popBackStack(); + getSupportFragmentManager().beginTransaction().add(R.id.nav_host_fragment, fr).addToBackStack("a").commit(); } private void initViews() { diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java index 42c117e..3363a64 100644 --- a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java @@ -164,7 +164,7 @@ public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { }; recyclerView.addOnItemTouchListener(onItemTouchListener); - + //FloatingActionButton onClick event btn_fab.setOnClickListener(new View.OnClickListener() { @Override diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/MyPieceX.kt b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/MyPieceX.kt new file mode 100644 index 0000000..dafdcb0 --- /dev/null +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/MyPieceX.kt @@ -0,0 +1,21 @@ +package com.doubleslash.ddamiapp.model + + +import com.google.gson.annotations.SerializedName + +data class MyPieceX( + @SerializedName("description") + val description: String, + @SerializedName("fileUrl") + val fileUrl: List, + @SerializedName("_id") + val id: String, + @SerializedName("like") + val like: List, + @SerializedName("likeCount") + val likeCount: Int, + @SerializedName("title") + val title: String, + @SerializedName("views") + val views: Int +) \ No newline at end of file diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/StudentX.kt b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/StudentX.kt new file mode 100644 index 0000000..5b5fed6 --- /dev/null +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/StudentX.kt @@ -0,0 +1,13 @@ +package com.doubleslash.ddamiapp.model + + +import com.google.gson.annotations.SerializedName + +data class StudentX( + @SerializedName("department") + val department: String, + @SerializedName("_id") + val id: String, + @SerializedName("university") + val university: String +) \ No newline at end of file diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserRoomDAO.kt b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserRoomDAO.kt new file mode 100644 index 0000000..8c3f6b8 --- /dev/null +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserRoomDAO.kt @@ -0,0 +1,11 @@ +package com.doubleslash.ddamiapp.model + + +import com.google.gson.annotations.SerializedName + +data class UserRoomDAO( + @SerializedName("result") + val result: Int, + @SerializedName("user") + val user: UserX +) \ No newline at end of file diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserX.kt b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserX.kt new file mode 100644 index 0000000..990778d --- /dev/null +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/model/UserX.kt @@ -0,0 +1,29 @@ +package com.doubleslash.ddamiapp.model + + +import com.google.gson.annotations.SerializedName + +data class UserX( + @SerializedName("follow") + val follow: Int, + @SerializedName("followerCount") + val followerCount: Int, + @SerializedName("_id") + val id: String, + @SerializedName("imageUrl") + val imageUrl: String, + @SerializedName("likeField") + val likeField: List, + @SerializedName("myPieces") + val myPieces: List, + @SerializedName("state") + val state: Boolean, + @SerializedName("stateMessage") + val stateMessage: String, + @SerializedName("student") + val student: StudentX, + @SerializedName("userId") + val userId: String, + @SerializedName("userName") + val userName: String +) \ No newline at end of file diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/network/kotlin/UserRoomApi.kt b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/network/kotlin/UserRoomApi.kt new file mode 100644 index 0000000..0dfd13e --- /dev/null +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/network/kotlin/UserRoomApi.kt @@ -0,0 +1,12 @@ +package com.doubleslash.ddamiapp.network.kotlin + +import com.doubleslash.ddamiapp.model.MyroomPageDAO +import com.google.gson.JsonObject +import io.reactivex.Single +import retrofit2.http.Body +import retrofit2.http.POST + +interface UserRoomApi { + @POST("/user/detail/{id}" ) + fun myroom(@Body Body: JsonObject): Single +} \ No newline at end of file diff --git a/DdamiApp/app/src/main/res/drawable/myroom_img_shape.xml b/DdamiApp/app/src/main/res/drawable/myroom_img_shape.xml index ef2912a..218e2d1 100644 --- a/DdamiApp/app/src/main/res/drawable/myroom_img_shape.xml +++ b/DdamiApp/app/src/main/res/drawable/myroom_img_shape.xml @@ -4,6 +4,6 @@ - + android:bottomRightRadius="6dp"> + \ No newline at end of file diff --git a/DdamiApp/app/src/main/res/layout/item_myroom.xml b/DdamiApp/app/src/main/res/layout/item_myroom.xml index fd7849f..81fb6a3 100644 --- a/DdamiApp/app/src/main/res/layout/item_myroom.xml +++ b/DdamiApp/app/src/main/res/layout/item_myroom.xml @@ -1,20 +1,22 @@ - - + - - - \ No newline at end of file + + \ No newline at end of file diff --git a/DdamiApp/app/src/main/res/layout/nav_header_main2.xml b/DdamiApp/app/src/main/res/layout/nav_header_main2.xml index d4e4eb2..7d9199a 100644 --- a/DdamiApp/app/src/main/res/layout/nav_header_main2.xml +++ b/DdamiApp/app/src/main/res/layout/nav_header_main2.xml @@ -45,7 +45,7 @@ android:text="미대생 인증" android:textSize="12dp" android:background="@drawable/verify_btn" - android:textColor="@android:color/darker_gray" + android:textColor="#fff" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@id/textView_name" From 33bc1541cd20d85d808b581cc891a4cc896420f9 Mon Sep 17 00:00:00 2001 From: hb7829 Date: Fri, 14 Aug 2020 14:01:01 +0900 Subject: [PATCH 2/3] add followService --- .../ddamiapp/fragment/MainFragment.java | 3 +- .../ddamiapp/fragment/MyRoomFragment.java | 38 +++--- .../activity_shop_writing_activity1_1.xml | 2 +- .../activity_shop_writing_activity1_2.xml | 2 +- .../activity_shop_writing_activity2_1.xml | 2 +- .../app/src/main/res/layout/fragment_shop.xml | 2 +- .../main/res/layout/fragment_shop_first.xml | 2 +- .../main/res/layout/fragment_shop_list1.xml | 2 +- .../main/res/layout/fragment_shop_list2.xml | 2 +- .../main/res/layout/fragment_shop_list3.xml | 2 +- .../main/res/layout/fragment_shop_list4.xml | 2 +- .../main/res/layout/fragment_shop_list5.xml | 2 +- .../main/res/layout/fragment_shop_normal.xml | 2 +- .../main/res/layout/fragment_shop_second.xml | 2 +- .../src/main/res/layout/nav_drawer_menu.xml | 2 +- .../main/res/layout/someone_room_profile.xml | 117 ------------------ 16 files changed, 37 insertions(+), 147 deletions(-) delete mode 100644 DdamiApp/app/src/main/res/layout/someone_room_profile.xml diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MainFragment.java b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MainFragment.java index 0652098..ae40b6a 100644 --- a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MainFragment.java +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MainFragment.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; +import com.doubleslash.ddamiapp.activity.DetailActivity; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -21,7 +22,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.doubleslash.ddamiapp.R; -import com.doubleslash.ddamiapp.activity.DetailActivity; +//import com.doubleslash.ddamiapp.activity.DetailActivity; import com.doubleslash.ddamiapp.activity.MainActivity; import com.doubleslash.ddamiapp.activity.login.CustomBaseView; import com.doubleslash.ddamiapp.adapter.MainAdapter; diff --git a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java index 3363a64..b037cc6 100644 --- a/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java +++ b/DdamiApp/app/src/main/java/com/doubleslash/ddamiapp/fragment/MyRoomFragment.java @@ -70,10 +70,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, if (!getArguments().getBoolean("Myroom")) { btn_fab.setVisibility(View.GONE); btn_modify.setVisibility(View.GONE); -// btn_follow.setVisibility(View.VISIBLE); + btn_follow.setVisibility(View.VISIBLE); } - btn_follow.setVisibility(View.VISIBLE); //get values from bundle String input_id = getArguments().getString("Id"); int input_field_size = getArguments().getInt("FieldCount"); @@ -179,20 +178,27 @@ public void onClick(View view) { btn_follow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - JsonObject input = new JsonObject(); - String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjMxMzlhOGNiMGUwZjQyZDBhMDJiOWEiLCJ1c2VySWQiOiJ0ZXN0IiwiaWF0IjoxNTk3MjU0MjgzLCJleHAiOjE1OTc4NTkwODMsImlzcyI6ImRkYW1pLmNvbSIsInN1YiI6InVzZXJJbmZvIn0.vXZr-6P0IQXNYaknHIgqBhXUlOnknobDU9uY2ojPVGk"; - input.addProperty("token", token); - ApiService.INSTANCE.getFollowService().follow("5f34f2f999fef948e0f8b10b",input) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe( - it -> { - Log.e("sss!!!", it.toString()); - }, - it -> { - Log.e("fff!!!", it.toString()); - } - ); +// JsonObject input = new JsonObject(); +// String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjMxMzlhOGNiMGUwZjQyZDBhMDJiOWEiLCJ1c2VySWQiOiJ0ZXN0IiwiaWF0IjoxNTk3MjU0MjgzLCJleHAiOjE1OTc4NTkwODMsImlzcyI6ImRkYW1pLmNvbSIsInN1YiI6InVzZXJJbmZvIn0.vXZr-6P0IQXNYaknHIgqBhXUlOnknobDU9uY2ojPVGk"; +// input.addProperty("token", token); +// ApiService.INSTANCE.getFollowService().follow("5f34f2f999fef948e0f8b10b",input) +// .subscribeOn(Schedulers.io()) +// .observeOn(AndroidSchedulers.mainThread()) +// .subscribe( +// it -> { +// Log.e("sss!!!", it.toString()); +// }, +// it -> { +// Log.e("fff!!!", it.toString()); +// } +// ); + if(btn_follow.getText().toString().equals("+ Follow")) { + btn_follow.setText("Unfollow"); + followerNum.setText(Integer.valueOf(followerNum.getText().toString()) + 1); + } else if(btn_follow.getText().toString().equals("Unfollow")) { + btn_follow.setText("+ Follow"); + followerNum.setText(Integer.valueOf(followerNum.getText().toString()) - 1); + } } }); return view; diff --git a/DdamiApp/app/src/main/res/layout/activity_shop_writing_activity1_1.xml b/DdamiApp/app/src/main/res/layout/activity_shop_writing_activity1_1.xml index eac9bd7..3f6c4ef 100644 --- a/DdamiApp/app/src/main/res/layout/activity_shop_writing_activity1_1.xml +++ b/DdamiApp/app/src/main/res/layout/activity_shop_writing_activity1_1.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context=".activity.Shop.ShopWritingActivity1_1"> + tools:context=".activity.shop.ShopWritingActivity1_1"> + tools:context=".fragment.shop.ShopFragment"> + tools:context=".fragment.shop.ShopFirstFragment"> diff --git a/DdamiApp/app/src/main/res/layout/fragment_shop_list2.xml b/DdamiApp/app/src/main/res/layout/fragment_shop_list2.xml index 02de974..70fd594 100644 --- a/DdamiApp/app/src/main/res/layout/fragment_shop_list2.xml +++ b/DdamiApp/app/src/main/res/layout/fragment_shop_list2.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".fragment.Shop.ShopListFragment2" + tools:context=".fragment.shop.ShopListFragment2" android:background="@color/colorPrimary"> diff --git a/DdamiApp/app/src/main/res/layout/fragment_shop_list3.xml b/DdamiApp/app/src/main/res/layout/fragment_shop_list3.xml index e76e1b9..bcfe227 100644 --- a/DdamiApp/app/src/main/res/layout/fragment_shop_list3.xml +++ b/DdamiApp/app/src/main/res/layout/fragment_shop_list3.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".fragment.Shop.ShopListFragment3" + tools:context=".fragment.shop.ShopListFragment3" android:background="@color/colorPrimaryDark"> + tools:context=".fragment.shop.ShopListFragment4"> + tools:context=".fragment.shop.ShopListFragment5"> + tools:context=".fragment.shop.ShopNormalFragment"> + tools:context=".fragment.shop.ShopSecondFragment"> + android:visibility="gone"/> - - - - - - - - - - - - -