Jump to content

Batysta Azevedo

Members
  • Content count

    3
  • Joined

  • Last visited

Posts posted by Batysta Azevedo


  1. Instalei um tema no wordpress , tô precisando de uma ajudinha alguém poderia mim dizer como ativar o slide desse tema www.azevedosilkexpress.com
    A demo do tema é esse www.portotheme.com/wordpress/porto/shop8

    demo.jpg



  2. Gente estou tentando colocar um webview com Pull to Refresh e um codigo que faz o file de enviar arquivos abrir dentro do webview.
    Até ai consegui fazer os dois só que quando eu uso os dois codigos juntos um deles para de funcionar.
    Não sei oq fazer, me ajudem por favor.


    activity_main.xml codigos:

    <?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"
    tools:context="com.example.smart.projeto.MainActivity">

    <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <WebView
    android:id="@+id/wvSite"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="8dp" />

    </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.constraint.ConstraintLayout>


    MainActivity.java codigo:

    package com.example.smart.projeto;

    import android.content.ActivityNotFoundException;
    import android.content.Intent;
    import android.content.res.Configuration;
    import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Build;
    import android.support.annotation.RequiresApi;
    import android.support.v4.widget.SwipeRefreshLayout;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.webkit.ValueCallback;
    import android.webkit.WebChromeClient;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.ProgressBar;
    import android.widget.Toast;

    public class MainActivity extends AppCompatActivity {

    WebView web;

    SwipeRefreshLayout swipe;

    private ValueCallback<Uri> mUploadMessage;
    public ValueCallback<Uri[]> uploadMessage;
    private final static int FILECHOOSER_RESULTCODE=1;
    public static final int REQUEST_SELECT_FILE = 100;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);



    swipe = (SwipeRefreshLayout) findViewById(R.id.swipe);
    swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {

    LoadWeb();
    }
    });

    LoadWeb();







    }

    public void LoadWeb(){

    web = (WebView) findViewById(R.id.wvSite);

    web = new WebView(this);
    web.getSettings().setJavaScriptEnabled(true);
    web.getSettings().setAllowFileAccess(true);
    web.getSettings().setAllowFileAccess(true);
    web.getSettings().setAllowContentAccess(true);
    web.loadUrl("http://clubgames.biz/teste/");
    swipe.setRefreshing(true);
    web.setWebViewClient(new WebViewClient(){


    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

    web.loadUrl("file:///android_asset/error.html");
    }

    public void onPageFinished(WebView view, String url){

    //Hide the SwipeReefreshLayout

    swipe.setRefreshing(false);
    }



    });

    web.setWebChromeClient(new WebChromeClient()
    {
    protected void openFileChooser(ValueCallback uploadMsg, String acceptType)
    {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
    }


    // For Lollipop 5.0+ Devices
    public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
    {
    if (uploadMessage != null) {
    uploadMessage.onReceiveValue(null);
    uploadMessage = null;
    }

    uploadMessage = filePathCallback;

    Intent intent = fileChooserParams.createIntent();
    try
    {
    startActivityForResult(intent, REQUEST_SELECT_FILE);
    } catch (ActivityNotFoundException e)
    {
    uploadMessage = null;
    Toast.makeText(MainActivity.this, "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
    return false;
    }
    return true;
    }

    //For Android 4.1 only
    protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
    {
    mUploadMessage = uploadMsg;
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, "File Browser"), FILECHOOSER_RESULTCODE);
    }

    protected void openFileChooser(ValueCallback<Uri> uploadMsg)
    {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
    }


    });

    setContentView(web);

    }




    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent)
    {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
    if (requestCode == REQUEST_SELECT_FILE)
    {
    if (uploadMessage == null)
    return;
    uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
    uploadMessage = null;
    }
    }
    else if (requestCode == FILECHOOSER_RESULTCODE)
    {
    if (null == mUploadMessage)
    return;
    // Use MainActivity.RESULT_OK if you're implementing WebView inside Fragment
    // Use RESULT_OK only if you're implementing WebView inside an Activity
    Uri result = intent == null || resultCode != MainActivity.RESULT_OK ? null : intent.getData();
    mUploadMessage.onReceiveValue(result);
    mUploadMessage = null;
    }
    else
    Toast.makeText(MainActivity.this, "Failed to Upload Image", Toast.LENGTH_LONG).show();
    }






    @Override
    public void onBackPressed(){

    if (web.canGoBack()){
    web.goBack();
    }else {
    finish();
    }
    }


    }


    AndroidManifest.xml codigo:


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.smart.projeto">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    </application>

    </manifest>



  3. Gente estou tentando colocar um webview com Pull to Refresh e um codigo que faz o file de enviar arquivos abrir dentro do webview.
    Até ai consegui fazer os dois só que quando eu uso os dois codigos juntos um deles para de funcionar.
    Não sei oq fazer, me ajudem por favor.


    activity_main.xml codigos:

    <?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"
    tools:context="com.example.smart.projeto.MainActivity">

    <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <WebView
    android:id="@+id/wvSite"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="8dp" />

    </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.constraint.ConstraintLayout>


    MainActivity.java codigo:

    package com.example.smart.projeto;

    import android.content.ActivityNotFoundException;
    import android.content.Intent;
    import android.content.res.Configuration;
    import android.graphics.Bitmap;
    import android.net.Uri;
    import android.os.Build;
    import android.support.annotation.RequiresApi;
    import android.support.v4.widget.SwipeRefreshLayout;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.webkit.ValueCallback;
    import android.webkit.WebChromeClient;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    import android.widget.ProgressBar;
    import android.widget.Toast;

    public class MainActivity extends AppCompatActivity {

    WebView web;

    SwipeRefreshLayout swipe;

    private ValueCallback<Uri> mUploadMessage;
    public ValueCallback<Uri[]> uploadMessage;
    private final static int FILECHOOSER_RESULTCODE=1;
    public static final int REQUEST_SELECT_FILE = 100;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);



    swipe = (SwipeRefreshLayout) findViewById(R.id.swipe);
    swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {

    LoadWeb();
    }
    });

    LoadWeb();







    }

    public void LoadWeb(){

    web = (WebView) findViewById(R.id.wvSite);

    web = new WebView(this);
    web.getSettings().setJavaScriptEnabled(true);
    web.getSettings().setAllowFileAccess(true);
    web.getSettings().setAllowFileAccess(true);
    web.getSettings().setAllowContentAccess(true);
    web.loadUrl("http://clubgames.biz/teste/");
    swipe.setRefreshing(true);
    web.setWebViewClient(new WebViewClient(){


    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

    web.loadUrl("file:///android_asset/error.html");
    }

    public void onPageFinished(WebView view, String url){

    //Hide the SwipeReefreshLayout

    swipe.setRefreshing(false);
    }



    });

    web.setWebChromeClient(new WebChromeClient()
    {
    protected void openFileChooser(ValueCallback uploadMsg, String acceptType)
    {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
    }


    // For Lollipop 5.0+ Devices
    public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
    {
    if (uploadMessage != null) {
    uploadMessage.onReceiveValue(null);
    uploadMessage = null;
    }

    uploadMessage = filePathCallback;

    Intent intent = fileChooserParams.createIntent();
    try
    {
    startActivityForResult(intent, REQUEST_SELECT_FILE);
    } catch (ActivityNotFoundException e)
    {
    uploadMessage = null;
    Toast.makeText(MainActivity.this, "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
    return false;
    }
    return true;
    }

    //For Android 4.1 only
    protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
    {
    mUploadMessage = uploadMsg;
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/*");
    startActivityForResult(Intent.createChooser(intent, "File Browser"), FILECHOOSER_RESULTCODE);
    }

    protected void openFileChooser(ValueCallback<Uri> uploadMsg)
    {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
    }


    });

    setContentView(web);

    }




    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent)
    {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    {
    if (requestCode == REQUEST_SELECT_FILE)
    {
    if (uploadMessage == null)
    return;
    uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
    uploadMessage = null;
    }
    }
    else if (requestCode == FILECHOOSER_RESULTCODE)
    {
    if (null == mUploadMessage)
    return;
    // Use MainActivity.RESULT_OK if you're implementing WebView inside Fragment
    // Use RESULT_OK only if you're implementing WebView inside an Activity
    Uri result = intent == null || resultCode != MainActivity.RESULT_OK ? null : intent.getData();
    mUploadMessage.onReceiveValue(result);
    mUploadMessage = null;
    }
    else
    Toast.makeText(MainActivity.this, "Failed to Upload Image", Toast.LENGTH_LONG).show();
    }






    @Override
    public void onBackPressed(){

    if (web.canGoBack()){
    web.goBack();
    }else {
    finish();
    }
    }


    }


    AndroidManifest.xml codigo:


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.smart.projeto">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    </application>

    </manifest>

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.