forked from gdgvilnius/MaistoBankas
-
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.
### Rodyti įrašus išsaugotus duomenų bazėje Nuskenuotų prekių sąrašą vis atnaujinti įrašais duomenų bazėje * `MainFragment`e `onResume` metode iškviesti `dbHelper.getScannedItemDao().queryForAll();` * Sąrašo atvaizdavimui sukurti naują adapterį * Sąrašo eilutės vaizdavimui sukurti layout'ą (pradžiai tik su `TextView` barkodo atvaizdavimui)
- Loading branch information
1 parent
e8f589d
commit 585d87a
Showing
8 changed files
with
139 additions
and
38 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
54 changes: 54 additions & 0 deletions
54
app/src/main/java/lt/andro/maistobankas/adapter/ScannedItemsAdapter.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,54 @@ | ||
package lt.andro.maistobankas.adapter; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
import android.widget.TextView; | ||
|
||
import java.util.List; | ||
|
||
import lt.andro.maistobankas.R; | ||
import lt.andro.maistobankas.db.ScannedItem; | ||
|
||
/** | ||
* @author Vilius Kraujutis viliusk@gmail.com | ||
* @since 2014-02-08 16:02 | ||
*/ | ||
public class ScannedItemsAdapter extends BaseAdapter { | ||
private final Context context; | ||
private final List<ScannedItem> scannedItems; | ||
|
||
public ScannedItemsAdapter(Context context, List<ScannedItem> scannedItems) { | ||
this.context = context; | ||
this.scannedItems = scannedItems; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return scannedItems.size(); | ||
} | ||
|
||
@Override | ||
public ScannedItem getItem(int position) { | ||
return scannedItems.get(position); | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return getItem(position).getId(); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
if (convertView == null) { | ||
convertView = LayoutInflater.from(context).inflate(R.layout.row_scanned_item, parent, false); | ||
} | ||
|
||
final TextView barcodeView = (TextView) convertView.findViewById(R.id.row_scanned_item_barcode); | ||
final ScannedItem item = getItem(position); | ||
barcodeView.setText(item.getBarcode()); | ||
return convertView; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/lt/andro/maistobankas/util/ScanUtil.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,20 @@ | ||
package lt.andro.maistobankas.util; | ||
|
||
import android.support.v4.app.FragmentActivity; | ||
|
||
import lt.andro.maistobankas.IntentIntegrator; | ||
import lt.andro.maistobankas.R; | ||
|
||
/** | ||
* @author Vilius Kraujutis viliusk@gmail.com | ||
* @since 2014-02-08 16:30 | ||
*/ | ||
public class ScanUtil { | ||
|
||
public static void initiateScan(FragmentActivity activity) { | ||
IntentIntegrator integrator = new IntentIntegrator(activity); | ||
integrator.setMessage(activity.getString(R.string.barcode_scan_message)); | ||
integrator.initiateScan(); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:id="@+id/row_scanned_item_barcode" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
tools:text="123412341234" /> | ||
|
||
</LinearLayout> |
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