Remove useless network requests, change names

This commit is contained in:
Matthieu 2020-03-06 00:11:12 +01:00
parent e1d8015374
commit 03ec30ef28
5 changed files with 24 additions and 74 deletions

View File

@ -15,8 +15,8 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
class ProfileTest { class ProfileTest {
@get:Rule @get:Rule
var activityRule: ActivityScenarioRule<MainActivityMarie> var activityRule: ActivityScenarioRule<MainActivity>
= ActivityScenarioRule(MainActivityMarie::class.java) = ActivityScenarioRule(MainActivity::class.java)
@Test @Test
fun testFollowersTextView() { fun testFollowersTextView() {

View File

@ -13,7 +13,7 @@
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".PostActivity"></activity> <activity android:name=".PostActivity"></activity>
<activity android:name=".ProfileActivity"></activity> <activity android:name=".ProfileActivity"></activity>
<activity android:name=".MainActivityMarie"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -0,0 +1,20 @@
package com.h.pixeldroid
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById<Button>(R.id.button)
button.setOnClickListener((View.OnClickListener {
val intent = Intent(this, ProfileActivity::class.java)
startActivity(intent) }))
}
}

View File

@ -1,70 +0,0 @@
package com.h.pixeldroid
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.objects.Status
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
class MainActivityMarie : AppCompatActivity() {
private var statuses: ArrayList<Status>? = null
private val BASE_URL = "https://pixelfed.de/"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
loadData()
}
private fun loadData() {
//Define the Retrofit request//
val pixelfedAPI = Retrofit.Builder()
//Set the APIs base URL//
.baseUrl(BASE_URL)
//Specify the converter factory to use for serialization and deserialization//
.addConverterFactory(GsonConverterFactory.create())
//Add a call adapter factory to support RxJava return types//
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
//Build the Retrofit instance//
.build().create(PixelfedAPI::class.java)
pixelfedAPI.timelinePublic(null, null, null, null, null)
.enqueue(object : Callback<List<Status>> {
override fun onResponse(call: Call<List<Status>>, response: Response<List<Status>>) {
if (response.code() == 200) {
Log.e("OK", response.body().toString())
statuses = response.body() as ArrayList<Status>?
}
}
override fun onFailure(call: Call<List<Status>>, t: Throwable) {
Log.e("Ouch, not OK", t.toString())
}
})
val button = findViewById<Button>(R.id.button)
button.setOnClickListener((View.OnClickListener {
val intent = Intent(this, ProfileActivity::class.java)
startActivity(intent) }))
}
}

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivityMarie"> tools:context=".MainActivity">
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"