Updated FriendsListFragment local variables.

This commit is contained in:
Pierre 2018-04-14 17:52:11 +02:00
parent 2074792212
commit 064f80a9ed

View File

@ -16,6 +16,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -47,12 +48,7 @@ public class FriendsListFragment extends Fragment
/** /**
* Debug tag * Debug tag
*/ */
private String TAG = "FriendsListFragment"; private static final String TAG = "FriendsListFragment";
/**
* The root view of the fragment
*/
private View rootView;
/** /**
* Application context * Application context
@ -94,11 +90,21 @@ public class FriendsListFragment extends Fragment
*/ */
private FriendsAdapter fAdapter; private FriendsAdapter fAdapter;
/**
* Loading progress bar
*/
private ProgressBar mProgressBar;
/** /**
* No friend notice * No friend notice
*/ */
private TextView mNoFriendNotice; private TextView mNoFriendNotice;
/**
* Friends list view
*/
private ListView mFriendsListView;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -109,7 +115,7 @@ public class FriendsListFragment extends Fragment
//Create database helper //Create database helper
mDbHelper = DatabaseHelper.getInstance(mContext); mDbHelper = DatabaseHelper.getInstance(mContext);
//Create friendlist operation object //Create friend list helper object
flistHelper = new FriendsListHelper(mDbHelper, mContext); flistHelper = new FriendsListHelper(mDbHelper, mContext);
//Create get user helper //Create get user helper
@ -139,12 +145,16 @@ public class FriendsListFragment extends Fragment
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
rootView = view; //Get loading progress bar
mProgressBar = view.findViewById(R.id.fragment_friendslist_progressbar);
//Get the no friend notice //Get the no friend notice
mNoFriendNotice = view.findViewById(R.id.no_friend_notice); mNoFriendNotice = view.findViewById(R.id.no_friend_notice);
mNoFriendNotice.setVisibility(View.GONE); mNoFriendNotice.setVisibility(View.GONE);
//Get friends listview
mFriendsListView = view.findViewById(R.id.fragment_friendslist_listview);
//Retain the fragment //Retain the fragment
//setRetainInstance(true); //setRetainInstance(true);
@ -236,13 +246,12 @@ public class FriendsListFragment extends Fragment
//Set the adapter //Set the adapter
fAdapter = new FriendsAdapter(this, getActivity(), friendsList); fAdapter = new FriendsAdapter(this, getActivity(), friendsList);
ListView listView = rootView.findViewById(R.id.fragment_friendslist_listview); mFriendsListView.setAdapter(fAdapter);
listView.setAdapter(fAdapter);
//Register the view for the context menu //Register the view for the context menu
registerForContextMenu(listView); registerForContextMenu(mFriendsListView);
listView.setOnItemClickListener(this); mFriendsListView.setOnItemClickListener(this);
} }
@Override @Override
@ -387,13 +396,7 @@ public class FriendsListFragment extends Fragment
* @param display Specify whether the loading bar has to be shown or not * @param display Specify whether the loading bar has to be shown or not
*/ */
private void display_progress_bar(boolean display){ private void display_progress_bar(boolean display){
mProgressBar.setVisibility(display ? View.VISIBLE : View.GONE);
//Get the view
rootView.findViewById(R.id.fragment_friendslist_progressbar).setVisibility(
display ? View.VISIBLE : View.GONE
);
} }
/** /**