use of com.applozic.mobicommons.commons.image.ImageLoader 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);
AlTask.execute(applozicGetMemberFromContactGroupTask);
} 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()) {
AlTask.execute(new AlGetMembersFromContactGroupListTask(getContext(), listener, null, groupList, "9"));
} else {
AlTask.execute(new AlGetMembersFromContactGroupListTask(getContext(), listener, groupList, null, "9"));
}
}
}
use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.
the class ProfileFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = inflater.inflate(R.layout.al_activity_profile, container, false);
img_profile = (ImageView) view.findViewById(R.id.applozic_user_profile);
statusEdit = (ImageView) view.findViewById(R.id.status_edit_btn);
displayNameEdit = (ImageView) view.findViewById(R.id.displayName_edit_btn);
contactEdit = (ImageView) view.findViewById(R.id.contact_edit_btn);
selectImageProfileIcon = (ImageView) view.findViewById(R.id.applozic_user_profile_camera);
logoutbtn = (Button) view.findViewById(R.id.applozic_profile_logout);
displayNameText = (TextView) view.findViewById(R.id.applozic_profile_displayname);
statusText = (TextView) view.findViewById(R.id.applozic_profile_status);
contactNumberText = (TextView) view.findViewById(R.id.applozic_profile_contact);
applozicProfileContactLayout = (RelativeLayout) view.findViewById(R.id.applozic_profile_contact_section_rl);
setupDeviderView(view, R.id.applozic_profile_section_rl, R.id.applozic_profile_verticalline_rl);
setupDeviderView(view, R.id.applozic_datausage_section_rl, R.id.applozic_datausage_verticalline_rl);
setupDeviderView(view, R.id.applozic_notification_section_rl, R.id.applozic_notification_verticalline_rl);
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.my_toolbar);
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
toolbarTitle.setText(R.string.applozic_user_profile_heading);
ObjectAnimator animation = ObjectAnimator.ofFloat(toolbarTitle, "translationY", 0f);
animation.setDuration(10);
animation.start();
toolbar.setClickable(false);
// toolbar.setTitle(getString(R.string.applozic_user_profile_heading));
// toolbar.setSubtitle("");
setHasOptionsMenu(true);
contactService = new AppContactService(getActivity());
userContact = contactService.getContactById(MobiComUserPreference.getInstance(getActivity()).getUserId());
if (!TextUtils.isEmpty(userContact.getDisplayName())) {
displayNameText.setText(userContact.getDisplayName());
}
if (!TextUtils.isEmpty(userContact.getStatus())) {
statusText.setText(userContact.getStatus());
}
if (!TextUtils.isEmpty(userContact.getContactNumber())) {
contactNumberText.setText(userContact.getContactNumber());
} else {
applozicProfileContactLayout.setVisibility(View.GONE);
}
final Context context = getActivity().getApplicationContext();
mImageLoader = new ImageLoader(context, img_profile.getHeight()) {
@Override
protected Bitmap processBitmap(Object data) {
return contactService.downloadContactImage(context, (Contact) data);
}
};
// For profile image
selectImageProfileIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
processPhotoOption();
}
});
logoutbtn.setVisibility(View.GONE);
logoutbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Applozic.logoutUser(getContext(), new AlLogoutHandler() {
@Override
public void onSuccess(Context context) {
try {
final String logoutActivity = ApplozicSetting.getInstance(getActivity()).getActivityCallback(ApplozicSetting.RequestCode.USER_LOOUT);
if (logoutActivity != null && getActivity() != null) {
Intent intent = new Intent(getActivity(), Class.forName(logoutActivity));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
getActivity().finish();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Exception exception) {
}
});
}
});
statusEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.status);
final EditText input = new EditText(getContext());
input.setInputType(InputType.TYPE_CLASS_TEXT);
builder.setView(input);
builder.setPositiveButton(R.string.ok_alert, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changedStatusString = input.getText().toString();
Contact contact = new Contact();
contact.setStatus(changedStatusString);
AlTask.execute(new ProfilePictureUpload(contact, getActivity(), null, statusText, null));
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
});
displayNameEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getString(R.string.display_name));
final EditText input = new EditText(getContext());
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
builder.setView(input);
builder.setPositiveButton(getString(R.string.ok_alert), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
displayName = input.getText().toString();
if (!displayName.trim().isEmpty() && !TextUtils.isEmpty(displayName)) {
Contact contact = new Contact();
contact.setFullName(displayName);
AlTask.execute(new ProfilePictureUpload(contact, getActivity(), displayNameText, null, null));
}
}
});
builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
});
contactEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getString(R.string.profile_contact));
final EditText input = new EditText(getContext());
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_PHONE);
builder.setView(input);
builder.setPositiveButton(getString(R.string.ok_alert), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
contactNumber = input.getText().toString();
if (!contactNumber.trim().isEmpty() && !TextUtils.isEmpty(contactNumber)) {
Contact contact = new Contact();
contact.setContactNumber(contactNumber);
AlTask.execute(new ProfilePictureUpload(contact, getActivity(), null, null, contactNumberText));
}
}
});
builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
});
mImageLoader.setImageFadeIn(false);
mImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_180_holo_light);
mImageLoader.loadImage(userContact, img_profile);
return view;
}
use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.
the class ChannelFragment method onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
inviteMessage = Utils.getMetaDataValue(getActivity().getApplicationContext(), SHARE_TEXT);
baseContactService = new AppContactService(getActivity());
mAdapter = new ChannelAdapter(getActivity().getApplicationContext());
if (savedInstanceState != null) {
mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
}
final Context context = getActivity().getApplicationContext();
mChannelImageLoader = new ImageLoader(context, getListPreferredItemHeight()) {
@Override
protected Bitmap processBitmap(Object data) {
return baseContactService.downloadGroupImage(context, (Channel) data);
}
};
// Set a placeholder loading image for the image loader
mChannelImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light);
// Add a cache to the image loader
mChannelImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f);
mChannelImageLoader.setImageFadeIn(false);
}
use of com.applozic.mobicommons.commons.image.ImageLoader in project Applozic-Android-SDK by AppLozic.
the class ChannelInfoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.channel_info_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
if (!TextUtils.isEmpty(jsonString)) {
alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
} else {
alCustomizationSettings = new AlCustomizationSettings();
}
refreshBroadcast = new RefreshBroadcast();
baseContactService = new AppContactService(getApplicationContext());
channelImage = (ImageView) findViewById(R.id.channelImage);
userPreference = MobiComUserPreference.getInstance(this);
createdBy = (TextView) findViewById(R.id.created_by);
groupParticipantsTexView = (TextView) findViewById(R.id.groupParticipantsTexView);
exitChannelButton = (Button) findViewById(R.id.exit_channel);
deleteChannelButton = (Button) findViewById(R.id.delete_channel_button);
channelDeleteRelativeLayout = (RelativeLayout) findViewById(R.id.channel_delete_relativeLayout);
channelExitRelativeLayout = (RelativeLayout) findViewById(R.id.channel_exit_relativeLayout);
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
nestedScrollView = findViewById(R.id.nestedScrollView);
textViewGroupDescription = findViewById(R.id.groupDescriptionTexView);
cardViewGroupDescriptionContainer = findViewById(R.id.groupDescriptionCardView);
collapsingToolbarLayout.setContentScrimColor(Color.parseColor(alCustomizationSettings.getCollapsingToolbarLayoutColor()));
groupParticipantsTexView.setTextColor(Color.parseColor(alCustomizationSettings.getGroupParticipantsTextColor()));
deleteChannelButton.setBackgroundColor(Color.parseColor((alCustomizationSettings.getGroupDeleteButtonBackgroundColor())));
exitChannelButton.setBackgroundColor(Color.parseColor(alCustomizationSettings.getGroupExitButtonBackgroundColor()));
mActionBar = getSupportActionBar();
mActionBar.setDisplayHomeAsUpEnabled(true);
mActionBar.setHomeButtonEnabled(true);
mActionBar.setDisplayShowHomeEnabled(true);
mainListView = (ListView) findViewById(R.id.mainList);
mainListView.setLongClickable(true);
mainListView.setSmoothScrollbarEnabled(true);
if (Utils.hasLollipop()) {
mainListView.setNestedScrollingEnabled(true);
}
nestedScrollView.post(new Runnable() {
@Override
public void run() {
nestedScrollView.scrollTo(nestedScrollView.getLeft(), groupParticipantsTexView.getTop());
}
});
connectivityReceiver = new ConnectivityReceiver();
mobiComKitBroadcastReceiver = new MobiComKitBroadcastReceiver(this);
registerForContextMenu(mainListView);
if (alCustomizationSettings.isHideGroupExitButton()) {
channelExitRelativeLayout.setVisibility(View.GONE);
}
if (alCustomizationSettings.isHideGroupDeleteButton()) {
channelDeleteRelativeLayout.setVisibility(View.GONE);
}
if (getIntent().getExtras() != null) {
channelKey = getIntent().getIntExtra(CHANNEL_KEY, 0);
channelUpdateReceiver = getIntent().getParcelableExtra(CHANNEL_UPDATE_RECEIVER);
channel = ChannelService.getInstance(this).getChannelByChannelKey(channelKey);
isUserPresent = ChannelService.getInstance(this).processIsUserPresentInChannel(channelKey);
if (channel != null) {
String title = ChannelUtils.getChannelTitleName(channel, userPreference.getUserId());
if (!TextUtils.isEmpty(channel.getAdminKey())) {
contact = baseContactService.getContactById(channel.getAdminKey());
mActionBar.setTitle(title);
if (userPreference.getUserId().equals(contact.getUserId())) {
createdBy.setText(getString(R.string.channel_created_by) + " " + getString(R.string.you_string));
} else {
createdBy.setText(getString(R.string.channel_created_by) + " " + contact.getDisplayName());
}
}
updateChannelDescriptionUIFrom(channel.getMetadata());
if (!isUserPresent) {
channelExitRelativeLayout.setVisibility(View.GONE);
channelDeleteRelativeLayout.setVisibility(View.VISIBLE);
}
}
}
if (channel != null && channel.getType() != null) {
if (Channel.GroupType.BROADCAST.getValue().equals(channel.getType())) {
deleteChannelButton.setText(R.string.broadcast_delete_button);
exitChannelButton.setText(R.string.broadcast_exit_button);
channelExitRelativeLayout.setVisibility(View.GONE);
channelDeleteRelativeLayout.setVisibility(View.VISIBLE);
} else {
deleteChannelButton.setText(R.string.channel_delete_group_button);
exitChannelButton.setText(R.string.channel_exit_button);
}
}
contactImageLoader = new ImageLoader(getApplicationContext(), getListPreferredItemHeight()) {
@Override
protected Bitmap processBitmap(Object data) {
return baseContactService.downloadContactImage(getApplicationContext(), (Contact) data);
}
};
contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light);
contactImageLoader.addImageCache(this.getSupportFragmentManager(), 0.1f);
contactImageLoader.setImageFadeIn(false);
channelImageLoader = new ImageLoader(getApplicationContext(), getListPreferredItemHeight()) {
@Override
protected Bitmap processBitmap(Object data) {
return baseContactService.downloadGroupImage(getApplicationContext(), (Channel) data);
}
};
channelImageLoader.setLoadingImage(R.drawable.applozic_group_icon);
channelImageLoader.addImageCache(this.getSupportFragmentManager(), 0.1f);
channelImageLoader.setImageFadeIn(false);
if (channelImage != null && !channel.isBroadcastMessage()) {
channelImageLoader.loadImage(channel, channelImage);
} else {
channelImage.setImageResource(R.drawable.applozic_ic_applozic_broadcast);
}
channelUserMapperList = ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(channel.getKey());
contactsAdapter = new ContactsAdapter(this);
mainListView.setAdapter(contactsAdapter);
Helper.getListViewSize(mainListView);
mainListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
// Pause image loader to ensure smoother scrolling when flinging
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
contactImageLoader.setPauseWork(true);
} else {
contactImageLoader.setPauseWork(false);
}
}
@Override
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
}
});
exitChannelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
leaveChannel(channel);
}
});
deleteChannelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deleteChannel(channel);
}
});
cardViewGroupDescriptionContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isUserPresent && alCustomizationSettings.isEditChannelDescriptionAllowed() && channel != null) {
Intent editChannelNameIntent = new Intent(ChannelInfoActivity.this, EditChannelDescriptionActivity.class);
GroupInfoUpdate groupInfoUpdate = new GroupInfoUpdate(channel.getMetadata(), channel.getKey());
String groupJson = GsonUtils.getJsonFromObject(groupInfoUpdate, GroupInfoUpdate.class);
editChannelNameIntent.putExtra(GROUP_UPDTAE_INFO, groupJson);
startActivityForResult(editChannelNameIntent, REQUEST_CODE_FOR_CHANNEL_NEW_DESCRIPTION);
} else {
Toast.makeText(ChannelInfoActivity.this, alCustomizationSettings.isEditChannelDescriptionAllowed() ? getString(R.string.channel_edit_description_alert) : getString(R.string.editing_channel_description_is_not_allowed), Toast.LENGTH_SHORT).show();
}
}
});
registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Aggregations