1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-09 12:32:30 +01:00
This commit is contained in:
Allan Wang 2017-06-05 23:06:15 -07:00
parent bb49bd9c9f
commit bc0559e9cc
12 changed files with 172 additions and 5 deletions

1
app/.gitignore vendored
View File

@ -1 +1,2 @@
/build
fabric.properties

View File

@ -80,6 +80,7 @@ dependencies {
compile "com.android.support:recyclerview-v7:${ANDROID_SUPPORT_LIBS}"
compile "com.android.support:cardview-v7:${ANDROID_SUPPORT_LIBS}"
compile "com.android.support:preference-v14:${ANDROID_SUPPORT_LIBS}"
compile "com.android.support.constraint:constraint-layout:${CONSTRAINT_LAYOUT}"
//Logging
compile "com.jakewharton.timber:timber:${TIMBER}"
@ -119,9 +120,9 @@ dependencies {
compile "com.jakewharton.rxbinding2:rxbinding:${RX_BINDING}"
compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:${RX_BINDING}"
compile "org.greenrobot:eventbus:${EVENT_BUS}"
// compile "org.greenrobot:eventbus:${EVENT_BUS}"
compile "com.facebook.stetho:stetho-okhttp3:${STETHO}"
// compile "com.facebook.stetho:stetho-okhttp3:${STETHO}"
compile "com.lapism:searchview:${SEARCH_VIEW}"
@ -147,6 +148,7 @@ dependencies {
// transitive = true
// }
compile "co.zsmb:materialdrawer-kt:${MATERIAL_DRAWER_KT}"
compile "com.mikepenz:fastadapter-commons:${FAST_ADAPTER}@aar"
compile "nz.bradcampbell:paperparcel:${PAPER_PARCEL}"
compile "nz.bradcampbell:paperparcel-kotlin:${PAPER_PARCEL}"

View File

@ -40,7 +40,7 @@ class FrostApp : Application() {
refWatcher = LeakCanary.install(this)
if (BuildConfig.DEBUG) {
Timber.plant(DebugTree())
LeakCanary.enableDisplayLeakActivity(this)
// LeakCanary.enableDisplayLeakActivity(this)
} else {
Fabric.with(this, Crashlytics(), Answers())
Timber.plant(CrashReportingTree())

View File

@ -1,10 +1,26 @@
package com.pitchedapps.frost
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.RecyclerView
import butterknife.ButterKnife
import com.mikepenz.fastadapter.FastAdapter
import com.pitchedapps.frost.utils.bindView
import com.pitchedapps.frost.views.AccountItem
/**
* Created by Allan Wang on 2017-06-04.
*/
class SelectorActivity : AppCompatActivity() {
val recycler: RecyclerView by bindView(R.id.selector_recycler)
val adapter = FastItemAdapter<AccountItem>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_selector)
ButterKnife.bind(this)
recycler.adapter = adapter
adapter.addal
}
}

View File

@ -36,8 +36,11 @@ data class CookieModel(@PrimaryKey var id: Long = Prefs.userIdDefault, var name:
fun loadFbCookie(id: Long): CookieModel? = (select from CookieModel::class where (CookieModel_Table.id eq id)).querySingle()
fun loadFbCookie(name: String): CookieModel? = (select from CookieModel::class where (CookieModel_Table.name eq name)).querySingle()
/**
* Loads cookies sorted by name
*/
fun loadFbCookiesAsync(callback: (cookies: List<CookieModel>) -> Unit) {
(select from CookieModel::class).async().queryListResultCallback { _, tResult -> callback.invoke(tResult) }.execute()
(select from CookieModel::class).orderBy(CookieModel_Table.name, true).async().queryListResultCallback { _, tResult -> callback.invoke(tResult) }.execute()
}
fun saveFbCookie(cookie: CookieModel, callback: (() -> Unit)? = null) {

View File

@ -0,0 +1,71 @@
package com.pitchedapps.frost.views
import android.graphics.drawable.Drawable
import android.support.v7.widget.AppCompatTextView
import android.support.v7.widget.RecyclerView
import android.view.View
import android.widget.ImageView
import butterknife.ButterKnife
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.mikepenz.fastadapter.items.AbstractItem
import com.pitchedapps.frost.R
import com.pitchedapps.frost.facebook.PROFILE_PICTURE_URL
import com.pitchedapps.frost.utils.bindView
/**
* Created by Allan Wang on 2017-06-05.
*/
class AccountItem(val id: Long, val name: String) : AbstractItem<AccountItem, AccountItem.ViewHolder>() {
constructor() : this(-1L, "")
override fun getType(): Int = R.id.item_account
override fun getViewHolder(v: View) = ViewHolder(v)
override fun getLayoutRes(): Int = R.layout.view_account
override fun bindView(viewHolder: ViewHolder, payloads: List<Any>) {
super.bindView(viewHolder, payloads)
with(viewHolder) {
text.visibility = View.INVISIBLE
if (id != -1L) {
text.text = name
Glide.with(itemView).load(PROFILE_PICTURE_URL(id)).listener(object : RequestListener<Drawable> {
override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
text.fadeIn()
return false
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
text.fadeIn()
return false
}
}).into(image)
} else {
text.text = itemView.context.getString(R.string.add_account)
//todo add plus image
}
}
}
override fun unbindView(holder: ViewHolder) {
super.unbindView(holder)
with(holder) {
text.text = null
image.setImageDrawable(null)
}
}
class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
val image: ImageView by bindView(R.id.account_image)
val text: AppCompatTextView by bindView(R.id.account_text)
init {
ButterKnife.bind(v)
}
}
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/text_select_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/select_facebook_account"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/selector_recycler"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_select_account"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/select_facebook_account"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/selector_recycler"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp" />
</android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin">
<ImageView
android:id="@+id/account_image"
android:layout_width="200dp"
android:layout_height="200dp" />
<android.support.v7.widget.AppCompatTextView
android:id="@+id/account_text"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:maxLines="1" />
</LinearLayout>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="item_account" type="id" />
</resources>

View File

@ -25,4 +25,6 @@
<string name="loading_account">Getting everything ready…</string>
<string name="welcome">Welcome %s</string>
<string name="login">Login</string>
<string name="select_facebook_account">Select Facebook Account</string>
<string name="add_account">Add Account</string>
</resources>

View File

@ -18,6 +18,7 @@ allprojects {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
}
}

View File

@ -49,4 +49,6 @@ EVENT_BUS=3.0.0
PAPER_PARCEL=2.0.1
SWIPE_BACK=3.1.2
CRASHLYTICS=2.6.8
LEAK_CANARY=1.5.1
LEAK_CANARY=1.5.1
CONSTRAINT_LAYOUT=1.0.2
FAST_ADAPTER=2.6.0