Could you please help me and tell me what's wrong?
public class SecondActivity extends AppCompatActivity {
//CONECTANDO O APP À INTERNET
HashMap<Integer,View> views = new HashMap<Integer,View>();
Assincrona assinc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
//CONECTANDO O APP À INTERNET
views.put(R.id.progressBar, findViewById(R.id.progressBar));
views.put(R.id.txtServidor, findViewById(R.id.txtServidor));
views.put(R.id.etProduto, findViewById(R.id.etProduto));
views.put(R.id.etValor, findViewById(R.id.etValor));
assinc=new Assincrona(3, 3, true,views,this);//
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
//CONECTANDO O APP À INTERNET
public void conectar(View v){
if(NetSource.isConected(this)){
ViewMap.setVisibility(views, R.id.progressBar, true);
Log.i("LOG", "conectado");
assinc.play();
Log.i("LOG", "depois do play");
}
else{
Log.i("LOG", "sem conexão");
ViewMap.setContentTextView(views, R.id.txtServidor, "Sem conexão");
ViewMap.setVisibility(views, R.id.progressBar, false);
}
}//
}
/**
* Created by Administrador on 21/10/2015.
* CONECTANDO A APP À INTERNET
*/
public class Assincrona extends offUIImplementation {
public Assincrona(int timeout, int tentativas, boolean askRetry,
HashMap<Integer, View> views, Context context) {
super(timeout, tentativas, askRetry, views, context);
configRetry("Falha de conexao!", "Tentar novamente?", "sim", "não");
// TODO Auto-generated constructor stub
}
@Override
public GenericAsync configTypeAsync() {
// TODO Auto-generated method stub
return new Requisição();
}
@Override
public void fail(GenericAsync arg0) {
setContentTextView(R.id.txtServidor, "Conexao falida!");
setVisibility(R.id.progressBar, false);
}
@Override
public void sucess(GenericAsync arg0) {
Log.i("LOG", "sucess");
setContentTextView(R.id.txtServidor, arg0.getReturn());
setVisibility(R.id.progressBar, false);
}
public class Requisição extends GenericAsync {
@Override
public String task(String... arg0) {
RequestParameters[] parametros = {
new RequestParameters("action", "1")
//new RequestParameters("produto", getContentEditText(R.id.etProduto)),
//new RequestParameters("valor", getContentEditText(R.id.etValor))
};
return NetSource.sendGet("http://lascode.esy.es/webservice.php",
parametros).toString();
//return NetSource.sendGet("http://lascode.esy.es/webservice.php",
//parametros).toString().replace("<br/>","\n");
}
}
/*public class Requisição extends GenericAsync{
@Override
public String task(String... arg0) {
RequestParameters[] parametros = {new
RequestParameters("nome","andre"),
new RequestParameters("apelido","figas")};
return NetSource.sendPost("http://192.168.0.18/android/nome.php/",
parametros).toString().replace("<br/>","\n");
}
}*/
}
//Conteúdo do xml:
<EditText
android:id="@+id/etProduto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="*Produto"
android:inputType="text" />
<EditText
android:id="@+id/etValor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="*Valor"
android:inputType="number" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Conteudo do Servidor"
android:layout_gravity="center_horizontal"
android:id="@+id/txtServidor" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cadastrar novo produto"
android:id="@+id/btn_txt_net"
android:onClick="conectar"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>