Giter Club home page Giter Club logo

geteventcalendar's Introduction

geteventcalendar's People

Contributors

kocerenes avatar

Stargazers

Marcelo Antônio Chaves Mendes avatar  avatar Kadir Öner avatar Gulten Dogan avatar Adem ATİCİ avatar

Watchers

 avatar

geteventcalendar's Issues

fixed keep getting "Request cancelled" message after clicking "GET EVENT"

fix these two functions:

private fun makeRequestTask() {
        var mLastError: Exception? = null

        lifecycleScope.launch {

            mProgress!!.show()

            val job = async(Dispatchers.IO) {
                try {
                    Log.d("zzanzu", "makeRequestTask: doInBackground")
                    getDataFromCalendar()
                } catch (e: Exception) {
                    Log.d("zzanzu", "makeRequestTask2: $e")
                    mLastError = e
                    null
                }
            }

            val output = job.await()

            if (mLastError != null) {
                if (mLastError is GooglePlayServicesAvailabilityIOException) {
                    showGooglePlayServicesAvailabilityErrorDialog(
                        (mLastError as GooglePlayServicesAvailabilityIOException)
                            .connectionStatusCode
                    )
                } else if (mLastError is UserRecoverableAuthIOException) {
                    startActivityForResult(
                        (mLastError as UserRecoverableAuthIOException).intent,
                        REQUEST_AUTHORIZATION
                    )
                } else {
                    binding.txtOut.text =
                        "The following error occurred:\n" + mLastError!!.message
                }
            } else {
                binding.txtOut.text = "Request cancelled."
            }

            mProgress!!.hide()
            if (output == null || output.size == 0) {
                Log.d("Google", "veri yok")
            } else {
                for (index in 0 until output.size) {
                    binding.txtOut.text = (TextUtils.join("\n", output))
                    Log.d(
                        "Google",
                        output[index].id.toString() + " " + output[index].summary + " " + output[index].startDate
                    )
                }
            }
        }
    }
private fun getDataFromCalendar(): MutableList<GetEventModel> {
        val now = DateTime(System.currentTimeMillis())
        val eventStrings = ArrayList<GetEventModel>()

        val events = mService!!.events().list("primary")
            .setMaxResults(10)
            .setTimeMin(now)
            .setOrderBy("startTime")
            .setSingleEvents(true)
            .execute()
        val items = events.items

        for (event in items) {
            var start = event.start.dateTime
            if (start == null) {
                start = event.start.date
            }

            eventStrings.add(
                GetEventModel(
                    summary = event.summary,
                    startDate = start.toString()
                )
            )
        }
        return eventStrings
    }

and then add any schedule to your default google calendar for today.

then finally you can see your data in text area.

good luck!

credentials.json placement or other changes to get it working?

Hey thanks for the article and the code! I am able to get the app to run and it shows the accounts and I can select an email account. The accountName is set as expected. I followed your article and placed a credentials.json in the app folder. I do not see any reference to that file in the code.

I click the "get event" button and I see a progress indicator and then back to the main page. I'm missing something here. Any suggestions on how I might get this sample working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.