diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 1334456..181837d 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -13,7 +13,6 @@
-
diff --git a/SpannedGridLayoutManager/build.gradle b/SpannedGridLayoutManager/build.gradle
index b2e8b86..de6459f 100644
--- a/SpannedGridLayoutManager/build.gradle
+++ b/SpannedGridLayoutManager/build.gradle
@@ -28,5 +28,5 @@ tasks.withType(Javadoc).configureEach {
dependencies {
implementation 'androidx.recyclerview:recyclerview:1.4.0-rc01'
- implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21'
+ implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0'
}
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 670d4d1..2e818cc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,8 +17,8 @@ android {
applicationId "ru.dimon6018.metrolauncher"
minSdk 21
targetSdk 35
- versionCode 59
- versionName "Exp. 7743"
+ versionCode 60
+ versionName "Exp. n"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt b/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
index 780a506..820cea0 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/Main.kt
@@ -67,7 +67,12 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.sendCrash
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.setUpApps
import ru.dimon6018.metrolauncher.helpers.utils.Utils.Companion.unregisterPackageReceiver
-// Main application screen (tiles, apps)
+/**
+ * Main application screen (tiles, apps)
+ * @see Application
+ * @see Start
+ * @see AllApps
+ */
class Main : AppCompatActivity() {
private lateinit var pagerAdapter: FragmentStateAdapter
@@ -117,7 +122,11 @@ class Main : AppCompatActivity() {
}
}
- // Turn off animations if developer mode is enabled to prevent some animation issues
+ /**
+ * Turn off animations if developer mode is enabled to prevent some animation issues
+ * @see onCreate
+ * @see disableAnims
+ */
private fun handleDevMode() {
if (isDevMode(this) && PREFS.isAutoShutdownAnimEnabled) {
disableAnims()
@@ -132,12 +141,20 @@ class Main : AppCompatActivity() {
startActivity(intent)
}
+ /**
+ * Called when the application is started.
+ * Updates the icon cache, application list and checks the application version
+ * @see onCreate
+ */
private suspend fun initializeData() {
pagerAdapter = WinAdapter(this@Main)
setMainViewModel()
checkUpdate()
}
+ /**
+ * Configures the user interface according to the settings
+ */
private fun setupUI() {
WindowCompat.setDecorFitsSystemWindows(window, false)
if (PREFS.isWallpaperEnabled) {
@@ -180,6 +197,10 @@ class Main : AppCompatActivity() {
}
}
+ /**
+ * Creates OnBackPressedCallback, which is needed to move to the previous ViewPager screen by pressing/gesturing backwards.
+ * Or disables the search
+ */
private fun setupBackPressedDispatcher() {
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
@@ -199,6 +220,9 @@ class Main : AppCompatActivity() {
}
}
+ /**
+ * Creates OnPageChangeCallback for some required actions
+ */
private fun createPageChangeCallback() = object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
@@ -265,6 +289,7 @@ class Main : AppCompatActivity() {
regenerateIcons()
}
+
private suspend fun regenerateIcons() {
val isCustomIconsInstalled = PREFS.iconPackPackage != "null"
var diskCache = initDiskCache(this)
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
index 5fcb862..bcc96bb 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/Start.kt
@@ -20,7 +20,6 @@ import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
-import android.view.animation.LinearInterpolator
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.ImageView
@@ -75,7 +74,6 @@ import ru.dimon6018.metrolauncher.databinding.TileBinding
import ru.dimon6018.metrolauncher.helpers.dragndrop.ItemTouchCallback
import ru.dimon6018.metrolauncher.helpers.dragndrop.ItemTouchHelperAdapter
import ru.dimon6018.metrolauncher.helpers.dragndrop.ItemTouchHelperViewHolder
-import ru.dimon6018.metrolauncher.helpers.dragndrop.OnStartDragListener
import ru.dimon6018.metrolauncher.helpers.receivers.PackageChangesReceiver
import ru.dimon6018.metrolauncher.helpers.ui.StartRecyclerView
import ru.dimon6018.metrolauncher.helpers.utils.Utils
@@ -87,7 +85,7 @@ import ru.dimon6018.metrolauncher.helpers.utils.Utils.MarginItemDecoration
import kotlin.random.Random
// Start screen
-class Start : Fragment(), OnStartDragListener {
+class Start : Fragment() {
private lateinit var mItemTouchHelper: ItemTouchHelper
@@ -122,7 +120,7 @@ class Start : Fragment(), OnStartDragListener {
): View {
_binding = LauncherStartScreenBinding.inflate(inflater, container, false)
mainViewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
- binding.startFrame.setOnClickListener {
+ binding.startTiles.setOnClickListener {
mAdapter?.let { if (it.isEditMode) it.disableEditMode() }
}
ViewCompat.setOnApplyWindowInsetsListener(binding.startTiles) { view, insets ->
@@ -135,9 +133,7 @@ class Start : Fragment(), OnStartDragListener {
)
insets
}
- if (PREFS.isWallpaperEnabled) {
- binding.startTiles.isUpdateEnabled = true
- }
+ if (PREFS.isWallpaperEnabled) binding.startTiles.isUpdateEnabled = true
return binding.root
}
@@ -159,6 +155,10 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Sets up a data observer
+ * @see onViewCreated
+ */
private fun observe() {
if (!screenLoaded || mainViewModel.getTileDao().getTilesLiveData()
.hasActiveObservers()
@@ -171,7 +171,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
}
-
+ /**
+ * Stops the data observer
+ */
private fun stopObserver() {
mainViewModel.getTileDao().getTilesLiveData().removeObservers(viewLifecycleOwner)
}
@@ -182,19 +184,34 @@ class Start : Fragment(), OnStartDragListener {
_binding = null
}
+ /**
+ * Sets up the adapter and ItemTouchHelper
+ * @see onViewCreated
+ */
private fun setupAdapter() {
mAdapter = NewStartAdapter(requireContext(), tiles!!)
mItemTouchHelper = ItemTouchHelper(ItemTouchCallback(mAdapter!!))
}
+ /**
+ * Adds a Callback for Activity, which is needed to exit desktop edit mode using the back button/gesture gesture
+ * @see NewStartAdapter.enableEditMode
+ */
private fun addCallback() {
activity?.onBackPressedDispatcher?.addCallback(viewLifecycleOwner, backCallback)
}
+ /**
+ * Removes Callback for Activity after exiting desktop edit mode
+ * @see NewStartAdapter.disableEditMode
+ */
private fun removeCallback() {
backCallback.remove()
}
+ /**
+ * Configures RecyclerView, sets Adapter and LayoutManager
+ */
private fun configureRecyclerView() {
binding.startTiles.apply {
layoutManager = mSpannedLayoutManager
@@ -204,6 +221,11 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Configures the SpannedLayoutManager using the current settings and screen orientation
+ *
+ * @param context Context
+ */
private fun setupRecyclerViewLayoutManager(context: Context?) {
if (mSpannedLayoutManager != null) mSpannedLayoutManager = null
if (!isLandscape) {
@@ -296,13 +318,9 @@ class Start : Fragment(), OnStartDragListener {
isStartMenuOpened = false
}
- override fun onStartDrag(viewHolder: RecyclerView.ViewHolder?) {
- if (viewHolder != null && !PREFS.isStartBlocked && mAdapter != null) {
- if (!mAdapter!!.isEditMode) mAdapter!!.enableEditMode()
- mItemTouchHelper.startDrag(viewHolder)
- }
- }
-
+ /**
+ * Sets BroadcastReceiver, which is needed to update the tile list when uninstalling / installing applications
+ */
@SuppressLint("InlinedApi", "UnspecifiedRegisterReceiverFlag")
private fun registerBroadcast() {
Log.d("Start", "reg broadcaster")
@@ -362,6 +380,12 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Called from BroadcastReceiver, updates the tile list
+ * @param packageName Application package name
+ * @param isDelete if True, removes the application tile with [packageName] package name
+ * @see registerBroadcast
+ */
private fun broadcastListUpdater(packageName: String, isDelete: Boolean) {
packageName.apply {
Log.d("Start", "update list by broadcaster")
@@ -383,6 +407,10 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Adds an application tile to the desktop
+ * @param packageName Application package name
+ */
private fun pinApp(packageName: String) {
lifecycleScope.launch(ioDispatcher) {
if (mAdapter != null) {
@@ -407,6 +435,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Removes BroadcastReceiver
+ */
private fun unregisterBroadcast() {
isBroadcasterRegistered = false
packageBroadcastReceiver?.apply {
@@ -422,6 +453,10 @@ class Start : Fragment(), OnStartDragListener {
unregisterBroadcast()
}
+ /**
+ * “Removes” a tile (replaces it with a Placeholder)
+ * @param tile Tile object
+ */
private suspend fun destroyTile(tile: Tile) {
tile.apply {
tileType = -1
@@ -485,6 +520,10 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Launches the application or activity of MPL settings
+ * @param packageName Application package name
+ */
private fun startApp(packageName: String) {
isAppOpened = true
if (activity != null) {
@@ -503,6 +542,12 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Tile Screen Adapter
+ * @param context Context
+ * @param list Current tile list
+ * @see setupAdapter
+ */
inner class NewStartAdapter(val context: Context, var list: MutableList) :
RecyclerView.Adapter(), ItemTouchHelperAdapter {
@@ -523,6 +568,11 @@ class Start : Fragment(), OnStartDragListener {
setHasStableIds(true)
}
+ /**
+ * Called to update the data
+ * @param newData New tile list
+ * @see observe
+ */
fun setData(newData: MutableList) {
val diffUtilCallback = DiffUtilCallback(list, newData)
val diffResult = DiffUtil.calculateDiff(diffUtilCallback, false)
@@ -531,6 +581,9 @@ class Start : Fragment(), OnStartDragListener {
tiles = newData
}
+ /**
+ * Called to activate the desktop editing mode
+ */
fun enableEditMode() {
Log.d("EditMode", "enter edit mode")
(requireActivity() as Main).configureViewPagerScroll(false)
@@ -552,6 +605,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Called to disable the desktop editing mode
+ */
fun disableEditMode() {
Log.d("EditMode", "exit edit mode")
removeCallback()
@@ -569,14 +625,12 @@ class Start : Fragment(), OnStartDragListener {
// tile animation in edit mode
fun animateItemEditMode(view: View, position: Int) {
- if (!isEditMode || list[position] == selectedItem) return
+ if (!PREFS.isTilesAnimEnabled || !isEditMode || list[position] == selectedItem) return
val rad = 5
val randomX = Random.nextFloat() * 2 * rad - rad
val randomY = Random.nextFloat() * 2 * rad - rad
- view.animate().setDuration(1000).translationX(randomX).translationY(randomY)
- .setInterpolator(
- LinearInterpolator()
- ).withEndAction {
+ if (view.scaleX != 0.9f) view.animate().scaleX(0.9f).scaleY(0.9f).setDuration(300).start()
+ view.animate().setDuration(1000).translationX(randomX).translationY(randomY).withEndAction {
animateItemEditMode(view, position)
}.start()
}
@@ -608,6 +662,13 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * This function is needed for tile configuration
+ * @param holder TileViewHolder
+ * @param item Tile object
+ * @param position Holder position
+ * @see onBindViewHolder
+ */
private fun bindDefaultTile(holder: TileViewHolder, item: Tile, position: Int) {
setTileSize(item, holder.binding.tileLabel)
setTileIconSize(holder.binding.tileIcon, item.tileSize, context.resources)
@@ -617,14 +678,39 @@ class Start : Fragment(), OnStartDragListener {
setTileAnimation(holder.itemView, position)
}
+ /**
+ * Creates an animation in edit mode or restores the default scale and translation settings
+ * @param view ItemView
+ * @param pos View position
+ * @see bindDefaultTile
+ */
private fun setTileAnimation(view: View, pos: Int) {
- animateItemEditMode(view, pos)
+ if (isEditMode) {
+ animateItemEditMode(view, pos)
+ } else {
+ if (view.scaleX != 1f) view.scaleX = 1f
+ if (view.scaleY != 1f) view.scaleY = 1f
+ if (view.translationY != 0f) view.translationY = 0f
+ if (view.translationX != 0f) view.translationX = 0f
+ }
}
+ /**
+ * Sets the text of the tile
+ * @param textView MaterialTextView of a tile
+ * @param item Tile object
+ * @see bindDefaultTile
+ */
private fun setTileText(textView: MaterialTextView, item: Tile) {
textView.text = item.tileLabel
}
+ /**
+ * Sets the application icon to the tile from the “cache”. Removes tiles in case of a problem.
+ * @param imageView ImageView
+ * @param item Tile object
+ * @see bindDefaultTile
+ */
private fun setTileIcon(imageView: ImageView, item: Tile) {
imageView.load(mainViewModel.getIconFromCache(item.tilePackage)) {
listener(onError = { request: ImageRequest, error: ErrorResult ->
@@ -635,6 +721,13 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Sets the size of the application icon on the tile
+ * @param imageView ImageView
+ * @param tileSize tileSize value, which is stored in the Tile object
+ * @param res Context.resources
+ * @see bindDefaultTile
+ */
private fun setTileIconSize(imageView: ImageView, tileSize: String, res: Resources) {
imageView.layoutParams.apply {
when (tileSize) {
@@ -673,6 +766,12 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Sets the color of the tile. If the desktop wallpaper is on, makes the tiles transparent
+ * @param holder TileViewHolder
+ * @param item Tile object
+ * @see bindDefaultTile
+ */
private fun setTileColor(holder: TileViewHolder, item: Tile) {
if (!PREFS.isWallpaperEnabled) {
if (item.tileColor != -1) {
@@ -687,7 +786,12 @@ class Start : Fragment(), OnStartDragListener {
}
}
}
-
+ /**
+ * Sets the size of the application icon on the tile
+ * @param item Tile object
+ * @param mTextView MaterialTextView of a tile
+ * @see bindDefaultTile
+ */
private fun setTileSize(item: Tile, mTextView: MaterialTextView) {
mTextView.apply {
when (item.tileSize) {
@@ -708,6 +812,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Called when moving tiles
+ */
override fun onItemMove(fromPosition: Int, toPosition: Int) {
if (!isEditMode) {
enableEditMode()
@@ -725,7 +832,7 @@ class Start : Fragment(), OnStartDragListener {
notifyItemChanged(position)
}
- override fun onDragAndDropCompleted(viewHolder: RecyclerView.ViewHolder?) {
+ override fun onDragAndDropCompleted() {
if (!isEditMode) return
lifecycleScope.launch(defaultDispatcher) {
val newData = ArrayList()
@@ -741,7 +848,12 @@ class Start : Fragment(), OnStartDragListener {
}
}
- // A popup window that shows the tile buttons (resize, unpin, customize)
+ /**
+ * A popup window that shows the tile buttons (resize, unpin, customize)
+ * @param holder TileViewHolder
+ * @param item Tile object
+ * @param position Tile position
+ */
private fun showTilePopupWindow(holder: TileViewHolder, item: Tile, position: Int) {
binding.startTiles.isScrollEnabled = false
holder.itemView.clearAnimation()
@@ -815,6 +927,7 @@ class Start : Fragment(), OnStartDragListener {
}
}
resize.setOnClickListener {
+
lifecycleScope.launch(ioDispatcher) {
when (item.tileSize) {
"small" -> item.tileSize = "medium"
@@ -843,23 +956,31 @@ class Start : Fragment(), OnStartDragListener {
}
}
- // The bottom panel with tile settings, which rises from the bottom
+ /**
+ * The bottom panel with tile settings, which rises from the bottom
+ * @param item Tile object
+ */
fun showSettingsBottomSheet(item: Tile) {
- val bottomsheet = BottomSheetDialog(context)
- bottomsheet.setContentView(R.layout.start_tile_settings_bottomsheet)
- bottomsheet.dismissWithAnimation = true
+ val bottomSheet = BottomSheetDialog(context)
+ bottomSheet.setContentView(R.layout.start_tile_settings_bottomsheet)
+ bottomSheet.dismissWithAnimation = true
val bottomSheetInternal =
- bottomsheet.findViewById(com.google.android.material.R.id.design_bottom_sheet)
+ bottomSheet.findViewById(com.google.android.material.R.id.design_bottom_sheet)
BottomSheetBehavior.from(bottomSheetInternal!!).peekHeight =
context.resources.getDimensionPixelSize(R.dimen.bottom_sheet_size)
- configureTileBottomSheet(bottomSheetInternal, bottomsheet, item)
- bottomsheet.show()
+ configureTileBottomSheet(bottomSheetInternal, bottomSheet, item)
+ bottomSheet.show()
}
- // creating the interface of the bottom panel is done here
+ /**
+ * Creating the interface of the bottom panel is done here
+ * @param bottomSheetInternal bottomSheet view
+ * @param bottomSheet BottomSheetDialog object
+ * @param item Tile object
+ */
private fun configureTileBottomSheet(
bottomSheetInternal: View,
- bottomsheet: BottomSheetDialog,
+ bottomSheet: BottomSheetDialog,
item: Tile
) {
val label = bottomSheetInternal.findViewById(R.id.appLabelSheet)
@@ -926,24 +1047,24 @@ class Start : Fragment(), OnStartDragListener {
if (editor.text.toString() == "") originalLabel else editor.text.toString()
mainViewModel.getTileDao().updateTile(item)
}
- bottomsheet.dismiss()
+ bottomSheet.dismiss()
}
removeColor.setOnClickListener {
lifecycleScope.launch(ioDispatcher) {
item.tileColor = -1
mainViewModel.getTileDao().updateTile(item)
}
- bottomsheet.dismiss()
+ bottomSheet.dismiss()
}
changeColor.setOnClickListener {
val dialog = AccentDialog()
dialog.configure(item, this@NewStartAdapter, mainViewModel.getTileDao())
dialog.show(childFragmentManager, "accentDialog")
- bottomsheet.dismiss()
+ bottomSheet.dismiss()
}
uninstall.setOnClickListener {
startActivity(Intent(Intent.ACTION_DELETE).setData(Uri.parse("package:" + item.tilePackage)))
- bottomsheet.dismiss()
+ bottomSheet.dismiss()
}
appInfo.setOnClickListener {
startActivity(
@@ -953,11 +1074,14 @@ class Start : Fragment(), OnStartDragListener {
)
)
)
- bottomsheet.dismiss()
+ bottomSheet.dismiss()
}
}
- // Default tile
+ /**
+ * Default TileViewHolder (user apps)
+ * @param binding TileBinding
+ */
@SuppressLint("ClickableViewAccessibility")
inner class TileViewHolder(val binding: TileBinding) :
RecyclerView.ViewHolder(binding.root), ItemTouchHelperViewHolder {
@@ -1012,6 +1136,9 @@ class Start : Fragment(), OnStartDragListener {
if (PREFS.customFontInstalled) customFont?.let { binding.tileLabel.typeface = it }
}
+ /**
+ * Called by clicking on a tile
+ */
private fun handleClick() {
val item = list[absoluteAdapterPosition]
if (isEditMode) {
@@ -1028,6 +1155,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Called by long pressing on a tile
+ */
private fun handleLongClick() {
if (!isEditMode && !PREFS.isStartBlocked) enableEditMode()
}
@@ -1047,6 +1177,11 @@ class Start : Fragment(), OnStartDragListener {
override fun onItemSelected() {}
override fun onItemClear() {}
}**/
+
+ /**
+ * Placeholder tile
+ * @param binding SpaceTileBinding
+ */
inner class SpaceViewHolder(binding: SpaceTileBinding) :
RecyclerView.ViewHolder(binding.root) {
init {
@@ -1057,6 +1192,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * DiffUtilCallback is needed to efficiently update the tile list
+ */
class DiffUtilCallback(private val old: List, private val new: List) :
DiffUtil.Callback() {
override fun getOldListSize(): Int {
@@ -1076,7 +1214,9 @@ class Start : Fragment(), OnStartDragListener {
}
}
- // Responsible for tile color selection
+ /**
+ * Dialog in which the user can select a color for the tile
+ */
class AccentDialog : DialogFragment() {
private lateinit var item: Tile
@@ -1140,6 +1280,11 @@ class Start : Fragment(), OnStartDragListener {
}
}
+ /**
+ * Changes the color of the tile and saves it
+ * @param color Color value
+ * @see setOnClick
+ */
private fun updateTileColor(color: Int) {
lifecycleScope.launch(Dispatchers.IO) {
item.tileColor = color
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
index 220b963..38befb9 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/Prefs.kt
@@ -3,6 +3,10 @@ package ru.dimon6018.metrolauncher.content.data
import android.content.Context
import android.content.SharedPreferences
+/**
+ * Needed to store/modify MPL settings
+ * @param context Context
+ */
class Prefs(context: Context) {
val prefs: SharedPreferences
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt
index 6dd5489..aa2e4cf 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/content/data/tile/Tile.kt
@@ -4,6 +4,17 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+/**
+ * Tile object
+ * @param tilePosition Tile position in the list
+ * @param id Unique value for tile
+ * @param tileColor Tile color
+ * @param tileType The type of tile, which will change its appearance
+ * @param isSelected is unused and will be deleted
+ * @param tileSize Tile size
+ * @param tileLabel Tile name (most often the name of the application, but it can be changed)
+ * @param tilePackage Application package
+ */
@Entity(tableName = "tiles")
data class Tile(
@PrimaryKey
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt
index a3f0095..e0c946a 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchCallback.kt
@@ -22,7 +22,6 @@ class ItemTouchCallback(private val mAdapter: Start.NewStartAdapter) : ItemTouch
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder
): Boolean {
- Log.d("moved", "move")
return if (!PREFS.isStartBlocked && mAdapter.isEditMode && viewHolder.itemViewType != mAdapter.spaceType) {
mAdapter.onItemMove(viewHolder.bindingAdapterPosition, target.bindingAdapterPosition)
true
@@ -42,6 +41,6 @@ class ItemTouchCallback(private val mAdapter: Start.NewStartAdapter) : ItemTouch
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, i: Int) {}
override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
super.clearView(recyclerView, viewHolder)
- mAdapter.onDragAndDropCompleted(viewHolder)
+ mAdapter.onDragAndDropCompleted()
}
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchHelperAdapter.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchHelperAdapter.kt
index 681c0ce..bc03304 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchHelperAdapter.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/ItemTouchHelperAdapter.kt
@@ -9,7 +9,7 @@ interface ItemTouchHelperAdapter {
*
* @param fromPosition The start position of the moved item.
* @param toPosition Then end position of the moved item.
- * @see RecyclerView.getAdapterPositionFor
+ * @see RecyclerView.findViewHolderForAdapterPosition
* @see RecyclerView.ViewHolder.getAdapterPosition
*/
fun onItemMove(fromPosition: Int, toPosition: Int)
@@ -18,10 +18,16 @@ interface ItemTouchHelperAdapter {
* Called when an item has been dismissed by a swipe.
*
* @param position The position of the item dismissed.
- * @see RecyclerView.getAdapterPositionFor
+ * @see RecyclerView.findViewHolderForAdapterPosition
* @see RecyclerView.ViewHolder.getAdapterPosition
*/
fun onItemDismiss(position: Int)
- fun onDragAndDropCompleted(viewHolder: RecyclerView.ViewHolder?)
+ /**
+ * Called when Drag and Drop is completed.
+ *
+ * @see RecyclerView.findViewHolderForAdapterPosition
+ * @see RecyclerView.ViewHolder.getAdapterPosition
+ */
+ fun onDragAndDropCompleted()
}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/OnStartDragListener.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/OnStartDragListener.kt
deleted file mode 100644
index 4cc6d86..0000000
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/dragndrop/OnStartDragListener.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package ru.dimon6018.metrolauncher.helpers.dragndrop
-
-import androidx.recyclerview.widget.RecyclerView
-
-interface OnStartDragListener {
- /**
- * Called when a view is requesting a start of a drag.
- *
- * @param viewHolder The holder of the view to drag.
- */
- fun onStartDrag(viewHolder: RecyclerView.ViewHolder?)
-}
\ No newline at end of file
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt
index 7887ca8..98b5f83 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/MetroRecyclerView.kt
@@ -5,8 +5,9 @@ import android.util.AttributeSet
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView
-// RecyclerView that can block scrolling
-
+/**
+ * RecyclerView that can block scrolling
+ */
open class MetroRecyclerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
diff --git a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt
index 06f0309..841c643 100644
--- a/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt
+++ b/app/src/main/java/ru/dimon6018/metrolauncher/helpers/ui/StartRecyclerView.kt
@@ -12,7 +12,9 @@ import android.view.View
import android.view.ViewParent
import ru.dimon6018.metrolauncher.helpers.utils.Utils
-// RecyclerView which is used by tiles on the start screen
+/**
+ * MetroRecyclerView which is used by tiles on the start screen
+ */
class StartRecyclerView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
diff --git a/build.gradle b/build.gradle
index 316c53d..db944a5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id 'com.android.application' version '8.7.2' apply false
- id 'com.android.library' version '8.7.2' apply false
+ id 'com.android.application' version '8.7.3' apply false
+ id 'com.android.library' version '8.7.3' apply false
id 'org.jetbrains.kotlin.android' version '2.1.0' apply false
id 'com.google.devtools.ksp' version "2.1.0-1.0.29" apply false
}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Languages.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Languages.java
deleted file mode 100644
index faf1973..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Languages.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.kwabenaberko.openweathermaplib.constant;
-
-public class Languages {
-
- public static final String AFRIKAANS = "af";
- public static final String ALBANIAN = "al";
- public static final String ARABIC = "ar";
- public static final String AZERBAIJANI = "az";
- public static final String BULGARIAN = "bg";
- public static final String CATALAN = "ca";
- public static final String CZECH = "cz";
- public static final String DANISH = "da";
- public static final String GERMAN = "de";
- public static final String GREEK = "el";
- public static final String ENGLISH = "en";
- public static final String BASQUE = "eu";
- public static final String PERSIAN = "fa";
- public static final String FINNISH = "fi";
- public static final String FRENCH = "fr";
- public static final String GALICIAN = "gl";
- public static final String HEBREW = "he";
- public static final String HINDI = "hi";
- public static final String CROATIAN = "hr";
- public static final String HUNGARIAN = "hu";
- public static final String INDONESIAN = "id";
- public static final String ITALIAN = "it";
- public static final String JAPANESE = "ja";
- public static final String KOREAN = "kr";
- public static final String LATVIAN = "la";
- public static final String LITHUANIAN = "lt";
- public static final String MACEDONIAN = "mk";
- public static final String NORWEGIAN = "no";
- public static final String DUTCH = "nl";
- public static final String POLISH = "pl";
- public static final String PORTUGUESE = "pt";
- public static final String PORTUGUES_BRASIL = "pt_br";
- public static final String ROMANIAN = "ro";
- public static final String RUSSIAN = "ru";
- public static final String SWEDISH = "se";
- public static final String SLOVAK = "sk";
- public static final String SLOVENIAN = "sl";
- public static final String SPANISH = "es";
- public static final String SERBIAN = "sr";
- public static final String THAI = "th";
- public static final String TURKISH = "tr";
- public static final String UKRAINIAN = "ua";
- public static final String VIETNAMESE = "vi";
- public static final String CHINESE_SIMPLIFIED = "zh_cn";
- public static final String CHINESE_TRADITIONAL = "zh_tw";
- public static final String ZULU = "zu";
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Languages.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Languages.kt
new file mode 100644
index 0000000..d9704ec
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Languages.kt
@@ -0,0 +1,50 @@
+package com.kwabenaberko.openweathermaplib.constant
+
+object Languages {
+ const val AFRIKAANS: String = "af"
+ const val ALBANIAN: String = "al"
+ const val ARABIC: String = "ar"
+ const val AZERBAIJANI: String = "az"
+ const val BULGARIAN: String = "bg"
+ const val CATALAN: String = "ca"
+ const val CZECH: String = "cz"
+ const val DANISH: String = "da"
+ const val GERMAN: String = "de"
+ const val GREEK: String = "el"
+ const val ENGLISH: String = "en"
+ const val BASQUE: String = "eu"
+ const val PERSIAN: String = "fa"
+ const val FINNISH: String = "fi"
+ const val FRENCH: String = "fr"
+ const val GALICIAN: String = "gl"
+ const val HEBREW: String = "he"
+ const val HINDI: String = "hi"
+ const val CROATIAN: String = "hr"
+ const val HUNGARIAN: String = "hu"
+ const val INDONESIAN: String = "id"
+ const val ITALIAN: String = "it"
+ const val JAPANESE: String = "ja"
+ const val KOREAN: String = "kr"
+ const val LATVIAN: String = "la"
+ const val LITHUANIAN: String = "lt"
+ const val MACEDONIAN: String = "mk"
+ const val NORWEGIAN: String = "no"
+ const val DUTCH: String = "nl"
+ const val POLISH: String = "pl"
+ const val PORTUGUESE: String = "pt"
+ const val PORTUGUES_BRASIL: String = "pt_br"
+ const val ROMANIAN: String = "ro"
+ const val RUSSIAN: String = "ru"
+ const val SWEDISH: String = "se"
+ const val SLOVAK: String = "sk"
+ const val SLOVENIAN: String = "sl"
+ const val SPANISH: String = "es"
+ const val SERBIAN: String = "sr"
+ const val THAI: String = "th"
+ const val TURKISH: String = "tr"
+ const val UKRAINIAN: String = "ua"
+ const val VIETNAMESE: String = "vi"
+ const val CHINESE_SIMPLIFIED: String = "zh_cn"
+ const val CHINESE_TRADITIONAL: String = "zh_tw"
+ const val ZULU: String = "zu"
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Units.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Units.java
deleted file mode 100644
index c2daeb3..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Units.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.kwabenaberko.openweathermaplib.constant;
-
-/**
- * Created by Kwabena Berko on 8/6/2017.
- */
-
-public class Units {
- public static final String METRIC = "metric";
- public static final String IMPERIAL = "imperial";
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Units.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Units.kt
new file mode 100644
index 0000000..dc85488
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/constant/Units.kt
@@ -0,0 +1,9 @@
+package com.kwabenaberko.openweathermaplib.constant
+
+/**
+ * Created by Kwabena Berko on 8/6/2017.
+ */
+object Units {
+ const val METRIC: String = "metric"
+ const val IMPERIAL: String = "imperial"
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/OpenWeatherMapHelper.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/OpenWeatherMapHelper.java
deleted file mode 100644
index 2485798..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/OpenWeatherMapHelper.java
+++ /dev/null
@@ -1,268 +0,0 @@
-package com.kwabenaberko.openweathermaplib.implementation;
-
-import androidx.annotation.NonNull;
-
-import com.kwabenaberko.openweathermaplib.implementation.callback.CurrentWeatherCallback;
-import com.kwabenaberko.openweathermaplib.implementation.callback.ThreeHourForecastCallback;
-import com.kwabenaberko.openweathermaplib.model.currentweather.CurrentWeather;
-import com.kwabenaberko.openweathermaplib.model.threehourforecast.ThreeHourForecast;
-import com.kwabenaberko.openweathermaplib.network.OpenWeatherMapClient;
-import com.kwabenaberko.openweathermaplib.network.OpenWeatherMapService;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.util.HashMap;
-import java.util.Map;
-
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class OpenWeatherMapHelper {
-
- private static final String APPID = "appId";
- private static final String UNITS = "units";
- private static final String LANGUAGE = "lang";
- private static final String QUERY = "q";
- private static final String CITY_ID = "id";
- private static final String LATITUDE = "lat";
- private static final String LONGITUDE = "lon";
- private static final String ZIP_CODE = "zip";
-
- private final OpenWeatherMapService openWeatherMapService;
- private final Map options;
-
-
- public OpenWeatherMapHelper(String apiKey){
- openWeatherMapService = OpenWeatherMapClient.getClient().create(OpenWeatherMapService.class);
- options = new HashMap<>();
- options.put(APPID, apiKey == null ? "" : apiKey);
- }
-
-
- //SETUP METHODS
- public void setUnits(String units){
- options.put(UNITS, units);
- }
- public void setLanguage(String lang) {
- options.put(LANGUAGE, lang);
- }
-
-
- private Throwable NoAppIdErrMessage() {
- return new Throwable("UnAuthorized. Please set a valid OpenWeatherMap API KEY.");
- }
-
-
- private Throwable NotFoundErrMsg(String str) {
- Throwable throwable = null;
- try {
- JSONObject obj = new JSONObject(str);
- throwable = new Throwable(obj.getString("message"));
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- if (throwable == null){
- throwable = new Throwable("An unexpected error occurred.");
- }
-
-
- return throwable;
- }
-
-// CURRENT WEATHER METHODS
-// START
-
- //GET CURRENT WEATHER BY CITY NAME
- public void getCurrentWeatherByCityName(String city, final CurrentWeatherCallback callback){
- options.put(QUERY, city);
-
- openWeatherMapService.getCurrentWeatherByCityName(options).enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
- handleCurrentWeatherResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
- }
-
- //GET CURRENT WEATHER BY CITY ID
- public void getCurrentWeatherByCityID(String id, final CurrentWeatherCallback callback){
- options.put(CITY_ID, id);
- openWeatherMapService.getCurrentWeatherByCityID(options).enqueue(new Callback() {
- @Override
- public void onResponse(Call call, Response response) {
- handleCurrentWeatherResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
-
- }
-
- //GET CURRENT WEATHER BY GEOGRAPHIC COORDINATES
- public void getCurrentWeatherByGeoCoordinates(double latitude, double longitude, final CurrentWeatherCallback callback){
- options.put(LATITUDE, String.valueOf(latitude));
- options.put(LONGITUDE, String.valueOf(longitude));
- openWeatherMapService.getCurrentWeatherByGeoCoordinates(options).enqueue(new Callback() {
- @Override
- public void onResponse(Call call, Response response) {
- handleCurrentWeatherResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
- }
-
- //GET CURRENT WEATHER BY ZIP CODE
-
- public void getCurrentWeatherByZipCode(String zipCode, final CurrentWeatherCallback callback){
- options.put(ZIP_CODE, zipCode);
- openWeatherMapService.getCurrentWeatherByZipCode(options).enqueue(new Callback() {
- @Override
- public void onResponse(Call call, Response response) {
- handleCurrentWeatherResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
- }
-
- private void handleCurrentWeatherResponse(Response response, CurrentWeatherCallback callback){
- if (response.code() == HttpURLConnection.HTTP_OK){
- callback.onSuccess(response.body());
- }
- else if (response.code() == HttpURLConnection.HTTP_FORBIDDEN || response.code() == HttpURLConnection.HTTP_UNAUTHORIZED){
- callback.onFailure(NoAppIdErrMessage());
- }
- else{
- try {
- callback.onFailure(NotFoundErrMsg(response.errorBody().string()));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
-
-// CURRENT WEATHER METHODS
-// END
-
-
-
-
-// THREE HOUR FORECAST METHODS
-// START
-
- //GET THREE HOUR FORECAST BY CITY NAME
- public void getThreeHourForecastByCityName(String city, final ThreeHourForecastCallback callback){
- options.put(QUERY, city);
- openWeatherMapService.getThreeHourForecastByCityName(options)
- .enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
- handleThreeHourForecastResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
-
- }
-
- //GET THREE HOUR FORECAST BY CITY ID
- public void getThreeHourForecastByCityID(String id, final ThreeHourForecastCallback callback){
- options.put(CITY_ID, id);
- openWeatherMapService.getThreeHourForecastByCityID(options)
- .enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
- handleThreeHourForecastResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
-
- }
-
- //GET THREE HOUR FORECAST BY GEO C0ORDINATES
- public void getThreeHourForecastByGeoCoordinates(double latitude, double longitude, final ThreeHourForecastCallback callback){
- options.put(LATITUDE, String.valueOf(latitude));
- options.put(LONGITUDE, String.valueOf(longitude));
- openWeatherMapService.getThreeHourForecastByGeoCoordinates(options)
- .enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
- handleThreeHourForecastResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
-
- }
-
- //GET THREE HOUR FORECAST BY ZIP CODE
- public void getThreeHourForecastByZipCode(String zipCode, final ThreeHourForecastCallback callback){
- options.put(ZIP_CODE, zipCode);
- openWeatherMapService.getThreeHourForecastByZipCode(options)
- .enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
- handleThreeHourForecastResponse(response, callback);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable throwable) {
- callback.onFailure(throwable);
- }
- });
-
- }
-
- private void handleThreeHourForecastResponse(Response response, ThreeHourForecastCallback callback){
- if (response.code() == HttpURLConnection.HTTP_OK){
- callback.onSuccess(response.body());
- }
- else if (response.code() == HttpURLConnection.HTTP_FORBIDDEN || response.code() == HttpURLConnection.HTTP_UNAUTHORIZED){
- callback.onFailure(NoAppIdErrMessage());
- }
- else{
- try {
- callback.onFailure(NotFoundErrMsg(response.errorBody().string()));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
-
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/OpenWeatherMapHelper.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/OpenWeatherMapHelper.kt
new file mode 100644
index 0000000..4c3f408
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/OpenWeatherMapHelper.kt
@@ -0,0 +1,263 @@
+package com.kwabenaberko.openweathermaplib.implementation
+
+import com.kwabenaberko.openweathermaplib.implementation.callback.CurrentWeatherCallback
+import com.kwabenaberko.openweathermaplib.implementation.callback.ThreeHourForecastCallback
+import com.kwabenaberko.openweathermaplib.model.currentweather.CurrentWeather
+import com.kwabenaberko.openweathermaplib.model.threehourforecast.ThreeHourForecast
+import com.kwabenaberko.openweathermaplib.network.OpenWeatherMapClient
+import com.kwabenaberko.openweathermaplib.network.OpenWeatherMapService
+import org.json.JSONException
+import org.json.JSONObject
+import retrofit2.Call
+import retrofit2.Callback
+import retrofit2.Response
+import java.io.IOException
+import java.net.HttpURLConnection
+import java.util.HashMap
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class OpenWeatherMapHelper(apiKey: String?) {
+ private val openWeatherMapService: OpenWeatherMapService = OpenWeatherMapClient.getClient()
+ .create(OpenWeatherMapService::class.java)
+ private val options = HashMap()
+
+
+ init {
+ options.put(APPID, if (apiKey == null) "" else apiKey)
+ }
+
+
+ //SETUP METHODS
+ fun setUnits(units: String?) {
+ options.put(UNITS, units)
+ }
+
+ fun setLanguage(lang: String?) {
+ options.put(LANGUAGE, lang)
+ }
+
+
+ private fun noAppIdErrMessage(): Throwable {
+ return Throwable("UnAuthorized. Please set a valid OpenWeatherMap API KEY.")
+ }
+
+
+ private fun notFoundErrMsg(str: String): Throwable {
+ var throwable: Throwable? = null
+ try {
+ val obj = JSONObject(str)
+ throwable = Throwable(obj.getString("message"))
+ } catch (e: JSONException) {
+ e.printStackTrace()
+ }
+
+ if (throwable == null) {
+ throwable = Throwable("An unexpected error occurred.")
+ }
+
+
+ return throwable
+ }
+
+ // CURRENT WEATHER METHODS
+ // START
+ //GET CURRENT WEATHER BY CITY NAME
+ fun getCurrentWeatherByCityName(city: String?, callback: CurrentWeatherCallback) {
+ options.put(QUERY, city)
+
+ openWeatherMapService.getCurrentWeatherByCityName(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call,
+ response: Response
+ ) {
+ handleCurrentWeatherResponse(response, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ //GET CURRENT WEATHER BY CITY ID
+ fun getCurrentWeatherByCityID(id: String?, callback: CurrentWeatherCallback) {
+ options.put(CITY_ID, id)
+ openWeatherMapService.getCurrentWeatherByCityID(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call?,
+ response: Response?
+ ) {
+ handleCurrentWeatherResponse(response!!, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ //GET CURRENT WEATHER BY GEOGRAPHIC COORDINATES
+ fun getCurrentWeatherByGeoCoordinates(
+ latitude: Double,
+ longitude: Double,
+ callback: CurrentWeatherCallback
+ ) {
+ options.put(LATITUDE, latitude.toString())
+ options.put(LONGITUDE, longitude.toString())
+ openWeatherMapService.getCurrentWeatherByGeoCoordinates(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call?,
+ response: Response?
+ ) {
+ handleCurrentWeatherResponse(response!!, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ //GET CURRENT WEATHER BY ZIP CODE
+ fun getCurrentWeatherByZipCode(zipCode: String?, callback: CurrentWeatherCallback) {
+ options.put(ZIP_CODE, zipCode)
+ openWeatherMapService.getCurrentWeatherByZipCode(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call?,
+ response: Response?
+ ) {
+ handleCurrentWeatherResponse(response!!, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ private fun handleCurrentWeatherResponse(
+ response: Response,
+ callback: CurrentWeatherCallback
+ ) {
+ if (response.code() == HttpURLConnection.HTTP_OK) {
+ callback.onSuccess(response.body())
+ } else if (response.code() == HttpURLConnection.HTTP_FORBIDDEN || response.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ callback.onFailure(noAppIdErrMessage())
+ } else {
+ try {
+ callback.onFailure(notFoundErrMsg(response.errorBody()!!.string()))
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+ }
+ }
+
+
+ // CURRENT WEATHER METHODS
+ // END
+ // THREE HOUR FORECAST METHODS
+ // START
+ //GET THREE HOUR FORECAST BY CITY NAME
+ fun getThreeHourForecastByCityName(city: String?, callback: ThreeHourForecastCallback) {
+ options.put(QUERY, city)
+ openWeatherMapService.getThreeHourForecastByCityName(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call,
+ response: Response
+ ) {
+ handleThreeHourForecastResponse(response, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ //GET THREE HOUR FORECAST BY CITY ID
+ fun getThreeHourForecastByCityID(id: String?, callback: ThreeHourForecastCallback) {
+ options.put(CITY_ID, id)
+ openWeatherMapService.getThreeHourForecastByCityID(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call,
+ response: Response
+ ) {
+ handleThreeHourForecastResponse(response, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ //GET THREE HOUR FORECAST BY GEO C0ORDINATES
+ fun getThreeHourForecastByGeoCoordinates(
+ latitude: Double,
+ longitude: Double,
+ callback: ThreeHourForecastCallback
+ ) {
+ options.put(LATITUDE, latitude.toString())
+ options.put(LONGITUDE, longitude.toString())
+ openWeatherMapService.getThreeHourForecastByGeoCoordinates(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call,
+ response: Response
+ ) {
+ handleThreeHourForecastResponse(response, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ //GET THREE HOUR FORECAST BY ZIP CODE
+ fun getThreeHourForecastByZipCode(zipCode: String?, callback: ThreeHourForecastCallback) {
+ options.put(ZIP_CODE, zipCode)
+ openWeatherMapService.getThreeHourForecastByZipCode(options)?.enqueue(object : Callback {
+ override fun onResponse(
+ call: Call,
+ response: Response
+ ) {
+ handleThreeHourForecastResponse(response, callback)
+ }
+
+ override fun onFailure(call: Call, throwable: Throwable) {
+ callback.onFailure(throwable)
+ }
+ })
+ }
+
+ private fun handleThreeHourForecastResponse(
+ response: Response,
+ callback: ThreeHourForecastCallback
+ ) {
+ if (response.code() == HttpURLConnection.HTTP_OK) {
+ callback.onSuccess(response.body())
+ } else if (response.code() == HttpURLConnection.HTTP_FORBIDDEN || response.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ callback.onFailure(noAppIdErrMessage())
+ } else {
+ try {
+ callback.onFailure(notFoundErrMsg(response.errorBody()!!.string()))
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+ }
+ }
+
+
+ companion object {
+ private const val APPID = "appId"
+ private const val UNITS = "units"
+ private const val LANGUAGE = "lang"
+ private const val QUERY = "q"
+ private const val CITY_ID = "id"
+ private const val LATITUDE = "lat"
+ private const val LONGITUDE = "lon"
+ private const val ZIP_CODE = "zip"
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/CurrentWeatherCallback.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/CurrentWeatherCallback.java
deleted file mode 100644
index ea9a5fb..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/CurrentWeatherCallback.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.kwabenaberko.openweathermaplib.implementation.callback;
-
-import com.kwabenaberko.openweathermaplib.model.currentweather.CurrentWeather;
-
-public interface CurrentWeatherCallback{
- void onSuccess(CurrentWeather currentWeather);
- void onFailure(Throwable throwable);
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/CurrentWeatherCallback.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/CurrentWeatherCallback.kt
new file mode 100644
index 0000000..7536336
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/CurrentWeatherCallback.kt
@@ -0,0 +1,8 @@
+package com.kwabenaberko.openweathermaplib.implementation.callback
+
+import com.kwabenaberko.openweathermaplib.model.currentweather.CurrentWeather
+
+interface CurrentWeatherCallback {
+ fun onSuccess(currentWeather: CurrentWeather?)
+ fun onFailure(throwable: Throwable?)
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/ThreeHourForecastCallback.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/ThreeHourForecastCallback.java
deleted file mode 100644
index 2a59707..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/ThreeHourForecastCallback.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.kwabenaberko.openweathermaplib.implementation.callback;
-
-import com.kwabenaberko.openweathermaplib.model.threehourforecast.ThreeHourForecast;
-
-public interface ThreeHourForecastCallback{
- void onSuccess(ThreeHourForecast threeHourForecast);
- void onFailure(Throwable throwable);
-}
\ No newline at end of file
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/ThreeHourForecastCallback.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/ThreeHourForecastCallback.kt
new file mode 100644
index 0000000..4a5b450
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/implementation/callback/ThreeHourForecastCallback.kt
@@ -0,0 +1,8 @@
+package com.kwabenaberko.openweathermaplib.implementation.callback
+
+import com.kwabenaberko.openweathermaplib.model.threehourforecast.ThreeHourForecast
+
+interface ThreeHourForecastCallback {
+ fun onSuccess(threeHourForecast: ThreeHourForecast?)
+ fun onFailure(throwable: Throwable?)
+}
\ No newline at end of file
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Clouds.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Clouds.java
deleted file mode 100644
index 0bf8ec3..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Clouds.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class Clouds {
-
- @SerializedName("all")
- private double all;
-
- public double getAll() {
- return all;
- }
-}
-
-
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Clouds.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Clouds.kt
new file mode 100644
index 0000000..48c5bc3
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Clouds.kt
@@ -0,0 +1,17 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class Clouds {
+ @SerializedName("all")
+ private val all = 0.0
+
+ fun getAll(): Double {
+ return all
+ }
+}
+
+
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Coord.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Coord.java
deleted file mode 100644
index 85c71b7..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Coord.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class Coord {
-
- @SerializedName("lon")
- private double lon;
-
- @SerializedName("lat")
- private double lat;
-
- public double getLon() {
- return lon;
- }
-
- public double getLat() {
- return lat;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Coord.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Coord.kt
new file mode 100644
index 0000000..b17374e
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Coord.kt
@@ -0,0 +1,22 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class Coord {
+ @SerializedName("lon")
+ private val lon = 0.0
+
+ @SerializedName("lat")
+ private val lat = 0.0
+
+ fun getLon(): Double {
+ return lon
+ }
+
+ fun getLat(): Double {
+ return lat
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Main.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Main.java
deleted file mode 100644
index 7b8efec..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Main.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class Main {
- @SerializedName("temp")
- private double temp;
-
- @SerializedName("feels_like")
- private double feelsLike;
-
- @SerializedName("temp_min")
- private double tempMin;
-
- @SerializedName("temp_max")
- private double tempMax;
-
- @SerializedName("pressure")
- private double pressure;
-
- @SerializedName("humidity")
- private double humidity;
-
- @SerializedName("sea_level")
- private Double seaLevel;
-
- @SerializedName("grnd_level")
- private Double grndLevel;
-
- @SerializedName("temp_kf")
- private Double tempKf;
-
-
- public double getTemp() {
- return temp;
- }
-
- public double getFeelsLike() {
- return feelsLike;
- }
-
- public double getTempMin() {
- return tempMin;
- }
-
- public double getTempMax() {
- return tempMax;
- }
-
- public double getPressure() {
- return pressure;
- }
-
- public double getHumidity() {
- return humidity;
- }
-
- public Double getSeaLevel() {
- return seaLevel;
- }
-
- public Double getGrndLevel() {
- return grndLevel;
- }
-
- public Double getTempKf() {
- return tempKf;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Main.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Main.kt
new file mode 100644
index 0000000..57b7a93
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Main.kt
@@ -0,0 +1,72 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class Main {
+ @SerializedName("temp")
+ private val temp = 0.0
+
+ @SerializedName("feels_like")
+ private val feelsLike = 0.0
+
+ @SerializedName("temp_min")
+ private val tempMin = 0.0
+
+ @SerializedName("temp_max")
+ private val tempMax = 0.0
+
+ @SerializedName("pressure")
+ private val pressure = 0.0
+
+ @SerializedName("humidity")
+ private val humidity = 0.0
+
+ @SerializedName("sea_level")
+ private val seaLevel: Double? = null
+
+ @SerializedName("grnd_level")
+ private val grndLevel: Double? = null
+
+ @SerializedName("temp_kf")
+ private val tempKf: Double? = null
+
+
+ fun getTemp(): Double {
+ return temp
+ }
+
+ fun getFeelsLike(): Double {
+ return feelsLike
+ }
+
+ fun getTempMin(): Double {
+ return tempMin
+ }
+
+ fun getTempMax(): Double {
+ return tempMax
+ }
+
+ fun getPressure(): Double {
+ return pressure
+ }
+
+ fun getHumidity(): Double {
+ return humidity
+ }
+
+ fun getSeaLevel(): Double? {
+ return seaLevel
+ }
+
+ fun getGrndLevel(): Double? {
+ return grndLevel
+ }
+
+ fun getTempKf(): Double? {
+ return tempKf
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Precipitation.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Precipitation.java
deleted file mode 100644
index bf0d29b..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Precipitation.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-public class Precipitation {
-
- @SerializedName("1h")
- private Double oneHour;
-
- @SerializedName("3h")
- private Double threeHour;
-
- public Double getOneHour() {
- return oneHour;
- }
-
- public Double getThreeHour() {
- return threeHour;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Precipitation.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Precipitation.kt
new file mode 100644
index 0000000..1412a52
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Precipitation.kt
@@ -0,0 +1,19 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+open class Precipitation {
+ @SerializedName("1h")
+ private val oneHour: Double? = null
+
+ @SerializedName("3h")
+ private val threeHour: Double? = null
+
+ fun getOneHour(): Double? {
+ return oneHour
+ }
+
+ fun getThreeHour(): Double? {
+ return threeHour
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Rain.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Rain.java
deleted file mode 100644
index 7ac3f86..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Rain.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-
-public class Rain extends Precipitation {}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Rain.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Rain.kt
new file mode 100644
index 0000000..1aec8a3
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Rain.kt
@@ -0,0 +1,4 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+
+class Rain : Precipitation()
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Snow.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Snow.java
deleted file mode 100644
index 6cd04e5..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Snow.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-
-public class Snow extends Precipitation { }
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Snow.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Snow.kt
new file mode 100644
index 0000000..e995909
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Snow.kt
@@ -0,0 +1,4 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+
+class Snow : Precipitation()
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Sys.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Sys.java
deleted file mode 100644
index 90aa18c..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Sys.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class Sys {
-
- @SerializedName("type")
- private double type;
-
- @SerializedName("id")
- private Long id;
-
- @SerializedName("message")
- private Double message;
-
- @SerializedName("country")
- private String country;
-
- @SerializedName("sunrise")
- private Long sunrise;
-
- @SerializedName("sunset")
- private Long sunset;
-
- @SerializedName("pod")
- private Character pod;
-
- public double getType() {
- return type;
- }
-
- public Long getId() {
- return id;
- }
-
- public Double getMessage() {
- return message;
- }
-
- public String getCountry() {
- return country;
- }
-
- public Long getSunrise() {
- return sunrise;
- }
-
- public Long getSunset() {
- return sunset;
- }
-
- public Character getPod() {
- return pod;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Sys.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Sys.kt
new file mode 100644
index 0000000..3921cee
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Sys.kt
@@ -0,0 +1,57 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class Sys {
+ @SerializedName("type")
+ private val type = 0.0
+
+ @SerializedName("id")
+ private val id: Long? = null
+
+ @SerializedName("message")
+ private val message: Double? = null
+
+ @SerializedName("country")
+ private val country: String? = null
+
+ @SerializedName("sunrise")
+ private val sunrise: Long? = null
+
+ @SerializedName("sunset")
+ private val sunset: Long? = null
+
+ @SerializedName("pod")
+ private val pod: Char? = null
+
+ fun getType(): Double {
+ return type
+ }
+
+ fun getId(): Long? {
+ return id
+ }
+
+ fun getMessage(): Double? {
+ return message
+ }
+
+ fun getCountry(): String? {
+ return country
+ }
+
+ fun getSunrise(): Long? {
+ return sunrise
+ }
+
+ fun getSunset(): Long? {
+ return sunset
+ }
+
+ fun getPod(): Char? {
+ return pod
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Weather.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Weather.java
deleted file mode 100644
index 5ac2b7a..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Weather.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class Weather {
-
- @SerializedName("id")
- private Long id;
-
- @SerializedName("main")
- private String main;
-
- @SerializedName("description")
- private String description;
-
- @SerializedName("icon")
- private String icon;
-
- public Long getId() {
- return id;
- }
-
- public String getMain() {
- return main;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getIcon() {
- return icon;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Weather.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Weather.kt
new file mode 100644
index 0000000..15e591a
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Weather.kt
@@ -0,0 +1,36 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class Weather {
+ @SerializedName("id")
+ private val id: Long? = null
+
+ @SerializedName("main")
+ private val main: String? = null
+
+ @SerializedName("description")
+ private val description: String? = null
+
+ @SerializedName("icon")
+ private val icon: String? = null
+
+ fun getId(): Long? {
+ return id
+ }
+
+ fun getMain(): String? {
+ return main
+ }
+
+ fun getDescription(): String? {
+ return description
+ }
+
+ fun getIcon(): String? {
+ return icon
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Wind.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Wind.java
deleted file mode 100644
index 707da79..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Wind.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.common;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class Wind {
- @SerializedName("speed")
- private double speed;
-
- @SerializedName("deg")
- private double deg;
-
- @SerializedName("gust")
- private Double gust;
-
- public double getSpeed() {
- return speed;
- }
-
- public double getDeg() {
- return deg;
- }
-
- public Double getGust() {
- return gust;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Wind.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Wind.kt
new file mode 100644
index 0000000..a7421a1
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/common/Wind.kt
@@ -0,0 +1,29 @@
+package com.kwabenaberko.openweathermaplib.model.common
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class Wind {
+ @SerializedName("speed")
+ private val speed = 0.0
+
+ @SerializedName("deg")
+ private val deg = 0.0
+
+ @SerializedName("gust")
+ private val gust: Double? = null
+
+ fun getSpeed(): Double {
+ return speed
+ }
+
+ fun getDeg(): Double {
+ return deg
+ }
+
+ fun getGust(): Double? {
+ return gust
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/currentweather/CurrentWeather.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/currentweather/CurrentWeather.java
deleted file mode 100644
index 370a5aa..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/currentweather/CurrentWeather.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.currentweather;
-
-import com.google.gson.annotations.SerializedName;
-import com.kwabenaberko.openweathermaplib.model.common.Clouds;
-import com.kwabenaberko.openweathermaplib.model.common.Main;
-import com.kwabenaberko.openweathermaplib.model.common.Rain;
-import com.kwabenaberko.openweathermaplib.model.common.Snow;
-import com.kwabenaberko.openweathermaplib.model.common.Weather;
-import com.kwabenaberko.openweathermaplib.model.common.Wind;
-import com.kwabenaberko.openweathermaplib.model.common.Coord;
-import com.kwabenaberko.openweathermaplib.model.common.Sys;
-
-import java.util.List;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class CurrentWeather {
-
- @SerializedName("coord")
- private Coord coord;
-
- @SerializedName("weather")
- private List weather;
-
- @SerializedName("base")
- private String base;
-
- @SerializedName("main")
- private Main main;
-
- @SerializedName("visibility")
- private Long visibility;
-
- @SerializedName("wind")
- private Wind wind;
-
- @SerializedName("clouds")
- private Clouds clouds;
-
- @SerializedName("rain")
- private Rain rain;
-
- @SerializedName("snow")
- private Snow snow;
-
- @SerializedName("dt")
- private Long dt;
-
- @SerializedName("sys")
- private Sys sys;
-
- @SerializedName("timezone")
- private Long timezone;
-
- @SerializedName("id")
- private Long id;
-
- @SerializedName("name")
- private String name;
-
- @SerializedName("cod")
- private Integer cod;
-
- public Coord getCoord() {
- return coord;
- }
-
- public List getWeather() {
- return weather;
- }
-
- public String getBase() {
- return base;
- }
-
- public Main getMain() {
- return main;
- }
-
- public Long getVisibility() {
- return visibility;
- }
-
- public Wind getWind() {
- return wind;
- }
-
- public Clouds getClouds() {
- return clouds;
- }
-
- public Rain getRain() {
- return rain;
- }
-
- public Snow getSnow() {
- return snow;
- }
-
- public Long getDt() {
- return dt;
- }
-
- public Sys getSys() {
- return sys;
- }
-
- public Long getTimezone() {
- return timezone;
- }
-
- public Long getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public Integer getCod() {
- return cod;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/currentweather/CurrentWeather.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/currentweather/CurrentWeather.kt
new file mode 100644
index 0000000..7b4c67a
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/currentweather/CurrentWeather.kt
@@ -0,0 +1,121 @@
+package com.kwabenaberko.openweathermaplib.model.currentweather
+
+import com.google.gson.annotations.SerializedName
+import com.kwabenaberko.openweathermaplib.model.common.Clouds
+import com.kwabenaberko.openweathermaplib.model.common.Coord
+import com.kwabenaberko.openweathermaplib.model.common.Main
+import com.kwabenaberko.openweathermaplib.model.common.Rain
+import com.kwabenaberko.openweathermaplib.model.common.Snow
+import com.kwabenaberko.openweathermaplib.model.common.Sys
+import com.kwabenaberko.openweathermaplib.model.common.Weather
+import com.kwabenaberko.openweathermaplib.model.common.Wind
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+class CurrentWeather {
+ @SerializedName("coord")
+ private val coord: Coord? = null
+
+ @SerializedName("weather")
+ private val weather: MutableList? = null
+
+ @SerializedName("base")
+ private val base: String? = null
+
+ @SerializedName("main")
+ private val main: Main? = null
+
+ @SerializedName("visibility")
+ private val visibility: Long? = null
+
+ @SerializedName("wind")
+ private val wind: Wind? = null
+
+ @SerializedName("clouds")
+ private val clouds: Clouds? = null
+
+ @SerializedName("rain")
+ private val rain: Rain? = null
+
+ @SerializedName("snow")
+ private val snow: Snow? = null
+
+ @SerializedName("dt")
+ private val dt: Long? = null
+
+ @SerializedName("sys")
+ private val sys: Sys? = null
+
+ @SerializedName("timezone")
+ private val timezone: Long? = null
+
+ @SerializedName("id")
+ private val id: Long? = null
+
+ @SerializedName("name")
+ private val name: String? = null
+
+ @SerializedName("cod")
+ private val cod: Int? = null
+
+ fun getCoord(): Coord? {
+ return coord
+ }
+
+ fun getWeather(): MutableList? {
+ return weather
+ }
+
+ fun getBase(): String? {
+ return base
+ }
+
+ fun getMain(): Main? {
+ return main
+ }
+
+ fun getVisibility(): Long? {
+ return visibility
+ }
+
+ fun getWind(): Wind? {
+ return wind
+ }
+
+ fun getClouds(): Clouds? {
+ return clouds
+ }
+
+ fun getRain(): Rain? {
+ return rain
+ }
+
+ fun getSnow(): Snow? {
+ return snow
+ }
+
+ fun getDt(): Long? {
+ return dt
+ }
+
+ fun getSys(): Sys? {
+ return sys
+ }
+
+ fun getTimezone(): Long? {
+ return timezone
+ }
+
+ fun getId(): Long? {
+ return id
+ }
+
+ fun getName(): String? {
+ return name
+ }
+
+ fun getCod(): Int? {
+ return cod
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/City.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/City.java
deleted file mode 100644
index 1a02bdb..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/City.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.threehourforecast;
-
-import com.google.gson.annotations.SerializedName;
-import com.kwabenaberko.openweathermaplib.model.common.Coord;
-
-/**
- * Created by Kwabena Berko on 8/6/2017.
- */
-
-public class City {
-
- @SerializedName("id")
- private long id;
-
- @SerializedName("name")
- private String name;
-
- @SerializedName("coord")
- private Coord coord;
-
- @SerializedName("country")
- private String country;
-
- @SerializedName("timezone")
- private Long timezone;
-
- @SerializedName("population")
- private Long population;
-
- @SerializedName("sunrise")
- private Long sunrise;
-
- @SerializedName("sunset")
- private Long sunset;
-
- public long getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public Coord getCoord() {
- return coord;
- }
-
- public String getCountry() {
- return country;
- }
-
- public Long getTimezone() {
- return timezone;
- }
-
- public Long getPopulation() {
- return population;
- }
-
- public Long getSunrise() {
- return sunrise;
- }
-
- public Long getSunset() {
- return sunset;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/City.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/City.kt
new file mode 100644
index 0000000..11341cd
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/City.kt
@@ -0,0 +1,65 @@
+package com.kwabenaberko.openweathermaplib.model.threehourforecast
+
+import com.google.gson.annotations.SerializedName
+import com.kwabenaberko.openweathermaplib.model.common.Coord
+
+/**
+ * Created by Kwabena Berko on 8/6/2017.
+ */
+class City {
+ @SerializedName("id")
+ private val id: Long = 0
+
+ @SerializedName("name")
+ private val name: String? = null
+
+ @SerializedName("coord")
+ private val coord: Coord? = null
+
+ @SerializedName("country")
+ private val country: String? = null
+
+ @SerializedName("timezone")
+ private val timezone: Long? = null
+
+ @SerializedName("population")
+ private val population: Long? = null
+
+ @SerializedName("sunrise")
+ private val sunrise: Long? = null
+
+ @SerializedName("sunset")
+ private val sunset: Long? = null
+
+ fun getId(): Long {
+ return id
+ }
+
+ fun getName(): String? {
+ return name
+ }
+
+ fun getCoord(): Coord? {
+ return coord
+ }
+
+ fun getCountry(): String? {
+ return country
+ }
+
+ fun getTimezone(): Long? {
+ return timezone
+ }
+
+ fun getPopulation(): Long? {
+ return population
+ }
+
+ fun getSunrise(): Long? {
+ return sunrise
+ }
+
+ fun getSunset(): Long? {
+ return sunset
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecast.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecast.java
deleted file mode 100644
index 06b6013..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecast.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.threehourforecast;
-
-import com.google.gson.annotations.SerializedName;
-
-import java.util.List;
-
-/**
- * Created by Kwabena Berko on 8/6/2017.
- */
-
-public class ThreeHourForecast {
-
- @SerializedName("cod")
- private String cod;
-
- @SerializedName("message")
- private double message;
-
- @SerializedName("cnt")
- private int cnt;
-
- @SerializedName("list")
- private List list;
-
- @SerializedName("city")
- private City city;
-
-
- public String getCod() {
- return cod;
- }
-
- public double getMessage() {
- return message;
- }
-
- public int getCnt() {
- return cnt;
- }
-
- public List getList() {
- return list;
- }
-
- public City getCity() {
- return city;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecast.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecast.kt
new file mode 100644
index 0000000..e5ac00c
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecast.kt
@@ -0,0 +1,44 @@
+package com.kwabenaberko.openweathermaplib.model.threehourforecast
+
+import com.google.gson.annotations.SerializedName
+
+/**
+ * Created by Kwabena Berko on 8/6/2017.
+ */
+class ThreeHourForecast {
+ @SerializedName("cod")
+ private val cod: String? = null
+
+ @SerializedName("message")
+ private val message = 0.0
+
+ @SerializedName("cnt")
+ private val cnt = 0
+
+ @SerializedName("list")
+ private val list: MutableList? = null
+
+ @SerializedName("city")
+ private val city: City? = null
+
+
+ fun getCod(): String? {
+ return cod
+ }
+
+ fun getMessage(): Double {
+ return message
+ }
+
+ fun getCnt(): Int {
+ return cnt
+ }
+
+ fun getList(): MutableList? {
+ return list
+ }
+
+ fun getCity(): City? {
+ return city
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecastWeather.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecastWeather.java
deleted file mode 100644
index ec6532f..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecastWeather.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package com.kwabenaberko.openweathermaplib.model.threehourforecast;
-
-import com.google.gson.annotations.SerializedName;
-import com.kwabenaberko.openweathermaplib.model.common.Clouds;
-import com.kwabenaberko.openweathermaplib.model.common.Main;
-import com.kwabenaberko.openweathermaplib.model.common.Rain;
-import com.kwabenaberko.openweathermaplib.model.common.Snow;
-import com.kwabenaberko.openweathermaplib.model.common.Sys;
-import com.kwabenaberko.openweathermaplib.model.common.Weather;
-import com.kwabenaberko.openweathermaplib.model.common.Wind;
-
-import java.util.List;
-
-/**
- * Created by Kwabena Berko on 8/6/2017.
- */
-
-public class ThreeHourForecastWeather {
-
- @SerializedName("dt")
- private Long dt;
-
- @SerializedName("main")
- private Main main;
-
- @SerializedName("weather")
- private List weather;
-
- @SerializedName("clouds")
- private Clouds clouds;
-
- @SerializedName("wind")
- private Wind wind;
-
- @SerializedName("visibility")
- private Long visibility;
-
- @SerializedName("pop")
- private Double pop;
-
- @SerializedName("rain")
- private Rain rain;
-
- @SerializedName("snow")
- private Snow snow;
-
- @SerializedName("sys")
- private Sys mSys;
-
- @SerializedName("dt_txt")
- private String dtTxt;
-
- public Long getDt() {
- return dt;
- }
-
- public void setDt(Long dt) {
- this.dt = dt;
- }
-
- public Main getMain() {
- return main;
- }
-
- public void setMain(Main main) {
- this.main = main;
- }
-
- public List getWeather() {
- return weather;
- }
-
- public void setWeather(List weather) {
- this.weather = weather;
- }
-
- public Clouds getClouds() {
- return clouds;
- }
-
- public void setClouds(Clouds clouds) {
- this.clouds = clouds;
- }
-
- public Wind getWind() {
- return wind;
- }
-
- public Long getVisibility() {
- return visibility;
- }
-
- public Double getPop() {
- return pop;
- }
-
- public void setWind(Wind wind) {
- this.wind = wind;
- }
-
- public Rain getRain() {
- return rain;
- }
-
- public void setRain(Rain rain) {
- this.rain = rain;
- }
-
- public Snow getSnow() {
- return snow;
- }
-
- public void setSnow(Snow snow) {
- this.snow = snow;
- }
-
- public Sys getmSys() {
- return mSys;
- }
-
- public void setmSys(Sys mSys) {
- this.mSys = mSys;
- }
-
- public String getDtTxt() {
- return dtTxt;
- }
-
- public void setDtTxt(String dtTxt) {
- this.dtTxt = dtTxt;
- }
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecastWeather.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecastWeather.kt
new file mode 100644
index 0000000..828dce2
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/model/threehourforecast/ThreeHourForecastWeather.kt
@@ -0,0 +1,128 @@
+package com.kwabenaberko.openweathermaplib.model.threehourforecast
+
+import com.google.gson.annotations.SerializedName
+import com.kwabenaberko.openweathermaplib.model.common.Clouds
+import com.kwabenaberko.openweathermaplib.model.common.Main
+import com.kwabenaberko.openweathermaplib.model.common.Rain
+import com.kwabenaberko.openweathermaplib.model.common.Snow
+import com.kwabenaberko.openweathermaplib.model.common.Sys
+import com.kwabenaberko.openweathermaplib.model.common.Weather
+import com.kwabenaberko.openweathermaplib.model.common.Wind
+
+/**
+ * Created by Kwabena Berko on 8/6/2017.
+ */
+class ThreeHourForecastWeather {
+ @SerializedName("dt")
+ private var dt: Long? = null
+
+ @SerializedName("main")
+ private var main: Main? = null
+
+ @SerializedName("weather")
+ private var weather: MutableList? = null
+
+ @SerializedName("clouds")
+ private var clouds: Clouds? = null
+
+ @SerializedName("wind")
+ private var wind: Wind? = null
+
+ @SerializedName("visibility")
+ private val visibility: Long? = null
+
+ @SerializedName("pop")
+ private val pop: Double? = null
+
+ @SerializedName("rain")
+ private var rain: Rain? = null
+
+ @SerializedName("snow")
+ private var snow: Snow? = null
+
+ @SerializedName("sys")
+ private var mSys: Sys? = null
+
+ @SerializedName("dt_txt")
+ private var dtTxt: String? = null
+
+ fun getDt(): Long? {
+ return dt
+ }
+
+ fun setDt(dt: Long?) {
+ this.dt = dt
+ }
+
+ fun getMain(): Main? {
+ return main
+ }
+
+ fun setMain(main: Main?) {
+ this.main = main
+ }
+
+ fun getWeather(): MutableList? {
+ return weather
+ }
+
+ fun setWeather(weather: MutableList?) {
+ this.weather = weather
+ }
+
+ fun getClouds(): Clouds? {
+ return clouds
+ }
+
+ fun setClouds(clouds: Clouds?) {
+ this.clouds = clouds
+ }
+
+ fun getWind(): Wind? {
+ return wind
+ }
+
+ fun getVisibility(): Long? {
+ return visibility
+ }
+
+ fun getPop(): Double? {
+ return pop
+ }
+
+ fun setWind(wind: Wind?) {
+ this.wind = wind
+ }
+
+ fun getRain(): Rain? {
+ return rain
+ }
+
+ fun setRain(rain: Rain?) {
+ this.rain = rain
+ }
+
+ fun getSnow(): Snow? {
+ return snow
+ }
+
+ fun setSnow(snow: Snow?) {
+ this.snow = snow
+ }
+
+ fun getmSys(): Sys? {
+ return mSys
+ }
+
+ fun setmSys(mSys: Sys?) {
+ this.mSys = mSys
+ }
+
+ fun getDtTxt(): String? {
+ return dtTxt
+ }
+
+ fun setDtTxt(dtTxt: String?) {
+ this.dtTxt = dtTxt
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapClient.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapClient.java
deleted file mode 100644
index ecc32ab..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapClient.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.kwabenaberko.openweathermaplib.network;
-
-import retrofit2.Retrofit;
-import retrofit2.converter.gson.GsonConverterFactory;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public class OpenWeatherMapClient {
- private static final String BASE_URL = "https://api.openweathermap.org";
- private static Retrofit retrofit = null;
- public static Retrofit getClient(){
- if (retrofit == null){
- retrofit = new Retrofit.Builder()
- .baseUrl(BASE_URL)
- .addConverterFactory(GsonConverterFactory.create())
- .build();
- }
- return retrofit;
- }
-
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapClient.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapClient.kt
new file mode 100644
index 0000000..30e67b5
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapClient.kt
@@ -0,0 +1,21 @@
+package com.kwabenaberko.openweathermaplib.network
+
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+object OpenWeatherMapClient {
+ private const val BASE_URL = "https://api.openweathermap.org"
+ private var retrofit: Retrofit? = null
+ fun getClient(): Retrofit {
+ if (retrofit == null) {
+ retrofit = Retrofit.Builder()
+ .baseUrl(BASE_URL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build()
+ }
+ return retrofit!!
+ }
+}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.java b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.java
deleted file mode 100644
index 421eea8..0000000
--- a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.kwabenaberko.openweathermaplib.network;
-
-import com.kwabenaberko.openweathermaplib.model.currentweather.CurrentWeather;
-import com.kwabenaberko.openweathermaplib.model.threehourforecast.ThreeHourForecast;
-
-import java.util.Map;
-
-import retrofit2.Call;
-import retrofit2.http.GET;
-import retrofit2.http.QueryMap;
-
-/**
- * Created by Kwabena Berko on 7/25/2017.
- */
-
-public interface OpenWeatherMapService {
-
- String CURRENT = "/data/2.5/weather";
- String FORECAST = "/data/2.5/forecast";
-
- //Current Weather Endpoints start
- @GET(CURRENT)
- Call getCurrentWeatherByCityName(@QueryMap Map options);
-
- @GET(CURRENT)
- Call getCurrentWeatherByCityID(@QueryMap Map options);
-
- @GET(CURRENT)
- Call getCurrentWeatherByGeoCoordinates(@QueryMap Map options);
-
- @GET(CURRENT)
- Call getCurrentWeatherByZipCode(@QueryMap Map options);
-
- //Current Weather Endpoints end
-
- //Three hour forecast endpoints start
- @GET(FORECAST)
- Call getThreeHourForecastByCityName(@QueryMap Map options);
-
- @GET(FORECAST)
- Call getThreeHourForecastByCityID(@QueryMap Map options);
-
- @GET(FORECAST)
- Call getThreeHourForecastByGeoCoordinates(@QueryMap Map options);
-
- @GET(FORECAST)
- Call getThreeHourForecastByZipCode(@QueryMap Map options);
-}
diff --git a/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.kt b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.kt
new file mode 100644
index 0000000..e740276
--- /dev/null
+++ b/openweathermaphelper/src/main/java/com/kwabenaberko/openweathermaplib/network/OpenWeatherMapService.kt
@@ -0,0 +1,44 @@
+package com.kwabenaberko.openweathermaplib.network
+
+import com.kwabenaberko.openweathermaplib.model.currentweather.CurrentWeather
+import com.kwabenaberko.openweathermaplib.model.threehourforecast.ThreeHourForecast
+import retrofit2.Call
+import retrofit2.http.GET
+import retrofit2.http.QueryMap
+
+/**
+ * Created by Kwabena Berko on 7/25/2017.
+ */
+interface OpenWeatherMapService {
+ //Current Weather Endpoints start
+ @GET(CURRENT)
+ fun getCurrentWeatherByCityName(@QueryMap options: MutableMap?): Call?
+
+ @GET(CURRENT)
+ fun getCurrentWeatherByCityID(@QueryMap options: MutableMap?): Call?
+
+ @GET(CURRENT)
+ fun getCurrentWeatherByGeoCoordinates(@QueryMap options: MutableMap?): Call?
+
+ @GET(CURRENT)
+ fun getCurrentWeatherByZipCode(@QueryMap options: MutableMap?): Call?
+
+ //Current Weather Endpoints end
+ //Three hour forecast endpoints start
+ @GET(FORECAST)
+ fun getThreeHourForecastByCityName(@QueryMap options: MutableMap?): Call?
+
+ @GET(FORECAST)
+ fun getThreeHourForecastByCityID(@QueryMap options: MutableMap?): Call?
+
+ @GET(FORECAST)
+ fun getThreeHourForecastByGeoCoordinates(@QueryMap options: MutableMap?): Call?
+
+ @GET(FORECAST)
+ fun getThreeHourForecastByZipCode(@QueryMap options: MutableMap?): Call?
+
+ companion object {
+ const val CURRENT: String = "/data/2.5/weather"
+ const val FORECAST: String = "/data/2.5/forecast"
+ }
+}
diff --git a/settings.gradle b/settings.gradle
index ede6601..3cd7740 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -17,4 +17,4 @@ rootProject.name = "MetroLauncher"
include ':app'
include ':SpannedGridLayoutManager'
include ':liboverscroll'
-include ':openweathermaphelper'
+//include ':openweathermaphelper'