Skip to content

Commit

Permalink
Fix bugs, refactoring
Browse files Browse the repository at this point in the history
Fix humberger icon on Toolbar, fix handling of error response, enable to specify / edit / send information of tags, fix misc bugs, refactoring
  • Loading branch information
geckour committed Dec 26, 2017
1 parent 8973a30 commit c392bfc
Show file tree
Hide file tree
Showing 22 changed files with 324 additions and 248 deletions.
11 changes: 5 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies {
def okhttp_version = '3.8.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
Expand Down Expand Up @@ -82,7 +82,9 @@ dependencies {

implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation("com.squareup.retrofit2:converter-gson:$retrofit_version", {
exclude group: 'com.google.code.gson', module: 'gson'
})
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"

Expand All @@ -102,8 +104,5 @@ repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"jp.co.seesaa.geckour.picrossmaker","split":"","minSdkVersion":"21"}}]
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.design.widget.AppBarLayout
import android.support.design.widget.NavigationView
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.widget.Toolbar
import android.util.Size
import android.view.Gravity
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.widget.Toolbar
import com.trello.rxlifecycle2.components.RxActivity
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity
import jp.co.seesaa.geckour.picrossmaker.fragment.ProblemsFragment
import jp.co.seesaa.geckour.picrossmaker.R
import jp.co.seesaa.geckour.picrossmaker.databinding.ActivityMainBinding
Expand All @@ -21,10 +22,11 @@ import jp.co.seesaa.geckour.picrossmaker.fragment.SearchFragment
import jp.co.seesaa.geckour.picrossmaker.util.MyAlertDialogFragment
import jp.co.seesaa.geckour.picrossmaker.util.showSnackbar

class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListener, EditorFragment.IListener, MyAlertDialogFragment.IListener {
class MainActivity : RxAppCompatActivity(), NavigationView.OnNavigationItemSelectedListener, EditorFragment.IListener, MyAlertDialogFragment.IListener {

lateinit var binding: ActivityMainBinding
lateinit var toolbar: Toolbar
lateinit var drawerToggle: ActionBarDrawerToggle
val onClearScrollFlags by lazy { { (toolbar.layoutParams as AppBarLayout.LayoutParams).scrollFlags = 0 } }
val onSetScrollFlags by lazy { {
(toolbar.layoutParams as AppBarLayout.LayoutParams).scrollFlags =
Expand All @@ -34,14 +36,19 @@ class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListen
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)

binding.appBarMain?.appBar?.apply {
toolbar = (LayoutInflater.from(context).inflate(R.layout.toolbar_main, null) as Toolbar).apply {
viewTreeObserver.addOnGlobalLayoutListener(onClearScrollFlags)
}
removeAllViews()
addView(toolbar)
setActionBar(toolbar)
setSupportActionBar(toolbar)

drawerToggle = ActionBarDrawerToggle(this@MainActivity, binding.drawerLayout, toolbar, R.string.accessibility_desc_drawer_open, R.string.accessibility_desc_drawer_close)
binding.drawerLayout.addDrawerListener(drawerToggle)
}

binding.appBarMain?.fabLeft?.hide()

binding.navView.setNavigationItemSelectedListener(this)
Expand All @@ -52,6 +59,12 @@ class MainActivity : RxActivity(), NavigationView.OnNavigationItemSelectedListen
}
}

override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)

drawerToggle.syncState()
}

override fun onBackPressed() {
binding.drawerLayout.apply {
if (isDrawerOpen(Gravity.START)) closeDrawer(Gravity.START)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import jp.co.seesaa.geckour.picrossmaker.api.model.Result
import jp.co.seesaa.geckour.picrossmaker.api.model.SearchQuery
import jp.co.seesaa.geckour.picrossmaker.api.service.ApiService
import jp.co.seesaa.geckour.picrossmaker.util.OkHttpProvider
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
Expand All @@ -24,7 +25,7 @@ class ApiClient {
.build()
.create(ApiService::class.java)

fun registerProblem(problem: Problem): Single<Result<String>> = service.registerProblem(problem)
fun registerProblem(problem: Problem): Single<Response<Result<Result.Data<String>>>> = service.registerProblem(problem)

fun search(title: String?, tags: List<String>?): Single<Result<Result.Data<Result.Data.Problems>>> = service.search(SearchQuery(title, tags))
fun search(title: String?, tags: List<String>?): Single<Response<Result<Result.Data<Result.Data.Problems>>>> = service.search(title, tags)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data class Problem(

val title: String,

val tags: List<String>,
val tags: List<String> = listOf(),

@SerializedName("keys_horizontal")
val keysHorizontal: List<List<Int>>,
Expand All @@ -16,8 +16,8 @@ data class Problem(
val keysVertical: List<List<Int>>,

@SerializedName("created_at")
val createdAt: Long = System.currentTimeMillis(),
val createdAt: Long,

@SerializedName("edited_at")
val editedAt: Long = System.currentTimeMillis()
val editedAt: Long
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.reactivex.Single
import jp.co.seesaa.geckour.picrossmaker.api.model.Problem
import jp.co.seesaa.geckour.picrossmaker.api.model.Result
import jp.co.seesaa.geckour.picrossmaker.api.model.SearchQuery
import retrofit2.Response
import retrofit2.http.*

interface ApiService {
Expand All @@ -12,11 +13,15 @@ interface ApiService {
fun registerProblem(
@Body
problem: Problem
): Single<Result<String>>
): Single<Response<Result<Result.Data<String>>>>

@FormUrlEncoded
@POST("api/v1/search/problems")
fun search(
@Body
query: SearchQuery
): Single<Result<Result.Data<Result.Data.Problems>>>
@Field("title")
title: String?,

@Field("tags")
tags: List<String>?
): Single<Response<Result<Result.Data<Result.Data.Problems>>>>
}
Loading

0 comments on commit c392bfc

Please sign in to comment.