@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 onFailure(RegisteredUsersApiResponse registeredUsersApiResponse, String[] userIdArray, Exception exception) { if (footerView != null) { footerView.setVisibility(View.GONE); } 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(); }
public void userUnBlockDialog(final Contact contact) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()). setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { blockUserProcess(contact, false); } }); alertDialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); String name = contact.getDisplayName(); alertDialog.setMessage(getString(R.string.user_un_block_info).replace("[name]", name)); alertDialog.setCancelable(true); alertDialog.create().show(); }
/** * Gets the preferred height for each item in the ListView, in pixels, after accounting for * screen density. ImageLoader uses this value to resize thumbnail images to match the ListView * item height. * * @return The preferred height in pixels, based on the current theme. */ private int getListPreferredItemHeight() { final TypedValue typedValue = new TypedValue(); // Resolve list item preferred height theme attribute into typedValue getActivity().getTheme().resolveAttribute( android.R.attr.listPreferredItemHeight, typedValue, true); // Create a new DisplayMetrics object final DisplayMetrics metrics = new DisplayMetrics(); // Populate the DisplayMetrics getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); // Return theme value based on DisplayMetrics return (int) typedValue.getDimension(metrics); }
public void openInvite() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND) .setType("text/plain").putExtra(Intent.EXTRA_TEXT, inviteMessage); List<Intent> targetedShareIntents = new ArrayList<Intent>(); List<ResolveInfo> resInfo = getActivity().getPackageManager().queryIntentActivities(intent, 0); if (!resInfo.isEmpty()) { for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; Intent targetedShareIntent = new Intent(Intent.ACTION_SEND); targetedShareIntent.setType("text/plain") .setAction(Intent.ACTION_SEND) .putExtra(Intent.EXTRA_TEXT, inviteMessage) .setPackage(packageName); targetedShareIntents.add(targetedShareIntent); } Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Share Via"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); startActivity(chooserIntent); } }
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(); } } }; new UserBlockTask(getActivity(), listener, contact.getUserId(), block).execute((Void) null); }
/** * Instantiates a new Contacts Adapter. * * @param context A context that has access to the app's layout. */ public ContactsAdapter(Context context) { super(context, null, 0); this.context = context; // Stores inflater for use later mInflater = LayoutInflater.from(context); // Loads a string containing the English alphabet. To fully localize the app, provide a // strings.xml file in res/values-<x> directories, where <x> is a locale. In the file, // define a string with android:name="alphabet" and contents set to all of the // alphabetic characters in the language in their proper sort order, in upper case if // applicable. final String alphabet = context.getString(R.string.alphabet); // Instantiates a new AlphabetIndexer bound to the column used to sort contact names. // The cursor is left null, because it has not yet been retrieved. mAlphabetIndexer = new AlphabetIndexer(null, 1, alphabet); // Defines a span for highlighting the part of a display name that matches the search // string highlightTextSpan = new TextAppearanceSpan(getActivity(), R.style.searchTextHiglight); }
@Override public void onDestroy() { super.onDestroy(); if (refreshContactsScreenBroadcast != null) { LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(refreshContactsScreenBroadcast); } }
@Override public void onResume() { super.onResume(); try { if (refreshContactsScreenBroadcast != null) { LocalBroadcastManager.getInstance(getActivity()).registerReceiver(refreshContactsScreenBroadcast, new IntentFilter(BroadcastService.INTENT_ACTIONS.UPDATE_USER_DETAIL.toString())); } if (isDeviceContactSync) { if (userPreference.getDeviceContactSyncTime() != 0) { Date date = new Date(); if ((date.getTime() - userPreference.getDeviceContactSyncTime()) >= CONSTANT_TIME) { Intent intent = new Intent(getActivity(), DeviceContactSyncService.class); intent.putExtra(DeviceContactSyncService.PROCESS_USER_DETAILS, true); DeviceContactSyncService.enqueueWork(getContext(), intent); } } } } catch (Exception e) { } }
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (loading && ((alCustomizationSettings.isRegisteredUserContactListCall() || ApplozicSetting.getInstance(getActivity()).isRegisteredUsersContactCall()) && Utils.isInternetAvailable(getActivity().getApplicationContext()) && TextUtils.isEmpty(userPreference.getContactsGroupId())) && (totalItemCount > previousTotal)) { loading = false; previousTotal = totalItemCount; currentPage++; } if ((!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) && (!MobiComKitPeopleActivity.isSearching)) { // I load the next page of gigs using a background task, // but you can call any function here. processLoadRegisteredUsers(); loading = true; } }
RegisteredUsersAsyncTask usersAsyncTask = new RegisteredUsersAsyncTask(getActivity(), usersAsyncTaskTaskListener, alCustomizationSettings.getTotalRegisteredUserToFetch(), userPreference.getRegisteredUsersLastFetchTime(), null, null, true); usersAsyncTask.execute((Void) null);
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (isDeviceContactSync) { return contactDatabase.getPhoneContactCursorLoader(mSearchTerm, userIdArray, alCustomizationSettings != null && alCustomizationSettings.isShowAllDeviceContacts()); } else { return contactDatabase.getSearchCursorLoader(mSearchTerm, userIdArray, MobiComUserPreference.getInstance(getActivity()).getParentGroupKey()); } }
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); isDeviceContactSync = Applozic.getInstance(getContext()).isDeviceContactSync(); if (savedInstanceState != null) { final Context context = getActivity().getApplicationContext(); mImageLoader = new ImageLoader(context, getListPreferredItemHeight()) { @Override mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f); mImageLoader.setImageFadeIn(false); if (!TextUtils.isEmpty(MobiComUserPreference.getInstance(context).getContactsGroupId())) { ApplozicGetMemberFromContactGroupTask applozicGetMemberFromContactGroupTask = new ApplozicGetMemberFromContactGroupTask(getActivity(), MobiComUserPreference.getInstance(context).getContactsGroupId(), String.valueOf(Channel.GroupType.CONTACT_GROUP.getValue()), eventMemberListener); applozicGetMemberFromContactGroupTask.execute(); } else if (userIdArray != null) {