Tech Programming Ideas is one of the best places on the programming for programmers. Learn coding with Tech Programming Ideas tutorials. We are covered android programming, php, yii2 framework, javascript, mysql, vb.net etc.
Certainly! When using Yii2, the convention is to create a separate search model for handling search and filtering logic. Here's a basic example of a PostSearch model with filtering capabilities for the author.name attribute:
Assuming you have a Post model with a hasOne relation to Author:
//Attach a media controller to video view MediaController mediaController = new MediaController(this); videoView.setMediaController(mediaController); mediaController.setAnchorView(videoView);
//Specify the location of media file Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.favicon);
//Attach a media controller to video view MediaController mediaController = new MediaController(this); videoView.setMediaController(mediaController); mediaController.setAnchorView(videoView); //add your video URL Uri uri = Uri.parse("Add URL here..");
mOnInitializedListener = new YouTubePlayer.OnInitializedListener() { @Override public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
//Load video list /* List<String> videoList = new ArrayList<>(); videoList.add("saIqHKolTHc"); videoList.add("ov8YX9tNyio"); youTubePlayer.loadVideos(videoList); */ //play list //youTubePlayer.loadPlaylist("PLIFW--Hzc0hbgKs_ZIzMWnElNkHkpsmGP"); //play video youTubePlayer.loadVideo("saIqHKolTHc"); }
@Override public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
date = (EditText)findViewById(R.id.edtDateofbirth);
date.addTextChangedListener(new TextWatcher() {
private String current = "";
private String ddmmyyyy = "DDMMYYYY";
private Calendar cal = Calendar.getInstance();
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!s.toString().equals(current)) {
String clean = s.toString().replaceAll("[^\\d.]", "");
String cleanC = current.replaceAll("[^\\d.]", "");
int cl = clean.length();
int sel = cl;
for (int i = 2; i <= cl && i < 6; i += 2) {
sel++;
}
//Fix for pressing delete next to a forward slash
if (clean.equals(cleanC)) sel--;
if (clean.length() < 8){
clean = clean + ddmmyyyy.substring(clean.length());
}else{
//This part makes sure that when we finish entering numbers
//the date is correct, fixing it otherwise
int day = Integer.parseInt(clean.substring(0,2));
int mon = Integer.parseInt(clean.substring(2,4));
int year = Integer.parseInt(clean.substring(4,8));
year = (year<1900)?1900:(year>2100)?2100:year;
cal.set(Calendar.YEAR, year);
// ^ first set year for the line below to work correctly
//with leap years - otherwise, date e.g. 29/02/2012
//would be automatically corrected to 28/02/2012
//This is the file we are going to download. //Please add your server file location .
URL url = new URL("http://www.mission2win.in/pdf/pdf22.pdf");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
//set path where to save the file
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file to save
File file = new File(SDCardRoot,"pdf22.pdf");
FileOutputStream fileOutput = new FileOutputStream(file);
//stream used for reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();
//create a buffer
byte[] buffer = new byte[124];
int bufferLength = 0;
Verify permission and add this code to give a permission
public static void verifyStoragePermissions(Activity activity) {
// Check if we have write permission
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
ActivityCompat.requestPermissions(
activity,
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE
);
}
}
Other wise add several permission to Manifest file.
<!-- Permission required for Downloading Files -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permission required for Checking Internet Connection -->
//set path where to save the file
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file to save
File file = new File(SDCardRoot,"pdf22.pdf");
FileOutputStream fileOutput = new FileOutputStream(file);
//stream used for reading the data from the internet
InputStream inputStream = urlConnection.getInputStream();
//This is total size of the downloading file totalSize = urlConnection.getContentLength(); runOnUiThread(new Runnable() { @Override public void run() { progressBar.setMax(totalSize); } });
//create a buffer
byte[] buffer = new byte[124];
int bufferLength = 0;