using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using workflow.Authorize;
using System.Web.Script.Serialization;
using workflow.DataHolders;
using workflow.Models;
using workflow;
using System.Net;
using System.Net.Mail;
[AllowAnonymous]
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ValidateAndSignUp(ForCompany newCompany)
{
if (ModelState.IsValid)
{
company NewCompany = new company();
TryUpdateModel(NewCompany);
context.companies.Add(NewCompany);
int processStatus= context.SaveChanges();
if (processStatus != 0)
{
MailMessage message = new MailMessage();
message.To.Add(newCompany.Email);
message.Subject = "You have created new account";
message.Body = "Hi, Welcom to HWorkflow website this email is to approve your account and to creat the first user, please click on the link below to approve your account and to creat your first user";
message.From = new MailAddress("HWorkflowTeam@hworkflow.com");
message.IsBodyHtml = true;
var credential = new NetworkCredential
{
UserName = "hworkflowteam", // replace with valid value
Password = "No-access" // replace with valid value
};
var smtp = new SmtpClient();
smtp.Credentials = credential;
smtp.Host = "mail.hworkflow.com";
smtp.Port = 25;
smtp.EnableSsl = true;
await smtp.SendMailAsync(message);
}
return RedirectToAction("index", "Home");
}
else
{
return View("signUp", newCompany);
}
}
我在这行中收到此错误:
public class VideoActivity extends Activity implements
FensterPlayerControllerVisibilityListener {
ListView listview;
CustomListAdapter adapter;
private static ProgressDialog progressDialog;
public static int currentItem;
public static ArrayList<String> videoLIst;
public static MediaController mediaController ;
boolean pauseOnScroll = true;
boolean pauseOnFling = true;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
System.gc();
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
int memoryClass = am.getMemoryClass();
int largememoryclass = am.getLargeMemoryClass();
Log.v("onCreate", "memoryClass:" + Integer.toString(memoryClass));
Log.v("onCreate", "largememoryClass:" + Integer.toString(largememoryclass));
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
videoLIst = new ArrayList<String>();
mediaController = new MediaController(VideoActivity.this);
videoLIst.add("http://journey.coderspreview.com/uploads/Home_Video/mov_bbb.mp4");
videoLIst.add("http://journey.coderspreview.com/uploads/experience/165/video/father-and-young-daughter.mp4");
videoLIst.add("http://journey.coderspreview.com/uploads/experience/185/video/couple-on-sail-boat.mp4");
videoLIst.add("http://journey.coderspreview.com/uploads/experience/39/video/VID-20141231-WA0006.mp4");
videoLIst.add("http://journey.coderspreview.com/uploads/experience/26/video/VID-20141216-WA0004.mp4");
listview = (ListView) findViewById(R.id.list);
listview.setFastScrollEnabled(true);
listview.setAdapter(new CustomListAdapter(this, videoLIst));
listview.setScrollingCacheEnabled(false);
listview.setRecyclerListener(new RecyclerListener() {
@Override
public void onMovedToScrapHeap(View view) {
FensterVideoView videoView = (FensterVideoView)view.findViewById(R.id.VideoView);
}
});
listview.setOnScrollListener(new AbsListView.OnScrollListener() {
private int mFirstVisibleRow = -1;
private int mActiveItem = -1;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
FensterVideoView videoView = (FensterVideoView)view.findViewById(R.id.VideoView);
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
videoView.destroyDrawingCache();
} else {
videoView.buildDrawingCache();
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
int firstVisibleRow = listview.getFirstVisiblePosition();
int lastvisiblerow =listview.getLastVisiblePosition();
if( mFirstVisibleRow != firstVisibleRow )
{
mFirstVisibleRow = firstVisibleRow;
// Cancel the video of the previous active item
FensterVideoView prevActiveVideoView = getVideoViewForRow(mActiveItem);
if( prevActiveVideoView != null )
{
prevActiveVideoView.pause();
prevActiveVideoView.clearAnimation();
// prevActiveVideoView.destroyDrawingCache();
}
// Start the video of the new active item
mActiveItem = mFirstVisibleRow + 1;
FensterVideoView newActiveVideoView = getVideoViewForRow(mActiveItem);
if(newActiveVideoView != null)
{
newActiveVideoView.start();
// newActiveVideoView.buildDrawingCache();
}
}
FensterVideoView lastVideoView = getVideoViewForRow(lastvisiblerow);
if(lastVideoView != null)
{
lastVideoView.pause();
}
}
private FensterVideoView getVideoViewForRow(int row)
{
int firstVisibleRow = listview.getFirstVisiblePosition();
View rowView = listview.getChildAt(row-firstVisibleRow);
return (rowView == null) ? null : (FensterVideoView)rowView.findViewById(R.id.VideoView);
}
});
}
static class ViewHolderItem {
TextView textViewItem;
FensterVideoView video;
ProgressBar progressbar;
}
public class CustomListAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
private ArrayList<String> videoList;
public CustomListAdapter(Activity activity, ArrayList<String> videoList) {
this.activity = activity;
this.videoList = videoList;
}
@Override
public int getCount() {
return videoList.size();
}
@Override
public Object getItem(int location) {
return videoList.get(location);
}
@Override
public long getItemId(int position) {
return position;
}
@SuppressLint("NewApi")
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
Log.d("in getview method:",""+position);
final ViewHolderItem viewHolder;
if (convertView == null){
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.video_list_item, null);
viewHolder = new ViewHolderItem();
viewHolder.video = (FensterVideoView)convertView.findViewById(R.id.VideoView);
viewHolder.progressbar = (ProgressBar)convertView.findViewById(R.id.progress);
viewHolder.textViewItem =(TextView)convertView.findViewById(R.id.txvposition);
int pos;
pos=viewHolder.video.getCurrentPosition();
Log.d("current item position:",""+pos);
convertView.setTag(viewHolder);
}else{
viewHolder = (ViewHolderItem) convertView.getTag();
}
viewHolder.textViewItem.setText("Video"+position);
// mediaController.setAnchorView(viewHolder.video);
Log.d("video url inadapter:", ""+videoLIst.toString());
// BitmapFactory.Options o = new BitmapFactory.Options();
// o.inSampleSize = 2;
// Bitmap b = BitmapFactory.decodeFile(videoLIst.get(position), o);
Uri uri = Uri.parse(videoLIst.get(position));
// Uri uri = Uri.parse("android.resource://com.example.videoviewexample/"+videoLIst.get(position));
// viewHolder.video.setMediaController(mediaController);
// viewHolder.video.setVideoURI(uri);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// viewHolder.video.setVisibility(View.GONE);
// viewHolder.video.setVisibility(View.VISIBLE);
viewHolder.video.setVideoFromBeginning(videoLIst.get(position));
viewHolder.video.setBackgroundColor(Color.TRANSPARENT);
}
}, 100);
//viewHolder.video.start();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
viewHolder.video.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(final MediaPlayer arg0) {
viewHolder.progressbar.setVisibility(View.GONE);
viewHolder.video.start();
viewHolder.video.setBackgroundResource(0);
arg0.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
Log.d("In onpreparedListener oncompletion method:",""+ mp);
}
});
}
});
viewHolder.video.setOnInfoListener(new OnInfoListener() {
@Override
public boolean onInfo(final MediaPlayer mp, final int what, int extra) {
// TODO Auto-generated method stub
Log.d("BUFFRRING START", "On_InFO");
if (MediaPlayer.MEDIA_INFO_BUFFERING_START == what) {
viewHolder.progressbar.setVisibility(View.VISIBLE);
Log.d("BUFFRRING START", "" + what);
}
if (MediaPlayer.MEDIA_INFO_BUFFERING_END == what) {
viewHolder.progressbar.setVisibility(View.GONE);
Log.d("BUFFRRING END", "" + what);
}
if (MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START == what) {
viewHolder.progressbar.setVisibility(View.GONE);
Log.d("RENDERING END", "" + what);
}
mp.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
Log.d("In setOnInfoListener oncompletion method:",""+ mp);
}
});
return false;
}
});
viewHolder.video.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
// TODO Auto-generated method stub
Log.d("Error", "------>error" + what + "/" + extra);
if (extra != 0) {
Toast.makeText(VideoActivity.this, "Can't Play Video",
Toast.LENGTH_SHORT).show();
}
if (what == 100)
{
viewHolder.video.stopPlayback();
}
if(what == -107)
{
Log.d("in error -107","error");
mp.release();
viewHolder.video.stopPlayback();
}
if(what == 1)
{
Log.d("in error 1","error");
viewHolder.video.stopPlayback();
}
return false;
}
});
}
}, 100);
viewHolder.video.clearAnimation();
return convertView;
}
}
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
@Override
public void onControlsVisibilityChange(boolean value) {
// TODO Auto-generated method stub
}
}
I am getting this error:
07-29 16:37:54.615: E/AndroidRuntime(5407): FATAL EXCEPTION: main
07-29 16:37:54.615: E/AndroidRuntime(5407): Process: com.example.videoviewexample, PID: 5407
07-29 16:37:54.615: E/AndroidRuntime(5407): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.videoviewexample/com.example.videoviewexample.VideoActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f03001a
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.ActivityThread.access$800(ActivityThread.java:151)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.os.Handler.dispatchMessage(Handler.java:102)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.os.Looper.loop(Looper.java:135)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.ActivityThread.main(ActivityThread.java:5257)
07-29 16:37:54.615: E/AndroidRuntime(5407): at java.lang.reflect.Method.invoke(Native Method)
07-29 16:37:54.615: E/AndroidRuntime(5407): at java.lang.reflect.Method.invoke(Method.java:372)
07-29 16:37:54.615: E/AndroidRuntime(5407): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
07-29 16:37:54.615: E/AndroidRuntime(5407): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
07-29 16:37:54.615: E/AndroidRuntime(5407): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f03001a
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.content.res.Resources.getValue(Resources.java:1266)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2649)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.content.res.Resources.getLayout(Resources.java:1082)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.view.LayoutInflater.inflate(LayoutInflater.java:412)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
07-29 16:37:54.615: E/AndroidRuntime(5407): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.Activity.setContentView(Activity.java:2145)
07-29 16:37:54.615: E/AndroidRuntime(5407): at com.example.videoviewexample.VideoActivity.onCreate(VideoActivity.java:69)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.Activity.performCreate(Activity.java:5990)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
07-29 16:37:54.615: E/AndroidRuntime(5407): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
07-29 16:37:54.615: E/AndroidRuntime(5407): ... 10 more
但是这个布局在三个布局中都是大的,正常的和xlarge然后是什么问题?
我无法确定问题,如何解决这个问题?
答案 0 :(得分:0)
从我所看到的问题似乎并不存在。我认为问题是
A)您错误地定义了布局名称。尝试添加另一个布局