mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Simplified ConversationsListHelper constructor
This commit is contained in:
parent
0eed4d1f6e
commit
882a949169
@ -1,6 +1,7 @@
|
||||
package org.communiquons.android.comunic.client.data.helpers;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -51,10 +52,10 @@ class ConversationsListDbHelper {
|
||||
/**
|
||||
* Create the conversation database helper
|
||||
*
|
||||
* @param databaseHelper Object pointing on database helper
|
||||
* @param context Application context
|
||||
*/
|
||||
ConversationsListDbHelper(@NonNull DatabaseHelper databaseHelper){
|
||||
this.databaseHelper = databaseHelper;
|
||||
ConversationsListDbHelper(@NonNull Context context){
|
||||
this.databaseHelper = DatabaseHelper.getInstance(context);
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,31 +38,14 @@ public class ConversationsListHelper extends BaseHelper {
|
||||
*/
|
||||
private ConversationsListDbHelper convDBHelper;
|
||||
|
||||
/**
|
||||
* Database helper
|
||||
*/
|
||||
private DatabaseHelper dbHelper;
|
||||
|
||||
/**
|
||||
* The constructor of the class
|
||||
*
|
||||
* @param context The context of execution of the application
|
||||
* @param dbHelper Database helper
|
||||
*/
|
||||
public ConversationsListHelper(Context context, DatabaseHelper dbHelper){
|
||||
super(context);
|
||||
|
||||
convDBHelper = new ConversationsListDbHelper(dbHelper);
|
||||
this.dbHelper = dbHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor of the class
|
||||
*
|
||||
* @param context The context of execution of the application
|
||||
*/
|
||||
public ConversationsListHelper(Context context){
|
||||
this(context, DatabaseHelper.getInstance(context));
|
||||
super(context);
|
||||
convDBHelper = new ConversationsListDbHelper(context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +175,7 @@ public class MainActivity extends BaseActivity implements
|
||||
dbHelper = DatabaseHelper.getInstance(this);
|
||||
|
||||
//Initialize conversation list helper
|
||||
conversationsListHelper = new ConversationsListHelper(this, dbHelper);
|
||||
conversationsListHelper = new ConversationsListHelper(this);
|
||||
|
||||
//Use navigation bar
|
||||
getSupportActionBar().hide();
|
||||
|
@ -208,14 +208,11 @@ public class ConversationFragment extends Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Database helper
|
||||
DatabaseHelper dbHelper = DatabaseHelper.getInstance(getActivity());
|
||||
|
||||
//Set conversation message helper
|
||||
convMessHelper = new ConversationMessagesHelper(getActivity());
|
||||
|
||||
//Set conversation list helper
|
||||
convListHelper = new ConversationsListHelper(getActivity(), dbHelper);
|
||||
convListHelper = new ConversationsListHelper(getActivity());
|
||||
|
||||
//Get the conversation ID
|
||||
assert getArguments() != null;
|
||||
|
@ -108,14 +108,11 @@ public class ConversationsListFragment extends AbstractFragment implements Adapt
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
//Database helper
|
||||
DatabaseHelper dbHelper = DatabaseHelper.getInstance(getActivity());
|
||||
|
||||
//Instantiate the user information helper
|
||||
userHelper = new GetUsersHelper(Objects.requireNonNull(getActivity()));
|
||||
|
||||
//Create the conversation list helper
|
||||
conversationsListHelper = new ConversationsListHelper(getActivity(), dbHelper);
|
||||
conversationsListHelper = new ConversationsListHelper(getActivity());
|
||||
|
||||
//Get the conversation target list view
|
||||
conversationsListView = view.findViewById(R.id.fragment_conversationslist_list);
|
||||
|
@ -168,14 +168,11 @@ public class UpdateConversationFragment extends Fragment {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Get database helper instance
|
||||
DatabaseHelper dbHelper = DatabaseHelper.getInstance(getActivity());
|
||||
|
||||
//Get User helper
|
||||
usersHelper = new GetUsersHelper(Objects.requireNonNull(getActivity()));
|
||||
|
||||
//Get conversation list helper
|
||||
convListHelper = new ConversationsListHelper(getActivity(), dbHelper);
|
||||
convListHelper = new ConversationsListHelper(getActivity());
|
||||
|
||||
//Get conversation opener
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user