use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class MessageClientService method getTopicId.
public String getTopicId(Integer conversationId) {
try {
String topicId = null;
String url = getProductTopicIdUrl() + "?conversationId=" + conversationId;
String response = httpRequestUtils.getResponse(url, "application/json", "application/json");
if (response == null || TextUtils.isEmpty(response) || response.equals("UnAuthorized Access")) {
return null;
}
ApiResponse productConversationIdResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
if ("success".equals(productConversationIdResponse.getStatus())) {
topicId = productConversationIdResponse.getResponse().toString();
return topicId;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class ConversationClientService method closeConversationByTopicId.
public String closeConversationByTopicId(Set<String> topicIds, String userId) {
String response = "";
try {
StringBuffer stringBuffer = new StringBuffer();
if (topicIds != null && topicIds.size() > 0) {
for (String topicId : topicIds) {
stringBuffer.append(TOPIC_ID).append("=").append(URLEncoder.encode(topicId, "UTF-8")).append("&");
}
stringBuffer.append(WITH_USER_ID).append("=").append(URLEncoder.encode(userId, "UTF-8"));
response = httpRequestUtils.getResponse(getConversationCloseByTopicIdUrl() + "?" + stringBuffer.toString(), "application/json", null);
if (TextUtils.isEmpty(response)) {
return null;
}
ApiResponse apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
Utils.printLog(context, TAG, "Conversation close by topic id :" + response);
if (apiResponse != null && apiResponse.isSuccess()) {
return apiResponse.getResponse().toString();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class AppContactFragment method blockUserProcess.
public void blockUserProcess(final Contact contact, final boolean block) {
final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.please_wait_info), true);
UserBlockTask.TaskListener listener = new UserBlockTask.TaskListener() {
@Override
public void onSuccess(ApiResponse apiResponse) {
getLoaderManager().restartLoader(ContactsQuery.QUERY_ID, null, AppContactFragment.this);
}
@Override
public void onFailure(ApiResponse apiResponse, Exception exception) {
String error = getString(Utils.isInternetAvailable(getActivity()) ? R.string.applozic_server_error : R.string.you_need_network_access_for_block_or_unblock);
Toast toast = Toast.makeText(getActivity(), error, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
@Override
public void onCompletion() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
};
AlTask.execute(new UserBlockTask(getActivity(), listener, contact.getUserId(), block));
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method muteGroupChat.
public void muteGroupChat() {
final CharSequence[] items = { ApplozicService.getContext(getContext()).getString(R.string.eight_Hours), ApplozicService.getContext(getContext()).getString(R.string.one_week), ApplozicService.getContext(getContext()).getString(R.string.one_year) };
Date date = Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime();
millisecond = date.getTime();
final MuteNotificationAsync.TaskListener taskListener = new MuteNotificationAsync.TaskListener() {
@Override
public void onSuccess(ApiResponse apiResponse) {
if (menu != null) {
menu.findItem(R.id.muteGroup).setVisible(false);
menu.findItem(R.id.unmuteGroup).setVisible(true);
}
}
@Override
public void onFailure(ApiResponse apiResponse, Exception exception) {
}
@Override
public void onCompletion() {
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()).setTitle(ApplozicService.getContext(getContext()).getString(R.string.mute_group_for)).setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, final int selectedItem) {
if (selectedItem == 0) {
millisecond = millisecond + 28800000;
} else if (selectedItem == 1) {
millisecond = millisecond + 604800000;
} else if (selectedItem == 2) {
millisecond = millisecond + 31558000000L;
}
muteNotificationRequest = new MuteNotificationRequest(channel.getKey(), millisecond);
MuteNotificationAsync muteNotificationAsync = new MuteNotificationAsync(getContext(), taskListener, muteNotificationRequest);
AlTask.execute(muteNotificationAsync);
dialog.dismiss();
}
});
AlertDialog alertdialog = builder.create();
alertdialog.show();
}
use of com.applozic.mobicomkit.feed.ApiResponse in project Applozic-Android-SDK by AppLozic.
the class UserClientService method getUsersBySearchString.
/**
* Will return a list of contacts matching the search term , from the server. Search happens by user-id.
*
* <p>Note: This is a network method. Run it asynchronously.</p>
*
* To get result use:
* <code>
* String userDetails = apiResponse.getResponse();
* UserDetail[] userDetails = (UserDetail[]) GsonUtils.getObjectFromJson(GsonUtils.getJsonFromObject(userDetails, List.class), UserDetail[].class);
* </code>
*
* <p>Note: This is a network method. Run it asynchronously.</p>
*
* @param searchString the search term
* @return the api response. use {@link ApiResponse#isSuccess()} to check for success. cast the result from {@link ApiResponse#getResponse()}
* to a {@link UserDetail} array to get the list in usable form
* @throws ApplozicException when the backend returns an error response
*/
@Nullable
public ApiResponse getUsersBySearchString(@Nullable String searchString) throws ApplozicException {
if (TextUtils.isEmpty(searchString)) {
return null;
}
String response;
ApiResponse apiResponse;
try {
response = httpRequestUtils.getResponse(getUserSearchUrl() + "?name=" + URLEncoder.encode(searchString, "UTF-8"), "application/json", "application/json");
if (TextUtils.isEmpty(response)) {
return null;
}
Utils.printLog(context, TAG, "Search user response : " + response);
apiResponse = (ApiResponse) GsonUtils.getObjectFromJson(response, ApiResponse.class);
} catch (Exception e) {
throw new ApplozicException(e.getMessage());
}
return apiResponse;
}
Aggregations