Swipe Refresh
This commit is contained in:
@@ -47,6 +47,7 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -32,6 +33,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@@ -63,6 +65,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
final SwipeRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
|
||||
refreshLayout.setColorSchemeColors(Color.BLUE);
|
||||
|
||||
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
|
||||
|
||||
// your action when refresh layout swiped
|
||||
web.clearCache(true);
|
||||
reStart();
|
||||
refreshLayout.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
fbtn_live = (FloatingActionButton) findViewById(R.id.fbtn_live);
|
||||
fbtn_live.setOnClickListener(new View.OnClickListener() {
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
|
||||
@@ -6,6 +6,22 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/wv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
</WebView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fbtn_live"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -17,15 +33,8 @@
|
||||
android:backgroundTint="#FF5722"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/menu_live"
|
||||
android:focusable="true"
|
||||
android:src="@android:drawable/ic_media_play"
|
||||
app:tint="@null"
|
||||
android:focusable="true" />
|
||||
|
||||
<WebView
|
||||
android:id="@+id/wv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</WebView>
|
||||
app:tint="@null" />
|
||||
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user