Skip to content

convert to kotlin from java #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: final
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand All @@ -22,11 +24,15 @@ android {
}

// If you need to add more flavors, consider using flavor dimensions.
flavorDimensions "flavor"
productFlavors {
mock {
dimension "flavor"

applicationIdSuffix = ".mock"
}
prod {
dimension "flavor"

}
}
Expand All @@ -52,6 +58,9 @@ android {
all versions in a single place. This improves readability and helps managing project complexity.
*/
dependencies {
// Kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

// App's dependencies, including test
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void intentWithStubbedNoteId() {

// Lazily start the Activity from the ActivityTestRule this time to inject the start Intent
Intent startIntent = new Intent();
startIntent.putExtra(NoteDetailActivity.EXTRA_NOTE_ID, NOTE.getId());
startIntent.putExtra(NoteDetailActivity.Companion.getEXTRA_NOTE_ID(), NOTE.getId());
mNoteDetailActivityTestRule.launchActivity(startIntent);

registerIdlingResource();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2015, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.android.testing.notes.addnote

import android.os.Bundle
import android.support.annotation.VisibleForTesting
import android.support.test.espresso.IdlingResource
import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import com.example.android.testing.notes.R
import com.example.android.testing.notes.util.EspressoIdlingResource
import kotlinx.android.synthetic.main.activity_addnote.*

/**
* Displays an add note screen.
*/
class AddNoteActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_addnote)

// Set up the toolbar.
setSupportActionBar(toolbar)
supportActionBar?.run {
setTitle(R.string.add_note)
setDisplayHomeAsUpEnabled(true)
setDisplayShowHomeEnabled(true)
}

if (null == savedInstanceState) {
initFragment(AddNoteFragment.newInstance())
}
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}

private fun initFragment(detailFragment: Fragment) {
// Add the AddNoteFragment to the layout
supportFragmentManager
.beginTransaction()
.add(R.id.contentFrame, detailFragment)
.commit()
}

val countingIdlingResource: IdlingResource
@VisibleForTesting
get() = EspressoIdlingResource.idlingResource
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,37 @@
* limitations under the License.
*/

package com.example.android.testing.notes.notedetail;
package com.example.android.testing.notes.addnote

import android.support.annotation.Nullable;
import java.io.IOException

/**
* This specifies the contract between the view and the presenter.
*/
public interface NoteDetailContract {
interface AddNoteContract {

interface View {

void setProgressIndicator(boolean active);
fun showEmptyNoteError()

void showMissingNote();
fun showNotesList()

void hideTitle();
fun openCamera(saveTo: String)

void showTitle(String title);
fun showImagePreview(uri: String)

void showImage(String imageUrl);
fun showImageError()
}

void hideImage();
interface UserActionsListener {

void hideDescription();
fun saveNote(title: String, description: String)

void showDescription(String description);
}
@Throws(IOException::class)
fun takePicture()

interface UserActionsListener {
fun imageAvailable()

void openNote(@Nullable String noteId);
fun imageCaptureFailed()
}
}
Loading