protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            DropBoxConfig.Configure()
            .SetAppName("SimpleTestApp")
            .SetAuthorizeUrl("https://www.dropbox.com/1/oauth2/authorize")
            .SetApiKey("")
            .SetRedirectUri("https://xamarin.com")
            .SetTokenAppName("DropBox");

            //you can access directly as well
            //DropBoxConfig.Instance.ApiKey = "";

            try
            {
                if (string.IsNullOrWhiteSpace((DropBoxConfig.Instance.ApiKey)))
                {
                    throw new System.Exception("You must enter an ApiKey");
                }

                ListView.Adapter           = new DropboxListAdapter(this);
                ListView.FastScrollEnabled = true;

                if (DropBoxHelper.IsAuthenticated)
                {
                    //already authenticated so no need to do anything at this point
                    await((DropboxListAdapter)ListView.Adapter).LoadFolderAsync();

                    //authenticated so refresh the adapter
                    ((DropboxListAdapter)ListView.Adapter).NotifyDataSetChanged();
                }
                else
                {
                    //setup a new dropbox helper and set a handler for after being authenticated
                    var authHelp = new DropBoxHelper(async() =>
                    {
                        //once authenticated load the folder contents
                        await((DropboxListAdapter)ListView.Adapter).LoadFolderAsync();

                        //authenticated so refresh the adapter
                        ((DropboxListAdapter)ListView.Adapter).NotifyDataSetChanged();
                    });

                    authHelp.PresentAuthController(this);
                }
            }
            catch (System.Exception ex)
            {
                ShowMessage("Error", ex.Message);
            }
        }
Ejemplo n.º 2
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Config the dropbox helper settings
            DropBoxConfig.Configure()
            .SetAppName("SimpleTestApp")
            .SetAuthorizeUrl("https://www.dropbox.com/1/oauth2/authorize")
            .SetApiKey("")
            .SetRedirectUri("https://xamarin.com")
            .SetTokenAppName("DropBox");

            //you can access directly as well
            //DropBoxConfig.Instance.ApiKey = "";

            return(true);
        }