Search in sources :

Example 1 with ImageLoader

use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment 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();
    }
    applozicDocumentView = new ApplozicDocumentView(getContext());
    restrictedWords = FileUtils.loadRestrictedWordsFile(getContext());
    conversationUIService = new ConversationUIService(getActivity());
    syncCallService = SyncCallService.getInstance(getActivity());
    appContactService = new AppContactService(getActivity());
    messageDatabaseService = new MessageDatabaseService(getActivity());
    fileClientService = new FileClientService(getActivity());
    setHasOptionsMenu(true);
    imageThumbnailLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return fileClientService.loadThumbnailImage(getContext(), (Message) data, getImageLayoutParam(false).width, getImageLayoutParam(false).height);
        }
    };
    imageCache = ImageCache.getInstance((getActivity()).getSupportFragmentManager(), 0.1f);
    imageThumbnailLoader.setImageFadeIn(false);
    imageThumbnailLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
    messageImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return fileClientService.loadMessageImage(getContext(), (String) data);
        }
    };
    messageImageLoader.setImageFadeIn(false);
    messageImageLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
    applozicAudioRecordManager = new ApplozicAudioRecordManager(getActivity());
    mDetector = new GestureDetectorCompat(getContext(), this);
}
Also used : AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) ConversationUIService(com.applozic.mobicomkit.uiwidgets.conversation.ConversationUIService) AppContactService(com.applozic.mobicomkit.contact.AppContactService) Message(com.applozic.mobicomkit.api.conversation.Message) FileClientService(com.applozic.mobicomkit.api.attachment.FileClientService) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) Bitmap(android.graphics.Bitmap) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) ApplozicDocumentView(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicDocumentView) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService) ApplozicAudioRecordManager(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicAudioRecordManager)

Example 2 with ImageLoader

use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.

the class AppContactFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    contactDatabase = new ContactDatabase(getContext());
    contactService = new AppContactService(getActivity());
    mAdapter = new ContactsAdapter(getActivity().getApplicationContext());
    userPreference = MobiComUserPreference.getInstance(getContext());
    inviteMessage = Utils.getMetaDataValue(getActivity().getApplicationContext(), SHARE_TEXT);
    if (savedInstanceState != null) {
        mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
        mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
        alCustomizationSettings = (AlCustomizationSettings) savedInstanceState.getSerializable(AL_CUSTOMIZATION_SETTINGS);
    }
    refreshContactsScreenBroadcast = new RefreshContactsScreenBroadcast();
    final Context context = getActivity().getApplicationContext();
    mImageLoader = new ImageLoader(context, getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return contactService.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 (!TextUtils.isEmpty(MobiComUserPreference.getInstance(context).getContactsGroupId())) {
        ChannelDatabaseService channelDatabaseService = ChannelDatabaseService.getInstance(context);
        userIdArray = channelDatabaseService.getChannelMemberByName(MobiComUserPreference.getInstance(context).getContactsGroupId(), String.valueOf(Channel.GroupType.CONTACT_GROUP.getValue()));
        if (Utils.isInternetAvailable(getContext())) {
            ApplozicGetMemberFromContactGroupTask.GroupMemberListener eventMemberListener = new ApplozicGetMemberFromContactGroupTask.GroupMemberListener() {

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

                @Override
                public void onFailure(String response, Context context) {
                }
            };
            ApplozicGetMemberFromContactGroupTask applozicGetMemberFromContactGroupTask = new ApplozicGetMemberFromContactGroupTask(getActivity(), MobiComUserPreference.getInstance(context).getContactsGroupId(), String.valueOf(Channel.GroupType.CONTACT_GROUP.getValue()), eventMemberListener);
            applozicGetMemberFromContactGroupTask.execute();
        } else if (userIdArray != null) {
            getLoaderManager().initLoader(ContactSelectionFragment.ContactsQuery.QUERY_ID, null, AppContactFragment.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();
                userIdArray = contactList;
                getLoaderManager().initLoader(ContactSelectionFragment.ContactsQuery.QUERY_ID, null, AppContactFragment.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) 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 3 with ImageLoader

use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.

the class ContactsListFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Create the main contacts adapter
    mAdapter = new ContactsAdapter(getActivity());
    mSearchTerm = ((MobiComKitPeopleActivity) getActivity()).getSearchTerm();
    if (savedInstanceState != null) {
        // If we're restoring state after this fragment was recreated then
        // retrieve previous search term and previously selected search
        // result.
        mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
        mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
    }
    /*
         * An ImageLoader object loads and resizes an image in the background and binds it to the
         * QuickContactBadge in each item layout of the ListView. ImageLoader implements memory
         * caching for each image, which substantially improves refreshes of the ListView as the
         * user scrolls through it.
         *
         * To learn more about downloading images asynchronously and caching the results, read the
         * Android training class Displaying Bitmaps Efficiently.
         *
         * http://developer.android.com/training/displaying-bitmaps/
         */
    mImageLoader = new ImageLoader(getActivity(), getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            // return loadContactPhotoThumbnail((String) data, getImageSize());
            return ContactUtils.loadContactPhoto((Uri) data, getImageSize(), getActivity());
        }
    };
    // 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);
    InstructionUtil.showToast(getActivity(), R.string.info_sample_contact_list, R.color.instruction_color);
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) Uri(android.net.Uri)

Example 4 with ImageLoader

use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.

the class UserProfileFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    baseContactService = new AppContactService(getActivity());
    final Context context = getActivity().getApplicationContext();
    contactImageLoader = new ImageLoader(context, ImageUtils.getLargestScreenDimension((Activity) getContext())) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return baseContactService.downloadContactImage(context, (Contact) data);
        }
    };
    contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_180_holo_light);
    contactImageLoader.addImageCache((getActivity()).getSupportFragmentManager(), 0.1f);
    contactImageLoader.setImageFadeIn(false);
}
Also used : Context(android.content.Context) Bitmap(android.graphics.Bitmap) AppContactService(com.applozic.mobicomkit.contact.AppContactService) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 5 with ImageLoader

use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.

the class MessageInfoFragment method init.

private void init() {
    if (contactImageLoader == null) {
        contactImageLoader = new ImageLoader(getContext(), getListPreferredItemHeight()) {

            @Override
            protected Bitmap processBitmap(Object data) {
                BaseContactService contactService = new AppContactService(getContext());
                return contactService.downloadContactImage(getContext(), (Contact) data);
            }
        };
        contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light);
        contactImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f);
    }
    if (locationImageLoader == null) {
        locationImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) {

            @Override
            protected Bitmap processBitmap(Object data) {
                FileClientService fileClientService = new FileClientService(getContext());
                return fileClientService.loadMessageImage(getContext(), (String) data);
            }
        };
        locationImageLoader.setImageFadeIn(false);
        locationImageLoader.addImageCache(((FragmentActivity) getContext()).getSupportFragmentManager(), 0.1f);
    }
    Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.my_toolbar);
    toolbar.setClickable(false);
    toolbar.setTitle(getString(R.string.applozic_message_info));
    toolbar.setSubtitle("");
}
Also used : Bitmap(android.graphics.Bitmap) BaseContactService(com.applozic.mobicomkit.contact.BaseContactService) AppContactService(com.applozic.mobicomkit.contact.AppContactService) FileClientService(com.applozic.mobicomkit.api.attachment.FileClientService) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) Contact(com.applozic.mobicommons.people.contact.Contact) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Bitmap (android.graphics.Bitmap)9 ImageLoader (com.applozic.mobicommons.commons.image.ImageLoader)9 AppContactService (com.applozic.mobicomkit.contact.AppContactService)8 Contact (com.applozic.mobicommons.people.contact.Contact)6 Context (android.content.Context)5 Toolbar (android.support.v7.widget.Toolbar)3 AlCustomizationSettings (com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings)3 ProgressDialog (android.app.ProgressDialog)2 SpannableString (android.text.SpannableString)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)2 ChannelDatabaseService (com.applozic.mobicomkit.channel.database.ChannelDatabaseService)2 ContactDatabase (com.applozic.mobicomkit.contact.database.ContactDatabase)2 AlGetMembersFromContactGroupListTask (com.applozic.mobicomkit.uiwidgets.async.AlGetMembersFromContactGroupListTask)2 ApplozicGetMemberFromContactGroupTask (com.applozic.mobicomkit.uiwidgets.async.ApplozicGetMemberFromContactGroupTask)2 Channel (com.applozic.mobicommons.people.channel.Channel)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2