-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Busqueda de vehiculos y chofers y asignacion a las expediciones
- Loading branch information
1 parent
819e1e7
commit 69373f0
Showing
13 changed files
with
342 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
app/src/main/java/es/incaser/apps/stockcontrol/Search.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package es.incaser.apps.stockcontrol; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.database.Cursor; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.os.Bundle; | ||
import android.text.Editable; | ||
import android.text.TextWatcher; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import static es.incaser.apps.tools.Tools.dateStr2str; | ||
|
||
|
||
public class Search extends ActionBarActivity implements TextWatcher{ | ||
ListView lv_search; | ||
EditText txt_search; | ||
SearchAdapter searchAdapter; | ||
DbAdapter dbAdapter; | ||
String tabla; | ||
String campoBusqueda; | ||
String campoRetorno; | ||
Bundle bundleOrig; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_search); | ||
bundleOrig = getIntent().getExtras(); | ||
tabla = bundleOrig.getString("tabla"); | ||
campoBusqueda = bundleOrig.getString("campoBusqueda",""); | ||
campoRetorno = bundleOrig.getString("campoRetorno",""); | ||
|
||
txt_search = (EditText) findViewById(R.id.txt_buscador); | ||
txt_search.addTextChangedListener(this); | ||
|
||
lv_search = (ListView) findViewById(R.id.lv_result_search); | ||
searchAdapter = new SearchAdapter(this); | ||
lv_search.setAdapter(searchAdapter); | ||
|
||
|
||
} | ||
|
||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_search, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@Override | ||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTextChanged(CharSequence s, int start, int before, int count) { | ||
|
||
} | ||
|
||
@Override | ||
public void afterTextChanged(Editable s) { | ||
searchAdapter.search(s.toString()); | ||
searchAdapter.notifyDataSetChanged(); | ||
} | ||
|
||
public class SearchAdapter extends BaseAdapter implements View.OnClickListener{ | ||
Context context; | ||
Cursor cursor; | ||
|
||
public SearchAdapter(Context ctx){ | ||
context = ctx; | ||
dbAdapter = new DbAdapter(context); | ||
search(""); | ||
} | ||
|
||
public void search(String searchText){ | ||
cursor = dbAdapter.getBusqueda(tabla, campoBusqueda, campoRetorno, searchText); | ||
cursor.moveToFirst(); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return cursor.getCount(); | ||
} | ||
|
||
@Override | ||
public Object getItem(int position) { | ||
cursor.moveToPosition(position); | ||
return cursor; | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
cursor.moveToPosition(position); | ||
return cursor.getLong(cursor.getColumnIndex("id")); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
View myView = null; | ||
|
||
if (convertView == null) { | ||
LayoutInflater myInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
myView = myInflater.inflate(R.layout.item_search, null); | ||
} else { | ||
myView = convertView; | ||
} | ||
cursor.moveToPosition(position); | ||
myView.setOnClickListener(this); | ||
TextView tvName = (TextView) myView.findViewById(R.id.tv_item_search); | ||
tvName.setText(cursor.getString(cursor.getColumnIndex(campoRetorno))); | ||
return myView; | ||
} | ||
|
||
|
||
@Override | ||
public void onClick(View v) { | ||
Intent returnIntent = new Intent(); | ||
returnIntent.putExtra("id",cursor.getString(0)); | ||
returnIntent.putExtra(campoRetorno, cursor.getString(cursor.getColumnIndex(campoRetorno))); | ||
returnIntent.putExtra("tipoMov",bundleOrig.getString("tipoMov")); | ||
returnIntent.putExtra("serieMov",bundleOrig.getString("serieMov")); | ||
returnIntent.putExtra("documentoMov",bundleOrig.getString("documentoMov")); | ||
|
||
|
||
setResult(RESULT_OK,returnIntent); | ||
finish(); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | ||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
tools:context="es.incaser.apps.stockcontrol.Search"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
<EditText | ||
android:id="@+id/txt_buscador" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Buscar..." | ||
/> | ||
</LinearLayout> | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<ListView | ||
android:id="@+id/lv_result_search" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
</ListView> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</RelativeLayout> |
Oops, something went wrong.