Skip to content
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

Refactory to kotlin and update libraries #46

Open
wants to merge 4 commits into
base: master
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
27 changes: 15 additions & 12 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'
apply plugin: 'com.jakewharton.butterknife'

android {
Expand All @@ -10,14 +12,14 @@ android {
defaultConfig {
applicationId "com.cielo.ordermanager.sdk.sample"
minSdkVersion 23
targetSdkVersion 27
targetSdkVersion 28
versionCode 2
versionName "2.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}


lintOptions{
lintOptions {
abortOnError false
}

Expand Down Expand Up @@ -53,21 +55,22 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// ------------- DEPENDENCIAS NECESSÁRIAS PRO ORDER MANAGER SDK ------------x- //
implementation 'com.cielo.lio:order-manager:1.4.0'
implementation 'com.cielo.lio:order-manager:1.5.1'
// --------------------------------------------------------------------------- //

implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:6.7.1') {
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:6.7.1') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
}
implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'

implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.cielo.ordermanager.sdk

import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.recyclerview.widget.RecyclerView

class RecyclerViewEmptySupport(context: Context, attrs: AttributeSet) : RecyclerView(context, attrs) {

private var emptyView: View? = null
private val emptyObserver: AdapterDataObserver = object : AdapterDataObserver() {
override fun onChanged() {
val adapter = adapter
if (adapter != null && emptyView != null) {
if (adapter.itemCount == 0) {
emptyView?.visibility = View.VISIBLE
[email protected] = View.GONE
} else {
emptyView?.visibility = View.GONE
[email protected] = View.VISIBLE
}
}
}
}

override fun setAdapter(adapter: Adapter<*>?) {
super.setAdapter(adapter)
adapter?.registerAdapterDataObserver(emptyObserver)
emptyObserver.onChanged()
}

fun setEmptyView(emptyView: View?) {
this.emptyView = emptyView
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.cielo.ordermanager.sdk.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import cielo.orders.domain.Order
import com.cielo.ordermanager.sdk.R

class OrderRecyclerViewAdapter(private val orderItemList: List<Order?>?) : androidx.recyclerview.widget.RecyclerView.Adapter<OrderRecyclerViewAdapter.OrderViewHolder>() {

class OrderViewHolder(itemView: View) : androidx.recyclerview.widget.RecyclerView.ViewHolder(itemView) {
var title: TextView
var summary: TextView

init {
title = itemView.findViewById<View>(R.id.title) as TextView
summary = itemView.findViewById<View>(R.id.summary) as TextView
}
}

override fun onCreateViewHolder(parent: ViewGroup, index: Int): OrderViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.order_item, parent, false)
return OrderViewHolder(view)
}

override fun onBindViewHolder(holder: OrderViewHolder, position: Int) {
if (orderItemList!![position] != null) {
val order = orderItemList[position]
var product = ""
if (!order!!.items.isEmpty()) {
product = order.reference + " - "
}
if (order.releaseDate != null) holder.title.text = order.releaseDate.toString()
holder.summary.text = product + "R$ " + order.price
}
}

override fun getItemCount(): Int {
return orderItemList?.size ?: 0
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.cielo.ordermanager.sdk.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.TextView
import cielo.sdk.order.payment.PaymentCode
import com.cielo.ordermanager.sdk.R

class PaymentCodeSpinnerAdapter(context: Context, textViewResourceId: Int) : ArrayAdapter<PaymentCode>(context, textViewResourceId, PaymentCode.values()) {
private val values: List<PaymentCode> = listOf(*PaymentCode.values())
var inflater: LayoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
var tempProduct: PaymentCode? = null
override fun getCount(): Int {
return values.size
}

override fun getItem(position: Int): PaymentCode {
return values[position]
}

override fun getItemId(position: Int): Long {
return position.toLong()
}

override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
return getCustomView(position, convertView, parent)
}

override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup?): View {
return getCustomView(position, convertView, parent)
}

private fun getCustomView(position: Int, convertView: View?, parent: ViewGroup?): View {
val row = inflater.inflate(R.layout.spinner_item, parent, false)
tempProduct = null
tempProduct = values[position]
val label = row.findViewById<View>(R.id.simple_title) as TextView
label.text = tempProduct!!.name
return row
}

}
Loading