Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjoongcho committed Apr 22, 2018
1 parent a2a7c78 commit f528507
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 360 deletions.
7 changes: 5 additions & 2 deletions app/build.gradle
Expand Up @@ -5,7 +5,6 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

android {
buildToolsVersion '27.0.2'
compileSdkVersion 27

compileOptions {
Expand Down Expand Up @@ -50,6 +49,10 @@ android {
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }

packagingOptions {
exclude 'META-INF/commons_release.kotlin_module'
}
}

repositories {
Expand Down Expand Up @@ -93,7 +96,7 @@ dependencies {
implementation 'com.simplemobiletools:commons:3.7.8'
// implementation project(":simple-commons")

implementation 'io.github.aafactory:commons:0.0.2'
implementation 'io.github.aafactory:commons:0.1.1'
// implementation project(":aafactory-commons")
}

Expand Up @@ -9,14 +9,14 @@ import android.support.v7.widget.SearchView
import android.view.Menu
import android.view.MenuItem
import android.widget.AdapterView
import io.github.aafactory.commons.utils.BitmapUtils
import kotlinx.android.synthetic.main.activity_address_search.*
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.adapters.AddressItemAdapter
import me.blog.korn123.easyphotomap.extensions.makeSnackBar
import me.blog.korn123.easyphotomap.helper.*
import me.blog.korn123.easyphotomap.models.PhotoMapItem
import me.blog.korn123.easyphotomap.utils.BitmapUtils
import me.blog.korn123.easyphotomap.utils.CommonUtils
import me.blog.korn123.easyphotomap.utils.EasyPhotoMapUtils
import org.apache.commons.io.FilenameUtils

/**
Expand Down Expand Up @@ -80,7 +80,7 @@ class AddressSearchActivity : AppCompatActivity() {
query?.let {
mListAddress.clear()
try {
val listAddress = CommonUtils.getFromLocationName(this@AddressSearchActivity, it, maxResults, 0)
val listAddress = EasyPhotoMapUtils.getFromLocationName(this@AddressSearchActivity, it, maxResults, 0)
listAddress?.let {
mListAddress.addAll(it)
if (mAddressAdapter == null) {
Expand All @@ -93,7 +93,7 @@ class AddressSearchActivity : AppCompatActivity() {
val fileName = FilenameUtils.getName(intent.getStringExtra(COLUMN_IMAGE_PATH))
val item = PhotoMapItem()
item.imagePath = intent.getStringExtra(COLUMN_IMAGE_PATH)
item.info = CommonUtils.fullAddress(address)
item.info = EasyPhotoMapUtils.fullAddress(address)
item.latitude = address.latitude
item.longitude = address.longitude
item.date = intent.getStringExtra(COLUMN_DATE)
Expand Down
Expand Up @@ -6,6 +6,7 @@ import android.content.DialogInterface
import android.graphics.Typeface
import android.os.Bundle
import android.os.Handler
import io.github.aafactory.commons.utils.BitmapUtils
import kotlinx.android.synthetic.main.activity_batch_popup.*
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.extensions.config
Expand All @@ -15,8 +16,7 @@ import me.blog.korn123.easyphotomap.helper.PHOTO_MAP_THUMBNAIL_FIXED_WIDTH_HEIGH
import me.blog.korn123.easyphotomap.helper.PhotoMapDbHelper
import me.blog.korn123.easyphotomap.helper.WORKING_DIRECTORY
import me.blog.korn123.easyphotomap.models.PhotoMapItem
import me.blog.korn123.easyphotomap.utils.BitmapUtils
import me.blog.korn123.easyphotomap.utils.CommonUtils
import me.blog.korn123.easyphotomap.utils.EasyPhotoMapUtils
import org.apache.commons.io.FileUtils
import org.apache.commons.io.FilenameUtils
import java.io.File
Expand Down Expand Up @@ -128,21 +128,21 @@ class BatchPopupActivity : SimpleActivity() {
if (PhotoMapDbHelper.selectPhotoMapItemBy(COLUMN_IMAGE_PATH, targetFile.absolutePath).size > 0) {
mReduplicationCount++
} else {
val exifInfo = CommonUtils.parseExifDescription(targetFile.absolutePath)
val exifInfo = EasyPhotoMapUtils.parseExifDescription(targetFile.absolutePath)
val item = PhotoMapItem()
item.imagePath = targetFile.absolutePath
if (exifInfo.date != null) {
item.date = CommonUtils.dateTimePattern.format(exifInfo.date)
item.date = EasyPhotoMapUtils.dateTimePattern.format(exifInfo.date)
} else {
item.date = getString(R.string.file_explorer_message2)
}

exifInfo.geoLocation?.let {
item.longitude = it.longitude
item.latitude = it.latitude
val listAddress = CommonUtils.getFromLocation(this@BatchPopupActivity, item.latitude, item.longitude, 1, 0)
val listAddress = EasyPhotoMapUtils.getFromLocation(this@BatchPopupActivity, item.latitude, item.longitude, 1, 0)
listAddress?.let {
if (it.isNotEmpty()) item.info = CommonUtils.fullAddress(it[0])
if (it.isNotEmpty()) item.info = EasyPhotoMapUtils.fullAddress(it[0])
}
PhotoMapDbHelper.insertPhotoMapItem(item)
val srcPath = targetFile.absolutePath
Expand Down
Expand Up @@ -8,13 +8,13 @@ import android.os.Environment
import android.provider.MediaStore
import android.support.v4.content.FileProvider
import android.util.Log
import io.github.aafactory.commons.utils.BitmapUtils
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.extensions.config
import me.blog.korn123.easyphotomap.extensions.showConfirmDialogWithFinish
import me.blog.korn123.easyphotomap.helper.*
import me.blog.korn123.easyphotomap.models.PhotoMapItem
import me.blog.korn123.easyphotomap.utils.BitmapUtils
import me.blog.korn123.easyphotomap.utils.CommonUtils
import me.blog.korn123.easyphotomap.utils.EasyPhotoMapUtils
import org.apache.commons.io.FileUtils
import org.apache.commons.io.FilenameUtils
import java.io.File
Expand Down Expand Up @@ -115,21 +115,21 @@ class CameraActivity : SimpleActivity() {
targetFile = File(mCurrentFileName)
fileName = FilenameUtils.getName(mCurrentFileName)
}
val exifInfo = CommonUtils.parseExifDescription(targetFile.absolutePath)
val exifInfo = EasyPhotoMapUtils.parseExifDescription(targetFile.absolutePath)
val item = PhotoMapItem()
item.imagePath = targetFile.absolutePath
if (exifInfo.date != null) {
item.date = CommonUtils.dateTimePattern.format(exifInfo.date)
item.date = EasyPhotoMapUtils.dateTimePattern.format(exifInfo.date)
} else {
item.date = getString(R.string.file_explorer_message2)
}

exifInfo.geoLocation?.let {
item.longitude = it.longitude
item.latitude = it.latitude
val listAddress = CommonUtils.getFromLocation(this@CameraActivity, item.latitude, item.longitude, 1, 0)
val listAddress = EasyPhotoMapUtils.getFromLocation(this@CameraActivity, item.latitude, item.longitude, 1, 0)
listAddress?.let { it ->
item.info = CommonUtils.fullAddress(it[0])
item.info = EasyPhotoMapUtils.fullAddress(it[0])
}

PhotoMapDbHelper.insertPhotoMapItem(item)
Expand Down
Expand Up @@ -14,6 +14,7 @@ import android.view.*
import android.widget.ArrayAdapter
import android.widget.HorizontalScrollView
import android.widget.TextView
import io.github.aafactory.commons.extensions.dpToPixel
import kotlinx.android.synthetic.main.activity_file_explorer.*
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.adapters.ExplorerItemAdapter
Expand All @@ -24,7 +25,7 @@ import me.blog.korn123.easyphotomap.helper.CAMERA_DIRECTORY
import me.blog.korn123.easyphotomap.helper.RegistrationThread
import me.blog.korn123.easyphotomap.helper.WORKING_DIRECTORY
import me.blog.korn123.easyphotomap.models.FileItem
import me.blog.korn123.easyphotomap.utils.CommonUtils
import me.blog.korn123.easyphotomap.utils.EasyPhotoMapUtils
import org.apache.commons.io.FilenameUtils
import org.apache.commons.lang.StringUtils
import java.io.File
Expand Down Expand Up @@ -156,7 +157,7 @@ class FileExplorerActivity : SimpleActivity() {
val textView = TextView(this)
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16F)
textView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
textView.setPadding(CommonUtils.dpToPixel(this, 5F), 0, CommonUtils.dpToPixel(this, 5F), 0)
textView.setPadding(dpToPixel(5F), 0, dpToPixel(5F), 0)
textView.gravity = Gravity.CENTER_VERTICAL
textView.text = path
textView.setOnClickListener {
Expand Down Expand Up @@ -220,7 +221,7 @@ class FileExplorerActivity : SimpleActivity() {
fileItem.setImagePathAndFileName(path)
try {
fileItem.length = f.length()
fileItem.takenDate = CommonUtils.getDateFromJpegMetaData(f)
fileItem.takenDate = EasyPhotoMapUtils.getDateFromJpegMetaData(f)
} catch (e: Exception){
e.printStackTrace()
}
Expand Down
Expand Up @@ -39,6 +39,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.views.FastScroller
import io.github.aafactory.commons.helpers.PERMISSION_ACCESS_COARSE_LOCATION
import io.github.aafactory.commons.helpers.PERMISSION_ACCESS_FINE_LOCATION
import io.github.aafactory.commons.utils.BitmapUtils
import kotlinx.android.synthetic.main.activity_maps.*
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.adapters.RecommendationItemAdapter
Expand All @@ -47,8 +48,7 @@ import me.blog.korn123.easyphotomap.extensions.getLocationWithGPSProvider
import me.blog.korn123.easyphotomap.extensions.showAlertDialog
import me.blog.korn123.easyphotomap.helper.*
import me.blog.korn123.easyphotomap.models.PhotoMapItem
import me.blog.korn123.easyphotomap.utils.BitmapUtils
import me.blog.korn123.easyphotomap.utils.CommonUtils
import me.blog.korn123.easyphotomap.utils.EasyPhotoMapUtils
import org.apache.commons.io.FilenameUtils
import org.apache.commons.lang.StringUtils
import java.io.File
Expand Down Expand Up @@ -173,7 +173,7 @@ class MapsActivity : SimpleActivity(), OnMapReadyCallback {
val inflater = this.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val customView = inflater.inflate(R.layout.popup_window_recommendation, null)
recyclerView = customView.findViewById<RecyclerView>(R.id.recommendation_items)
CommonUtils.setChildViewTypeface(customView as ViewGroup)
EasyPhotoMapUtils.setChildViewTypeface(customView as ViewGroup)
val listOfSortEntry: List<Map.Entry<String, Int>>?
if (mEnableDateFilter) {
listPhotoMapItem.map { item ->
Expand All @@ -187,7 +187,7 @@ class MapsActivity : SimpleActivity(), OnMapReadyCallback {
mRecommendMap.put(it, count)
}
}
listOfSortEntry = CommonUtils.entriesSortedByKeys(mRecommendMap)
listOfSortEntry = EasyPhotoMapUtils.entriesSortedByKeys(mRecommendMap)
} else {
listPhotoMapItem.map { it ->
val pattern = "[0-9]{1,9}"
Expand All @@ -199,7 +199,7 @@ class MapsActivity : SimpleActivity(), OnMapReadyCallback {
}
}
}
listOfSortEntry = CommonUtils.entriesSortedByValues(mRecommendMap)
listOfSortEntry = EasyPhotoMapUtils.entriesSortedByValues(mRecommendMap)
}

mListRecommendationOrigin.clear()
Expand Down Expand Up @@ -283,7 +283,7 @@ class MapsActivity : SimpleActivity(), OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_maps)
CommonUtils.initWorkingDirectory()
EasyPhotoMapUtils.initWorkingDirectory()

savedInstanceState?.let {
when (it.getBoolean(HAVE_CAMERA_POSITION, false)) {
Expand Down Expand Up @@ -412,7 +412,7 @@ class MapsActivity : SimpleActivity(), OnMapReadyCallback {
private fun migrateLegacyData() {
val legacyFile = File(LEGACY_PHOTO_DATA_PATH)
if (legacyFile.exists()) {
val listPhotoMapData = CommonUtils.readDataFile(LEGACY_PHOTO_DATA_PATH)
val listPhotoMapData = EasyPhotoMapUtils.readDataFile(LEGACY_PHOTO_DATA_PATH)
listPhotoMapData?.map { data ->
val temps = StringUtils.split(data, "|")
val item = PhotoMapItem().apply {
Expand Down
Expand Up @@ -5,10 +5,10 @@ import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Bundle
import com.github.chrisbanes.photoview.PhotoView
import io.github.aafactory.commons.utils.BitmapUtils
import kotlinx.android.synthetic.main.activity_popup_image.*
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.helper.COLUMN_IMAGE_PATH
import me.blog.korn123.easyphotomap.utils.BitmapUtils
import java.io.File

/**
Expand Down
Expand Up @@ -15,13 +15,14 @@ import android.view.View
import android.widget.AdapterView
import android.widget.LinearLayout
import android.widget.TextView
import io.github.aafactory.commons.extensions.dpToPixel
import kotlinx.android.synthetic.main.activity_thumbnail_explorer.*
import me.blog.korn123.easyphotomap.R
import me.blog.korn123.easyphotomap.adapters.ThumbnailItemAdapter
import me.blog.korn123.easyphotomap.extensions.showAlertDialog
import me.blog.korn123.easyphotomap.helper.RegistrationThread
import me.blog.korn123.easyphotomap.models.ThumbnailItem
import me.blog.korn123.easyphotomap.utils.CommonUtils
import me.blog.korn123.easyphotomap.utils.EasyPhotoMapUtils
import org.apache.commons.io.FilenameUtils
import java.util.*

Expand All @@ -44,7 +45,7 @@ class ThumbnailExplorerActivity : AppCompatActivity() {
setDisplayHomeAsUpEnabled(true)
}
setAdapter()
thumbnailGrid.columnWidth = ((CommonUtils.getDefaultDisplay(this).x - CommonUtils.dpToPixel(this@ThumbnailExplorerActivity, 30f, 1)) / 3)
thumbnailGrid.columnWidth = ((EasyPhotoMapUtils.getDefaultDisplay(this).x - dpToPixel(30F, 1)) / 3)
setOnItemClickListener()

findViewById<View>(R.id.startSync).setOnClickListener {
Expand Down Expand Up @@ -79,15 +80,15 @@ class ThumbnailExplorerActivity : AppCompatActivity() {
}

fun setAdapter() {
val listPhotoEntity = CommonUtils.fetchAllThumbnail(this@ThumbnailExplorerActivity)
val listPhotoEntity = EasyPhotoMapUtils.fetchAllThumbnail(this@ThumbnailExplorerActivity)
mThumbnailEntityAdapter = ThumbnailItemAdapter(this, this, R.layout.item_thumbnail, listPhotoEntity)
thumbnailGrid.adapter = mThumbnailEntityAdapter
}

private fun setOnItemClickListener() {
thumbnailGrid.onItemClickListener = AdapterView.OnItemClickListener { parent, _, position, _ ->
val photoEntity = parent.adapter.getItem(position) as ThumbnailItem
val imagePath = CommonUtils.getOriginImagePath(this@ThumbnailExplorerActivity, photoEntity.imageId)
val imagePath = EasyPhotoMapUtils.getOriginImagePath(this@ThumbnailExplorerActivity, photoEntity.imageId)
val positiveListener = PositiveListener(this@ThumbnailExplorerActivity, this@ThumbnailExplorerActivity, FilenameUtils.getName(imagePath) + ".origin", imagePath)
if (imagePath == null) {
showAlertDialog(getString(R.string.thumbnail_explorer_message4))
Expand All @@ -109,8 +110,8 @@ class ThumbnailExplorerActivity : AppCompatActivity() {

inner class ThumbnailCreatorThread(var context: Context) : Thread() {
override fun run() {
val listOriginImage = CommonUtils.fetchAllImages(context)
val listThumbnail = CommonUtils.fetchAllThumbnail(context)
val listOriginImage = EasyPhotoMapUtils.fetchAllImages(context)
val listThumbnail = EasyPhotoMapUtils.fetchAllThumbnail(context)
val listImageId = ArrayList<String>()
listThumbnail.map { thumbnailItem -> listImageId.add(thumbnailItem.imageId) }
mCompleted = listThumbnail.size
Expand Down

0 comments on commit f528507

Please sign in to comment.