List of usage examples for android.app Activity isFinishing
public boolean isFinishing()
From source file:com.vuze.android.remote.SessionInfo.java
private void openTorrentWithMetaData(final Activity activity, final String name, final String metainfo) { executeRpc(new RpcExecuter() { @Override/*from w w w .ja v a 2 s . c o m*/ public void executeRpc(TransmissionRPC rpc) { rpc.addTorrentByMeta(metainfo, true, new TorrentAddedReceivedListener2(SessionInfo.this, activity, true, null)); } }); activity.runOnUiThread(new Runnable() { @Override public void run() { Context context = activity.isFinishing() ? VuzeRemoteApp.getContext() : activity; String s = context.getResources().getString(R.string.toast_adding_xxx, name); Toast.makeText(context, s, Toast.LENGTH_SHORT).show(); } }); VuzeEasyTracker.getInstance(activity).sendEvent("RemoteAction", "AddTorrent", "AddTorrentByMeta", null); }
From source file:com.appbase.androidquery.callback.AbstractAjaxCallback.java
/** * Starts the async process. /*from w w w .j a v a 2s . co m*/ * * If activity is passed, the callback method will not be invoked if the activity is no longer in use. * Specifically, isFinishing() is called to determine if the activity is active. * * @param act activity */ public void async(Activity act) { if (act.isFinishing()) { AQUtility.warn("Warning", "Possible memory leak. Calling ajax with a terminated activity."); } if (type == null) { AQUtility.warn("Warning", "type() is not called with response type."); return; } this.act = new WeakReference<Activity>(act); async((Context) act); }
From source file:com.silentcircle.contacts.editor.ContactEditorFragment.java
private void bindEditors() { // bindEditors() can only bind views if there is data in mState, so immediately return // if mState is null if (mState == null) { return;// w ww . j av a2s . c o m } // Sort the editors Collections.sort(mState, mComparator); // Remove any existing editors and rebuild any visible mContent.removeAllViews(); final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext); int numRawContacts = mState.size(); for (int i = 0; i < numRawContacts; i++) { // TODO ensure proper ordering of entities in the list final RawContactDelta rawContactDelta = mState.get(i); if (!rawContactDelta.isVisible()) continue; final AccountType type = rawContactDelta.getAccountType(accountTypes); final long rawContactId = rawContactDelta.getRawContactId(); final BaseRawContactEditorView editor; editor = (RawContactEditorView) inflater.inflate(R.layout.raw_contact_editor_view, mContent, false); ((RawContactEditorView) editor).setParent(this); editor.setEnabled(mEnabled); mContent.addView(editor); editor.setState(rawContactDelta, type, mViewIdGenerator, isEditingUserProfile()); // Set up the photo handler. bindPhotoHandler(editor, type, mState); // If a new photo was chosen but not yet saved, we need to // update the thumbnail to reflect this. Bitmap bitmap = updatedBitmapForRawContact(rawContactId); if (bitmap != null) editor.setPhotoBitmap(bitmap); if (editor instanceof RawContactEditorView) { final Activity activity = getActivity(); final RawContactEditorView rawContactEditor = (RawContactEditorView) editor; Editor.EditorListener listener = new Editor.EditorListener() { @Override public void onRequest(int request) { if (activity.isFinishing()) { // Make sure activity is still running. return; } if (request == Editor.EditorListener.FIELD_CHANGED && !isEditingUserProfile()) { acquireAggregationSuggestions(activity, rawContactEditor); } } @Override public void onDeleteRequested(Editor removedEditor) { } }; final TextFieldsEditorView nameEditor = rawContactEditor.getNameEditor(); if (mRequestFocus) { nameEditor.requestFocus(); mRequestFocus = false; } nameEditor.setEditorListener(listener); final TextFieldsEditorView phoneticNameEditor = rawContactEditor.getPhoneticNameEditor(); phoneticNameEditor.setEditorListener(listener); rawContactEditor.setAutoAddToDefaultGroup(mAutoAddToDefaultGroup); if (rawContactId == mAggregationSuggestionsRawContactId) { acquireAggregationSuggestions(activity, rawContactEditor); } } } mRequestFocus = false; bindGroupMetaData(); // Show editor now that we've loaded state mContent.setVisibility(View.VISIBLE); // Refresh Action Bar as the visibility of the join command // Activity can be null if we have been detached from the Activity final SherlockFragmentActivity activity = getSherlockActivity(); if (activity != null) activity.supportInvalidateOptionsMenu(); }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
private void showToast(String msg, int duration) { Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { return;/*w ww. j a va 2s . c o m*/ } Toast.makeText(activity, msg, duration).show(); }
From source file:com.appbase.androidquery.callback.AbstractAjaxCallback.java
private boolean isActive() { if (act == null) return true; Activity a = act.get(); if (a == null || a.isFinishing()) { return false; }// w w w. ja v a2 s . com return true; }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Displays an alert dialog that allows the user to select applications from all non-system * applications installed on the current profile. After the user selects an app, this app can't * be uninstallation./*ww w. j a v a2s . c om*/ */ private void showBlockUninstallationPrompt() { Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { return; } List<ApplicationInfo> applicationInfoList = mPackageManager.getInstalledApplications(0 /* No flag */); List<ResolveInfo> resolveInfoList = new ArrayList<ResolveInfo>(); Collections.sort(applicationInfoList, new ApplicationInfo.DisplayNameComparator(mPackageManager)); for (ApplicationInfo applicationInfo : applicationInfoList) { // Ignore system apps because they can't be uninstalled. if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.resolvePackageName = applicationInfo.packageName; resolveInfoList.add(resolveInfo); } } final BlockUninstallationInfoArrayAdapter blockUninstallationInfoArrayAdapter = new BlockUninstallationInfoArrayAdapter( getActivity(), R.id.pkg_name, resolveInfoList); ListView listview = new ListView(getActivity()); listview.setAdapter(blockUninstallationInfoArrayAdapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { blockUninstallationInfoArrayAdapter.onItemClick(parent, view, pos, id); } }); new AlertDialog.Builder(getActivity()).setTitle(R.string.block_uninstallation_title).setView(listview) .setPositiveButton(R.string.close, null /* Nothing to do */).show(); }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Asks for the package name whose uninstallation should be blocked / unblocked. *///from ww w .j av a2s . co m private void showBlockUninstallationByPackageNamePrompt() { Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { return; } View view = LayoutInflater.from(activity).inflate(R.layout.simple_edittext, null); final EditText input = (EditText) view.findViewById(R.id.input); input.setHint(getString(R.string.input_package_name_hints)); AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.block_uninstallation_title).setView(view) .setPositiveButton(R.string.block, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String pkgName = input.getText().toString(); if (!TextUtils.isEmpty(pkgName)) { mDevicePolicyManager.setUninstallBlocked(mAdminComponentName, pkgName, true); showToast(R.string.uninstallation_blocked, pkgName); } else { showToast(R.string.block_uninstallation_failed_invalid_pkgname); } } }).setNeutralButton(R.string.unblock, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String pkgName = input.getText().toString(); if (!TextUtils.isEmpty(pkgName)) { mDevicePolicyManager.setUninstallBlocked(mAdminComponentName, pkgName, false); showToast(R.string.uninstallation_allowed, pkgName); } else { showToast(R.string.block_uninstallation_failed_invalid_pkgname); } } }).setNegativeButton(android.R.string.cancel, null).show(); }
From source file:com.vuze.android.remote.SessionInfo.java
public void openTorrent(final Activity activity, final String sTorrentURL, final String friendlyName) { if (sTorrentURL == null || sTorrentURL.length() == 0) { return;//ww w .java 2 s . c o m } executeRpc(new RpcExecuter() { @Override public void executeRpc(TransmissionRPC rpc) { rpc.addTorrentByUrl(sTorrentURL, true, new TorrentAddedReceivedListener2(SessionInfo.this, activity, true, sTorrentURL)); } }); activity.runOnUiThread(new Runnable() { @Override public void run() { Context context = activity.isFinishing() ? VuzeRemoteApp.getContext() : activity; String s = context.getResources().getString(R.string.toast_adding_xxx, friendlyName == null ? sTorrentURL : friendlyName); Toast.makeText(context, s, Toast.LENGTH_SHORT).show(); } }); VuzeEasyTracker.getInstance(activity).sendEvent("RemoteAction", "AddTorrent", "AddTorrentByUrl", null); }
From source file:org.kontalk.ui.AbstractComposeFragment.java
public final boolean isFinishing() { Activity activity = getActivity(); return (activity == null || activity.isFinishing()) || isRemoving(); }