在AVPlayerViewController
中,有一项功能可以停止播放视频,并通过滑动视图关闭public class MainActivity extends AppCompatActivity {
ListView listView;
EditText editText;
Button button;
ArrayList<Subjects> SubjectList = new ArrayList<Subjects>();
String HttpURL = "http://10.1.55.212/PHPFiles/Subjects.php";
ListViewAdapter listViewAdapter;
ProgressBar progressBar ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (ListView) findViewById(R.id.listView1);
editText = (EditText) findViewById(R.id.edittext1);
button = (Button) findViewById(R.id.button);
progressBar = (ProgressBar)findViewById(R.id.progressbar);
listView.setTextFilterEnabled(true);
listViewAdapter = new ListViewAdapter(MainActivity.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Subjects ListViewClickData = (Subjects) parent.getItemAtPosition(position);
Intent intent = new Intent(MainActivity.this, UpdateActivity.class);
intent.putExtra("id", ListViewClickData.getName());
intent.putExtra("nameCon", ListViewClickData.getCon());
intent.putExtra("location", ListViewClickData.getLoc());
intent.putExtra("datePro", ListViewClickData.getPro());
intent.putExtra("dateSale", ListViewClickData.getSale());
startActivity(intent);
}
});
editText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence stringVar, int start, int before, int count) {
listViewAdapter.getFilter().filter(stringVar.toString());
}
});
new ParseJSonDataClass(this).execute();
}
public void onClick(View v){
if(v.getId()==R.id.button){
IntentIntegrator scanIntegrator = new IntentIntegrator(this);
scanIntegrator.initiateScan();
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanningResult != null) {
String scanContent = scanningResult.getContents();
editText.setText(scanContent);
}
else{
Toast toast = Toast.makeText(getApplicationContext(),
"No scan data received!", Toast.LENGTH_SHORT);
toast.show();
}
}
private class ParseJSonDataClass extends AsyncTask<Void, Void, Void> {
public Context context;
String FinalJSonResult;
public ParseJSonDataClass(Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... arg0) {
HttpParseClass httpParseClass = new HttpParseClass(HttpURL);
try {
httpParseClass.ExecutePostRequest();
if (httpParseClass.getResponseCode() == 200) {
FinalJSonResult = httpParseClass.getResponse();
if (FinalJSonResult != null) {
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(FinalJSonResult);
JSONObject jsonObject;
Subjects subjects;
SubjectList = new ArrayList<Subjects>();
for (int i = 0; i < jsonArray.length(); i++) {
jsonObject = jsonArray.getJSONObject(i);
String tempName = jsonObject.getString("id").toString();
String tempCon = jsonObject.getString("nameCon").toString();
String tempLoc = jsonObject.getString("location").toString();
String tempPro = jsonObject.getString("datePro").toString();
String tempSale = jsonObject.getString("dateSale").toString();
subjects = new Subjects(tempName, tempCon, tempLoc, tempPro, tempSale);
SubjectList.add(subjects);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
Toast.makeText(context, httpParseClass.getErrorMessage(), Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
progressBar.setVisibility(View.INVISIBLE);
listViewAdapter = new ListViewAdapter(MainActivity.this, R.layout.listview_items_layout, SubjectList);
listView.setAdapter(listViewAdapter);
}
}
。
我想禁用此功能。我想我需要禁用手势识别器!?
但我不知道如何为玩家做这件事。
答案 0 :(得分:1)
我最近偶然发现了类似的问题。您可以从contentView
的{{1}}访问手势识别器。
如果您只想保留点按手势识别器,则可能需要使用以下功能:
AVPlayerViewController
答案 1 :(得分:0)
删除手势对我没有用。在没有任何操作的情况下添加新的UIPanGestureRecognizer
。
extension AVPlayerViewController {
func disableGesture() {
let panGesture = UIPanGestureRecognizer(target: self, action: nil)
self.view.addGestureRecognizer(panGesture)
}
}