Example usage for android.app Activity getApplication

List of usage examples for android.app Activity getApplication

Introduction

In this page you can find the example usage for android.app Activity getApplication.

Prototype

public final Application getApplication() 

Source Link

Document

Return the application that owns this activity.

Usage

From source file:net.tjado.passwdsafe.FileListFragment.java

/** Update files after the loader is complete */
private void updateFiles(List<Map<String, Object>> fileData) {
    SimpleAdapter adapter = null;/*from www. j a  va2 s  .c  o  m*/
    if (fileData != null) {
        adapter = new SimpleAdapter(getActivity(), fileData, R.layout.file_list_item,
                new String[] { TITLE, ICON, MOD_DATE }, new int[] { R.id.text, R.id.icon, R.id.mod_date });
        adapter.setViewBinder(new SimpleAdapter.ViewBinder() {
            @Override
            public boolean setViewValue(View view, Object data, String textRepresentation) {
                switch (view.getId()) {
                case R.id.icon: {
                    ImageView iv = (ImageView) view;
                    iv.setImageResource((int) data);
                    iv.setColorFilter(getResources().getColor(R.color.treeview_icons));
                    return true;
                }
                case R.id.text: {
                    TextView tv = (TextView) view;
                    tv.setText(textRepresentation);
                    tv.requestLayout();
                    return true;
                }
                case R.id.mod_date: {
                    if (data == null) {
                        view.setVisibility(View.GONE);
                        return true;
                    } else {
                        view.setVisibility(View.VISIBLE);
                        return false;
                    }
                }
                }
                return false;
            }
        });
    }

    View rootView = getView();
    if (rootView == null) {
        // Fragment destroyed
        return;
    }
    View groupPanel = rootView.findViewById(R.id.current_group_panel);
    TextView groupLabel = (TextView) rootView.findViewById(R.id.current_group_label);
    TextView emptyLabel = (TextView) rootView.findViewById(android.R.id.empty);
    if (itsDir == null) {
        groupPanel.setVisibility(View.GONE);
        groupLabel.setText("");
        emptyLabel.setText(R.string.ext_storage_not_mounted);
    } else {
        groupPanel.setVisibility(View.VISIBLE);
        groupLabel.setText(itsDir.toString());
        emptyLabel.setText(R.string.no_files);
    }

    setListAdapter(adapter);

    // Open the default file
    if (getListAdapter() != null) {
        Activity act = getActivity();
        PasswdSafeApp app = (PasswdSafeApp) act.getApplication();
        if (app.checkOpenDefault()) {
            SharedPreferences prefs = Preferences.getSharedPrefs(act);
            Uri defFile = Preferences.getDefFilePref(prefs);
            if (defFile != null) {
                itsListener.openFile(defFile, null);
            }
        }
    }
}

From source file:com.kncwallet.wallet.ui.HomeFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractWalletActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.wallet = application.getWallet();
    this.prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    this.loaderManager = getLoaderManager();
    this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE);

}

From source file:li.barter.fragments.AbstractBarterLiFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);
    mIsAttached = true;/*from  www.  j  a v a  2 s.c  o  m*/
    final RequestQueue requestQueue = ((IVolleyHelper) activity.getApplication()).getRequestQueue();
    mVolleyCallbacks = new VolleyCallbacks(requestQueue, this);
    mRequestCounter = new AtomicInteger(0);
}

From source file:systems.soapbox.ombuds.client.ui.WalletTransactionsFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractWalletActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.wallet = application.getWallet();
    this.resolver = activity.getContentResolver();
    this.loaderManager = getLoaderManager();
    this.devicePolicyManager = (DevicePolicyManager) application
            .getSystemService(Context.DEVICE_POLICY_SERVICE);
}

From source file:com.digi.android.wva.fragments.EndpointOptionsDialog.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    // getResources() must be called after the fragment has been
    // attached to an activity.
    alarmTypes = getResources().getStringArray(R.array.alarm_types);

    WvaApplication app = (WvaApplication) activity.getApplication();
    mHandler = app.getHandler();//  w w w  .  j  av  a 2s .  c  o  m
}

From source file:com.microsoft.office365.starter.models.O365CalendarModel.java

public void setActivity(Activity activity) {
    mApplication = (O365APIsStart_Application) activity.getApplication();
}

From source file:com.microsoft.office365.starter.models.O365CalendarModel.java

public O365CalendarModel(Activity activity) {
    mApplication = (O365APIsStart_Application) activity.getApplication();
}

From source file:org.jared.synodroid.ds.action.DownloadOriginalLinkAction.java

public void execute(ResponseHandler handlerP, SynoServer serverP) throws Exception {
    /*StringBuffer data = serverP.getDSMHandlerFactory().getDSHandler().getOriginalFile(task);
    OriginalFile ori = new OriginalFile();
    String[] temp = task.originalLink.split("/");
    ori.fileName = temp[(temp.length) - 1];
    ori.rawData = data;/*from   w ww . j a  v  a 2  s.  c o m*/
    serverP.fireMessage(handlerP, ResponseHandler.MSG_ORIGINAL_FILE_RETRIEVED, ori);
    */
    Activity a = ((Fragment) handlerP).getActivity();
    Intent msgIntent = new Intent(a, DownloadOriginalIntentService.class);
    msgIntent.putExtra(DownloadOriginalIntentService.TASKID, task.taskId);
    msgIntent.putExtra(DownloadOriginalIntentService.ORIGINAL_LINK, task.originalLink);
    msgIntent.putExtra(DownloadOriginalIntentService.COOKIES, serverP.getCookies());
    msgIntent.putExtra(DownloadOriginalIntentService.DSM_VERSION, serverP.getDsmVersion().getTitle());
    msgIntent.putExtra(DownloadOriginalIntentService.PATH, serverP.getUrl());
    msgIntent.putExtra(DownloadOriginalIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG);
    a.startService(msgIntent);
}

From source file:org.hopestarter.wallet.ui.send.SweepWalletFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractBindServiceActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.fragmentManager = getFragmentManager();
}

From source file:org.mozilla.gecko.AboutHomeContent.java

private String readFromZipFile(Activity activity, String filename) {
    ZipFile zip = null;/*w  ww . j a va2 s.  c o m*/
    String str = null;
    try {
        InputStream fileStream = null;
        File applicationPackage = new File(activity.getApplication().getPackageResourcePath());
        zip = new ZipFile(applicationPackage);
        if (zip == null)
            return null;
        ZipEntry fileEntry = zip.getEntry(filename);
        if (fileEntry == null)
            return null;
        fileStream = zip.getInputStream(fileEntry);
        str = readStringFromStream(fileStream);
    } catch (IOException ioe) {
        Log.e(LOGTAG, "error reading zip file: " + filename, ioe);
    } finally {
        try {
            if (zip != null)
                zip.close();
        } catch (IOException ioe) {
            // catch this here because we can continue even if the
            // close failed
            Log.e(LOGTAG, "error closing zip filestream", ioe);
        }
    }
    return str;
}