Search in sources :

Example 11 with AlCustomizationSettings

use of com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings in project Applozic-Android-SDK by AppLozic.

the class ContactSelectionFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    bundle = getArguments();
    String jsonString = FileUtils.loadSettingsJsonFile(getActivity().getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    userPreference = MobiComUserPreference.getInstance(getActivity());
    if (bundle != null) {
        channel = (Channel) bundle.getSerializable(CHANNEL_OBJECT);
        disableCheckBox = bundle.getBoolean(CHECK_BOX, false);
        channelName = bundle.getString(CHANNEL);
        imageUrl = bundle.getString(IMAGE_LINK);
        groupType = bundle.getInt(GROUP_TYPE);
        contactsGroupId = userPreference.getContactsGroupId();
    }
    setHasOptionsMenu(true);
    refreshContactsScreenBroadcast = new RefreshContactsScreenBroadcast();
    if (savedInstanceState != null) {
        mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
        mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
    }
    contactDatabase = new ContactDatabase(getContext());
    appContactService = new AppContactService(getActivity());
    mAdapter = new ContactsAdapter(getActivity());
    final Context context = getActivity().getApplicationContext();
    mImageLoader = new ImageLoader(context, getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return appContactService.downloadContactImage(context, (Contact) data);
        }
    };
    // Set a placeholder loading image for the image loader
    mImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light);
    // Add a cache to the image loader
    mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f);
    mImageLoader.setImageFadeIn(false);
    if (contactsGroupId != null) {
        ChannelDatabaseService channelDatabaseService = ChannelDatabaseService.getInstance(context);
        groupContacts = channelDatabaseService.getChannelMemberByName(contactsGroupId, String.valueOf(Channel.GroupType.CONTACT_GROUP.getValue()));
        if (Utils.isInternetAvailable(getContext())) {
            ApplozicGetMemberFromContactGroupTask.GroupMemberListener eventMemberListener = new ApplozicGetMemberFromContactGroupTask.GroupMemberListener() {

                @Override
                public void onSuccess(String[] userIdArray, Context context) {
                    if (isAdded()) {
                        groupContacts = new String[userIdArray.length];
                        groupContacts = userIdArray;
                        getLoaderManager().initLoader(ContactsQuery.QUERY_ID, null, ContactSelectionFragment.this);
                    }
                }

                @Override
                public void onFailure(String response, Context context) {
                }
            };
            // pass GroupId whose contact Members you want to show, contactGroupType
            ApplozicGetMemberFromContactGroupTask applozicGetMemberFromContactGroupTask = new ApplozicGetMemberFromContactGroupTask(getActivity(), contactsGroupId, String.valueOf(Channel.GroupType.CONTACT_GROUP.getValue()), eventMemberListener);
            applozicGetMemberFromContactGroupTask.execute();
        } else if (groupContacts != null) {
            getLoaderManager().initLoader(ContactsQuery.QUERY_ID, null, ContactSelectionFragment.this);
        }
    } else if (MobiComUserPreference.getInstance(getContext()).getContactGroupIdList() != null && !MobiComUserPreference.getInstance(getContext()).getContactGroupIdList().isEmpty()) {
        List<String> groupList = new ArrayList<String>();
        groupList.addAll(MobiComUserPreference.getInstance(getContext()).getContactGroupIdList());
        final ProgressDialog progressBar = new ProgressDialog(getContext());
        progressBar.setMessage(getContext().getResources().getString(R.string.processing_please_wait));
        progressBar.show();
        AlGetMembersFromContactGroupListTask.GetMembersFromGroupIdListListener listener = new AlGetMembersFromContactGroupListTask.GetMembersFromGroupIdListListener() {

            @Override
            public void onSuccess(Context context, String response, String[] contactList) {
                progressBar.dismiss();
                groupContacts = contactList;
                getLoaderManager().initLoader(ContactSelectionFragment.ContactsQuery.QUERY_ID, null, ContactSelectionFragment.this);
            }

            @Override
            public void onFailure(Context context, String response, Exception e) {
                progressBar.dismiss();
                Toast.makeText(getContext(), "Failed to load contacts : Response : " + response + "\nException : " + e, Toast.LENGTH_SHORT).show();
            }
        };
        if (MobiComUserPreference.getInstance(getContext()).isContactGroupNameList()) {
            new AlGetMembersFromContactGroupListTask(getContext(), listener, null, groupList, "9").execute();
        } else {
            new AlGetMembersFromContactGroupListTask(getContext(), listener, groupList, null, "9").execute();
        }
    }
}
Also used : Context(android.content.Context) AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) AppContactService(com.applozic.mobicomkit.contact.AppContactService) SpannableString(android.text.SpannableString) ContactDatabase(com.applozic.mobicomkit.contact.database.ContactDatabase) ProgressDialog(android.app.ProgressDialog) ChannelDatabaseService(com.applozic.mobicomkit.channel.database.ChannelDatabaseService) AlGetMembersFromContactGroupListTask(com.applozic.mobicomkit.uiwidgets.async.AlGetMembersFromContactGroupListTask) Contact(com.applozic.mobicommons.people.contact.Contact) ApplozicGetMemberFromContactGroupTask(com.applozic.mobicomkit.uiwidgets.async.ApplozicGetMemberFromContactGroupTask) Bitmap(android.graphics.Bitmap) List(java.util.List) ArrayList(java.util.ArrayList) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader)

Example 12 with AlCustomizationSettings

use of com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings in project Applozic-Android-SDK by AppLozic.

the class MobiComQuickConversationFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String jsonString = FileUtils.loadSettingsJsonFile(getActivity().getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    syncCallService = SyncCallService.getInstance(getActivity());
    conversationUIService = new ConversationUIService(getActivity());
    baseContactService = new AppContactService(getActivity());
    messageDatabaseService = new MessageDatabaseService(getActivity());
    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            MobiComUserPreference.getInstance(getActivity()).setDeviceTimeOffset(DateUtils.getTimeDiffFromUtc());
        }
    });
    thread.setPriority(Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    setHasOptionsMenu(true);
    BroadcastService.lastIndexForChats = 0;
}
Also used : AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) AppContactService(com.applozic.mobicomkit.contact.AppContactService) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)

Aggregations

AlCustomizationSettings (com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings)12 IntentFilter (android.content.IntentFilter)7 Toolbar (android.support.v7.widget.Toolbar)7 ConnectivityReceiver (com.applozic.mobicomkit.broadcast.ConnectivityReceiver)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 AppContactService (com.applozic.mobicomkit.contact.AppContactService)6 Intent (android.content.Intent)5 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)4 ApplozicPermissions (com.applozic.mobicomkit.uiwidgets.instruction.ApplozicPermissions)4 Bitmap (android.graphics.Bitmap)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 ConversationUIService (com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService)3 ImageLoader (com.applozic.mobicommons.commons.image.ImageLoader)3 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)3 MessageDatabaseService (com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)2 ContactDatabase (com.applozic.mobicomkit.contact.database.ContactDatabase)2 MobiComKitBroadcastReceiver (com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver)2 Contact (com.applozic.mobicommons.people.contact.Contact)2 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)2