I have a spinner of cities with default value "Other City". If the user can't find his city, when he selects Other City, a textInput (Your city) is shown. When the user enters his city name there and Clicks the button Register, the getText().toString() doesn't return the value. And also when the field is empty even though I have written validation code, it doesn't work.

Log.i("cities[0]", "("+cities[0]+")");
Log.i("regOtherCity", "("+(regUserOtherCity.getText().toString())+")");
if (userCity.equals(cities[0]) && TextUtils.isEmpty(regUserOtherCity.getText().toString()) )
{
           error = true;
            Log.i("checkerror", "("+cities[0]+")");
            regUserOtherCity.setError("Enter Your City");
            regUserOtherCity.requestFocus();
        }
        else if (userCity.equals(cities[0]))
            userCity = regUserOtherCity.getText().toString();
        Log.i("cities[0]", "("+cities[0]+")");
        Log.i("regOtherCity", "("+userCity+")");

I have tried debugging by using Logcat, the output is here for the time when the user enters 'my city' in the text input.

I/cities[0]: (Other City)
I/regOtherCity: (my city)
I/cities[0]: (Other City)
I/regOtherCity: ()

I'm designing a game engine that is supposed to be overridden. I have, for example, a class called Character. Should I prefix this with BaseCharacter or should I expect that whoever uses the framework prefixes their classes with GameNameCharacter or CharacterGameName?

What would be most convenient to you?

What are the benefits of aggregating a structure and functions associated with it in one object? What are the benefits of explicitly decalring a class. If i write procedural code i already know that some functions are working with specific structures. I just work with it and that's all.

For me the only benefit of OOP syntax is that it allows autocompletion tools to show me the list of methods. By the way, I noticed that I can't imagine to work without autocompletion tool like Intellisence. If I turn Intellisence off the main productivity bounty of OOP are going away and i should remember all signatures of public functions. I feel like i'm writing the same procedural code like if i'm not declared class explicitly.

Assume you have a library in which every function is public. Sooner or later developers who use your library will come up with a stable pattern of usage. In that terms external information of how developers are using you library already defines the public interface.

If your function is dealing with only inner context of library user will not use it. User will feel that in the library there are some other functions that allow him to do his task in a more convinient manner. Why should a user use an internal function if this fuction doesn't touch his context?

If the user of the library want to call the internal function that touches his context but this function is encapsulated who said that it was a right decision to make it encapsulated. User context “knows” better what should be encapsulated.

Even if the user of the library is messing with internals who said that it will lead to unmaintainability. On the next iteration developer will refactor the code and will come up with the proper maintainable call. For example if you have age field and getAge() method I will use getAge() because I understand that using age field is not maintainable. By the way that doesn’t mean that getAge() is maintainable. May be operating with the field is more simple and clean than with the getAge() method.

All of this stuff you can’t predict because you look at your library inside(internally) and not externally (just because you have no information of usage). If you write your own library that doesn’t mean that you know better how to use it. If you make something private that means that you define a pattern of usage (you say to developers: “Use this, not this”). But how you can define a pattern of usage if you don’t have enough information about user needs and context? Who said that some private function should be private?

Interface of the library should be defined by a user not by the creator. And user defines it by pattern of usage. Why can't you make everything public and let the user define what should be used and how and what should not? User context “knows” better what should be encapsulated and user code already “encapsulates” your library by the practice of using.

So what's the purpose of explicit encapsulation?

In singleton pattern the reference variable is declared as a private static variable. So what is the point of declaring this reference variable as a private static reference variable ?

So I've found this new API called the Screen Capture API and tried it on my desktop. I then tried the demo on Safari on ios, but unfortunately, the API doesn't seem to be implemented yet.

Is this API going to be added for ios Safari any time soon?

I have the bellow firebase fetch method.

The problem is that it will double values for no reason. So for example if in the first "loop" the value is media1 then in the next loop it will also say media1 even though at the point of this node there is only one thing... media1.

How can I solve this?

var mediaTheUserLikes = [String]()
var num = 0

func getYourLikesForThisPost() {
    mediaTheUserLikes.removeAll()
    ref.child("YourLikes").child(Auth.auth().currentUser!.uid).child((selectedPost?.user.userID)!).child(postID!).observe(.childAdded) { (snap) in
        if self.mediaTheUserLikes.count > 0 && self.mediaTheUserLikes[self.num] != snap.key {
            self.mediaTheUserLikes.append(snap.key)
        } else if self.mediaTheUserLikes.count == 0 {
            self.mediaTheUserLikes.append(snap.key)
        }
    }
}

My solution as seen above does not seem to work.

I have a UICollectionView that is anchored to my viewController, I made each collectionViewCell take up the width and height of the view. In my collectionViewCell, I have a view that has a fixed inset on each side. When I don't call sizeForItemAt and only use my flowLayout's itemSize (which is set to view.frame.size or collectionView.frame.size), the top and bottom seem to be cut off somehow; however, when I call both itemSize AND sizeForItemAt, the inset is uniform on each side and the cell isn't cut off.

All my cells are the same height and width (no heights are changing), so based on this answer, I thought I would only need itemSize (The docs say that when you don't call sizeForItemAt, it automatically uses and makes all cell sizes itemSize). I've tried making navigation bar translucent, making content adjustment insets equal to false, etc etc.

This is what I call in order for the insets to appear properly and not hidden under the navigation bar

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: collectionView.bounds.size.width, height: collectionView.bounds.size.height)
    }

And since I have a flowLayout, my itemSize is basically

CGSize(width: self.view.frame.size.width, height: self.view.frame.size.height)

Here is the insets made in the collection view cell:

let insets = UIEdgeInsets(top: 16, left: 16, bottom: -16, right: -16)
        let viewConstraints = [
            view1.leadingAnchor.constraint(equalTo: leadingAnchor, constant: stackInsets.left),
            view1.topAnchor.constraint(equalTo: topAnchor, constant: stackInsets.top),
            view1.trailingAnchor.constraint(equalTo: trailingAnchor, constant: stackInsets.right),
            view1.bottomAnchor.constraint(equalTo: bottomAnchor, constant: stackInsets.bottom)
        ]
        NSLayoutConstraint.activate(insets)

I thought itemSize would result in uniform and visible insets, but they only appeared when I called sizeForItemAt. My item size is the same size as what I put for sizeForItemAt and they have different results

Any help would be appreciated.

I've a class that needs to be include in lots of my activities , so I've made a class that needs to access the view . this is my code :

class Toolbar{
private lateinit var typeface:Typeface;
private lateinit var context:Context
private lateinit var tvToolbar:TextView;

fun MakeToolbar(context:Context, title:String){
    this.context=context
    init();
}

private fun init() {
    typeface= Func.getTypeFace(context)!!

    tvToolbar=((Activity)context).findViewById 

}

the problem is , in java I can easily access the context and use findViewById to get my view , Buy I can't do it in kotlin and it couldn't find the view .

How can I access a view in a non activity class?

Imagine an application that consumes an external data stream and creates objects of this type:

@Entity
public class Event {

  @OneToOne(cascade = CascadeType.ALL)
  private EventInfo info;

  @OneToOne(cascade = CascadeType.ALL)
  private EventSource source;

  ...

}

Later in the DAO:

session.save(event);

In the data stream, every Event has a fully self-contained JSON representation of both the EventInfo and the EventSource.

This has been working fine, but now need to refactor this code ans ensure that EventSource entities are re-used, i.e. change to:

  @ManyToOne(cascade = ???)
  private EventSource source;

Now the question is this. Given that the external data-stream always contains a full representation, it is necessary to look-up EventSource in the database and re-set the value in the Event object prior to saving the Event entity.

What layer of the receiving application should be responsible for the look-up?

I am little confused about using MVVM with mobile application. Why people is using MVVM when they have easy code behind with all page life cycle and events.

When using Terraform instead of Cloudformation on AWS, I usually get immediate feedback on the terminal, which makes the work very productive.

With CloudFormation, however, I tend to edit the file in my computer, upload it to Cloudformation console on AWS, and keep watching until I get an error/success. Even using CI/CD is not much of an advantage, as the result is usually ROLLBACK_COMPLETE, and I have to go to the console to see what went wrong.

I'm I following the right workflow for Cloudformation? Should I be doing things differently?

I am making an animation in an activity and when the user completes the activity I want to store the seconds (i.e. the amount of time a user uses the animation for) and the date in separate fields in Firestore.

However, the user can perform the activity several times a day so I want the seconds to add up as this happens on a particular date.

I get the total seconds for the animation by: when the animation starts:

  long timeS = SystemClock.elapsedRealtime();

When the animation ends:

  long timeE = SystemClock.elapsedRealtime();
      long elapsedMilliSeconds = timeE - timeS;
      double elapsedSeconds = elapsedMilliSeconds / 1000.0;

I get the date by using this:

   Date todaysdate = new Date();
   SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
   String date = format.format(todaysdate);

So in simple terms I want to store the elapsedSeconds and date variables in firebase - firestore. However, if the date is the same then I would like to add up the elapsedSeconds in the database (meaning if the user performs the animation multiple times a day).

My android app is not moving to the next screen when I request it to.

I have reviewed my code over and over for an hour, I've cleaned it and rebuilt it and I've synced it.

private TextView NeedNewAccountLink

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    InitializeFields();

    NeedNewAccountLink. setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            sendUserToRegisterActivity();
        }
    });
}

    NeedNewAccountLink = (TextView) findViewById(R.id.need_new_account_link);


private void sendUserToRegisterActivity() {

    Intent registerIntent = new Intent(LoginActivity.this, RegisterActivity.class);
    startActivity(registerIntent);
}

I want to click on the link and go to the next screen

EDIT !! This is what my LoginActivity file looks like. When I click the register link it says that my app has stopped.

private FirebaseUser currentUser;
private Button LoginButton, PhoneLoginButton;
private EditText UserEmail, UserPassword;
private TextView NeedNewAccountLink, ForgetPasswordLink;
private TextView AlreadyHaveAccountLink;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    InitializeFields();

    NeedNewAccountLink. setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            sendUserToRegisterActivity();
        }
    });
}

private void InitializeFields() {

    LoginButton = (Button) findViewById(R.id.login_button);
    PhoneLoginButton = (Button) findViewById(R.id.phone_login_button);
    UserEmail = (EditText) findViewById(R.id.login_email);
    UserPassword = (EditText) findViewById(R.id.login_password);
    NeedNewAccountLink = (TextView) findViewById(R.id.need_new_account_link);
    ForgetPasswordLink = (TextView) findViewById(R.id.forget_password_link);
}

@Override
protected void onStart() {
    super.onStart();

    if (currentUser != null){
        sendUserToMainActivity();

    }
}

private void sendUserToMainActivity() {

        Intent loginIntent = new Intent(LoginActivity.this, MainActivity.class);
        startActivity(loginIntent);
    }

private void sendUserToRegisterActivity() {

    Intent registerIntent = new Intent(LoginActivity.this, RegisterActivity.class);
    startActivity(registerIntent);
}

I just tried this and I am still getting the same error.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    NeedNewAccountLink = (TextView) findViewById(R.id.need_new_account_link);

    InitializeFields();

    NeedNewAccountLink. setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            sendUserToRegisterActivity();
        }
    });
}

private void InitializeFields() {

    LoginButton = (Button) findViewById(R.id.login_button);
    PhoneLoginButton = (Button) findViewById(R.id.phone_login_button);
    UserEmail = (EditText) findViewById(R.id.login_email);
    UserPassword = (EditText) findViewById(R.id.login_password);
    ForgetPasswordLink = (TextView) findViewById(R.id.forget_password_link);
}

I am designing a live quiz app that fetches data from server and question are displayed in a RecyclerView that contains a question and four options. Now when I select one option for a given question, it is selected properly but at the same time, the corresponding option for other question is selected automatically.

Screenshot of the item selection issue is the following.

enter image description here

Here is the adapter class of my RecyclerView

public class LiveTestAdapter extends RecyclerView.Adapter<LiveTestAdapter.CustomViewHolder>{
    private int mItemSelected=-1;
    private List<DmLiveQuiz> questionList;
    DmLiveQuiz questionsList; // DmLiveQuiz questionsList
    private Context context; //context
    final DataHolder dh=new DataHolder();
    public List<Integer> myResponse= new ArrayList<Integer>();
    public int qno;
    public String myQno;
    public int afterSub;
    DataHolder dataHolder;

    public LiveTestAdapter(List<DmLiveQuiz> questionList, Context context) {
        this.questionList = questionList;
        this.context = context; 
    }

    @NonNull
    @Override
    public CustomViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(parent.getContext()).inflate(R.layout.live_quiz_display_format,parent,false);
        return new CustomViewHolder(itemView);
    }
    @Override
    public void onBindViewHolder(@NonNull final CustomViewHolder holder,  int position) {

        questionsList=questionList.get(holder.getAdapterPosition());
        holder.tvQNo.setText(questionsList.getQuestionId()+"");
        holder.tvquestion.getLayoutParams().width= LinearLayout.LayoutParams.WRAP_CONTENT;
        holder.tvquestion.setText(questionsList.getQuestion());
        holder.optA.setText(questionsList.getOptA());
        holder.optB.setText(questionsList.getOptB());
        holder.optC.setText(questionsList.getOptC());
        holder.optD.setText(questionsList.getOptD());
        holder.optA.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                holder.optA.setBackgroundResource(R.drawable.button_border);
                holder.optB.setBackgroundResource(R.drawable.button_question_style);
                holder.optC.setBackgroundResource(R.drawable.button_question_style);
                holder.optD.setBackgroundResource(R.drawable.button_question_style);
                Toast toast = Toast.makeText(context, "Position :"+holder.getAdapterPosition(), Toast.LENGTH_SHORT);
                toast.show();

            }
        });
        holder.optB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                holder.optA.setBackgroundResource(R.drawable.button_question_style);
                holder.optB.setBackgroundResource(R.drawable.button_border);
                holder.optC.setBackgroundResource(R.drawable.button_question_style);
                holder.optD.setBackgroundResource(R.drawable.button_question_style);
                Toast toast = Toast.makeText(context, "Position :"+holder.getAdapterPosition(), Toast.LENGTH_SHORT);
                toast.show();

            }
        });
        holder.optC.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                holder.optA.setBackgroundResource(R.drawable.button_question_style);
                holder.optB.setBackgroundResource(R.drawable.button_question_style);
                holder.optC.setBackgroundResource(R.drawable.button_border);
                holder.optD.setBackgroundResource(R.drawable.button_question_style);
                Toast toast = Toast.makeText(context, "Position :"+holder.getAdapterPosition(), Toast.LENGTH_SHORT);
                toast.show();
            }
        });
        holder.optD.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                holder.optA.setBackgroundResource(R.drawable.button_question_style);
                holder.optB.setBackgroundResource(R.drawable.button_question_style);
                holder.optC.setBackgroundResource(R.drawable.button_question_style);
                holder.optD.setBackgroundResource(R.drawable.button_border);
                Toast toast = Toast.makeText(context, "Position :"+holder.getAdapterPosition(), Toast.LENGTH_SHORT);
                toast.show();

            }
        });
        holder.tvClear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                holder.optA.setBackgroundResource(R.drawable.button_question_style);
                holder.optB.setBackgroundResource(R.drawable.button_question_style);
                holder.optC.setBackgroundResource(R.drawable.button_question_style);
                holder.optD.setBackgroundResource(R.drawable.button_question_style);

            }
        });

    }

    @Override
    public int getItemCount() {
        return questionList.size();
    }

    public class CustomViewHolder extends RecyclerView.ViewHolder{
        TextView tvquestion, tvClear,tvQNo;
        Button optA,optB,optC,optD;
        public CustomViewHolder(View itemView) {
            super(itemView);
            tvQNo=(TextView)itemView.findViewById(R.id.tvLiveQuizQuestionNo);
            tvquestion=(TextView)itemView.findViewById(R.id.tvLiveQuizQuestion);
            optA=(Button)itemView.findViewById(R.id.buttonOptionA);
            optB=(Button)itemView.findViewById(R.id.buttonOptionB);
            optC=(Button)itemView.findViewById(R.id.buttonOptionC);
            optD=(Button)itemView.findViewById(R.id.buttonOptionD);
            tvClear=(TextView)itemView.findViewById(R.id.tvClearSelection);

        }
    } 
}

The only problem I am facing is the auto selection of unanswered options.

Please help me out in selecting the selected option only not the ones which are not selected. Thanks in advance.

I'm setting up a new Tabbed Activity in Android Studio and found an error on 'layout_behavior'. Can I just remove it?

I'm using minSdkVersion 15, and dependencies:

implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.android.support:design:28.0.0'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'

implementation 'com.android.support:support-v4:28.0.0'

implementation 'android.arch.lifecycle:extensions:1.1.1'

My activity_main.xml code:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:minHeight="?actionBarSize"
            android:padding="@dimen/appbar_padding"
            android:text="@string/app_name"
            android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>

Error in this line:

app:layout_behavior="@string/appbar_scrolling_view_behavior"

Is there any deference if I just remove it?

I have done light coding in C++ and Matlab. I'm looking to build a non-static mobile app that supports both iOS and android (so i'm hoping for something that is cross-platform) and a program for the admin device (computer). The connection between them will not be through the internet but via LAN. The function of the program is simple, a multiple choice quiz. The user opens the app on their phone and taps the "quiz" button. The admin computer receives the signal to send a question and then does so. The user answers the multiple choice question and sends the result back to the admin device. All of the users complete the quiz (a finite number of questions) and then the quiz can not be accessed again by the same device. The admin computer will need to collect all of the scores from each device (approximately 1000 devices). Additionally, the user devices must be identifiable, so that when a phone is brought to the administrator, you can match the phone to the data sent from it.

Which programming language should I start studying in order to learn how to create this? How would you suggest I go about learning it? Does someone have access to some code that is similar that I should modify instead of trying to build it all from scratch? Thanks in advance!

I am trying to implement the Translator Text API in an Android app. When trying to implement it into mine, I get a service not bound error so I thought that I would try the sample app that they provided, the link is below.

https://github.com/MicrosoftTranslator/Local-Feature-Android

However, when I run this app in my Android Studio and click the button in the app to bind service, it will not bind still. I do not know much about Android Studio and have no idea how to fix this problem, but I think that it should work in something as simple as the sample they provide.

Any help will be appreciated, thank you!

I was wondering, I"m looking to add update button in my fragment which when user click will check if updates available or not .

I"m looking for solution on How to acess json file from url and check if json value contains new value or not . if key matches to the already specified value then display message you data has been updated and if not then display No updates availaible.

For Example if below is the json file

[
   {
           "updateKey": "1"

      }
]

and if it contains other then 1 then show toast message with updates availaible.

anyone knows how to handling Kotlin-Room exceptions on UI thread with Anko doAsync using await suspended method inside a fragment. because I get an error (Unresolved reference: await) while using await() with doAsync

Note: I'm using kotlin_version = '1.3.21' with anko_version='0.10.8' and android studio 3.3.2

FirstFragment.kt

class FirstFragment : Fragment() {


override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_first, container, false)
}

private var dbInstance: PersonDatabase? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    doAsync {
      val instance = doAsync{ PersonDatabase.getInstance(this@FirstFragment.context!!) }
        dbInstance = instance.await()
  }

    button3.setOnClickListener {
        val name = editText.text.toString().trim()
        val age = editText2.text.toString().trim().toInt()
        val p =Person(null, name, age)
        doAsync {
            val insert = doAsync{ dbInstance?.personDau()?.insertData(p) }
            insert.await()
            insertMessage()
        }
    }
    button4.setOnClickListener {
        doAsync {
            val fetch = doAsync{ dbInstance?.personDau()?.getAll() }
            populateLis(fetch.await())
        }
    }

}

private fun populateLis(data: List<Person>?) {
    if (data == null){
        Toast.makeText(this.context,"No data",Toast.LENGTH_LONG).show()
        return
    }
    val adapter =object: ArrayAdapter<Person>(this.context, android.R.layout.simple_list_item_2, android.R.id.text1, data){
        override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
            val v = super.getView(position, convertView, parent)
            val p=data[position]
            v.findViewById<TextView>(android.R.id.text1).text=p.name
            v.findViewById<TextView>(android.R.id.text2).text=p.age.toString()
            return v
        }
    }
    personList.adapter = adapter
}

private fun insertMessage() {
    Toast.makeText(this.context,"Data inserted",Toast.LENGTH_LONG).show()

}

}

Gradle Top-level

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha01"


    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
    ext {
        androidSupportVersion = "28.0.0"

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Gradle App-level

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'




android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.martin.jetpack"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'com.android.support:design:28.0.0'
    implementation "com.android.support:customtabs:28.0.0"
    implementation 'com.android.support:mediarouter-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    def nav_version = "1.0.0-alpha01"

    implementation "android.arch.navigation:navigation-fragment:$nav_version" // For Kotlin use navigation-fragment-ktx
    implementation "android.arch.navigation:navigation-ui:$nav_version" // For Kotlin use navigation-ui-ktx

    // this for kotlin async
    def anko_version='0.10.8'
    implementation "org.jetbrains.anko:anko-commons:0.10.8"
    implementation "org.jetbrains.anko:anko-coroutines:$anko_version"

    // this is for android jetpack room
    def room_version = "1.1.0"
    implementation"android.arch.persistence.room:runtime:$room_version"
    kapt "android.arch.persistence.room:compiler:$room_version"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    // Core dependency
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
    // Android UI Programming
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
    // RxJava2 & Reactive Programming
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.1.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.1.1'


}

I want ETag to get the newer version of cache made by retrofit in the android studio so ,I try different header but not getting the result

public static final String HEADER_CACHE_CONTROL = "Cache-Control";
public static final String HEADER_PRAGMA = "Pragma"; 
return response.newBuilder()
                    .removeHeader(HEADER_PRAGMA)
                    .removeHeader(HEADER_CACHE_CONTROL)
                    .header("Cache-Control:", "private, must-revalidate")//cacheControl.toString())
                    .build();