Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / android / CHIPTool / app / src / main / java / com / google / chip / chiptool / commissioner / CommissionerActivity.java
1 /*
2  *   Copyright (c) 2020 Project CHIP Authors
3  *   All rights reserved.
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  */
18
19 package com.google.chip.chiptool.commissioner;
20
21 import android.content.Intent;
22 import android.os.Bundle;
23 import androidx.annotation.NonNull;
24 import androidx.appcompat.app.AppCompatActivity;
25 import androidx.fragment.app.Fragment;
26 import com.google.chip.chiptool.R;
27 import com.google.chip.chiptool.commissioner.thread.internal.SelectNetworkFragment;
28 import com.google.chip.chiptool.setuppayloadscanner.BarcodeFragment;
29 import com.google.chip.chiptool.setuppayloadscanner.CHIPDeviceInfo;
30
31 public class CommissionerActivity extends AppCompatActivity implements BarcodeFragment.Callback {
32
33   @Override
34   protected void onCreate(Bundle savedInstanceState) {
35     super.onCreate(savedInstanceState);
36     setContentView(R.layout.commissioner_activity);
37
38     if (savedInstanceState == null) {
39       showFragment(new BarcodeFragment());
40     }
41   }
42
43   @Override
44   public void onActivityResult(int requestCode, int resultCode, Intent data) {
45     super.onActivityResult(requestCode, resultCode, data);
46   }
47
48   @Override
49   public void onCHIPDeviceInfoReceived(@NonNull CHIPDeviceInfo deviceInfo) {
50     showFragment(new SelectNetworkFragment(deviceInfo));
51   }
52
53   public void finishCommissioning(int resultCode) {
54     Intent resultIntent = new Intent();
55     setResult(resultCode, resultIntent);
56     finish();
57   }
58
59   public void showFragment(Fragment fragment) {
60     getSupportFragmentManager()
61         .beginTransaction()
62         .replace(R.id.commissioner_service_activity, fragment, fragment.getClass().getSimpleName())
63         .addToBackStack(null)
64         .commit();
65   }
66 }