Skip to content

Commit

Permalink
change file name
Browse files Browse the repository at this point in the history
  • Loading branch information
kidozh committed May 27, 2020
1 parent 5e7603c commit ea5ed8c
Show file tree
Hide file tree
Showing 25 changed files with 593 additions and 45 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment:2.2.2'
implementation 'androidx.navigation:navigation-ui:2.2.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
android:label="@string/title_activity_global_settings" />

<activity android:name=".activities.bbsShowForumThreadActivity" />
<activity android:name=".activities.bbsShowThreadActivity" />
<activity android:name=".activities.bbsShowPostActivity" />
<activity
android:name=".activities.SplashScreenActivity"
android:theme="@style/AppTheme.NoActionBar"></activity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.android.material.tabs.TabLayout;
import com.kidozh.discuzhub.R;
import com.kidozh.discuzhub.activities.ui.UserGroup.UserGroupInfoFragment;
import com.kidozh.discuzhub.activities.ui.UserMedal.MedalFragment;
import com.kidozh.discuzhub.activities.ui.UserProfileList.UserProfileInfoListFragment;
import com.kidozh.discuzhub.activities.ui.userFriend.userFriendFragment;
import com.kidozh.discuzhub.entities.UserProfileItem;
Expand Down Expand Up @@ -454,18 +455,7 @@ private List<UserProfileItem> getEducationInfoList(){
return new ArrayList<>();
}
List<UserProfileItem> userProfileItemList = new ArrayList<>();
UserProfileResult.SpaceVariables spaceVariables = userProfileResult.userProfileVariableResult.space;
UserProfileResult.PrivacySetting privacySetting = spaceVariables.privacySetting;
userProfileItemList.add(
generateUserProfileItem(getString(R.string.user_profile_deploma),
spaceVariables.education,R.drawable.ic_study_degree_24px,
privacySetting.profilePrivacySetting.education)
);
userProfileItemList.add(
generateUserProfileItem(getString(R.string.user_profile_graduate_from),
spaceVariables.graduateschool,R.drawable.ic_school_24px,
privacySetting.profilePrivacySetting.graduateschool)
);




Expand All @@ -474,14 +464,25 @@ private List<UserProfileItem> getEducationInfoList(){

}

private List<UserProfileItem> getOccupationInfoList(){
private List<UserProfileItem> getEduOccupationInfoList(){
UserProfileResult userProfileResult = viewModel.getUserProfileResultLiveData().getValue();
if(userProfileResult == null){
return new ArrayList<>();
}
List<UserProfileItem> userProfileItemList = new ArrayList<>();
UserProfileResult.SpaceVariables spaceVariables = userProfileResult.userProfileVariableResult.space;
UserProfileResult.PrivacySetting privacySetting = spaceVariables.privacySetting;
userProfileItemList.add(
generateUserProfileItem(getString(R.string.user_profile_deploma),
spaceVariables.education,R.drawable.ic_study_degree_24px,
privacySetting.profilePrivacySetting.education)
);
userProfileItemList.add(
generateUserProfileItem(getString(R.string.user_profile_graduate_from),
spaceVariables.graduateschool,R.drawable.ic_school_24px,
privacySetting.profilePrivacySetting.graduateschool)
);

userProfileItemList.add(
generateUserProfileItem(getString(R.string.user_profile_company),
spaceVariables.company,R.drawable.ic_company_24px,
Expand Down Expand Up @@ -611,24 +612,28 @@ public personalInfoViewPagerAdapter(@NonNull FragmentManager fm, int behavior) {
@NonNull
@Override
public Fragment getItem(int position) {

UserProfileResult userProfileResult = viewModel.getUserProfileResultLiveData().getValue();
switch (position){
case 0:
return userFriendFragment.newInstance(userId);
if(userProfileResult!=null && userProfileResult.userProfileVariableResult!=null
&& userProfileResult.userProfileVariableResult.space !=null){
return MedalFragment.newInstance(userProfileResult.userProfileVariableResult.space.medals);
}
else {
return MedalFragment.newInstance(null);
}
case 1:
return userFriendFragment.newInstance(userId);
case 2:
return UserProfileInfoListFragment.newInstance(getString(R.string.user_profile_basic_information),
getBasicInfoList());
case 2:
return UserProfileInfoListFragment.newInstance(getString(R.string.user_profile_edu_information),
getEducationInfoList());
case 3:
return UserProfileInfoListFragment.newInstance(getString(R.string.user_profile_job),
getOccupationInfoList());
return UserProfileInfoListFragment.newInstance(getString(R.string.user_profile_edu_job),
getEduOccupationInfoList());
case 4:
return UserProfileInfoListFragment.newInstance(getString(R.string.user_profile_extra_information),
getExtraInfoList());
case 5:
UserProfileResult userProfileResult = viewModel.getUserProfileResultLiveData().getValue();
if(userProfileResult!=null && userProfileResult.userProfileVariableResult!=null
&& userProfileResult.userProfileVariableResult.space !=null){
return UserGroupInfoFragment.newInstance(userProfileResult.userProfileVariableResult.space.group,
Expand All @@ -648,19 +653,19 @@ public CharSequence getPageTitle(int position) {
UserProfileResult userProfileResult = viewModel.getUserProfileResultLiveData().getValue();
switch (position){
case 0:
return getString(R.string.user_profile_medal);
case 1:
if(userProfileResult !=null && userProfileResult.userProfileVariableResult!=null && userProfileResult.userProfileVariableResult.space!=null){
return getString(R.string.user_profile_friend_number_template, userProfileResult.userProfileVariableResult.space.friends);
}
else {
return getString(R.string.bbs_user_friend);
}

case 1:
return getString(R.string.user_profile_basic_information);
case 2:
return getString(R.string.user_profile_edu_information);
return getString(R.string.user_profile_basic_information);
case 3:
return getString(R.string.user_profile_job);
return getString(R.string.user_profile_edu_job);
case 4:
return getString(R.string.user_profile_extra_information);
case 5:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
import okhttp3.Request;
import okhttp3.Response;

public class bbsShowThreadActivity extends AppCompatActivity implements SmileyFragment.OnSmileyPressedInteraction,
public class bbsShowPostActivity extends AppCompatActivity implements SmileyFragment.OnSmileyPressedInteraction,
ThreadPostsAdapter.onFilterChanged,
ThreadPostsAdapter.onAdapterReply,
bbsPollFragment.OnFragmentInteractionListener{
private final static String TAG = bbsShowThreadActivity.class.getSimpleName();
private final static String TAG = bbsShowPostActivity.class.getSimpleName();
@BindView(R.id.bbs_thread_detail_recyclerview)
RecyclerView mRecyclerview;

Expand Down Expand Up @@ -150,7 +150,7 @@ public class bbsShowThreadActivity extends AppCompatActivity implements SmileyFr
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bbs_show_thread);
setContentView(R.layout.activity_bbs_show_post);
ButterKnife.bind(this);
threadDetailViewModel = new ViewModelProvider(this).get(ThreadDetailViewModel.class);
configureIntentData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.NonNull;
Expand All @@ -26,6 +27,7 @@

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.HttpUrl;

public class UserGroupInfoFragment extends Fragment {

Expand Down Expand Up @@ -102,6 +104,8 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
TextView groupMaxSignatureSizeTextview;
@BindView(R.id.user_group_begin_code_icon)
ImageView groupBeginCode;
@BindView(R.id.user_group_empty_view)
View userGroupEmptyview;

public void setCheckableImageview(ImageView imageview, boolean ok){
if(ok){
Expand All @@ -116,12 +120,25 @@ public void bindViewModel(){
mViewModel.adminGroupVariablesMutableLiveData.observe(getViewLifecycleOwner(), new Observer<UserProfileResult.AdminGroupVariables>() {
@Override
public void onChanged(UserProfileResult.AdminGroupVariables adminGroupVariables) {
if(mViewModel.adminGroupVariablesMutableLiveData.getValue() == null && mViewModel.groupVariablesMutableLiveData.getValue() == null){
userGroupEmptyview.setVisibility(View.VISIBLE);
}
else {
userGroupEmptyview.setVisibility(View.GONE);
}

if(adminGroupVariables == null || adminGroupVariables.groupTitle.length() == 0){
adminGroupCardview.setVisibility(View.GONE);
}
else {
if(adminGroupVariables.color!=null && adminGroupVariables.color.length()!=0){
// set background
//adminGroupCardview.setAlpha(0.5f);
adminGroupCardview.setCardBackgroundColor(Color.parseColor(adminGroupVariables.color));
adminGroupCardview.getBackground().setAlpha(140);
}
adminGroupCardview.setVisibility(View.VISIBLE);
adminGroupTitle.setText(adminGroupVariables.groupTitle);
adminGroupTitle.setText(Html.fromHtml(adminGroupVariables.groupTitle), TextView.BufferType.SPANNABLE);
adminGroupStarTextview.setText(String.valueOf(adminGroupVariables.stars));
adminGroupReadAccess.setText(String.valueOf(adminGroupVariables.readAccess));
setCheckableImageview(adminGroupAllowAttachment,adminGroupVariables.allowGetAttach);
Expand All @@ -141,12 +158,25 @@ public void onChanged(UserProfileResult.AdminGroupVariables adminGroupVariables)
mViewModel.groupVariablesMutableLiveData.observe(getViewLifecycleOwner(), new Observer<UserProfileResult.GroupVariables>() {
@Override
public void onChanged(UserProfileResult.GroupVariables groupVariables) {
if(mViewModel.adminGroupVariablesMutableLiveData.getValue() == null && mViewModel.groupVariablesMutableLiveData.getValue() == null){
userGroupEmptyview.setVisibility(View.VISIBLE);
}
else {
userGroupEmptyview.setVisibility(View.GONE);
}

if(groupVariables == null){
groupCardview.setVisibility(View.GONE);
}
else {
if(groupVariables.color!=null &&groupVariables.color.length()!=0){
// set background
groupCardview.setCardBackgroundColor(Color.parseColor(groupVariables.color));
groupCardview.getBackground().setAlpha(140);
//groupCardview.setBackgroundColor(Color.parseColor(groupVariables.color));
}
groupCardview.setVisibility(View.VISIBLE);
groupTitle.setText(groupVariables.groupTitle);
groupTitle.setText(Html.fromHtml(groupVariables.groupTitle), TextView.BufferType.SPANNABLE);
groupReadAccess.setText(String.valueOf(groupVariables.readAccess));
groupStarTextview.setText(String.valueOf(groupVariables.stars));
setCheckableImageview(groupAllowAttachment,groupVariables.allowGetAttach);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.kidozh.discuzhub.activities.ui.UserMedal;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

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

import com.kidozh.discuzhub.R;
import com.kidozh.discuzhub.adapter.MedalAdapter;
import com.kidozh.discuzhub.results.UserProfileResult;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* A fragment representing a list of Items.
* <p/>
* Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener}
* interface.
*/
public class MedalFragment extends Fragment {

// TODO: Customize parameter argument names
private static final String ARG_COLUMN_COUNT = "column-count";
// TODO: Customize parameters
private int mColumnCount = 1;
private OnListFragmentInteractionListener mListener;
MedalAdapter adapter = new MedalAdapter();
List<UserProfileResult.Medal> medalList;

/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public MedalFragment() {
}

// TODO: Customize parameter initialization

public static MedalFragment newInstance(List<UserProfileResult.Medal> medalList) {
MedalFragment fragment = new MedalFragment();
fragment.medalList = medalList;
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (getArguments() != null) {
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
}
}

@BindView(R.id.medal_recyclerview)
RecyclerView recyclerView;
@BindView(R.id.medal_empty_view)
View emptyView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_medal_list, container, false);
ButterKnife.bind(this,view);
// Set the adapter
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
adapter.setMedalList(medalList);

return view;
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// detect if no medal found
if(medalList == null || medalList.size() == 0){
emptyView.setVisibility(View.VISIBLE);
}
else {
emptyView.setVisibility(View.GONE);
}
}

@Override
public void onAttach(Context context) {
super.onAttach(context);

}

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

/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnListFragmentInteractionListener {
// TODO: Update argument type and name
void onListFragmentInteraction();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class UserProfileInfoListFragment extends Fragment {
TextView userProfileTitle;
@BindView(R.id.user_profile_info_recyclerview)
RecyclerView userProfileRecyclerview;
@BindView(R.id.user_profile_info_empty_view)
View userProfileEmptyView;

UserProfileItemAdapter adapter;

Expand Down Expand Up @@ -91,6 +93,12 @@ public void onChanged(String s) {
mViewModel.userProfileListMutableLiveData.observe(getViewLifecycleOwner(), new Observer<List<UserProfileItem>>() {
@Override
public void onChanged(List<UserProfileItem> userProfileItems) {
if(userProfileItems == null || userProfileItems.size() == 0){
userProfileEmptyView.setVisibility(View.VISIBLE);
}
else {
userProfileEmptyView.setVisibility(View.GONE);
}
adapter.setUserProfileItemList(userProfileItemList);
}
});
Expand Down
Loading

0 comments on commit ea5ed8c

Please sign in to comment.