Remove useless network requests, change names
This commit is contained in:
parent
e1d8015374
commit
03ec30ef28
|
@ -15,8 +15,8 @@ import org.junit.runner.RunWith
|
|||
@RunWith(AndroidJUnit4::class)
|
||||
class ProfileTest {
|
||||
@get:Rule
|
||||
var activityRule: ActivityScenarioRule<MainActivityMarie>
|
||||
= ActivityScenarioRule(MainActivityMarie::class.java)
|
||||
var activityRule: ActivityScenarioRule<MainActivity>
|
||||
= ActivityScenarioRule(MainActivity::class.java)
|
||||
|
||||
@Test
|
||||
fun testFollowersTextView() {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".PostActivity"></activity>
|
||||
<activity android:name=".ProfileActivity"></activity>
|
||||
<activity android:name=".MainActivityMarie">
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
|
|
@ -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) }))
|
||||
}
|
||||
}
|
|
@ -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 API’s 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) }))
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivityMarie">
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
|
|
Loading…
Reference in New Issue