-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
593 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
app/src/main/java/com/kidozh/discuzhub/activities/ui/UserMedal/MedalFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.