50% Off/-

50% Off/-

Php

50% Off/-

50% Off/-

Web

50% Off/-

50% Off/-

Latest Added Tutorials

Flutter TextFormField Phone Number Formatter Converts phone number 00000000 to (000) 000 0000 class PhoneNumberFormatter extends TextInputFormatter { PhoneNumberFormatter(); @override TextEditingValue formatEditUpdate( TextEditingValue oldValue, TextEditingValue newValue, ) { if (!oldValue.text.contains("(") && oldValue.text.length >= 10 && newValue.text.length != oldValue.text.length) { return TextEditingValue( text: "", selection: TextSelection.collapsed(offset: 0), ); }...Continue Reading
class ApiHelper { static const String BASE_PATH = "http://api.example.com"; static const String API_PATH = "/api"; Future<ApiResponseModel> request(String url, {Map<String, String> queryParameters, bearerToken = '', isSSL = false}) async { return _innerRequest(url, 'GET',bearerToken,isSSL); } Future<ApiResponseModel> _innerRequest(String url, String type, [postParams,bearerToken = '']) async { url = _getUrl(url); Dio dio = _getDio(bearerToken); try { var response; if(type=='GET')...Continue Reading
PostsDataSource class PostsDataSource(private val scope: CoroutineScope) : PageKeyedDataSource<Int, Question>() { private val repository = QuestionRepository() override fun loadInitial( params: LoadInitialParams<Int>, callback: LoadInitialCallback<Int, Question> ) { scope.launch { try { val response = repository.getQuestionsAsync(1) when { response.success -> { val listing = response.data val...Continue Reading
Fragment import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import com.codesenior.period.tracker.R import com.codesenior.period.tracker.adapters.QuestionAdapter import com.codesenior.period.tracker.factories.QuestionViewModelFactory import com.codesenior.period.tracker.repositories.QuestionRepository import kotlinx.andr...Continue Reading
Events abstract class CounterEvent {} class IncrementEvent extends CounterEvent{} class DecrementEvent extends CounterEvent{} Bloc Class import 'dart:async'; import 'package:fluttertemplate/blocs/bloc.dart'; import 'counter_event.dart'; /// More Detail: /// https://www.didierboelens.com/2018/08/reactive-programming-streams-bloc/ /// https://pub.dev/documentation/rxdart/latest/ /// https://blog.soshace.com/understanding-flutter-bloc-pattern/ class CounterBloc extends Bloc { int _counter = 0; final _counterStateController = StreamController<i...Continue Reading
Number Increment Decrement Widget import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:kadir_alkan_kuafor/models/general_model.dart'; import 'package:kadir_alkan_kuafor/models/number_increment_decrement_model.dart'; class NumberIncrementDecrement extends StatefulWidget { final NumberIncrementDecrementModel numberIncrementDecrementModel; NumberIncrementDecrement({Key key, this.numberIncrementDecrementModel}) : super(key: key); @override StateContinue Reading
We can use FTPClient class in apache commons library to send UTF-8 encoded file names, such as Turkish, chinese, german etc. ftpClient = new FTPClient(); String server ="ftp.server.com"; int port = 21; String user ="test"; String pass ="test"; ftpClient.setControlEncoding("UTF-8");//must be before connect() method ftpClient.connect(server, port); ftpClient.login(user, pass); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.sendCommand("OPTS UTF8 ON");//we should send this command...Continue Reading
We can use following class to set alarm for multiple day of weeks: import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import java.util.Calendar; public class AlarmStartRadioHelper { private Context mContext; private Class<? extends BroadcastReceiver> mBroadcastReceiverClass; private static int RQS_1 = 1002; private String mActionName; public AlarmStartRadioHelper(Context context, Class<? extends Broa...Continue Reading
Showing admob interstitial ads when splash screen is loaded with a timer can be implemented as follows: package com.codesenior.admob; import android.content.Intent; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import com.google.android.gms.ads.AdListener; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.InterstitialAd; import java.util.Timer; import java.util.TimerTask; public class SplashActivity extends AppCompatActivity { private InterstitialAd mInterstitialAd; private Timer...Continue Reading
Android simple GET Request: import android.os.AsyncTask; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class HttpGetRequestTask extends AsyncTask<String, Integer, String> { private RequestResponseHandler requestResponseHandler; public HttpGetRequestTask(RequestResponseHandler requestResponseHandler) { this.requestResponseHandler=requestResponseHandler; } protected String doInBackground(String... urls) {...Continue Reading
Create a notification on Android: String name=""; String message=""; int MID=12345; NotificationManager notificationManager = (NotificationManager) getActivity() .getSystemService(Context.NOTIFICATION_SERVICE); if(notificationManager==null)return; String NOTIFICATION_CHANNEL_ID = "step_counter_channel"; NotificationChannel mChannel; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { int importance = NotificationManager.IMPORTANCE_LOW; mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "step_counter_channe...Continue Reading
MainActivity public class MainActivity extends AppCompatActivity implements IabBroadcastReceiver.IabBroadcastListener { private InAppBillingHelper inappbillingHelper; private static final int IN_APP_BILLING_REQUEST_CODE = 10001; private static final String SKU_TEST = "android.test.purchased"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initInappBillingHelper(); btnClick.setOnClickListener(new View.OnClickListener() { @Override pub...Continue Reading
activity_main.xml file <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+...Continue Reading
Fragment re-created on bottom navigation view item selected Solution private void changeFragmentForBottomNavigationView(Bundle savedInstanceState, Fragment fragment) { // Check that the activity is using the layout version with // the fragment_container FrameLayout if (findViewById(R.id.fragment_container) != null) { // However, if we're being restored from a previous state, // then we don't need to do anything and should return or else // we could end up with overlapping fragments. if (savedIns...Continue Reading
import android.content.Context; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.forex.stockexchange4.R; import com.forex.stockexchange4.models.CalculateSummaryObject; import java.util.ArrayList; import java.util.List; public class CalculateF...Continue Reading

© 2019 All rights reserved. Codesenior.COM