; setBackgroundDrawable(新的彩色绘制(android.graphics.Color.TRANSPARENT)); btnCamera=(按钮)布局。findViewById(R.id.Button\u摄像头); btnCamera.
; setBackgroundDrawable(新的彩色绘制(android.graphics.Color.TRANSPARENT)); btnCamera=(按钮)布局。findViewById(R.id.Button\u摄像头); btnCamera.setOnClickListener(新视图.OnClickListener(){ @凌驾 公共void onClick(视图v){ Intent cameraIntent=newintent(android.provider.MediaStore.ACTION\u IMAGE\u CAPTURE); startActivityForResult(摄像机帐篷、摄像机请求); } }); btnGallery=(按钮)布局。findviewbyd(R.id.Button\u Gallery); btnGallery.setOnClickListener(新视图.OnClickListener(){ @凌驾 公共void onClick(视图v){ Intent gallerycontent=newintent(Intent.ACTION\u PICK,android.provider.MediaStore.Images.Media.EXTERNAL\u CONTENT\u URI); startActivityForResult(GalleryContent、RESULT\u LOAD\u IMG); } }); cancelPopUp=(按钮)layout.findViewById(R.id.btnCancelCamera); cancelPopUp.setOnClickListener(取消按钮\u单击\u listener); }捕获(例外e){ e、 printStackTrace(); } } 类MyListAdapter扩展了ArrayAdapter{ 语境; 国际布局资源; /**/ ArrayList数据=新的ArrayList(); 公共MyListAdapter(上下文上下文、int layoutResourceId、ArrayList数据){ 超级(上下文、布局资源ID、数据); this.layoutResourceId=layoutResourceId; this.context=上下文; 这个数据=数据; } @凌驾 public int getCount(){ 返回data.size(); } @凌驾 公共长getItemId(int位置){ 返回位置; } @凌驾 公共视图getView(最终整数位置、视图转换视图、视图组父视图){ 视图行=转换视图; 最终持有人; if(行==null){ 拉平机vi; vi=LayoutInflater.from(getContext()); 行=vi.充气(R.布局.所有后行,空); 保持架=新保持架(); holder.text\u ActivityId=(TextView)row.findViewById(R.id.textActivityId); holder.text\u InspectorName=(TextView)row.findViewById(R.id.textInspectorName); holder.text_SpChar=(TextView)row.findViewById(R.id.textSpChar); holder.text_Notation=(TextView)row.findViewById(R.id.textNotation); holder.txtViewDate=(TextView)row.findViewById(R.id.txt_Date); holder.txtInitialLetter=(TextView)row.findViewById(R.id.txt\u InitialLetter); holder.txtmark=(TextView)row.findViewById(R.id.textmark); holder.imgBtn_FollowUp=(ImageView)row.findViewById(R.id.imgButton_folowup); holder.imgBtn_RateEquipMent=(ImageView)行findViewById(R.id.imgButtonRateEquipment); holder.imgBtn_Camera=(ImageView)row.findViewById(R.id.imgButton_Camera); holder.imgBtn_Audio=(ImageView)row.findViewById(R.id.imgButton_RecordAudio); holder.horizontalScrollView=(horizontalScrollView)row.findViewById(R.id.hlist); holder.lLinearLayout=(LinearLayout)row.findViewById(R.id.innerlay); row.setTag(支架); }否则{ holder=(holder)行。getTag(); } 最终全部发布全部发布=data.get(位置); holder.text\u ActivityId.setText(all\u Post.getStrActivityId()); holder.text_InspectorName.setText(all_Post.getStringInspectorname()); 字符串typenameRGN=all_Post.getStrShortName(); Log.e(“typenameRGN”,“=”+typenameRGN); holder.txtInitialLetter.setText(typenameRGN); if(holder.txtInitialLetter.getText().toString().equals(“R”)){ 支架.txtInitialLetter.立根资源(R.可拉深.红色圆圈形状); } if(holder.txtInitialLetter.getText().toString().equals(“G”)){ 支架.txtInitialLetter.立根资源(R.可拉深.绿色\ U形); } if(holder.txtInitialLetter.getText().toString().equals(“N”)){ 支架.txtInitialLetter.setBackgroundResource(R.可拉深.蓝色圆圈形状); } holder.txtmark.setText(all_Post.getstremark()); holder.text_Notation.setText(all_Post.getStrNotationNo()); String strtextNotation=holder.text_Notation.getText().toString().trim(); Log.e(“strtextNotation”、“=”+strtextNotation); holder.txtViewDate.setText(all_Post.getActiondate()); strlitItem_ActivityId=all_Post.getStrActivityId(); Log.e(“strlitiem_ActivityId”,“=”+strlitiem_ActivityId); dbhelper=newmydbhelper(AllPosts\u Page.this); SQLiteDatabase db=dbhelper.getReadableDatabase(); Cursor Cursor=db.rawQuery(“从ActivityObjectList中选择*,其中activityId“+”=?”,新字符串[]{strlitItem\u activityId}); imageArray.clear(); if(cursor.moveToFirst()){ 做{ 字符串imagePath=cursor.getString(cursor.getColumnIndex(“imageaudioPath”); 添加(imagePath); } while(cursor.moveToNext()); } cursor.close(); //db.close(); //单击列表中照相机按钮的侦听器 holder.imgBtn_Camera.setOnClickListener(新视图.OnClickListener()){ @凌驾 公共void onClick(视图v){ string_ActivityId=all_Post.getStrActivityId(); 初始化窗口(); } }); 最终Stri; setBackgroundDrawable(新的彩色绘制(android.graphics.Color.TRANSPARENT)); btnCamera=(按钮)布局。findViewById(R.id.Button\u摄像头); btnCamera.,android,Android,; setBackgroundDrawable(新的彩色绘制(android.graphics.Color.TRANSPARENT)); btnCamera=(按钮)布局。findViewById(R.id.Button\u摄像头); btnCamera.setOnClickListener(新视图.OnClickListener(){ @凌驾 公共void onClick(视图v){ Intent cameraIntent=newintent(android.provider.MediaSto
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLayout = (MainLayout) this.getLayoutInflater().inflate(R.layout.all_post, null);
setContentView(mLayout);
dbhelper = new MyDbHelper(this);
imgLeftmenu = (ImageView) findViewById(R.id.imgLeftMenu);
imgSearch = (ImageView) findViewById(R.id.imgSearch);
imgAdd = (ImageView) findViewById(R.id.imgAdd);
listView = (ListView) findViewById(R.id.listview_AllPost);
populateList();
new GetgetDoenLoaddata().execute();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
str_Authentication_Token = sharedPreferences.getString("strAuthentication_Token", "");
str_UserId = sharedPreferences.getString("strUserId", "");
Log.e("Prefs", "str_Authentication_Token = " + str_Authentication_Token + "Prefs str_UserId = " + str_UserId);
SQLiteDatabase db = dbhelper.getWritableDatabase();
String query = "select * from SyncTime where WebServiceEntity ='" + "AllPost_ActivityList" + "'";
Cursor cursor = db.rawQuery(query, null);
while (cursor.moveToNext()) {
strSyncTime = cursor.getString(cursor.getColumnIndex("SyncTime"));
strSyncTime1 = strSyncTime.replaceAll(" ", "%20");
Log.e("strSyncTime ", " = " + strSyncTime1);
}
cursor.close();
Intent intent = getIntent();
String newAudioFile = intent.getStringExtra("newAudioFile");
Log.e("newAudioFile ", " = " + newAudioFile);
imgAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(AllPosts_Page.this, AddPost.class);
startActivity(i);
}
});
imgSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
private void populateList() {
descArray.clear();
List<All_Post> allDesc = dbhelper.getAllDescriptions();
for (All_Post all_Post : allDesc) {
descArray.add(all_Post);
}
if (adapter == null) {
adapter = new MyListAdapter(this, R.layout.all_post_row, descArray);
listView.setAdapter(adapter);
Log.e("Single Entry ", " !!!! ");
} else if (adapter != null) {
adapter.notifyDataSetChanged();
Log.e("Double Entry ", " !!!! ");
adapter = new MyListAdapter(this, R.layout.all_post_row, descArray);
listView.setAdapter(adapter);
}
}
@Override
protected void onResume() {
super.onResume();
populateList();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (dbhelper != null) {
dbhelper.close();
}
}
public void getDoenLoaddata() {
dbhelper = new MyDbHelper(this);
SQLiteDatabase db1 = dbhelper.getWritableDatabase();
Cursor cursor = db1.rawQuery("select * from ActivityObjectList", null);
if (cursor.moveToFirst()) {
do {
imageName = cursor.getString(cursor.getColumnIndex("imageaudioPath"));
String strDownLoadStatus = cursor.getString(cursor.getColumnIndex("DownLoad_Status"));
if (strDownLoadStatus.equalsIgnoreCase("0")) {
if (imageName.endsWith(mp3_Pattern)) {
str_DownLoadUrl = namespace + "/DownloadFile/FileName/" + imageName;
DownLoadAudioFile(str_DownLoadUrl, imageName);
strDownLoadStatus = "1";
dbhelper.update_DownLoadStatus(imageName, strDownLoadStatus);
}
if (imageName.endsWith(png_Pattern) || imageName.endsWith(jpg_pattern) || imageName.endsWith(bmp_pattern) || imageName.endsWith(gif_pattern) || imageName.endsWith(jpeg_pattern)) {
str_DownLoadUrl = namespace + "/DownloadFile/FileName/" + imageName;
download_PngFile(str_DownLoadUrl, imageName);
strDownLoadStatus = "1";
dbhelper.update_DownLoadStatus(imageName, strDownLoadStatus);
}
}
}
while (cursor.moveToNext());
}
cursor.close();
//db1.close();
}
private void initiatePopupWindow() {
try {
Log.e("string_ActivityId ", " = " + string_ActivityId);
dbhelper = new MyDbHelper(this);
SQLiteDatabase db = dbhelper.getReadableDatabase();
Cursor cursor1 = db.rawQuery("select * from ALL_Post where ActivityId " + "= ? ", new String[]{string_ActivityId});
if (cursor1.moveToFirst()) {
struserId1 = cursor1.getString(cursor1.getColumnIndex("UserId"));
strobjectId1 = cursor1.getString(cursor1.getColumnIndex("VesselId"));
Log.e("initiatePopupWindow ", "onCameraclick strobjectId1 = " + strobjectId1);
Log.e("initiatePopupWindow ", "onCameraclickt struserId1 = " + struserId1);
}
cursor1.close();
db.close();
LayoutInflater inflater = (LayoutInflater) AllPosts_Page.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.camera_popup, (ViewGroup) findViewById(R.id.popup_element));
pwindo = new PopupWindow(layout, 600, 380, true);
pwindo.showAtLocation(layout, Gravity.BOTTOM, 0, 0);
pwindo.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
btnCamera = (Button) layout.findViewById(R.id.button_Camera);
btnCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
btnGallery = (Button) layout.findViewById(R.id.button_Gallery);
btnGallery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
}
});
cancelPopUp = (Button) layout.findViewById(R.id.btnCancelCamera);
cancelPopUp.setOnClickListener(cancel_button_click_listener);
} catch (Exception e) {
e.printStackTrace();
}
}
class MyListAdapter extends ArrayAdapter<All_Post> {
Context context;
int layoutResourceId;
/**/
ArrayList<All_Post> data = new ArrayList<All_Post>();
public MyListAdapter(Context context, int layoutResourceId, ArrayList<All_Post> data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
}
@Override
public int getCount() {
return data.size();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
final Holder holder;
if (row == null) {
LayoutInflater vi;
vi = LayoutInflater.from(getContext());
row = vi.inflate(R.layout.all_post_row, null);
holder = new Holder();
holder.text_ActivityId = (TextView) row.findViewById(R.id.textActivityId);
holder.text_InspectorName = (TextView) row.findViewById(R.id.textInspectorName);
holder.text_SpChar = (TextView) row.findViewById(R.id.textSpChar);
holder.text_Notation = (TextView) row.findViewById(R.id.textNotation);
holder.txtViewDate = (TextView) row.findViewById(R.id.txt_Date);
holder.txtInitialLetter = (TextView) row.findViewById(R.id.txt_InitialLetter);
holder.txtRemark = (TextView) row.findViewById(R.id.textRemark);
holder.imgBtn_FollowUp = (ImageView) row.findViewById(R.id.imgButton_FoloowUp);
holder.imgBtn_RateEquipMent = (ImageView) row.findViewById(R.id.imgButtonRateEquipment);
holder.imgBtn_Camera = (ImageView) row.findViewById(R.id.imgButton_Camera);
holder.imgBtn_Audio = (ImageView) row.findViewById(R.id.imgButton_RecordAudio);
holder.horizontalScrollView = (HorizontalScrollView) row.findViewById(R.id.hlist);
holder.lLinearLayout = (LinearLayout) row.findViewById(R.id.innerlay);
row.setTag(holder);
} else {
holder = (Holder) row.getTag();
}
final All_Post all_Post = data.get(position);
holder.text_ActivityId.setText(all_Post.getStrActivityId());
holder.text_InspectorName.setText(all_Post.getStringInspectorname());
String typenameRGN = all_Post.getStrShortName();
Log.e("typenameRGN ", " = " + typenameRGN);
holder.txtInitialLetter.setText(typenameRGN);
if (holder.txtInitialLetter.getText().toString().equals("R")) {
holder.txtInitialLetter.setBackgroundResource(R.drawable.red_circle_shape);
}
if (holder.txtInitialLetter.getText().toString().equals("G")) {
holder.txtInitialLetter.setBackgroundResource(R.drawable.green_circle_shape);
}
if (holder.txtInitialLetter.getText().toString().equals("N")) {
holder.txtInitialLetter.setBackgroundResource(R.drawable.blue_circle_shape);
}
holder.txtRemark.setText(all_Post.getStrRemark());
holder.text_Notation.setText(all_Post.getStrNotationNo());
String strtextNotation = holder.text_Notation.getText().toString().trim();
Log.e("strtextNotation ", " = " + strtextNotation);
holder.txtViewDate.setText(all_Post.getActiondate());
strListItem_ActivityId = all_Post.getStrActivityId();
Log.e("strListItem_ActivityId ", " = " + strListItem_ActivityId);
dbhelper = new MyDbHelper(AllPosts_Page.this);
SQLiteDatabase db = dbhelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from ActivityObjectList where activityId " + "= ? ", new String[]{strListItem_ActivityId});
imageArray.clear();
if (cursor.moveToFirst()) {
do {
String imagePath = cursor.getString(cursor.getColumnIndex("imageaudioPath"));
imageArray.add(imagePath);
}
while (cursor.moveToNext());
}
cursor.close();
//db.close();
//OnClickListener for camera button in the List
holder.imgBtn_Camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
string_ActivityId = all_Post.getStrActivityId();
initiatePopupWindow();
}
});
final String actid = all_Post.getStrActivityId();
dbhelper = new MyDbHelper(context);
db = dbhelper.getReadableDatabase();
Cursor cursor1 = db.rawQuery("select * from ALL_Post where activityId ='" + actid + "'", null);
if (cursor1.moveToFirst()) {
do {
String strStarFlag = cursor1.getString(cursor1.getColumnIndex("StarFlag"));
Log.e("strStarFlag ", " is = " + strStarFlag);
if (strStarFlag.equals("0")) {
holder.imgBtn_RateEquipMent.setImageResource(R.drawable.stargrey_new);
} else if (strStarFlag.equals("1")) {
holder.imgBtn_RateEquipMent.setImageResource(R.drawable.yellow_star);
}
}
while (cursor1.moveToNext());
}
cursor1.close();
db.close();
return row;
}
}
private class GetgetDoenLoaddata extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... arg0) {
getDoenLoaddata();
return null;
}
}
}