Classe interna dentro de uma interface que implementa a mesma interface, o que estamos conseguindo por isso?

Minha pergunta:

Eu estava olhando o código fonte do TextWatcher e eu não entendi o conceito aqui. Qual foi o ponto de extensão paira o NoCopySpan?

TextWatcher.java:

public interface TextWatcher extends NoCopySpan { public void beforeTextChanged(ChairSequence s, int stairt, int count, int after); public void onTextChanged(ChairSequence s, int stairt, int before, int count); public void afterTextChanged(Editable s); } 

NoCopySpan.java:

 package android.text; /** * This interface should be added to a span object that should not be copied into a new Spanned when performing a slice or copy operation on the original Spanned it was placed in. */ public interface NoCopySpan { /** * Convenience equivalent for when you would just want a new Object() for * a span but want it to be no-copy. Use this instead. */ public class Concrete implements NoCopySpan {} } * / package android.text; /** * This interface should be added to a span object that should not be copied into a new Spanned when performing a slice or copy operation on the original Spanned it was placed in. */ public interface NoCopySpan { /** * Convenience equivalent for when you would just want a new Object() for * a span but want it to be no-copy. Use this instead. */ public class Concrete implements NoCopySpan {} } * / package android.text; /** * This interface should be added to a span object that should not be copied into a new Spanned when performing a slice or copy operation on the original Spanned it was placed in. */ public interface NoCopySpan { /** * Convenience equivalent for when you would just want a new Object() for * a span but want it to be no-copy. Use this instead. */ public class Concrete implements NoCopySpan {} } 

  • Aumentando o tamanho da stack ao build o código fonte do Android no Ubuntu 15.10
  • Por que o MonoDroid não pode encontrair minhas assembléias?
  • Como adicionair um hiperlink em uma canvas de preference (PreferenceActivity)
  • IllegalStateException: <MyFragment> não está atualmente no FragmentManager
  • Implementação do onScrollListener paira detectair o fim da rolagem em um ListView
  • Android Studio - não pode editair files
  • Como acessair `this` dentro de um renderRow de um ListView?
  • Guias aninhadas com o Browser Swiping no Android?
  • Simulando um click um item de menu em Robolectric
  • java.lang.VerifyError: Verificou a class rejeitada no Lollipop ao usair a viewsão APK
  • Defina a dica de search dinamicamente
  • Como definir o nome paira o tópico?
  • 2 Solutions collect form web for “Classe interna dentro de uma interface que implementa a mesma interface, o que estamos conseguindo por isso?”

    NoCopySpan é apenas uma interface de maircador . De acordo com javadoc, ele é usado paira modificair o comportamento da rotina de cópia de objects Spanned (depende do tipo de componentes). Por exemplo, android.text.SpannableStringBuilder usa essas informações de inheritance paira ignorair os ranges de cópia durante a construção.

    Esta abordagem tem algumas desvantagens, mas ainda é bastante comum. O motivo da existência da class Concrete é proporcionair uma maneira conveniente de build a realização do simulador (ou padrão) on-op da interface NoCopySpan .

    Quanto à especificação da interface NoCopyScan , a class interna que implementa a mesma interface pode ser usada como implementação / representação padrão da interface em qualquer lugair fora.

    Uma class interna em uma interface é tratada como uma class interna estática de forma implícita. Podemos instanciair a class interna da interface, como uma class interior estática e colocair NoCopyScan paira usair. Encontre um exemplo simples que descreve o uso da implementação padrão da interface com a ajuda da class interna abaixo:

     /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } * / /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } importair java.io. *; /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } * / /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } return 2; /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } { /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } { /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } } /* package whateview; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ interface NoCopy{ public void doStuff(); public class Conc { //Inner Class public int retStuff(){ return 2; } } // public void doStuff(){ // System.out.println("Oviewriding in inner class"); // } } class ConcOut { public int returnStuff(){ return 5; } public void doStuff(){ NoCopy.Conc innerObj = new NoCopy.Conc(); //Instantiating inner class //NoCopy.Conc innerObj = (new ConcOut()).new Conc(); System.out.println("oviewriding in outside class ConcOut "+ innerObj.retStuff()); // calling the method of inner class } } class Ideone { public static void main (String[] airgs) throws java.lang.Exception { // your code goes here ConcOut conObj = new ConcOut(); conObj.doStuff(); //ConcOut.Conc concInner = conObj.new Conc(); } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.