-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,196 additions
and
841 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'realm-android' | ||
apply plugin: 'kotlin-kapt' | ||
|
||
ext { | ||
bintrayRepo = 'RealmBrowser' | ||
bintrayName = 'com.github.saran2020.realmbrowser' | ||
|
||
libraryName = 'RealmBrowser' | ||
|
||
publishedGroupId = 'com.github.saran2020.realmbrowser' | ||
artifact = 'RealmBrowser' | ||
libraryVersion = '0.1' | ||
|
||
libraryDescription = 'A database browser for Android to browse Realm database' | ||
|
||
siteUrl = 'https://github.com/saran2020/RealmBrowser' | ||
gitUrl = 'https://github.com/saran2020/RealmBrowser.git' | ||
|
||
developerId = 'saran2020' | ||
developerName = 'Saran Sankaran' | ||
developerEmail = '[email protected]' | ||
|
||
licenseName = 'The Apache Software License, Version 2.0' | ||
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
allLicenses = ["Apache-2.0"] | ||
} | ||
|
||
android { | ||
compileSdkVersion 26 | ||
buildToolsVersion "27.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
|
||
implementation "com.android.support:appcompat-v7:$support_library" | ||
implementation "com.android.support:recyclerview-v7:$support_library" | ||
implementation "com.xiaofeng.android:flowlayoutmanager:$flow_layout_manager" | ||
|
||
// Test dependencies | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.1' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
//Add these lines to publish library to bintray. This is the readymade scripts made by github user nuuneoi to make uploading to bintray easy. | ||
//Place it at the end of the file | ||
if (project.rootProject.file('local.properties').exists()) { | ||
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' | ||
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' | ||
} | ||
|
||
subprojects { | ||
tasks.withType(Javadoc).all { enabled = false } | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
RealmBrowser/src/main/java/com/github/saran2020/realmbrowser/ActivityHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.github.saran2020.realmbrowser | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.github.saran2020.realmbrowser.data.model.ObjectType | ||
import io.realm.RealmFieldType | ||
|
||
/** | ||
* Helper class to store activity related stuff | ||
* Created by Saran on 14-Jan-18. | ||
*/ | ||
fun startResultActivity(context: Context, className: String, find: Byte) { | ||
val intent = Intent(context, ResultActivity::class.java) | ||
intent.putExtra(EXTRA_CLASS_NAME, className) | ||
intent.putExtra(EXTRA_FIND, find) | ||
context.startActivity(intent) | ||
} | ||
|
||
fun startResultActivity(context: Context, data: ObjectType) { | ||
val intent = Intent(context, ResultActivity::class.java) | ||
|
||
val objectInfo = data.objectInfo | ||
|
||
intent.putExtra(EXTRA_CLASS_NAME, objectInfo.parentClassName) | ||
intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_NAME, objectInfo.parentPrimaryKeyFieldName) | ||
intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_TYPE, objectInfo.parentPrimaryKeyType) | ||
intent.putExtra(EXTRA_KEY_FIELD_GETTER_NAME, objectInfo.fieldGetterName) | ||
intent.putExtra(EXTRA_KEY_FIELD_NAME, objectInfo.fieldName) | ||
intent.putExtra(EXTRA_KEY_FIELD_TYPE, objectInfo.fieldType) | ||
|
||
// check type and insert value | ||
when (objectInfo.parentPrimaryKeyType) { | ||
RealmFieldType.BOOLEAN.nativeValue -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue as Boolean) | ||
RealmFieldType.FLOAT.nativeValue -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue as Float) | ||
RealmFieldType.DOUBLE.nativeValue -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue as Double) | ||
|
||
RealmFieldType.STRING.nativeValue -> { | ||
intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue as String) | ||
} | ||
|
||
RealmFieldType.INTEGER.nativeValue -> { | ||
when (objectInfo.parentPrimaryKeyValue) { | ||
is Long -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue) | ||
is Int -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue) | ||
is Short -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue) | ||
is Byte -> intent.putExtra(EXTRA_PARENT_PRIMARY_KEY_VALUE, objectInfo.parentPrimaryKeyValue) | ||
else -> ERROR_TEXT | ||
} | ||
} | ||
} | ||
|
||
intent.putExtra(EXTRA_FIND, FIND_FIRST) | ||
|
||
context.startActivity(intent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
RealmBrowser/src/main/java/com/github/saran2020/realmbrowser/FindAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.github.saran2020.realmbrowser | ||
|
||
import android.content.Context | ||
import android.support.v4.content.res.ResourcesCompat | ||
import android.support.v7.widget.RecyclerView | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
|
||
/** | ||
* Created by Saran on 11-Nov-17. | ||
*/ | ||
class FindAdapter(private var context: Context, private var itemList: List<String>) : RecyclerView.Adapter<FindAdapter.ViewHolder>() { | ||
|
||
private val inflator = LayoutInflater.from(context) | ||
|
||
var selectedItem = NO_ITEM_SELECTED | ||
|
||
override fun getItemCount() = itemList.size | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder { | ||
val view = inflator.inflate(R.layout.chip_find_item, parent, false) | ||
return ViewHolder(view as TextView) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder?, position: Int) { | ||
holder?.textView?.text = itemList[position] | ||
} | ||
|
||
private fun setSelectedItem(textView: TextView, position: Int) { | ||
|
||
val selectedPosition: Byte = when (position) { | ||
0 -> FIND_ALL | ||
1 -> FIND_FIRST | ||
else -> NO_ITEM_SELECTED | ||
} | ||
|
||
selectedItem = if (selectedPosition == selectedItem) | ||
NO_ITEM_SELECTED | ||
else | ||
selectedPosition | ||
|
||
if (selectedItem == NO_ITEM_SELECTED) { | ||
|
||
// No item selected, set it back to default | ||
val defaultBackGround = ResourcesCompat.getDrawable(context.resources, R.drawable.background_chip, null) | ||
textView.background = defaultBackGround | ||
|
||
val textColor = ResourcesCompat.getColor(context.resources, R.color.findTextColor, null) | ||
textView.setTextColor(textColor) | ||
} else { | ||
|
||
// Item selected, set selected color | ||
val selectedColor = ResourcesCompat.getColor(context.resources, R.color.colorPrimary, null) | ||
textView.setBackgroundColor(selectedColor) | ||
|
||
val textColor = ResourcesCompat.getColor(context.resources, R.color.buttonTextColor, null) | ||
textView.setTextColor(textColor) | ||
} | ||
} | ||
|
||
inner class ViewHolder(val textView: TextView) : RecyclerView.ViewHolder(textView) { | ||
|
||
|
||
private var cancelOnClickListener = View.OnClickListener { | ||
val position = adapterPosition | ||
setSelectedItem(it as TextView, position) | ||
} | ||
|
||
init { | ||
textView.setOnClickListener(cancelOnClickListener) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.